Class: Gamefic::Subplot
- Inherits:
-
Object
- Object
- Gamefic::Subplot
- Includes:
- Stage
- Defined in:
- lib/gamefic/subplot.rb
Instance Attribute Summary collapse
- #denied_message ⇒ Object
-
#plot ⇒ Object
readonly
Returns the value of attribute plot.
Class Method Summary collapse
Instance Method Summary collapse
- #conclude ⇒ Object
- #concluded? ⇒ Boolean
- #default_conclusion ⇒ Object
- #default_scene ⇒ Object
- #exeunt(player) ⇒ Object
-
#initialize(plot, introduce: nil) ⇒ Subplot
constructor
A new instance of Subplot.
- #introduce(player) ⇒ Object
- #playbook ⇒ Object
- #ready ⇒ Object
-
#running? ⇒ Boolean
HACK: Always assume subplots are running for the sake of entity destruction.
- #update ⇒ Object
Methods included from Stage
Constructor Details
#initialize(plot, introduce: nil) ⇒ Subplot
29 30 31 32 33 34 35 |
# File 'lib/gamefic/subplot.rb', line 29 def initialize plot, introduce: nil @plot = plot @concluded = false stage &self.class.start_proc unless self.class.start_proc.nil? playbook.freeze self.introduce introduce unless introduce.nil? end |
Instance Attribute Details
#denied_message ⇒ Object
54 55 56 |
# File 'lib/gamefic/subplot.rb', line 54 def ||= 'You are already involved in another subplot.' end |
#plot ⇒ Object (readonly)
Returns the value of attribute plot.
8 9 10 |
# File 'lib/gamefic/subplot.rb', line 8 def plot @plot end |
Class Method Details
.start_proc ⇒ Object
18 19 20 |
# File 'lib/gamefic/subplot.rb', line 18 def start_proc @start_proc end |
Instance Method Details
#conclude ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/gamefic/subplot.rb', line 71 def conclude @concluded = true entities.each { |e| destroy e } players.each { |p| exeunt p } end |
#concluded? ⇒ Boolean
81 82 83 |
# File 'lib/gamefic/subplot.rb', line 81 def concluded? @concluded end |
#default_conclusion ⇒ Object
41 42 43 |
# File 'lib/gamefic/subplot.rb', line 41 def default_conclusion plot.default_conclusion end |
#default_scene ⇒ Object
37 38 39 |
# File 'lib/gamefic/subplot.rb', line 37 def default_scene plot.default_scene end |
#exeunt(player) ⇒ Object
66 67 68 69 |
# File 'lib/gamefic/subplot.rb', line 66 def exeunt player player.playbook = plot.playbook p_players.delete player end |
#introduce(player) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/gamefic/subplot.rb', line 58 def introduce player if plot.subbed?(player) player.tell else super end end |
#playbook ⇒ Object
45 46 47 |
# File 'lib/gamefic/subplot.rb', line 45 def playbook @playbook ||= plot.playbook.dup end |
#ready ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/gamefic/subplot.rb', line 85 def ready conclude if players.empty? return if concluded? playbook.freeze call_ready call_player_ready end |
#running? ⇒ Boolean
HACK: Always assume subplots are running for the sake of entity destruction
50 51 52 |
# File 'lib/gamefic/subplot.rb', line 50 def running? true end |
#update ⇒ Object
93 94 95 96 |
# File 'lib/gamefic/subplot.rb', line 93 def update call_player_update call_update end |