gamefic 4.2.3 → 4.2.5

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: a1ac6076d220397fbc78a3052bb6fbb9e83dfb3fda11aff3843abf6d3a39cd50
4
- data.tar.gz: 0a32fbb92c7104dc778eaa9b748e65d7e568f46a587eeef6d07fa96d972bf6f1
3
+ metadata.gz: 1e0ee9411012484287822ef70d9b657d157fac7a53950945ba749f5dbc457030
4
+ data.tar.gz: 867004cd0f6a9b402f53032ab4e3e0700f403bcddaa8c4ace1701afeb566e8a6
5
5
  SHA512:
6
- metadata.gz: db41d14514e7e73e9dc2b4c0bd5696a18da9635c4b2556d0930d01402aecb5bf68681226f410d5437a051bb709da7ee46b40c65885238b32d7a32f4f8676bc5c
7
- data.tar.gz: b6a8819cca8b2e66804f67cfea8841e0f3b07736116210f58e07e9bbe23ebe015ad1ab7c7ca1e040c0a0972cb59d27846d08800c7da42822c77056d58e721f64
6
+ metadata.gz: 2d46f337e4e17a0961062ffb43f14b6e5702b5bc388561d430101b8afead2707c889874f4b1df64d14253d7c1d4319d23e8ab2144c88286bc7295258346f11cb
7
+ data.tar.gz: 0a44dfea866e1280dfe964bbc2e0b6da11ed990b7df2f93f155ccbeb1fd98a900e0e062e14ceb5ef201917cfc4fe24171d4b23cee148f0e2f5ea055c5b6155be
data/.yardopts CHANGED
@@ -1 +1 @@
1
- --plugin yard-solargraph
1
+ --plugin yard-solargraph
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 4.2.5 - November 29, 2026
2
+ - Cue resolved named scenes in other narratives
3
+ - Fix included_scripts order in Opal
4
+
5
+ ## 4.2.4 - November 26, 2026
6
+ - Cue#output does not freeze data sources
7
+
1
8
  ## 4.2.3 - July 23, 2026
2
9
  - Add logger dependency
3
10
  - Cue does not freeze actor queue
@@ -43,9 +43,17 @@ module Gamefic
43
43
  scene.finish
44
44
  end
45
45
 
46
+ # A frozen snapshout of the current output.
47
+ #
46
48
  # @return [Props::Output]
47
49
  def output
48
- props&.output.clone.freeze || Props::Output::EMPTY
50
+ return Props::Output::EMPTY unless props
51
+ data = props.output
52
+ .raw_data
53
+ .clone
54
+ .transform_values! { |val| val.clone.freeze }
55
+ .freeze
56
+ Props::Output.new(**data).freeze
49
57
  end
50
58
 
51
59
  # @return [Cue]
@@ -78,13 +86,26 @@ module Gamefic
78
86
  # by symbolic keys can be instances of anonymous classes that cannot
79
87
  # be serialized, so memoizing them breaks snapshots.
80
88
  narrative&.prepare(key, actor, props, **context) ||
89
+ try_actor_narratives ||
81
90
  try_unblocked_class ||
82
91
  raise("Failed to cue #{key.inspect} in #{narrative.inspect}")
83
92
  end
84
93
 
85
94
  private
86
95
 
87
- # @return [Scene::Base]
96
+ # @todo This is a quick and dirty workaround for cues that reference a
97
+ # scene by a symbolic name that is defined in a different narrative.
98
+ #
99
+ # @return [Scene::Base, nil]
100
+ def try_actor_narratives
101
+ actor.narratives.to_a.reverse.each do |narr|
102
+ found = narr.prepare(key, actor, props, **context)
103
+ return found if found
104
+ end
105
+ nil
106
+ end
107
+
108
+ # @return [Scene::Base, nil]
88
109
  def try_unblocked_class
89
110
  return unless key.is_a?(Class) && key <= Scene::Base
90
111
 
@@ -10,93 +10,96 @@ module Gamefic
10
10
  # @param narrative [Narrative]
11
11
  # @return [self]
12
12
  def add(narrative)
13
- narrative_set.add(narrative)
13
+ narrative_array.push(narrative) unless narrative_array.include?(narrative)
14
14
  self
15
15
  end
16
16
 
17
17
  # @param narrative [Narrative]
18
18
  # @return [self]
19
19
  def delete(narrative)
20
- narrative_set.delete(narrative)
20
+ narrative_array.delete(narrative)
21
21
  self
22
22
  end
23
23
 
24
24
  def empty?
25
- narrative_set.empty?
25
+ narrative_array.empty?
26
26
  end
27
27
 
28
28
  # @return [Integer]
29
29
  def length
30
- narrative_set.length
30
+ narrative_array.length
31
31
  end
