Class: Gamefic::Subplot
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
blocks, script
Methods included from Serialize
instances, #serialized_class, string_to_constant, #to_serial
Methods included from Scriptable
included, #stage, #theater
#make_player_character, #player_class, #set_player_class
#actions, #disambiguate, #get_default_query, #interpret, #meta, #override, #parse, #respond, #set_default_query, #validate, #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
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/gamefic/subplot.rb', line 17
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
11
12
13
|
# File 'lib/gamefic/subplot.rb', line 11
def plot
@plot
end
|
Instance Method Details
#cast(cls, args = {}, &block) ⇒ Object
53
54
55
56
57
|
# File 'lib/gamefic/subplot.rb', line 53
def cast cls, args = {}, &block
ent = super
ent.playbooks.push plot.playbook unless ent.playbooks.include?(plot.playbook)
ent
end
|
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/gamefic/subplot.rb', line 66
def conclude
@concluded = true
players.each { |p| exeunt p }
entities.reject(&:nil?).each { |e| destroy e }
end
|
#concluded? ⇒ Boolean
77
78
79
|
# File 'lib/gamefic/subplot.rb', line 77
def concluded?
@concluded
end
|
Subclasses can override this method to handle additional configuration options.
100
101
|
# File 'lib/gamefic/subplot.rb', line 100
def configure more
end
|
#default_conclusion ⇒ Object
45
46
47
|
# File 'lib/gamefic/subplot.rb', line 45
def default_conclusion
plot.default_conclusion
end
|
#default_scene ⇒ Object
41
42
43
|
# File 'lib/gamefic/subplot.rb', line 41
def default_scene
plot.default_scene
end
|
#exeunt(player) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/gamefic/subplot.rb', line 59
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
|
49
50
51
|
# File 'lib/gamefic/subplot.rb', line 49
def playbook
@playbook ||= Gamefic::Plot::Playbook.new
end
|
33
34
35
|
# File 'lib/gamefic/subplot.rb', line 33
def players
@players ||= []
end
|
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/gamefic/subplot.rb', line 81
def ready
conclude if players.empty?
return if concluded?
playbook.freeze
call_ready
call_player_ready
end
|
29
30
31
|
# File 'lib/gamefic/subplot.rb', line 29
def static
plot.static
end
|
37
38
39
|
# File 'lib/gamefic/subplot.rb', line 37
def subplot
self
end
|
92
93
94
95
|
# File 'lib/gamefic/subplot.rb', line 92
def update
call_player_update
call_update
end
|