gamefic-standard 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rspec.yml +41 -40
  3. data/.rspec-opal +2 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile +2 -0
  6. data/README.md +64 -60
  7. data/Rakefile +14 -6
  8. data/gamefic-standard.gemspec +6 -3
  9. data/lib/gamefic-standard/actions/attack.rb +28 -0
  10. data/lib/gamefic-standard/actions/close.rb +14 -10
  11. data/lib/gamefic-standard/actions/drop.rb +20 -16
  12. data/lib/gamefic-standard/actions/enter.rb +29 -19
  13. data/lib/gamefic-standard/actions/go.rb +51 -47
  14. data/lib/gamefic-standard/actions/help.rb +52 -0
  15. data/lib/gamefic-standard/actions/insert.rb +33 -29
  16. data/lib/gamefic-standard/actions/inventory.rb +12 -8
  17. data/lib/gamefic-standard/actions/leave.rb +43 -39
  18. data/lib/gamefic-standard/actions/lock.rb +21 -17
  19. data/lib/gamefic-standard/actions/look.rb +117 -96
  20. data/lib/gamefic-standard/actions/move.rb +24 -0
  21. data/lib/gamefic-standard/actions/nil.rb +16 -15
  22. data/lib/gamefic-standard/actions/open.rb +5 -5
  23. data/lib/gamefic-standard/actions/place.rb +4 -4
  24. data/lib/gamefic-standard/actions/quit.rb +4 -8
  25. data/lib/gamefic-standard/actions/repeat.rb +14 -0
  26. data/lib/gamefic-standard/actions/save-restore-undo.rb +18 -0
  27. data/lib/gamefic-standard/actions/search.rb +5 -5
  28. data/lib/gamefic-standard/actions/take.rb +15 -4
  29. data/lib/gamefic-standard/actions/talk.rb +16 -4
  30. data/lib/gamefic-standard/actions/unlock.rb +10 -6
  31. data/lib/gamefic-standard/actions/wait.rb +3 -1
  32. data/lib/gamefic-standard/actions.rb +5 -0
  33. data/lib/gamefic-standard/articles.rb +2 -7
  34. data/lib/gamefic-standard/direction.rb +2 -3
  35. data/lib/gamefic-standard/entities/container.rb +2 -0
  36. data/lib/gamefic-standard/entities/door.rb +2 -0
  37. data/lib/gamefic-standard/entities/fixture.rb +2 -1
  38. data/lib/gamefic-standard/entities/item.rb +2 -0
  39. data/lib/gamefic-standard/entities/portal.rb +2 -0
  40. data/lib/gamefic-standard/entities/receptacle.rb +2 -0
  41. data/lib/gamefic-standard/entities/room.rb +21 -36
  42. data/lib/gamefic-standard/entities/rubble.rb +2 -1
  43. data/lib/gamefic-standard/entities/scenery.rb +2 -0
  44. data/lib/gamefic-standard/entities/supporter.rb +2 -0
  45. data/lib/gamefic-standard/entities/thing.rb +2 -0
  46. data/lib/gamefic-standard/give.rb +15 -14
  47. data/lib/gamefic-standard/grammar/pronoun.rb +80 -80
  48. data/lib/gamefic-standard/introduction.rb +8 -0
  49. data/lib/gamefic-standard/modules/enterable.rb +2 -0
  50. data/lib/gamefic-standard/modules/lockable.rb +3 -1
  51. data/lib/gamefic-standard/modules/standardized.rb +10 -12
  52. data/lib/gamefic-standard/modules.rb +0 -1
  53. data/lib/gamefic-standard/queries.rb +7 -20
  54. data/lib/gamefic-standard/version.rb +1 -1
  55. data/lib/gamefic-standard.rb +26 -8
  56. data/spec-opal/spec_helper.rb +32 -0
  57. metadata +33 -13
  58. data/lib/gamefic-standard/modules/use.rb +0 -45
  59. data/lib/gamefic-standard/test.rb +0 -34
@@ -1,25 +1,12 @@
1
- class Gamefic::Query::Available < Gamefic::Query::Base
2
- def context_from(subject)
3
- result = []
4
- top = subject.room || subject.parent
5
- unless top.nil?
6
- result.concat subquery_accessible(top)
7
- end
8
- result.delete subject
9
- subject.children.each do |c|
10
- result.push c
11
- result.concat subquery_accessible(c)
12
- end
13
- result
1
+ class Gamefic::Scope::Room < Gamefic::Scope::Base
2
+ def matches
3
+ [context.room].compact
14
4
  end
