gamefic 2.2.0 → 2.2.3
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/.rubocop.yml +1 -4
- data/CHANGELOG.md +9 -0
- data/lib/gamefic/plot/darkroom.rb +53 -13
- data/lib/gamefic/scriptable.rb +3 -2
- data/lib/gamefic/serialize.rb +0 -3
- data/lib/gamefic/subplot.rb +2 -2
- data/lib/gamefic/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57ab533bcfbcbd650cf3ee60c5a639b3ddd40ad3ad96d0d4e42e6658547f3d9
|
4
|
+
data.tar.gz: 904c5211a6bde65f870ae8bab1218423afd6618c6ddd79c44b01174bb069256b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc3e6a06d6ac451827cea70db94b8c9e4b10c795dac9812df0c24f8c1e0ce654748dfae53c4c0565bbfff8abb5d2f853f866c1aac8b398c5cf8331ee3ea1795
|
7
|
+
data.tar.gz: dd790a5574ae81e91b61d01c7f18adba0abcd7e43650e72934329dfd84c9515adb54b6e1e0938814c9d6c6582d23801c66a470a28ae99700659fa0c462830660
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 2.2.3 - July 9, 2022
|
2
|
+
- Fix Ruby version incompatibilities
|
3
|
+
|
4
|
+
## 2.2.2 - September 6, 2021
|
5
|
+
- Darkroom indexes non-static elements
|
6
|
+
|
7
|
+
## 2.2.1 - September 5, 2021
|
8
|
+
- Retain unknown values in restored snapshots
|
9
|
+
|
1
10
|
## 2.2.0 - September 4, 2021
|
2
11
|
- Dynamically inherit default attributes
|
3
12
|
|
@@ -3,9 +3,10 @@ module Gamefic
|
|
3
3
|
#
|
4
4
|
class Plot
|
5
5
|
class Darkroom
|
6
|
-
# @return [
|
6
|
+
# @return [Plot]
|
7
7
|
attr_reader :plot
|
8
8
|
|
9
|
+
# @param plot [Plot]
|
9
10
|
def initialize plot
|
10
11
|
@plot = plot
|
11
12
|
end
|
@@ -14,20 +15,9 @@ module Gamefic
|
|
14
15
|
#
|
15
16
|
# @return [Hash]
|
16
17
|
def save
|
17
|
-
index = plot.static + plot.players
|
18
|
-
plot.to_serial(index)
|
19
18
|
{
|
20
19
|
'program' => {}, # @todo Metadata for version control, etc.
|
21
|
-
'index' => index.map
|
22
|
-
if i.is_a?(Gamefic::Serialize)
|
23
|
-
{
|
24
|
-
'class' => i.class.to_s,
|
25
|
-
'ivars' => i.serialize_instance_variables(index)
|
26
|
-
}
|
27
|
-
else
|
28
|
-
i.to_serial(index)
|
29
|
-
end
|
30
|
-
end
|
20
|
+
'index' => index.map { |obj| serialize_indexed(obj) }
|
31
21
|
}
|
32
22
|
end
|
33
23
|
|
@@ -75,6 +65,56 @@ module Gamefic
|
|
75
65
|
end
|
76
66
|
end
|
77
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def index
|
72
|
+
@index ||= begin
|
73
|
+
populate_full_index_from(plot)
|
74
|
+
Set.new(plot.static + plot.players).merge(full_index).to_a
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def full_index
|
79
|
+
@full_index ||= Set.new
|
80
|
+
end
|
81
|
+
|
82
|
+
def populate_full_index_from(object)
|
83
|
+
return if full_index.include?(object)
|
84
|
+
if object.is_a?(Array) || object.is_a?(Set)
|
85
|
+
object.each { |ele| populate_full_index_from(ele) }
|
86
|
+
elsif object.is_a?(Hash)
|
87
|
+
object.each_pair do |k, v|
|
88
|
+
populate_full_index_from(k)
|
89
|
+
populate_full_index_from(v)
|
90
|
+
end
|
91
|
+
else
|
92
|
+
if object.is_a?(Gamefic::Serialize)
|
93
|
+
full_index.add object unless object.is_a?(Module) && object.name
|
94
|
+
object.instance_variables.each do |v|
|
95
|
+
next if object.class.excluded_from_serial.include?(v)
|
96
|
+
populate_full_index_from(object.instance_variable_get(v))
|
97
|
+
end
|
98
|
+
else
|
99
|
+
object.instance_variables.each do |v|
|
100
|
+
populate_full_index_from(object.instance_variable_get(v))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def serialize_indexed object
|
107
|
+
if object.is_a?(Gamefic::Serialize)
|
108
|
+
# Serialized objects in the index should be a full serialization.
|
109
|
+
# Serialize#to_serial rturns a reference to the indexed object.
|
110
|
+
{
|
111
|
+
'class' => object.class.to_s,
|
112
|
+
'ivars' => object.serialize_instance_variables(index)
|
113
|
+
}
|
114
|
+
else
|
115
|
+
object.to_serial(index)
|
116
|
+
end
|
117
|
+
end
|
78
118
|
end
|
79
119
|
end
|
80
120
|
end
|
data/lib/gamefic/scriptable.rb
CHANGED
@@ -76,8 +76,9 @@ Gamefic::Scriptable.module_exec do
|
|
76
76
|
instance = self
|
77
77
|
theater ||= Object.new
|
78
78
|
theater.instance_exec do
|
79
|
-
define_singleton_method :method_missing do |symbol, *args, &block|
|
80
|
-
instance.public_send :public_send, symbol, *args, &block
|
79
|
+
define_singleton_method :method_missing do |symbol, *args, **splat, &block|
|
80
|
+
result = instance.public_send :public_send, symbol, *args, **splat, &block
|
81
|
+
result
|
81
82
|
end
|
82
83
|
end
|
83
84
|
theater.extend Gamefic::Serialize
|
data/lib/gamefic/serialize.rb
CHANGED
@@ -15,7 +15,6 @@ module Gamefic
|
|
15
15
|
'name' => name
|
16
16
|
}
|
17
17
|
else
|
18
|
-
index.push self if self.is_a?(Gamefic::Serialize)
|
19
18
|
{
|
20
19
|
'class' => serialized_class(index),
|
21
20
|
'ivars' => serialize_instance_variables(index)
|
@@ -89,7 +88,6 @@ class Object
|
|
89
88
|
end
|
90
89
|
raise "Unable to find class #{self['class']} #{self}" if klass.nil?
|
91
90
|
object = klass.allocate
|
92
|
-
index.push object if object.is_a?(Gamefic::Serialize)
|
93
91
|
end
|
94
92
|
end
|
95
93
|
self['ivars'].each_pair do |k, v|
|
@@ -103,7 +101,6 @@ class Object
|
|
103
101
|
return index.index(match[1].to_i) if match
|
104
102
|
match = self.match(/#<SYM:([a-z0-9_\?\!]+)>/i)
|
105
103
|
return match[1].to_sym if match
|
106
|
-
return nil if self == '#<UNKNOWN>'
|
107
104
|
self
|
108
105
|
else
|
109
106
|
# true, false, or nil
|
data/lib/gamefic/subplot.rb
CHANGED
@@ -19,7 +19,7 @@ module Gamefic
|
|
19
19
|
@next_cue = next_cue
|
20
20
|
@concluded = false
|
21
21
|
@more = more
|
22
|
-
configure more
|
22
|
+
configure **more
|
23
23
|
run_scripts
|
24
24
|
playbook.freeze
|
25
25
|
self.introduce introduce unless introduce.nil?
|
@@ -97,7 +97,7 @@ module Gamefic
|
|
97
97
|
# Subclasses can override this method to handle additional configuration
|
98
98
|
# options.
|
99
99
|
#
|
100
|
-
def configure more
|
100
|
+
def configure **more
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
data/lib/gamefic/version.rb
CHANGED
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.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0'
|
151
151
|
requirements: []
|
152
|
-
rubygems_version: 3.
|
152
|
+
rubygems_version: 3.3.7
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Gamefic
|