Class: Swint::ClassRobot

Inherits:
AbstractRobot show all
Defined in:
lib/swint/class_robot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#energyObject (readonly)

Returns the value of attribute energy.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def energy
  @energy
end

#energy_leftObject (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

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def owner
  @owner
end

#posObject

Returns the value of attribute pos.



10
11
12
# File 'lib/swint/class_robot.rb', line 10

def pos
  @pos
end

#powerObject (readonly)

Returns the value of attribute power.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def power
  @power
end

#sightObject (readonly)

Returns the value of attribute sight.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def sight
  @sight
end

#speedObject (readonly)

Returns the value of attribute speed.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def speed
  @speed
end

#uriObject (readonly)

Returns the value of attribute uri.



12
13
14
# File 'lib/swint/class_robot.rb', line 12

def uri
  @uri
end

#weightObject (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

#flagsObject



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

#moveObject



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

#pushObject



38
39
40
# File 'lib/swint/class_robot.rb', line 38

def push
	check_direction(@instance.push)
end

#shoutObject



50
51
52
# File 'lib/swint/class_robot.rb', line 50

def shout
	@instance.shout
end