Module: Gamefic::Scriptable::Events
- Included in:
- Narrative, Gamefic::Scriptable
- Defined in:
- lib/gamefic/scriptable/events.rb
Overview
Scriptable methods related to creating event callbacks.
Instance Method Summary collapse
- #on_conclude(&block) ⇒ Object
- #on_player_conclude {|| ... } ⇒ Proc
- #on_player_output {|, | ... } ⇒ Proc
-
#on_player_ready {|| ... } ⇒ Object
Add a block to be executed for each player at the beginning of a turn.
-
#on_player_update {|| ... } ⇒ Object
Add a block to be executed for each player at the end of a turn.
-
#on_ready(&block) ⇒ Object
Add a block to be executed on preparation of every turn.
-
#on_update(&block) ⇒ Object
Add a block to be executed after the Plot is finished updating a turn.
Instance Method Details
#on_conclude(&block) ⇒ Object
53 54 55 |
# File 'lib/gamefic/scriptable/events.rb', line 53 def on_conclude &block rulebook.events.on_conclude(Callback.new(self, block)) end |
#on_player_conclude {|| ... } ⇒ Proc
59 60 61 |
# File 'lib/gamefic/scriptable/events.rb', line 59 def on_player_conclude &block rulebook.events.on_player_conclude(Callback.new(self, block)) end |
#on_player_output {|, | ... } ⇒ Proc
66 67 68 |
# File 'lib/gamefic/scriptable/events.rb', line 66 def on_player_output &block rulebook.events.on_player_output Callback.new(self, block) end |
#on_player_ready {|| ... } ⇒ Object
Add a block to be executed for each player at the beginning of a turn.
30 31 32 33 34 35 |
# File 'lib/gamefic/scriptable/events.rb', line 30 def on_player_ready &block wrapper = proc do players.each { |player| Stage.run(self, player, &block) } end on_ready &wrapper end |
#on_player_update {|| ... } ⇒ Object
Add a block to be executed for each player at the end of a turn.
46 47 48 49 50 51 |
# File 'lib/gamefic/scriptable/events.rb', line 46 def on_player_update &block wrapper = proc do players.each { |player| Stage.run(self, player, &block) } end on_update &wrapper end |