32
32
 
33
33
  def one?
34
- narrative_set.one?
34
+ narrative_array.one?
35
35
  end
36
36
 
37
37
  # @return [Array<Response>]
38
38
  def responses
39
- narrative_set.flat_map(&:responses)
39
+ narrative_array.flat_map(&:responses)
40
40
  end
41
41
 
42
42
  # @return [Array<Response>]
43
43
  def responses_for(*verbs)
44
- narrative_set.flat_map { |narr| narr.responses_for(*verbs) }
44
+ narrative_array.reverse.flat_map { |narr| narr.responses_for(*verbs) }
45
+ .reverse
46
+ .uniq(&:block)
47
+ .reverse
45
48
  end
46
49
 
47
50
  # @return [Array<Syntax>]
48
51
  def syntaxes
49
- narrative_set.flat_map(&:syntaxes)
52
+ narrative_array.flat_map(&:syntaxes)
50
53
  end
51
54
 
52
55
  # True if the specified verb is understood by any of the narratives.
53
56
  #
54
57
  # @param verb [String, Symbol]
55
58
  def understand?(verb)
56
- verb ? narrative_set.flat_map(&:synonyms).include?(verb.to_sym) : false
59
+ verb ? narrative_array.flat_map(&:synonyms).include?(verb.to_sym) : false
57
60
  end
58
61
 
59
62
  # @return [Array<Binding>]
60
63
  def before_commands
61
- narrative_set.flat_map(&:before_commands)
64
+ narrative_array.flat_map(&:before_commands)
62
65
  end
63
66
 
64
67
  # @return [Array<Binding>]
65
68
  def after_commands
66
- narrative_set.flat_map(&:after_commands)
69
+ narrative_array.flat_map(&:after_commands)
67
70
  end
68
71
 
69
72
  # @sg-ignore Type checker has trouble reconciling return type of `Set#each`
70
73
  # with unresolved `generic<R>` of `Enumerable#each`
71
74
  def each(&block)
72
- narrative_set.each(&block)
75
+ narrative_array.each(&block)
73
76
  end
74
77
 
75
78
  # @return [Array<Narrative>]
76
79
  def that_are(*args)
77
- narrative_set.to_a.that_are(*args)
80
+ narrative_array.to_a.that_are(*args)
78
81
  end
79
82
 
80
83
  # @return [Array<Narrative>]
81
84
  def that_are_not(*args)
82
- narrative_set.to_a.that_are_not(*args)
85
+ narrative_array.to_a.that_are_not(*args)
83
86
  end
84
87
 
85
88
  # @return [Array<Entity>]
86
89
  def entities
87
- narrative_set.flat_map(&:entities)
90
+ narrative_array.flat_map(&:entities)
88
91
  end
89
92
 
90
93
  # @return [Array<Binding>]
91
94
  def player_output_blocks
92
- narrative_set.flat_map(&:player_output_blocks).uniq(&:code)
95
+ narrative_array.flat_map(&:player_output_blocks).uniq(&:code)
93
96
  end
94
97
 
95
98
  private
96
99
 
97
- # @return [Set<Narrative>]
98
- def narrative_set
99
- @narrative_set ||= Set.new
100
+ # @return [Array<Narrative>]
101
+ def narrative_array
102
+ @narrative_array ||= []
100
103
  end
101
104
  end
102
105
  end
@@ -86,12 +86,6 @@ module Gamefic
86
86
  raw_data.replace data
87
87
  end
88
88
 
89
- def freeze
90
- raw_data.freeze
91
- raw_data.each_value(&:freeze)
92
- super
93
- end
94
-
95
89
  def method_missing method, *args
96
90
  return raw_data[method] if READER_METHODS.include?(method)
97
91
 
@@ -8,6 +8,7 @@ module Gamefic
8
8
  class MultipleChoice < Base
9
9
  use_props_class Props::MultipleChoice
10
10
 
11
+ # @param options [Array<String>]
11
12
  def initialize(...)
12
13
  super
13
14
  props.options.concat(context[:options] || [])
@@ -38,7 +38,10 @@ module Gamefic
38
38
  include Syntaxes
39
39
 
40
40
  def included_scripts
41
- ancestors.that_are(Scriptable).uniq
41
+ # Opal does not filter for unique ancestors (presumably because it can't
42
+ # guarantee Set ordering), so we need to reverse -> uniq -> reverse them
43
+ # to maintain the same order as Ruby.
44
+ ancestors.that_are(Scriptable).reverse.uniq.reverse
42
45
  end
43
46
  end
44
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gamefic
4
- VERSION = '4.2.3'
4
+ VERSION = '4.2.5'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.3
4
+ version: 4.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-07-23 00:00:00.000000000 Z
10
+ date: 2026-11-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: base64