Class: Zyps::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/zyps.rb

Overview

An action that one Creature takes on another.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAction

Returns a new instance of Action.



256
257
258
# File 'lib/zyps.rb', line 256

def initialize
	@started = false
end

Instance Attribute Details

#startedObject (readonly)

Whether the action was previously started.



254
255
256
# File 'lib/zyps.rb', line 254

def started
  @started
end

Instance Method Details

#copyObject

Make a deep copy.



261
# File 'lib/zyps.rb', line 261

def copy; self.clone; end

#do(actor, target) ⇒ Object

Raises:

  • (NotImplementedError)


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

Returns:

  • (Boolean)


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