gamefic 4.1.0 → 4.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5aaa5c2e7e709434b596c7bd216138ccc693d3893c56ed87ee54640e545d729
4
- data.tar.gz: a7f12b8da551d9f97b279e6050333561e5d348940681cab7cf894f97a9eca085
3
+ metadata.gz: e90aabf8b81551f127b57f7a70f62aa0cc92c0bc8e346ffe5056260678b0ae86
4
+ data.tar.gz: 7607b66f7927acd8310ba3a0be94834102c8fcf1d7458c3bbd950de44cabd9b0
5
5
  SHA512:
6
- metadata.gz: b15fe4c2f586a9164a3166273c15638e548fbcf78d3f3e5bef41f55a8c054c06f1d5a16c62cbb13a252e635e0416c5fcb6da1f8574a1ac3323bb117d76f78fea
7
- data.tar.gz: d26cb35d5a6fcae8f4c3511e2b22339491b5773d2288914c1125eeb38da4db51440e5780c28b1b4aec0344bb819f4abb97323d9ef5bcf21404667edf28705fe7
6
+ metadata.gz: c84cc7bf2a99438d3b61a11197b43c51d3577413f0249ad44360bb7b97520b3c1fec48e39f833c0bd999ae5de3a1b934e2d4b17983544840bccb861504207eca
7
+ data.tar.gz: 3c512256a34fa09048e79216a1defdc8fa076d89d2bb4549b1bbe35fbaae5c272eb156b84d5daa7f310a800d64217c49cb74c351115e7de8cd8ca25fd57382d5
@@ -22,7 +22,7 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.7', '3.0', '3.1', '3.3']
25
+ ruby-version: ['2.7', '3.0', '3.1', '3.3', '3.4']
26
26
 
27
27
  steps:
28
28
  - uses: actions/checkout@v3
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- Metrics/LineLength:
1
+ Layout/LineLength:
2
2
  Description: 'Limit lines to 80 characters.'
3
3
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits'
4
4
  Enabled: false
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --plugin yard-solargraph
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 4.1.2 - May 25, 2025
2
+ - Seed unreferenced entities
3
+ - Ensure seed uniqueness
4
+ - Add base64 dependency
5
+
6
+ ## 4.1.1 - March 2, 2025
7
+ - Warn for duplicate chapters
8
+ - YARD documentation
9
+
1
10
  ## 4.1.0 - February 1, 2025
2
11
  - Correct Scenes#pause block
3
12
 
data/Rakefile CHANGED
@@ -15,7 +15,8 @@ task :default => :spec
15
15
 
16
16
  Opal::RSpec::RakeTask.new(:opal) do |_, config|
17
17
  Opal.append_path File.join(__dir__, 'lib')
18
+ Opal.append_path File.join(__dir__, 'spec', 'fixtures', 'modular')
18
19
  config.default_path = 'spec'
19
20
  config.pattern = 'spec/**/*_spec.rb'
20
- config.requires = ['opal_helper']
21
+ config.requires = ['opal_helper', 'modular_test_script', 'modular_test_plot']
21
22
  end
data/gamefic.gemspec CHANGED
@@ -21,6 +21,9 @@ Gem::Specification.new do |s|
21
21
 
22
22
  s.required_ruby_version = '>= 2.7.0'
23
23
 
24
+ s.add_runtime_dependency 'base64', '~> 0.1'
25
+ s.add_runtime_dependency 'yard-solargraph', '~> 0.1'
26
+
24
27
  s.add_development_dependency 'opal', '~> 1.7'
25
28
  s.add_development_dependency 'opal-rspec', '~> 1.0'
26
29
  s.add_development_dependency 'opal-sprockets', '~> 1.0'
@@ -66,6 +66,8 @@ module Gamefic
66
66
  narrative_set.flat_map(&:after_commands)
67
67
  end
68
68
 
69
+ # @sg-ignore Type checker has trouble reconciling return type of `Set#each`
70
+ # with unresolved `generic<R>` of `Enumerable#each`
69
71
  def each(&block)
70
72
  narrative_set.each(&block)
71
73
  end
@@ -44,6 +44,7 @@ module Gamefic
44
44
 
45
45
  # Subclasses can override this method to handle additional configuration.
46
46
  #
47
+ # @return [void]
47
48
  def configure; end
48
49
 
49
50
  class << self
@@ -14,16 +14,16 @@ module Gamefic
14
14
 
15
15
  # Cast a player character in the plot.
