Class: Swint::ClassRobot
- Inherits:
-
AbstractRobot
- Object
- AbstractRobot
- Swint::ClassRobot
- Defined in:
- lib/swint/class_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(klass, pos) ⇒ ClassRobot
constructor
A new instance of ClassRobot.
- #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(klass, pos) ⇒ ClassRobot
Returns a new instance of ClassRobot.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/swint/class_robot.rb', line 14 def initialize(klass, pos) @klass = klass @instance = klass.new # a = [:speed, :sight, :power, :energy, :weight, :name, :owner] # a.each { |attr| send("self.#{attr}=", @instance.send(attr)) } @speed = @instance.speed @sight = @instance.sight @power = @instance.power @energy = @instance.energy @weight = @instance.weight @name = @instance.name @owner = @instance.owner @pos = pos restore end |
Instance Attribute Details
#energy ⇒ Object (readonly)
Returns the value of attribute energy.
12 13 14 |
# File 'lib/swint/class_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/class_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/class_robot.rb', line 12 def name @name end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def owner @owner end |
#pos ⇒ Object
Returns the value of attribute pos.
10 11 12 |
# File 'lib/swint/class_robot.rb', line 10 def pos @pos end |
#power ⇒ Object (readonly)
Returns the value of attribute power.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def power @power end |
#sight ⇒ Object (readonly)
Returns the value of attribute sight.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def sight @sight end |
#speed ⇒ Object (readonly)
Returns the value of attribute speed.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def speed @speed end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def uri @uri end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
12 13 14 |
# File 'lib/swint/class_robot.rb', line 12 def weight @weight end |
Instance Method Details
#end_game(msg) ⇒ Object
42 43 44 |
# File 'lib/swint/class_robot.rb', line 42 def end_game(msg) @instance.end_game(msg) end |
#flags ⇒ Object
54 55 56 |
# File 'lib/swint/class_robot.rb', line 54 def flags @instance.flags end |
#listen(msg) ⇒ Object
46 47 48 |
# File 'lib/swint/class_robot.rb', line 46 def listen(msg) @instance.listen(msg) end |
#move ⇒ Object
34 35 36 |
# File 'lib/swint/class_robot.rb', line 34 def move check_direction(@instance.move) end |
#next(map) ⇒ Object
30 31 32 |
# File 'lib/swint/class_robot.rb', line 30 def next(map) check_action(@instance.next(calculate_view(map)).to_sym) end |
#push ⇒ Object
38 39 40 |
# File 'lib/swint/class_robot.rb', line 38 def push check_direction(@instance.push) end |
#shout ⇒ Object
50 51 52 |
# File 'lib/swint/class_robot.rb', line 50 def shout @instance.shout end |