15
5
  end
16
6
 
17
- class Gamefic::Query::Room < Gamefic::Query::Base
18
- def context_from(subject)
19
- subject.room ? [subject.room] : []
7
+ # @todo Monkey patch
8
+ module Gamefic::Scriptable::Queries
9
+ def room *args
10
+ Gamefic::Query::Scoped.new Gamefic::Scope::Room, *([Room] + args)
20
11
  end
21
12
  end
22
-
23
- Gamefic.script do
24
- set_default_query Gamefic::Query::Available
25
- end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gamefic
4
4
  module Standard
5
- VERSION = '2.4.0'
5
+ VERSION = '3.0.0'
6
6
  end
7
7
  end
@@ -1,10 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gamefic'
2
4
 
3
- require 'gamefic-standard/version'
4
- require 'gamefic-standard/grammar'
5
- require 'gamefic-standard/articles'
6
- require 'gamefic-standard/queries'
7
- require 'gamefic-standard/modules'
8
- require 'gamefic-standard/direction'
9
- require 'gamefic-standard/entities'
10
- require 'gamefic-standard/actions'
5
+ module Gamefic
6
+ # The Gamefic standard library provides a base collection of entities and
7
+ # rules for interactive fiction.
8
+ #
9
+ module Standard
10
+ extend Gamefic::Scriptable
11
+
12
+ require 'gamefic-standard/version'
13
+ require 'gamefic-standard/grammar'
14
+ require 'gamefic-standard/articles'
15
+ require 'gamefic-standard/queries'
16
+ require 'gamefic-standard/modules'
17
+ require 'gamefic-standard/direction'
18
+ require 'gamefic-standard/entities'
19
+ require 'gamefic-standard/actions'
20
+ require 'gamefic-standard/introduction'
21
+
22
+ require 'gamefic-standard/give'
23
+
24
+ def connect(origin, destination, direction = nil, type: Portal, two_way: true)
25
+ origin.connect destination, direction: direction, type: type, two_way: two_way
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'gamefic-standard'
4
+
5
+ class TestPlot < Gamefic::Plot
6
+ include Gamefic::Standard
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ # Run specs in random order to surface order dependencies. If you find an
11
+ # order dependency and want to debug it, you can fix the order by providing
12
+ # the seed, which is printed after each run.
13
+ # --seed 1234
14
+ config.order = :random
15
+
16
+ # Seed global randomization in this process using the `--seed` CLI option.
17
+ # Setting this allows you to use `--seed` to deterministically reproduce
18
+ # test failures related to randomization by passing the same `--seed` value
19
+ # as the one that triggered the failure.
20
+ Kernel.srand config.seed
21
+
22
+ # Disable RSpec exposing methods globally on `Module` and `main`
23
+ config.disable_monkey_patching!
24
+
25
+ config.expect_with :rspec do |c|
26
+ c.syntax = :expect
27
+ end
28
+
29
+ config.after :each do
30
+ TestPlot.blocks.clear
31
+ end
32
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-11 00:00:00.000000000 Z
11
+ date: 2024-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
@@ -16,42 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '3.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
- version: '2.4'
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
27
41
  - !ruby/object:Gem::Dependency
28
- name: bundler
42
+ name: opal-rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '2.0'
47
+ version: '1.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '2.0'
54
+ version: '1.0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rake
56
+ name: opal-sprockets
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
61
+ version: '1.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '10.0'
68
+ version: '1.0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +105,7 @@ files:
91
105
  - ".github/workflows/rspec.yml"
92
106
  - ".gitignore"
93
107
  - ".rspec"
108
+ - ".rspec-opal"
94
109
  - ".travis.yml"
95
110
  - ".vscode/launch.json"
96
111
  - CHANGELOG.md
@@ -103,19 +118,24 @@ files:
103
118
  - gamefic-standard.gemspec
104
119
  - lib/gamefic-standard.rb
105
120
  - lib/gamefic-standard/actions.rb
121
+ - lib/gamefic-standard/actions/attack.rb
106
122
  - lib/gamefic-standard/actions/close.rb
107
123
  - lib/gamefic-standard/actions/drop.rb
108
124
  - lib/gamefic-standard/actions/enter.rb
109
125
  - lib/gamefic-standard/actions/go.rb