16
16
  #
17
- # @param character [Actor]
18
- # @return [Actor]
17
+ # @param character [Actor, Active]
18
+ # @return [Actor, Active]
19
19
  def cast(character = plot.introduce)
20
20
  plot.cast character
21
21
  end
22
22
 
23
23
  # Uncast a player character from the plot.
24
24
  #
25
- # @param character [Actor]
26
- # @return [Actor]
25
+ # @param character [Actor, Active]
26
+ # @return [Actor, Active]
27
27
  def uncast(character)
28
28
  plot.uncast character
29
29
  end
data/lib/gamefic/plot.rb CHANGED
@@ -41,6 +41,8 @@ module Gamefic
41
41
  end
42
42
 
43
43
  def self.append(chapter, **config)
44
+ Gamefic.logger.warn "Overwriting existing chapter #{chapter}" if appended_chapter_map.key?(chapter)
45
+
44
46
  appended_chapter_map[chapter] = config
45
47
  end
46
48
 
@@ -77,7 +77,7 @@ module Gamefic
77
77
  # gets sorted in descending order of their responses' overall precision,
78
78
  # so the action with the highest precision gets attempted first.
79
79
  #
80
- # @return [Integer]
80
+ # @return [::Integer]
81
81
  def precision
82
82
  @precision ||= calculate_precision
83
83
  end
@@ -18,7 +18,7 @@ module Gamefic
18
18
  # @param selection [Array<Entity>]
19
19
  # @param token [String]
20
20
  # @param use [Array<Class<Scanner::Base>>]
21
- # @return [Result]
21
+ # @return [Result, nil]
22
22
  def self.scan(selection, token, use = processors)
23
23
  result = nil
24
24
  use.each do |processor|
@@ -12,8 +12,8 @@ module Gamefic
12
12
  attr_reader :actor, :narrative, :props, :context
13
13
 
14
14
  # @param actor [Actor]
15
- # @param narrative [Narrative]
16
- # @param props [Props::Default]
15
+ # @param narrative [Narrative, nil]
16
+ # @param props [Props::Default, nil]
17
17
  def initialize(actor, narrative = nil, props = nil, **context)
18
18
  @actor = actor
19
19
  @narrative = narrative
@@ -95,16 +95,18 @@ module Gamefic
95
95
  @finish_blocks ||= []
96
96
  end
97
97
 
98
- # @yieldparam [Actor] The scene's actor
99
- # @yieldparam [Props::Default] The scene's props
100
- # @yieldparam [Hash] Additional context
98
+ # @yieldparam actor [Actor] The scene's actor
99
+ # @yieldparam props [Props::Default] The scene's props
100
+ # @yieldparam context [Hash] Additional context
101
+ # @yieldreceiver [Narrative]
101
102
  def on_start(&block)
102
103
  start_blocks.push block
103
104
  end
104
105
 
105
- # @yieldparam [Actor] The scene's actor
106
- # @yieldparam [Props::Default] The scene's props
107
- # @yieldparam [Hash] Additional context
106
+ # @yieldparam actor [Actor] The scene's actor
107
+ # @yieldparam props [Props::Default] The scene's props
108
+ # @yieldparam context [Hash] Additional context
109
+ # @yieldreceiver [Narrative]
108
110
  def on_finish(&block)
109
111
  finish_blocks.push block
110
112
  end
@@ -26,7 +26,7 @@ module Gamefic
26
26
  # @param verbs [Array<Symbol>]
27
27
  # @yieldparam [Actor]
28
28
  # @yieldparam [Command]
29
- # @yieldself [Object<self>]
29
+ # @yieldreceiver [Object<self>]
30
30
  def before_command(*verbs, &block)
