Class: Swint::XmlrpcRobot
- Inherits:
-
AbstractRobot
- Object
- AbstractRobot
- Swint::XmlrpcRobot
- Defined in:
- lib/swint/xmlrpc_robot.rb
Instance Attribute Summary collapse
-
#energy ⇒ Object
readonly
Returns the value of attribute energy.
-
#energy_left ⇒ Object
readonly
Returns the value of attribute energy_left.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#pos ⇒ Object
Returns the value of attribute pos.
-
#power ⇒ Object
readonly
Returns the value of attribute power.
-
#sight ⇒ Object
readonly
Returns the value of attribute sight.
-
#speed ⇒ Object
readonly
Returns the value of attribute speed.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
- #end_game(msg) ⇒ Object
- #flags ⇒ Object
-
#initialize(uri, pos) ⇒ XmlrpcRobot
constructor
A new instance of XmlrpcRobot.
- #listen(msg) ⇒ Object
- #move ⇒ Object
- #next(map) ⇒ Object
- #push ⇒ Object
- #shout ⇒ Object
Methods inherited from AbstractRobot
#calculate_view, #check_action, #check_direction, #has_energy?, #is_valid?, #restore, #to_s, #use_energy?
Constructor Details
#initialize(uri, pos) ⇒ XmlrpcRobot
Returns a new instance of XmlrpcRobot.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/swint/xmlrpc_robot.rb', line 14 def initialize(uri, pos) @uri = uri @server = XMLRPC::Client.new2(@uri) @gameid = @server.call('start_game') @speed = @server.call('get_speed', @gameid) @sight = @server.call('get_sight', @gameid) @power = @server.call('get_power', @gameid) @energy = @server.call('get_energy', @gameid) @weight = @server.call('get_weight', @gameid) @name = @server.call('get_name', @gameid) @owner = @server.call('get_owner', @gameid) @pos = pos restore end |
Instance Attribute Details
#energy ⇒ Object (readonly)
Returns the value of attribute energy.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def energy @energy end |
#energy_left ⇒ Object (readonly)
Returns the value of attribute energy_left.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def energy_left @energy_left end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def owner @owner end |
#pos ⇒ Object
Returns the value of attribute pos.
10 11 12 |
# File 'lib/swint/xmlrpc_robot.rb', line 10 def pos @pos end |
#power ⇒ Object (readonly)
Returns the value of attribute power.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def power @power end |
#sight ⇒ Object (readonly)
Returns the value of attribute sight.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def sight @sight end |
#speed ⇒ Object (readonly)
Returns the value of attribute speed.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def speed @speed end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def uri @uri end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
12 13 14 |
# File 'lib/swint/xmlrpc_robot.rb', line 12 def weight @weight end |
Instance Method Details
#end_game(msg) ⇒ Object
41 42 43 |
# File 'lib/swint/xmlrpc_robot.rb', line 41 def end_game(msg) @server.call('end_game', @gameid, msg) end |
#flags ⇒ Object
53 54 55 |
# File 'lib/swint/xmlrpc_robot.rb', line 53 def flags @server.call('flags', @gameid) end |
#listen(msg) ⇒ Object
45 46 47 |
# File 'lib/swint/xmlrpc_robot.rb', line 45 def listen(msg) @server.call('listen', @gameid, msg) end |
#move ⇒ Object
33 34 35 |
# File 'lib/swint/xmlrpc_robot.rb', line 33 def move check_direction(@server.call('move', @gameid)) end |
#next(map) ⇒ Object
29 30 31 |
# File 'lib/swint/xmlrpc_robot.rb', line 29 def next(map) check_action(@server.call('next', @gameid, calculate_view(map)).to_sym) end |
#push ⇒ Object
37 38 39 |
# File 'lib/swint/xmlrpc_robot.rb', line 37 def push check_direction(@server.call('push', @gameid)) end |
#shout ⇒ Object
49 50 51 |
# File 'lib/swint/xmlrpc_robot.rb', line 49 def shout @server.call('shout', @gameid) end |