gamefic 0.6.1 → 1.0.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/bin/gamefic +3 -0
- data/lib/gamefic/character.rb +42 -6
- data/lib/gamefic/director/parser.rb +25 -25
- data/lib/gamefic/engine/tty.rb +14 -2
- data/lib/gamefic/engine.rb +8 -7
- data/lib/gamefic/grammar/gender.rb +1 -1
- data/lib/gamefic/grammar/pronouns.rb +53 -8
- data/lib/gamefic/grammar/verbs.rb +1 -0
- data/lib/gamefic/grammar/word_adapter.rb +31 -18
- data/lib/gamefic/html.rb +27 -13
- data/lib/gamefic/plot/article_mount.rb +1 -1
- data/lib/gamefic/plot/scene_mount.rb +27 -110
- data/lib/gamefic/{snapshots.rb → plot/snapshot.rb} +60 -29
- data/lib/gamefic/plot/you_mount.rb +1 -1
- data/lib/gamefic/plot.rb +56 -29
- data/lib/gamefic/query/base.rb +3 -1
- data/lib/gamefic/scene/active.rb +11 -18
- data/lib/gamefic/scene/base.rb +21 -0
- data/lib/gamefic/scene/conclusion.rb +11 -0
- data/lib/gamefic/scene/custom.rb +21 -0
- data/lib/gamefic/scene/multiple_choice/input.rb +11 -0
- data/lib/gamefic/scene/multiple_choice.rb +73 -0
- data/lib/gamefic/scene/passive.rb +17 -0
- data/lib/gamefic/scene/pause.rb +24 -0
- data/lib/gamefic/scene/question.rb +21 -0
- data/lib/gamefic/scene/yes_or_no.rb +30 -0
- data/lib/gamefic/scene.rb +10 -120
- data/lib/gamefic/script/base.rb +7 -2
- data/lib/gamefic/script.rb +4 -0
- data/lib/gamefic/shell/command/base.rb +38 -0
- data/lib/gamefic/shell/command/play.rb +51 -0
- data/lib/gamefic/shell/command.rb +4 -0
- data/lib/gamefic/shell/registry.rb +13 -0
- data/lib/gamefic/shell.rb +14 -71
- data/lib/gamefic/source/file.rb +1 -1
- data/lib/gamefic/source.rb +5 -0
- data/lib/gamefic/tester.rb +0 -1
- data/lib/gamefic/version.rb +1 -1
- data/lib/gamefic.rb +1 -6
- metadata +69 -61
- data/lib/gamefic/scene/concluded.rb +0 -22
- data/lib/gamefic/scene/multiplechoice.rb +0 -74
- data/lib/gamefic/scene/paused.rb +0 -26
- data/lib/gamefic/scene/yesorno.rb +0 -43
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: An adventure game and interactive fiction framework
|
@@ -45,79 +45,88 @@ executables:
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- bin/gamefic
|
48
49
|
- lib/gamefic.rb
|
49
|
-
- lib/gamefic/grammar.rb
|
50
50
|
- lib/gamefic/action.rb
|
51
|
-
- lib/gamefic/
|
51
|
+
- lib/gamefic/ansi.rb
|
52
|
+
- lib/gamefic/character.rb
|
53
|
+
- lib/gamefic/command.rb
|
52
54
|
- lib/gamefic/core_ext/array.rb
|
53
55
|
- lib/gamefic/core_ext/string.rb
|
56
|
+
- lib/gamefic/describable.rb
|
57
|
+
- lib/gamefic/direction.rb
|
58
|
+
- lib/gamefic/director.rb
|
59
|
+
- lib/gamefic/director/delegate.rb
|
60
|
+
- lib/gamefic/director/order.rb
|
61
|
+
- lib/gamefic/director/parser.rb
|
62
|
+
- lib/gamefic/engine.rb
|
54
63
|
- lib/gamefic/engine/cgi.rb
|
55
64
|
- lib/gamefic/engine/tty.rb
|
65
|
+
- lib/gamefic/entity.rb
|
66
|
+
- lib/gamefic/grammar.rb
|
67
|
+
- lib/gamefic/grammar/conjugator.rb
|
68
|
+
- lib/gamefic/grammar/gender.rb
|
69
|
+
- lib/gamefic/grammar/person.rb
|
70
|
+
- lib/gamefic/grammar/plural.rb
|
71
|
+
- lib/gamefic/grammar/pronouns.rb
|
72
|
+
- lib/gamefic/grammar/tense.rb
|
73
|
+
- lib/gamefic/grammar/verb_set.rb
|
74
|
+
- lib/gamefic/grammar/verbs.rb
|
75
|
+
- lib/gamefic/grammar/word_adapter.rb
|
56
76
|
- lib/gamefic/html.rb
|
57
|
-
- lib/gamefic/
|
58
|
-
- lib/gamefic/
|
59
|
-
- lib/gamefic/
|
60
|
-
- lib/gamefic/
|
61
|
-
- lib/gamefic/
|
77
|
+
- lib/gamefic/keywords.rb
|
78
|
+
- lib/gamefic/node.rb
|
79
|
+
- lib/gamefic/plot.rb
|
80
|
+
- lib/gamefic/plot/article_mount.rb
|
81
|
+
- lib/gamefic/plot/command_mount.rb
|
82
|
+
- lib/gamefic/plot/entity_mount.rb
|
83
|
+
- lib/gamefic/plot/query_mount.rb
|
84
|
+
- lib/gamefic/plot/scene_mount.rb
|
85
|
+
- lib/gamefic/plot/snapshot.rb
|
86
|
+
- lib/gamefic/plot/you_mount.rb
|
87
|
+
- lib/gamefic/query.rb
|
88
|
+
- lib/gamefic/query/ambiguous_children.rb
|
89
|
+
- lib/gamefic/query/base.rb
|
62
90
|
- lib/gamefic/query/children.rb
|
91
|
+
- lib/gamefic/query/expression.rb
|
63
92
|
- lib/gamefic/query/family.rb
|
93
|
+
- lib/gamefic/query/many_children.rb
|
64
94
|
- lib/gamefic/query/matches.rb
|
65
95
|
- lib/gamefic/query/parent.rb
|
96
|
+
- lib/gamefic/query/plural_children.rb
|
66
97
|
- lib/gamefic/query/self.rb
|
67
98
|
- lib/gamefic/query/siblings.rb
|
68
|
-
- lib/gamefic/query/many_children.rb
|
69
|
-
- lib/gamefic/query/ambiguous_children.rb
|
70
|
-
- lib/gamefic/query/base.rb
|
71
|
-
- lib/gamefic/query/expression.rb
|
72
|
-
- lib/gamefic/query/plural_children.rb
|
73
99
|
- lib/gamefic/query/text.rb
|
74
100
|
- lib/gamefic/rule.rb
|
75
101
|
- lib/gamefic/scene.rb
|
76
|
-
- lib/gamefic/scene/concluded.rb
|
77
|
-
- lib/gamefic/scene/multiplechoice.rb
|
78
|
-
- lib/gamefic/scene/paused.rb
|
79
|
-
- lib/gamefic/scene/yesorno.rb
|
80
102
|
- lib/gamefic/scene/active.rb
|
103
|
+
- lib/gamefic/scene/base.rb
|
104
|
+
- lib/gamefic/scene/conclusion.rb
|
105
|
+
- lib/gamefic/scene/custom.rb
|
106
|
+
- lib/gamefic/scene/multiple_choice.rb
|
107
|
+
- lib/gamefic/scene/multiple_choice/input.rb
|
108
|
+
- lib/gamefic/scene/passive.rb
|
109
|
+
- lib/gamefic/scene/pause.rb
|
110
|
+
- lib/gamefic/scene/question.rb
|
111
|
+
- lib/gamefic/scene/yes_or_no.rb
|
112
|
+
- lib/gamefic/script.rb
|
113
|
+
- lib/gamefic/script/base.rb
|
114
|
+
- lib/gamefic/script/file.rb
|
115
|
+
- lib/gamefic/script/text.rb
|
116
|
+
- lib/gamefic/serialized.rb
|
81
117
|
- lib/gamefic/shell.rb
|
82
|
-
- lib/gamefic/
|
83
|
-
- lib/gamefic/
|
84
|
-
- lib/gamefic/
|
85
|
-
- lib/gamefic/
|
86
|
-
- lib/gamefic/syntax.rb
|
118
|
+
- lib/gamefic/shell/command.rb
|
119
|
+
- lib/gamefic/shell/command/base.rb
|
120
|
+
- lib/gamefic/shell/command/play.rb
|
121
|
+
- lib/gamefic/shell/registry.rb
|
87
122
|
- lib/gamefic/source.rb
|
88
123
|
- lib/gamefic/source/base.rb
|
89
124
|
- lib/gamefic/source/file.rb
|
90
125
|
- lib/gamefic/source/text.rb
|
91
|
-
- lib/gamefic/
|
92
|
-
- lib/gamefic/
|
93
|
-
- lib/gamefic/
|
94
|
-
- lib/gamefic/
|
95
|
-
- lib/gamefic/query.rb
|
96
|
-
- lib/gamefic/engine.rb
|
97
|
-
- lib/gamefic/direction.rb
|
98
|
-
- lib/gamefic/director/order.rb
|
99
|
-
- lib/gamefic/director/delegate.rb
|
100
|
-
- lib/gamefic/director/parser.rb
|
101
|
-
- lib/gamefic/plot/query_mount.rb
|
102
|
-
- lib/gamefic/plot/article_mount.rb
|
103
|
-
- lib/gamefic/plot/you_mount.rb
|
104
|
-
- lib/gamefic/plot/command_mount.rb
|
105
|
-
- lib/gamefic/plot/entity_mount.rb
|
106
|
-
- lib/gamefic/plot/scene_mount.rb
|
107
|
-
- lib/gamefic/director.rb
|
108
|
-
- lib/gamefic/grammar/conjugator.rb
|
109
|
-
- lib/gamefic/grammar/person.rb
|
110
|
-
- lib/gamefic/grammar/plural.rb
|
111
|
-
- lib/gamefic/grammar/tense.rb
|
112
|
-
- lib/gamefic/grammar/verb_set.rb
|
113
|
-
- lib/gamefic/grammar/verbs.rb
|
114
|
-
- lib/gamefic/grammar/gender.rb
|
115
|
-
- lib/gamefic/grammar/pronouns.rb
|
116
|
-
- lib/gamefic/grammar/word_adapter.rb
|
117
|
-
- lib/gamefic/serialized.rb
|
118
|
-
- lib/gamefic/keywords.rb
|
119
|
-
- lib/gamefic/plot.rb
|
120
|
-
- bin/gamefic
|
126
|
+
- lib/gamefic/stage.rb
|
127
|
+
- lib/gamefic/syntax.rb
|
128
|
+
- lib/gamefic/tester.rb
|
129
|
+
- lib/gamefic/version.rb
|
121
130
|
homepage: http://gamefic.com
|
122
131
|
licenses:
|
123
132
|
- MIT
|
@@ -128,19 +137,18 @@ require_paths:
|
|
128
137
|
- lib
|
129
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
130
139
|
requirements:
|
131
|
-
- -
|
140
|
+
- - ">="
|
132
141
|
- !ruby/object:Gem::Version
|
133
142
|
version: 1.9.3
|
134
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
144
|
requirements:
|
136
|
-
- -
|
145
|
+
- - ">="
|
137
146
|
- !ruby/object:Gem::Version
|
138
147
|
version: '0'
|
139
148
|
requirements: []
|
140
149
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.4.8
|
142
151
|
signing_key:
|
143
152
|
specification_version: 4
|
144
153
|
summary: Gamefic
|
145
154
|
test_files: []
|
146
|
-
has_rdoc:
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Gamefic
|
2
|
-
|
3
|
-
class ConcludedSceneManager < SceneManager
|
4
|
-
def scene_class
|
5
|
-
ConcludedScene
|
6
|
-
end
|
7
|
-
def state
|
8
|
-
@state ||= "Concluded"
|
9
|
-
end
|
10
|
-
def prompt
|
11
|
-
@prompt ||= "GAME OVER"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class ConcludedScene < Scene
|
16
|
-
# TODO: This class might need some logic for closing the game. Then again,
|
17
|
-
# maybe not. The Concluded state might be enough for the plot to know what
|
18
|
-
# to do. In fact, if the plot detects the Concluded state, it might never
|
19
|
-
# get around to calling the scene's finish proc.
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Gamefic
|
2
|
-
|
3
|
-
class MultipleChoiceSceneManager < SceneManager
|
4
|
-
def data_class
|
5
|
-
MultipleChoiceSceneData
|
6
|
-
end
|
7
|
-
def scene_class
|
8
|
-
MultipleChoiceScene
|
9
|
-
end
|
10
|
-
def state
|
11
|
-
@state ||= "MultipleChoice"
|
12
|
-
end
|
13
|
-
def prompt
|
14
|
-
@prompt ||= "Enter a choice:"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class MultipleChoiceSceneData < SceneData
|
19
|
-
attr_accessor :index, :selection, :options
|
20
|
-
def options
|
21
|
-
@options ||= []
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class MultipleChoiceScene < Scene
|
26
|
-
def initialize manager, key
|
27
|
-
super
|
28
|
-
@prompt ||= "Enter a choice:"
|
29
|
-
end
|
30
|
-
def start actor
|
31
|
-
super
|
32
|
-
list = '<ol class="multiple_choice">'
|
33
|
-
@data.options.each { |o|
|
34
|
-
list += "<li>#{o}</li>"
|
35
|
-
}
|
36
|
-
list += "</ol>"
|
37
|
-
actor.tell list
|
38
|
-
@data.prompt ||= @prompt
|
39
|
-
end
|
40
|
-
def finish actor, input
|
41
|
-
@data.input = input
|
42
|
-
@data.index = nil
|
43
|
-
@data.selection = nil
|
44
|
-
if @data.input.strip =~ /[0-9]+/
|
45
|
-
if input.to_i > 0
|
46
|
-
@data.index = input.to_i - 1
|
47
|
-
@data.selection = @data.options[@data.index]
|
48
|
-
@data.index = nil if @data.selection.nil?
|
49
|
-
end
|
50
|
-
else
|
51
|
-
i = 0
|
52
|
-
@data.options.each { |o|
|
53
|
-
if o.casecmp(@data.input).zero?
|
54
|
-
@data.index = i
|
55
|
-
@data.selection = o
|
56
|
-
break
|
57
|
-
end
|
58
|
-
i += 1
|
59
|
-
}
|
60
|
-
end
|
61
|
-
if @data.selection.nil?
|
62
|
-
# TODO: Consider allowing for an error block to customize this
|
63
|
-
# response.
|
64
|
-
actor.tell "That's not a valid selection."
|
65
|
-
else
|
66
|
-
@data.next_cue ||= :active
|
67
|
-
if !@finish.nil?
|
68
|
-
@finish.call actor, @data
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
data/lib/gamefic/scene/paused.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Gamefic
|
2
|
-
|
3
|
-
class PausedSceneManager < SceneManager
|
4
|
-
def scene_class
|
5
|
-
PausedScene
|
6
|
-
end
|
7
|
-
def data_class
|
8
|
-
PausedSceneData
|
9
|
-
end
|
10
|
-
def state
|
11
|
-
@state ||= "Paused"
|
12
|
-
end
|
13
|
-
def prompt
|
14
|
-
@prompt ||= "Press enter to continue..."
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class PausedSceneData < SceneData
|
19
|
-
attr_accessor :next_cue
|
20
|
-
end
|
21
|
-
|
22
|
-
class PausedScene < Scene
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Gamefic
|
2
|
-
|
3
|
-
class YesOrNoSceneManager < SceneManager
|
4
|
-
def scene_class
|
5
|
-
YesOrNoScene
|
6
|
-
end
|
7
|
-
def data_class
|
8
|
-
YesOrNoSceneData
|
9
|
-
end
|
10
|
-
def state
|
11
|
-
@state ||= "YesOrNo"
|
12
|
-
end
|
13
|
-
def prompt
|
14
|
-
@prompt ||= "Enter Yes Or No:"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class YesOrNoSceneData < SceneData
|
19
|
-
# @!attribute [rw] answer
|
20
|
-
# @return [String] The answer provided by the user, normalized to either "yes" or "no"
|
21
|
-
attr_accessor :answer
|
22
|
-
end
|
23
|
-
|
24
|
-
class YesOrNoScene < Scene
|
25
|
-
def finish actor, input
|
26
|
-
@data.input = input
|
27
|
-
# The input in a YesOrNoScene gets normalized to "yes" or "no"
|
28
|
-
@data.answer = nil
|
29
|
-
if input.downcase[0, 1] == "y"
|
30
|
-
@data.answer = "yes"
|
31
|
-
elsif input.downcase[0, 1] == "n"
|
32
|
-
@data.answer = "no"
|
33
|
-
end
|
34
|
-
if @data.answer.nil?
|
35
|
-
actor.tell "Please enter Yes or No."
|
36
|
-
else
|
37
|
-
return if @finish.nil?
|
38
|
-
@finish.call actor, data
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|