Class: Gamefic::Subplot
Overview
Subplots are disposable plots that run inside a parent plot. They can be started and concluded at any time during the parent plot’s execution.
Instance Attribute Summary collapse
Instance Method Summary
collapse
blocks, script
Methods included from Serialize
#serialized_class, string_to_constant, #to_serial
Methods included from Scriptable
included, #stage, #theater
#make_player_character, #player_class, #set_player_class
#actions, #after_action, #before_action, #get_default_query, #interpret, #meta, #override, #parse, #respond, #set_default_query, #verbs
#destroy, #entities, #make, #pick
#conclusion, #custom, #introduce, #introduction, #multiple_choice, #multiple_scene, #pause, #question, #scene_classes, #yes_or_no
#before_player_update, #before_player_update_procs, #on_player_conclude, #on_player_ready, #on_player_update, #on_ready, #on_update, #player_conclude_procs, #player_ready_procs, #player_update_procs, #ready_procs, #update_procs
Constructor Details
#initialize(plot, introduce: nil, next_cue: nil, **more) ⇒ Subplot
Returns a new instance of Subplot.
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/gamefic/subplot.rb', line 20
def initialize plot, introduce: nil, next_cue: nil, **more
@plot = plot
@next_cue = next_cue
@concluded = false
@more = more
configure **more
run_scripts
playbook.freeze
self.introduce introduce unless introduce.nil?
@static = [self] + scene_classes + entities
end
|
Instance Attribute Details
14
15
16
|
# File 'lib/gamefic/subplot.rb', line 14
def plot
@plot
end
|
Instance Method Details
#cast(cls, args = {}, &block) ⇒ Object
56
57
58
59
60
|
# File 'lib/gamefic/subplot.rb', line 56
def cast cls, args = {}, &block
ent = super
ent.playbooks.push plot.playbook unless ent.playbooks.include?(plot.playbook)
ent
end
|
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/gamefic/subplot.rb', line 69
def conclude
@concluded = true
players.each { |p| exeunt p }
entities.reject(&:nil?).each { |e| destroy e }
end
|
#concluded? ⇒ Boolean
80
81
82
|
# File 'lib/gamefic/subplot.rb', line 80
def concluded?
@concluded
end
|
Subclasses can override this method to handle additional configuration options.
103
104
|
# File 'lib/gamefic/subplot.rb', line 103
def configure **more
end
|
#default_conclusion ⇒ Object
48
49
50
|
# File 'lib/gamefic/subplot.rb', line 48
def default_conclusion
plot.default_conclusion
end
|
#default_scene ⇒ Object
44
45
46
|
# File 'lib/gamefic/subplot.rb', line 44
def default_scene
plot.default_scene
end
|
#exeunt(player) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/gamefic/subplot.rb', line 62
def exeunt player
player_conclude_procs.each { |block| block.call player }
player.playbooks.delete playbook
player.cue (@next_cue || default_scene)
players.delete player
end
|
36
37
38
|
# File 'lib/gamefic/subplot.rb', line 36
def players
@players ||= []
end
|
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/gamefic/subplot.rb', line 84
def ready
conclude if players.empty?
return if concluded?
playbook.freeze
call_ready
call_player_ready
end
|
32
33
34
|
# File 'lib/gamefic/subplot.rb', line 32
def static
plot.static
end
|
40
41
42
|
# File 'lib/gamefic/subplot.rb', line 40
def subplot
self
end
|
95
96
97
98
|
# File 'lib/gamefic/subplot.rb', line 95
def update
call_player_update
call_update
end
|