class Gamefic::Rulebook::Events
Blocks of code to be executed for various narrative events, such as on_ready
and on_update.
Attributes
conclude_blocks[R]
player_conclude_blocks[R]
player_output_blocks[R]
ready_blocks[R]
update_blocks[R]
Public Class Methods
new()
click to toggle source
# File lib/gamefic/rulebook/events.rb, line 19 def initialize @ready_blocks = [] @update_blocks = [] @conclude_blocks = [] @player_conclude_blocks = [] @player_output_blocks = [] end
Public Instance Methods
empty?()
click to toggle source
# File lib/gamefic/rulebook/events.rb, line 27 def empty? [player_output_blocks, player_conclude_blocks, ready_blocks, update_blocks, conclude_blocks].all?(&:empty?) end
freeze()
click to toggle source
Calls superclass method
# File lib/gamefic/rulebook/events.rb, line 31 def freeze super instance_variables.each { |k| instance_variable_get(k).freeze } self end
on_conclude(callback)
click to toggle source
@return [void]
# File lib/gamefic/rulebook/events.rb, line 47 def on_conclude callback @conclude_blocks.push callback end
on_player_conclude(callback)
click to toggle source
@yieldparam [Actor] @return [void]
# File lib/gamefic/rulebook/events.rb, line 53 def on_player_conclude callback @player_conclude_blocks.push callback end
on_player_output(callback)
click to toggle source
@yieldparam [Actor] @yieldparam [Hash] @return [void]
# File lib/gamefic/rulebook/events.rb, line 60 def on_player_output callback @player_output_blocks.push callback end
on_ready(callback)
click to toggle source
@return [void]
# File lib/gamefic/rulebook/events.rb, line 38 def on_ready callback @ready_blocks.push callback end
on_update(callback)
click to toggle source
# File lib/gamefic/rulebook/events.rb, line 42 def on_update callback @update_blocks.push callback end