class Goby::BattleCommand

Commands that are used in the battle system. At each turn, an Entity specifies which BattleCommand to use.

Constants

NO_ACTION

Text for when the battle command does nothing.

Attributes

name[RW]

Public Class Methods

new(name: "BattleCommand") click to toggle source

@param [String] name the name.

# File lib/goby/battle/battle_command.rb, line 11
def initialize(name: "BattleCommand")
  @name = name
end

Public Instance Methods

==(rhs) click to toggle source

@param [BattleCommand] rhs the command on the right. @return [Boolean] true iff the commands are considered equal.

# File lib/goby/battle/battle_command.rb, line 40
def ==(rhs)
  @name.casecmp(rhs.name).zero?
end
fails?(user) click to toggle source

This method can prevent the user from using this command based on a defined condition. Override for subclasses.

@param [Entity] user the one who is using the command. @return [Boolean] true iff the command cannot be used.

# File lib/goby/battle/battle_command.rb, line 20
def fails?(user)
  false
end
run(user, entity) click to toggle source

The process that runs when this command is used in battle. Override this function for subclasses.

@param [Entity] user the one who is using the command. @param [Entity] entity the one on whom the command is used.

# File lib/goby/battle/battle_command.rb, line 29
def run(user, entity)
  print NO_ACTION
end
to_s() click to toggle source

@return [String] the name of the BattleCommand.

# File lib/goby/battle/battle_command.rb, line 34
def to_s
  @name
end