31
31
  before_commands.push(proc do |actor, command|
32
32
  instance_exec(actor, command, &block) if verbs.empty? || verbs.include?(command.verb)
@@ -43,7 +43,7 @@ module Gamefic
43
43
  # @param verbs [Array<Symbol>]
44
44
  # @yieldparam [Actor]
45
45
  # @yieldparam [Command]
46
- # @yieldself [Object<self>]
46
+ # @yieldreceiver [Object<self>]
47
47
  def after_command(*verbs, &block)
48
48
  after_commands.push(proc do |actor, command|
49
49
  instance_exec(actor, command, &block) if verbs.empty? || verbs.include?(command.verb)
@@ -52,7 +52,7 @@ module Gamefic
52
52
 
53
53
  # Define a callback to be executed after a scene starts.
54
54
  #
55
- # @yieldself [Object<self>]
55
+ # @yieldreceiver [Object<self>]
56
56
  def on_ready(&block)
57
57
  ready_blocks.push block
58
58
  end
@@ -61,14 +61,14 @@ module Gamefic
61
61
  # a scene starts.
62
62
  #
63
63
  # @yieldparam [Actor]
64
- # @yieldself [Object<self>]
64
+ # @yieldreceiver [Object<self>]
65
65
  def on_player_ready(&block)
66
66
  ready_blocks.push(proc { players.each { |player| instance_exec(player, &block) } })
67
67
  end
68
68
 
69
69
  # Define a callback to be executed after a scene finishes.
70
70
  #
71
- # @yieldself [Object<self>]
71
+ # @yieldreceiver [Object<self>]
72
72
  def on_update(&block)
73
73
  update_blocks.push block
74
74
  end
@@ -77,7 +77,7 @@ module Gamefic
77
77
  # a scene finishes.
78
78
  #
79
79
  # @yieldparam [Actor]
80
- # @yieldself [Object<self>]
80
+ # @yieldreceiver [Object<self>]
81
81
  def on_player_update(&block)
82
82
  update_blocks.push(proc { players.each { |player| instance_exec(player, &block) } })
83
83
  end
@@ -97,7 +97,7 @@ module Gamefic
97
97
  #
98
98
  # @yieldparam [Actor]
99
99
  # @yieldparam [Props::Output]
100
- # @yieldself [Object<self>]
100
+ # @yieldreceiver [Object<self>]
101
101
  def on_player_output(&block)
102
102
  player_output_blocks.push(block)
103
103
  end
@@ -105,7 +105,7 @@ module Gamefic
105
105
  # Define a callback that gets executed when a narrative reaches a
106
106
  # conclusion.
107
107
  #
108
- # @yieldself [Object<self>]
108
+ # @yieldreceiver [Object<self>]
109
109
  def on_conclude(&block)
110
110
  conclude_blocks.push(block)
111
111
  end
@@ -117,7 +117,7 @@ module Gamefic
117
117
  # narrative itself concluding.
118
118
  #
119
119
  # @yieldparam [Actor]
120
- # @yieldself [Object<self>]
120
+ # @yieldreceiver [Object<self>]
121
121
  def on_player_conclude(&block)
122
122
  player_conclude_blocks.push(block)
123
123
  end
@@ -27,7 +27,7 @@ module Gamefic
27
27
  # @param verb [Symbol, String, nil] An imperative verb for the command
28
28
  # @param args [Array<Object>] Filters for the command's tokens
29
29
  # @yieldparam [Gamefic::Actor]
30
- # @yieldself [Object<self>]
30
+ # @yieldreceiver [Object<self>]
31
31
  # @return [Response]
32
32
  def respond verb, *args, &proc
33
33
  response = Response.new(verb&.to_sym, *args, &proc)
@@ -41,7 +41,7 @@ module Gamefic
41
41
  # @param verb [Symbol, String, nil] An imperative verb for the command
42
42
  # @param args [Array<Object>] Filters for the command's tokens
43
43
  # @yieldparam [Gamefic::Actor]
44
- # @yieldself [Object<self>]
44
+ # @yieldreceiver [Object<self>]
45
45
  # @return [Response]
46
46
  def meta verb, *args, &proc
47
47
  response = Response.new(verb&.to_sym, *args, meta: true, &proc)
@@ -11,11 +11,13 @@ module Gamefic
11
11
  # @return [Scene::Conclusion]
12
12
  attr_reader :default_conclusion
13
13
 
14
+ # @param [Scene::Base]
14
15
  def select_default_scene(klass)
15
16
  scene_classes.add klass
16
17
  @default_scene = klass
17
18
  end
18
19
 
20
+ # @param [Scene::Conclusion]
19
21
  def select_default_conclusion(klass)
20
22
  scene_classes.add klass
21
23
  @default_conclusion = klass
@@ -44,6 +46,7 @@ module Gamefic
44
46
  end
45
47
  alias scene block
46
48
 
49
+ # @return [Array<Proc>]
47
50
  def introductions
48
51
  @introductions ||= []
49
52
  end
@@ -60,7 +63,8 @@ module Gamefic
60
63
  #
61
64
  # @yieldparam [Gamefic::Actor]
62
65
  # @yieldparam [Props::Default]
63
- # @return [Symbol]
66
+ # @yieldreceiver [Object<self>]
67
+ # @return [void]
64
68
  def introduction(&start)
65
69
  introductions.push start
66
70
  end
@@ -84,9 +88,10 @@ module Gamefic
84
88
  # end
85
89
  #
86
90
  # @param name [Symbol, nil]
91
+ # @yieldreceiver [Class<Scene::MultipleChoice>]
87
92
  # @return [Class<Scene::MultipleChoice>]
88
93
  def multiple_choice(name = nil, &block)
89
- block Class.new(Scene::MultipleChoice, &block), name
94
+ self.block Class.new(Scene::MultipleChoice, &block), name
90
95
  end
91
96
 
92
97
  # Create a yes-or-no scene.
@@ -111,7 +116,7 @@ module Gamefic
111
116
  # @param name [Symbol, nil]
112
117
  # @return [Class<Scene::YesOrNo>]
113
118
  def yes_or_no(name = nil, &block)
114
- block Class.new(Scene::YesOrNo, &block), name
119
+ self.block Class.new(Scene::YesOrNo, &block), name
115
120
  end
116
121
 
117
122
  # Create an active choice scene.
@@ -119,7 +124,7 @@ module Gamefic
119
124
  # @param name [Symbol, nil]
120
125
  # @return [Class<Scene::ActiveChoice>]
121
126
  def active_choice(name = nil, &block)
122
- block Class.new(Scene::ActiveChoice, &block), name
127
+ self.block Class.new(Scene::ActiveChoice, &block), name
123
128
  end
124
129
 
125
130
  # Create a pause.
@@ -129,9 +134,10 @@ module Gamefic
129
134
  # @param name [Symbol, nil]
130
135
  # @yieldparam [Actor]
131
136
  # @yieldparam [Props::Default]
137
+ # @yieldreceiver [Object<self>]
132
138
  # @return [Class<Scene::Pause>]
133
139
  def pause(name = nil, &block)
134
- block(Class.new(Scene::Pause) do
140
+ self.block(Class.new(Scene::Pause) do
135
141
  on_start(&block)
136
142
  end, name)
137
143
  end
@@ -148,9 +154,10 @@ module Gamefic
148
154
  # @param name [Symbol, nil]
149
155
  # @yieldparam [Actor]
150
156
  # @yieldparam [Props::Default]
157
+ # @yieldreceiver [Object<self>]
151
158
  # @return [Class<Scene::Conclusion>]
152
159
  def conclusion(name = nil, &block)
153
- block(Class.new(Scene::Conclusion) do
160
+ self.block(Class.new(Scene::Conclusion) do
154
161
  on_start(&block)
155
162
  end, name)
156
163
  end
@@ -62,7 +62,7 @@ module Gamefic
62
62
  # pick('the red box')
63
63
  #
64
64
  # @param args [Array]
65
- # @return [Proxy]
65
+ # @return [Proxy::Pick]
66
66
  def pick *args
67
67
  Proxy::Pick.new(*args)
68
68
  end
@@ -18,7 +18,7 @@ module Gamefic
18
18
  # @param translation [String] The format of the translated command
19
19
  # @return [Syntax] the Syntax object
20
20
  def interpret command, translation
21
- syntaxes.push Syntax.new(command, translation)
21
+ syntaxes.push(Syntax.new(command, translation)).last
22
22
  end
23
23
 
24
24
  def syntaxes
@@ -3,7 +3,7 @@ module Gamefic
3
3
  module Seeds
4
4
  # @return [Array<Proc>]
5
5
  def seeds
6
- self.class.seeds
6
+ (included_scripts.flat_map(&:seeds) + self.class.seeds).uniq
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gamefic
4
- VERSION = '4.1.0'
4
+ VERSION = '4.1.2'
5
5
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-01 00:00:00.000000000 Z
11
+ date: 2025-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yard-solargraph
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: opal
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +140,7 @@ files:
112
140
  - ".rspec-opal"
113
141
  - ".rubocop.yml"
114
142
  - ".solargraph.yml"
143
+ - ".yardopts"
115
144
  - CHANGELOG.md
116
145
  - Gemfile
117
146
  - LICENSE
@@ -226,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
255
  - !ruby/object:Gem::Version
227
256
  version: '0'
228
257
  requirements: []
229
- rubygems_version: 3.3.7
258
+ rubygems_version: 3.5.22
230
259
  signing_key:
231
260
  specification_version: 4
232
261
  summary: Gamefic