Module: Gamefic::Plot::Scenes
- Included in:
- Gamefic::Plot, Subplot
- Defined in:
- lib/gamefic/plot/scenes.rb
Instance Method Summary collapse
-
#conclusion {|, | ... } ⇒ Object
Create a conclusion.
-
#custom(cls = Scene::Custom) {|, The| ... } ⇒ Object
Create a custom scene.
- #default_conclusion ⇒ Object
- #default_scene ⇒ Object
-
#introduce(player) ⇒ Object
Introduce a player to the game.
-
#introduction {|| ... } ⇒ Object
Add a block to be executed when a player is added to the game.
-
#multiple_choice(*choices) {|, | ... } ⇒ Object
Create a multiple-choice scene.
-
#multiple_scene(map = {}) {|, | ... } ⇒ Object
Choose a new scene based on a list of options.
-
#pause(prompt = nil) {|, | ... } ⇒ Object
Create a scene that pauses the game.
- #question(prompt = 'What is your answer?', &block) ⇒ Object
-
#yes_or_no(prompt = nil) {|, | ... } ⇒ Object
Create a yes-or-no scene.
Instance Method Details
#conclusion {|, | ... } ⇒ Object
Create a conclusion. The game (or the character’s participation in it) will end after this scene is complete.
88 89 90 |
# File 'lib/gamefic/plot/scenes.rb', line 88 def conclusion &block Scene::Conclusion.subclass &block end |
#custom(cls = Scene::Custom) {|, The| ... } ⇒ Object
Create a custom scene.
Custom scenes should always specify the next scene to be cued or prepared. If not, the scene will get repeated on the next turn.
This method creates a Scene::Custom by default. You can customize other scene types by specifying the class to create.
113 114 115 |
# File 'lib/gamefic/plot/scenes.rb', line 113 def custom cls = Scene::Custom, &block cls.subclass &block end |
#default_conclusion ⇒ Object
8 9 10 |
# File 'lib/gamefic/plot/scenes.rb', line 8 def default_conclusion @default_conclusion ||= Scene::Conclusion end |
#default_scene ⇒ Object
4 5 6 |
# File 'lib/gamefic/plot/scenes.rb', line 4 def default_scene @default_scene ||= Scene::Active end |
#introduce(player) ⇒ Object
Introduce a player to the game. This method is typically called by the Engine that manages game execution.
30 31 32 33 34 35 |
# File 'lib/gamefic/plot/scenes.rb', line 30 def introduce(player) player.playbook = playbook player.cue default_scene p_players.push player @introduction.call(player) unless @introduction.nil? end |
#introduction {|| ... } ⇒ Object
Add a block to be executed when a player is added to the game. Each Plot can only have one introduction. Subsequent calls will overwrite the existing one.
22 23 24 |
# File 'lib/gamefic/plot/scenes.rb', line 22 def introduction (&proc) @introduction = proc end |
#multiple_choice(*choices) {|, | ... } ⇒ Object
Create a multiple-choice scene. The user will be required to make a valid choice to continue.
42 43 44 45 46 47 |
# File 'lib/gamefic/plot/scenes.rb', line 42 def multiple_choice *choices, &block Scene::MultipleChoice.subclass do |actor, scene| scene..concat choices scene.on_finish &block end end |
#multiple_scene(map = {}) {|, | ... } ⇒ Object
Choose a new scene based on a list of options. This is a specialized type of multiple-choice scene that determines which scene to cue based on a Hash of choices and scene keys.
139 140 141 142 143 144 145 146 |
# File 'lib/gamefic/plot/scenes.rb', line 139 def multiple_scene map = {}, &block Scene::MultipleScene.subclass do |actor, scene| map.each_pair { |k, v| scene.map k, v } block.call actor, scene unless block.nil? end end |
#pause(prompt = nil) {|, | ... } ⇒ Object
Create a scene that pauses the game. This scene will execute the specified block and wait for input from the the user (e.g., pressing Enter) to continue.
75 76 77 78 79 80 |
# File 'lib/gamefic/plot/scenes.rb', line 75 def pause prompt = nil, &block Scene::Pause.subclass do |actor, scene| scene.prompt = prompt unless prompt.nil? block.call(actor, scene) unless block.nil? end end |
#question(prompt = 'What is your answer?', &block) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/gamefic/plot/scenes.rb', line 61 def question prompt = 'What is your answer?', &block Scene::Custom.subclass do |actor, scene| scene.prompt = prompt scene.on_finish &block end end |
#yes_or_no(prompt = nil) {|, | ... } ⇒ Object
Create a yes-or-no scene. The user will be required to answer Yes or No to continue.
54 55 56 57 58 59 |
# File 'lib/gamefic/plot/scenes.rb', line 54 def yes_or_no prompt = nil, &block Scene::YesOrNo.subclass do |actor, scene| scene.prompt = prompt scene.on_finish &block end end |