126
+ - lib/gamefic-standard/actions/help.rb
110
127
  - lib/gamefic-standard/actions/insert.rb
111
128
  - lib/gamefic-standard/actions/inventory.rb
112
129
  - lib/gamefic-standard/actions/leave.rb
113
130
  - lib/gamefic-standard/actions/lock.rb
114
131
  - lib/gamefic-standard/actions/look.rb
132
+ - lib/gamefic-standard/actions/move.rb
115
133
  - lib/gamefic-standard/actions/nil.rb
116
134
  - lib/gamefic-standard/actions/open.rb
117
135
  - lib/gamefic-standard/actions/place.rb
118
136
  - lib/gamefic-standard/actions/quit.rb
137
+ - lib/gamefic-standard/actions/repeat.rb
138
+ - lib/gamefic-standard/actions/save-restore-undo.rb
119
139
  - lib/gamefic-standard/actions/search.rb
120
140
  - lib/gamefic-standard/actions/take.rb
121
141
  - lib/gamefic-standard/actions/talk.rb
@@ -140,16 +160,16 @@ files:
140
160
  - lib/gamefic-standard/grammar.rb
141
161
  - lib/gamefic-standard/grammar/attributes.rb
142
162
  - lib/gamefic-standard/grammar/pronoun.rb
163
+ - lib/gamefic-standard/introduction.rb
143
164
  - lib/gamefic-standard/modules.rb
144
165
  - lib/gamefic-standard/modules/enterable.rb
145
166
  - lib/gamefic-standard/modules/lockable.rb
146
167
  - lib/gamefic-standard/modules/openable.rb
147
168
  - lib/gamefic-standard/modules/standardized.rb
148
- - lib/gamefic-standard/modules/use.rb
149
169
  - lib/gamefic-standard/pathfinder.rb
150
170
  - lib/gamefic-standard/queries.rb
151
- - lib/gamefic-standard/test.rb
152
171
  - lib/gamefic-standard/version.rb
172
+ - spec-opal/spec_helper.rb
153
173
  homepage: http://gamefic.com
154
174
  licenses:
155
175
  - MIT
@@ -162,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
182
  requirements:
163
183
  - - ">="
164
184
  - !ruby/object:Gem::Version
165
- version: '0'
185
+ version: 2.7.0
166
186
  required_rubygems_version: !ruby/object:Gem::Requirement
167
187
  requirements:
168
188
  - - ">="
@@ -1,45 +0,0 @@
1
- module Use
2
- def self.children *args
3
- Gamefic::Query::Children.new *args
4
- end
5
-
6
- def self.family *args
7
- Gamefic::Query::Family.new *args
8
- end
9
-
10
- def self.parent *args
11
- Gamefic::Query::Parent.new *args
12
- end
13
-
14
- def self.siblings *args
15
- Gamefic::Query::Siblings.new *args
16
- end
17
-
18
- def self.text *args
19
- Gamefic::Query::Text.new *args
20
- end
21
-
22
- def self.available *args
23
- Gamefic::Query::Available.new *args
24
- end
25
-
26
- def self.reachable *args
27
- available *args
28
- end
29
-
30
- def self.visible *args
31
- available *args
32
- end
33
-
34
- def self.room *args
35
- Gamefic::Query::Room.new *args
36
- end
37
-
38
- def self.itself *args
39
- Gamefic::Query::Itself.new *args
40
- end
41
-
42
- def self.from objects, *args
43
- Gamefic::Query::External.new objects, *args
44
- end
45
- end
@@ -1,34 +0,0 @@
1
- module Tester
2
- def test_procs
3
- @test_procs ||= Hash.new
4
- end
5
-
6
- def on_test name = :me, &block
7
- test_procs[name] = block
8
- end
9
-
10
- def run_test name, actor
11
- queue = []
12
- test_procs[name].call(actor, queue)
13
- actor.queue.concat queue
14
- end
15
- end
16
-
17
- class Gamefic::Plot
18
- include Tester
19
- end
20
-
21
- class Gamefic::Subplot
22
- include Tester
23
- end
24
-
25
- Gamefic.script do
26
- meta :test, Gamefic::Query::Text.new do |actor, name|
27
- sym = name.to_sym
28
- if test_procs[sym].nil?
29
- actor.tell "There's no test named '#{name}' in this game."
30
- else
31
- run_test sym, actor
32
- end
33
- end
34
- end