Sha256: f8ad9885023a47e918b83da46a0091628a8e90581a37d7ccc7d2e673b7d285fc
Contents?: true
Size: 574 Bytes
Versions: 5
Compression:
Stored size: 574 Bytes
Contents
class Toolbox attr_accessor :x attr_accessor :y attr_accessor :t attr_accessor :dead attr_accessor :energy def initialize bf, x, y, t, energy @x, @y, @t = x, y, t @battlefield, @energy, @dead = bf, energy, false end def state {:x=>x, :y=>y, :energy=>energy} end def tick @t += 1 @dead ||= t > @battlefield.config.toolboxes[:life_time] @battlefield.robots.each do |robot| if Math.hypot(@y - robot.y, robot.x - @x) < 20 && (!robot.dead) healing = robot.heal(self) @dead = true end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
UG_RRobots-2.0 | lib/toolboxes.rb |
UG_RRobots-1.3 | lib/toolboxes.rb |
UG_RRobots-1.2 | lib/toolboxes.rb |
UG_RRobots-2.2 | lib/toolboxes.rb |
UG_RRobots-2.1 | lib/toolboxes.rb |