Class: RTanque::Bot::Command

Inherits:
Struct
  • Object
show all
Defined in:
lib/rtanque/bot/command.rb

Overview

Command provide output from the Brain about the current state of the Match

They are made available to Brain via Brain#command

All values are bound. Setting an out-of-bounds value will result in it being set to the max/min allowed value.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fire_power=(value) ⇒ Float? (writeonly)

sets firing power. Setting to nil will stop firing. See #fire



17
18
19
# File 'lib/rtanque/bot/command.rb', line 17

def fire_power=(value)
  @fire_power = value
end

#heading=(value) ⇒ Float, RTanque::Heading (writeonly)



17
18
19
# File 'lib/rtanque/bot/command.rb', line 17

def heading=(value)
  @heading = value
end

#radar_heading=(value) ⇒ Float, RTanque::Heading (writeonly)



17
18
19
# File 'lib/rtanque/bot/command.rb', line 17

def radar_heading=(value)
  @radar_heading = value
end

#speed=(value) ⇒ Float (writeonly)



17
18
19
# File 'lib/rtanque/bot/command.rb', line 17

def speed=(value)
  @speed = value
end

#turret_heading=(value) ⇒ Float, RTanque::Heading (writeonly)



17
18
19
# File 'lib/rtanque/bot/command.rb', line 17

def turret_heading=(value)
  @turret_heading = value
end

Instance Method Details

#fire(power) ⇒ Object

Command provide output from the Brain about the current state of the Match

They are made available to Brain via Brain#command

All values are bound. Setting an out-of-bounds value will result in it being set to the max/min allowed value.



17
18
19
20
21
# File 'lib/rtanque/bot/command.rb', line 17

Command = Struct.new(:speed, :heading, :radar_heading, :turret_heading, :fire_power) do
  def fire(power = 3)
    self.fire_power = power
  end
end