Class: Zyps::Action
- Inherits:
-
Object
- Object
- Zyps::Action
- Defined in:
- lib/zyps.rb
Overview
An action that one Creature takes on another.
Direct Known Subclasses
BlendAction, BreedAction, DestroyAction, FaceAction, TagAction, TimedAction
Instance Attribute Summary collapse
-
#started ⇒ Object
readonly
Whether the action was previously started.
Instance Method Summary collapse
-
#copy ⇒ Object
Make a deep copy.
- #do(actor, target) ⇒ Object
-
#initialize ⇒ Action
constructor
A new instance of Action.
-
#start(actor, target) ⇒ Object
Start the action.
-
#started? ⇒ Boolean
Synonym for started.
-
#stop(actor, target) ⇒ Object
Stop the action.
Constructor Details
#initialize ⇒ Action
Returns a new instance of Action.
256 257 258 |
# File 'lib/zyps.rb', line 256 def initialize @started = false end |
Instance Attribute Details
#started ⇒ Object (readonly)
Whether the action was previously started.
254 255 256 |
# File 'lib/zyps.rb', line 254 def started @started end |
Instance Method Details
#copy ⇒ Object
Make a deep copy.
261 |
# File 'lib/zyps.rb', line 261 def copy; self.clone; end |
#do(actor, target) ⇒ Object
269 270 271 |
# File 'lib/zyps.rb', line 269 def do(actor, target) raise NotImplementedError.new("Action subclasses must implement a do(actor, target) instance method.") end |
#start(actor, target) ⇒ Object
Start the action. Overriding subclasses must either call “super” or set the @started attribute to true.
265 266 267 |
# File 'lib/zyps.rb', line 265 def start(actor, target) @started = true end |
#started? ⇒ Boolean
Synonym for started
280 |
# File 'lib/zyps.rb', line 280 def started?; started; end |
#stop(actor, target) ⇒ Object
Stop the action. Overriding subclasses must either call “super” or set the @started attribute to false.
275 276 277 |
# File 'lib/zyps.rb', line 275 def stop(actor, target) @started = false end |