Module: Gamefic::Plot::Callbacks

Included in:
Gamefic::Plot, Subplot
Defined in:
lib/gamefic/plot/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#before_player_update(&block) ⇒ Object

Add a block to be executed for each player before an update.

@yieldparam



41
42
43
# File 'lib/gamefic/plot/callbacks.rb', line 41

def before_player_update &block
  p_before_player_update_procs.push block
end

#on_player_ready {|| ... } ⇒ Object

Add a block to be executed for each player at the beginning of a turn.

Examples:

Tell the player how many turns they’ve played.

on_player_ready do |player|
  player[:turns] ||= 0
  if player[:turns] > 0
    player.tell "Turn #{player[:turns]}"
  end
  player[:turns] += 1
end

Yield Parameters:

  • (Gamefic::Performance)


34
35
36
# File 'lib/gamefic/plot/callbacks.rb', line 34

def on_player_ready &block
  p_player_ready_procs.push block
end

#on_player_update {|| ... } ⇒ Object

Add a block to be executed for each player at the end of a turn.

Yield Parameters:

  • (Character)


48
49
50
# File 'lib/gamefic/plot/callbacks.rb', line 48

def on_player_update &block
  p_player_update_procs.push block
end

#on_ready(&block) ⇒ Object

Add a block to be executed on preparation of every turn.

Examples:

Increment a turn counter

turn = 0
on_ready do
  turn += 1
end


12
13
14
# File 'lib/gamefic/plot/callbacks.rb', line 12

def on_ready &block
  p_ready_procs.push block
end

#on_update(&block) ⇒ Object

Add a block to be executed after the Plot is finished updating a turn.



18
19
20
# File 'lib/gamefic/plot/callbacks.rb', line 18

def on_update &block
  p_update_procs.push block
end