class ElGato::GameClient

Constants

SERVER_URI

Public Class Methods

new() click to toggle source
# File lib/el_gato/game_client.rb, line 7
def initialize
  DRb.start_service
  @game_server = DRbObject.new_with_uri(SERVER_URI)
  @player_id = SecureRandom.uuid
end

Public Instance Methods

add_player() click to toggle source
# File lib/el_gato/game_client.rb, line 17
def add_player
  @game_server.add_player @player_id
end
games() click to toggle source
# File lib/el_gato/game_client.rb, line 13
def games
  @game_server.games @player_id
end
move(args) click to toggle source
# File lib/el_gato/game_client.rb, line 27
def move args
  raise 'Play a game first' unless @current_game_id

  @game_server.move @current_game_id, @player_id, args
end
play() click to toggle source
# File lib/el_gato/game_client.rb, line 21
def play
  result = @game_server.play @player_id
  @current_game_id = result[:id] if result[:status] == :ready
  result
end