gamefic 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/gamefic/scene/base.rb +4 -2
- data/lib/gamefic/scene/conclusion.rb +1 -1
- data/lib/gamefic/scene/multiple_choice.rb +1 -11
- data/lib/gamefic/scene/pause.rb +1 -1
- data/lib/gamefic/scene/yes_or_no.rb +1 -1
- data/lib/gamefic/version.rb +1 -1
- data/lib/gamefic/world/scenes.rb +11 -11
- metadata +6 -7
- data/lib/gamefic/scene/custom.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad70329086d7b1e9dd06a8459c5b1ee95952ab5453f63afd4e7a87df6ba90e69
|
4
|
+
data.tar.gz: 443a8642312dd1da33612a78ce1598723a9336b46e55b840636c2f41804eb8c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c207722b0d00906579e9a221d0f8fad831a8f35694ac2252569d427d2846e113beda49c3e160083013284e6f5c85354f9959b49fceb4383100c451de61dc882
|
7
|
+
data.tar.gz: 899b4605d74e236a6904d80a6218c6c607c78594357124bb2b36ea12557bee1c485e76bde2eb8ed1f29359f7d6a6f32ca1d7c2294b0d56f9d1109ad195f7c890
|
data/CHANGELOG.md
CHANGED
data/lib/gamefic/scene/base.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Gamefic
|
2
|
-
#
|
3
|
-
#
|
2
|
+
# An abstract class for building different types of scenes. It can be
|
3
|
+
# extended either through concrete subclasses or by creating anonymous
|
4
|
+
# subclasses through a scene helper method like
|
5
|
+
# `Gamefic::World::Scenes#custom`.
|
4
6
|
#
|
5
7
|
class Scene::Base
|
6
8
|
include Gamefic::Serialize
|
@@ -6,7 +6,7 @@ module Gamefic
|
|
6
6
|
# The finish block's input parameter receives a MultipleChoice::Input object
|
7
7
|
# instead of a String.
|
8
8
|
#
|
9
|
-
class Scene::MultipleChoice < Scene::
|
9
|
+
class Scene::MultipleChoice < Scene::Base
|
10
10
|
# The zero-based index of the selected option.
|
11
11
|
#
|
12
12
|
# @return [Integer]
|
@@ -33,7 +33,6 @@ module Gamefic
|
|
33
33
|
get_choice
|
34
34
|
if selection.nil?
|
35
35
|
actor.tell invalid_message
|
36
|
-
tell_options
|
37
36
|
else
|
38
37
|
super
|
39
38
|
end
|
@@ -77,14 +76,5 @@ module Gamefic
|
|
77
76
|
}
|
78
77
|
end
|
79
78
|
end
|
80
|
-
|
81
|
-
def tell_options
|
82
|
-
list = '<ol class="multiple_choice">'
|
83
|
-
options.each { |o|
|
84
|
-
list += "<li><a href=\"#\" rel=\"gamefic\" data-command=\"#{o}\">#{o}</a></li>"
|
85
|
-
}
|
86
|
-
list += "</ol>"
|
87
|
-
actor.tell list
|
88
|
-
end
|
89
79
|
end
|
90
80
|
end
|
data/lib/gamefic/scene/pause.rb
CHANGED
@@ -4,7 +4,7 @@ module Gamefic
|
|
4
4
|
# block. After the scene is finished, the :active scene will be cued if no
|
5
5
|
# other scene has been prepared or cued.
|
6
6
|
#
|
7
|
-
class Scene::YesOrNo < Scene::
|
7
|
+
class Scene::YesOrNo < Scene::Base
|
8
8
|
attr_writer :invalid_message
|
9
9
|
|
10
10
|
def post_initialize
|
data/lib/gamefic/version.rb
CHANGED
data/lib/gamefic/world/scenes.rb
CHANGED
@@ -95,10 +95,10 @@ module Gamefic
|
|
95
95
|
#
|
96
96
|
# @param prompt [String]
|
97
97
|
# @yieldparam [Gamefic::Actor]
|
98
|
-
# @yieldparam [Gamefic::Scene::
|
99
|
-
# @return [Class<Gamefic::Scene::
|
98
|
+
# @yieldparam [Gamefic::Scene::Base]
|
99
|
+
# @return [Class<Gamefic::Scene::Base>]
|
100
100
|
def question prompt = 'What is your answer?', &block
|
101
|
-
s = Scene::
|
101
|
+
s = Scene::Base.subclass do |actor, scene|
|
102
102
|
scene.prompt = prompt
|
103
103
|
scene.on_finish &block
|
104
104
|
end
|
@@ -150,23 +150,23 @@ module Gamefic
|
|
150
150
|
# Custom scenes should always specify the next scene to be cued or
|
151
151
|
# prepared. If not, the scene will get repeated on the next turn.
|
152
152
|
#
|
153
|
-
# This method creates a Scene::
|
153
|
+
# This method creates a Scene::Base by default. You can customize other
|
154
154
|
# scene types by specifying the class to create.
|
155
155
|
#
|
156
156
|
# @example Ask the user for a name
|
157
|
-
# @scene = custom do |scene|
|
158
|
-
#
|
159
|
-
# scene.on_finish do
|
160
|
-
# actor.name =
|
157
|
+
# @scene = custom do |actor, scene|
|
158
|
+
# scene.prompt = "What's your name?"
|
159
|
+
# scene.on_finish do
|
160
|
+
# actor.name = scene.input
|
161
161
|
# actor.tell "Hello, #{actor.name}!"
|
162
|
-
# actor.cue
|
162
|
+
# actor.cue default_scene
|
163
163
|
# end
|
164
164
|
# end
|
165
165
|
#
|
166
166
|
# @param cls [Class] The class of scene to be instantiated.
|
167
167
|
# @yieldparam [Gamefic::Actor]
|
168
|
-
# @return [Class<Gamefic::Scene::
|
169
|
-
def custom cls = Scene::
|
168
|
+
# @return [Class<Gamefic::Scene::Base>]
|
169
|
+
def custom cls = Scene::Base, &block
|
170
170
|
s = cls.subclass &block
|
171
171
|
scene_classes.push s
|
172
172
|
s
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -113,7 +113,6 @@ files:
|
|
113
113
|
- lib/gamefic/scene/activity.rb
|
114
114
|
- lib/gamefic/scene/base.rb
|
115
115
|
- lib/gamefic/scene/conclusion.rb
|
116
|
-
- lib/gamefic/scene/custom.rb
|
117
116
|
- lib/gamefic/scene/multiple_choice.rb
|
118
117
|
- lib/gamefic/scene/multiple_scene.rb
|
119
118
|
- lib/gamefic/scene/pause.rb
|
@@ -134,7 +133,7 @@ homepage: http://gamefic.com
|
|
134
133
|
licenses:
|
135
134
|
- MIT
|
136
135
|
metadata: {}
|
137
|
-
post_install_message:
|
136
|
+
post_install_message:
|
138
137
|
rdoc_options: []
|
139
138
|
require_paths:
|
140
139
|
- lib
|
@@ -149,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
148
|
- !ruby/object:Gem::Version
|
150
149
|
version: '0'
|
151
150
|
requirements: []
|
152
|
-
rubygems_version: 3.1.
|
153
|
-
signing_key:
|
151
|
+
rubygems_version: 3.1.6
|
152
|
+
signing_key:
|
154
153
|
specification_version: 4
|
155
154
|
summary: Gamefic
|
156
155
|
test_files: []
|