Class: Goby::BattleCommand
- Inherits:
-
Object
- Object
- Goby::BattleCommand
- Defined in:
- lib/goby/battle/battle_command.rb
Overview
Commands that are used in the battle system. At each turn, an Entity specifies which BattleCommand to use.
Constant Summary collapse
- NO_ACTION =
Text for when the battle command does nothing.
"Nothing happens.\n\n"
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(rhs) ⇒ Boolean
True iff the commands are considered equal.
-
#fails?(user) ⇒ Boolean
This method can prevent the user from using this command based on a defined condition.
-
#initialize(name: "BattleCommand") ⇒ BattleCommand
constructor
A new instance of BattleCommand.
-
#run(user, entity) ⇒ Object
The process that runs when this command is used in battle.
-
#to_s ⇒ String
The name of the BattleCommand.
Constructor Details
#initialize(name: "BattleCommand") ⇒ BattleCommand
Returns a new instance of BattleCommand.
11 12 13 |
# File 'lib/goby/battle/battle_command.rb', line 11 def initialize(name: "BattleCommand") @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
44 45 46 |
# File 'lib/goby/battle/battle_command.rb', line 44 def name @name end |
Instance Method Details
#==(rhs) ⇒ Boolean
Returns true iff the commands are considered equal.
40 41 42 |
# File 'lib/goby/battle/battle_command.rb', line 40 def ==(rhs) @name.casecmp(rhs.name).zero? end |
#fails?(user) ⇒ Boolean
This method can prevent the user from using this command based on a defined condition. Override for subclasses.
20 21 22 |
# File 'lib/goby/battle/battle_command.rb', line 20 def fails?(user) false end |
#run(user, entity) ⇒ Object
The process that runs when this command is used in battle. Override this function for subclasses.
29 30 31 |
# File 'lib/goby/battle/battle_command.rb', line 29 def run(user, entity) print NO_ACTION end |
#to_s ⇒ String
Returns the name of the BattleCommand.
34 35 36 |
# File 'lib/goby/battle/battle_command.rb', line 34 def to_s @name end |