gamefic 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/gamefic/plot/darkroom.rb +53 -13
- data/lib/gamefic/serialize.rb +0 -2
- data/lib/gamefic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d03f9cc05efbae7569a6dfa66f5ffeccc629180581e8b6acabeddd40f8dca12
|
4
|
+
data.tar.gz: f48f8890c0d894be3c2e888a4d7325b936d66ebda39c5e2dd1c1e324dd1c091b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7776a069549d44db264d012a00306f95edcf890988cbf2669edd61de97d8cf9527306136bb8c7d07ccb7975c5a48c04029f7401a2e7ea94baf372df58c454722
|
7
|
+
data.tar.gz: ed07e4a417207f63b6bd3f84467efb2a0cd32e73d07ecc57a642b05e6dab4bf788f98b2ee3184e42a7ac0cacbb7e2985d2cdade1df513f6f7d3539f5e7ef56c2
|
data/CHANGELOG.md
CHANGED
@@ -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/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|
|
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.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: 2021-09-
|
11
|
+
date: 2021-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|