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

Parameters:

  • value (Float, nil)

    the value to set the attribute fire_power to.

Returns:

  • (Float, nil)

    the newly set value



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)

Returns the newly set value

Parameters:

  • value (Float, RTanque::Heading)

    the value to set the attribute heading to.

Returns:



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

def heading=(value)
  @heading = value
end

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

Returns the newly set value

Parameters:

  • value (Float, RTanque::Heading)

    the value to set the attribute radar_heading to.

Returns:



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

def radar_heading=(value)
  @radar_heading = value
end

#speed=(value) ⇒ Float (writeonly)

Returns the newly set value

Parameters:

  • value (Float)

    the value to set the attribute speed to.

Returns:

  • (Float)

    the newly set value



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

def speed=(value)
  @speed = value
end

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

Returns the newly set value

Parameters:

  • value (Float, RTanque::Heading)

    the value to set the attribute turret_heading to.

Returns:



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.

Parameters:



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