gamefic 1.2.0 → 1.3.0
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/lib/gamefic/core_ext/array.rb +1 -1
- data/lib/gamefic/plot/scene_mount.rb +4 -4
- data/lib/gamefic/plot/snapshot.rb +38 -32
- data/lib/gamefic/scene/multiple_choice.rb +0 -1
- data/lib/gamefic/shell.rb +4 -1
- data/lib/gamefic/subplot.rb +4 -3
- data/lib/gamefic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9653029c10eea5877023b0f33166f04097390a0
|
4
|
+
data.tar.gz: 7fc2ed5e68a3e308524abb5f2d273fbc69ea18bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f967f633d6054a4b9f3700938a0f0eb81a877957f3aa11c09119d102ddaac71fdb566ac9ffa5a9daddceec22aa523228c0271707d8a60ce71629618d666517
|
7
|
+
data.tar.gz: 857869d33e31abb8ca303b070210e626e7d4e0572416a71a70d2411e8878960100a2543d4c3887bad2cdd21cf4fe7bdf5135bebb363652551f1736ed69d387bd
|
@@ -66,12 +66,12 @@ module Gamefic
|
|
66
66
|
scenes[key] = Scene::Passive.new &block
|
67
67
|
end
|
68
68
|
|
69
|
-
#
|
69
|
+
# Choose a new scene based on a list of options.
|
70
70
|
# This is a specialized type of multiple-choice scene that determines
|
71
71
|
# which scene to cue based on a Hash of choices and scene keys.
|
72
72
|
#
|
73
73
|
# @example Select a scene
|
74
|
-
#
|
74
|
+
# multiple_scene :select_one_or_two, { "one" => :scene_one, "two" => :scene_two }
|
75
75
|
# scene :scene_one do |actor|
|
76
76
|
# actor.tell "You went to scene one"
|
77
77
|
# end
|
@@ -79,12 +79,12 @@ module Gamefic
|
|
79
79
|
# actor.tell "You went to scene two"
|
80
80
|
# end
|
81
81
|
# introduction do |actor|
|
82
|
-
# actor.cue
|
82
|
+
# actor.cue :select_one_or_two # The actor will be prompted to select "one" or "two" and get sent to the corresponding scene
|
83
83
|
# end
|
84
84
|
#
|
85
85
|
# @param key [Symbol] A unique name for the scene.
|
86
86
|
# @param map [Hash] A Hash of options and associated scene keys.
|
87
|
-
def
|
87
|
+
def multiple_scene key, map
|
88
88
|
scenes[key] = Scene::MultipleChoice.new(
|
89
89
|
options: map.keys,
|
90
90
|
finish: proc { |actor, input|
|
@@ -4,41 +4,11 @@ module Gamefic
|
|
4
4
|
module Plot::Snapshot
|
5
5
|
|
6
6
|
# Take a snapshot of the plot's current state.
|
7
|
+
# The snapshot is a hash with two keys: entities and subplots.
|
7
8
|
#
|
8
9
|
# @return [Hash]
|
9
10
|
def save
|
10
|
-
store =
|
11
|
-
index = 0
|
12
|
-
entities.each { |e|
|
13
|
-
hash = {}
|
14
|
-
e.serialized_attributes.each {|m|
|
15
|
-
con = m.to_s
|
16
|
-
if con.end_with?("?")
|
17
|
-
con = con[0..-2]
|
18
|
-
end
|
19
|
-
if e.respond_to?(m) == true
|
20
|
-
begin
|
21
|
-
val = e.send(m)
|
22
|
-
if val == false
|
23
|
-
hash[con] = false
|
24
|
-
elsif val
|
25
|
-
hash[con] = serialize_obj(val)
|
26
|
-
else
|
27
|
-
hash[con] = nil
|
28
|
-
end
|
29
|
-
rescue Exception => error
|
30
|
-
hash[con] = nil
|
31
|
-
end
|
32
|
-
end
|
33
|
-
}
|
34
|
-
hash[:class] = e.class.to_s
|
35
|
-
hash[:session] = {}
|
36
|
-
e.session.each_pair { |k, v|
|
37
|
-
hash[:session][k] = serialize_obj(v)
|
38
|
-
}
|
39
|
-
store.push hash
|
40
|
-
index += 1
|
41
|
-
}
|
11
|
+
store = get_entity_hash
|
42
12
|
if @initial_state.nil?
|
43
13
|
@initial_state = store
|
44
14
|
store = []
|
@@ -75,6 +45,42 @@ module Gamefic
|
|
75
45
|
internal_restore @initial_state
|
76
46
|
end
|
77
47
|
|
48
|
+
def get_entity_hash
|
49
|
+
store = []
|
50
|
+
index = 0
|
51
|
+
entities.each { |e|
|
52
|
+
hash = {}
|
53
|
+
e.serialized_attributes.each {|m|
|
54
|
+
con = m.to_s
|
55
|
+
if con.end_with?("?")
|
56
|
+
con = con[0..-2]
|
57
|
+
end
|
58
|
+
if e.respond_to?(m) == true
|
59
|
+
begin
|
60
|
+
val = e.send(m)
|
61
|
+
if val == false
|
62
|
+
hash[con] = false
|
63
|
+
elsif val
|
64
|
+
hash[con] = serialize_obj(val)
|
65
|
+
else
|
66
|
+
hash[con] = nil
|
67
|
+
end
|
68
|
+
rescue Exception => error
|
69
|
+
hash[con] = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
hash[:class] = e.class.to_s
|
74
|
+
hash[:session] = {}
|
75
|
+
e.session.each_pair { |k, v|
|
76
|
+
hash[:session][k] = serialize_obj(v)
|
77
|
+
}
|
78
|
+
store.push hash
|
79
|
+
index += 1
|
80
|
+
}
|
81
|
+
store
|
82
|
+
end
|
83
|
+
|
78
84
|
def internal_restore snapshot
|
79
85
|
index = 0
|
80
86
|
snapshot.each { |hash|
|
data/lib/gamefic/shell.rb
CHANGED
@@ -21,9 +21,12 @@ module Gamefic
|
|
21
21
|
decompress file, dir
|
22
22
|
run_game(dir)
|
23
23
|
end
|
24
|
-
rescue
|
24
|
+
rescue Zip::Error => e
|
25
25
|
puts "'#{file}' does not appear to be a valid Gamefic file."
|
26
26
|
show_exception(e) if options[:verbose]
|
27
|
+
rescue StandardError => e
|
28
|
+
puts "An error occurred: #{e.message}"
|
29
|
+
show_exception(e) if options[:verbose]
|
27
30
|
end
|
28
31
|
|
29
32
|
desc 'info FILE_NAME', 'Print information about a (.gfic) game'
|
data/lib/gamefic/subplot.rb
CHANGED
@@ -25,8 +25,8 @@ module Gamefic
|
|
25
25
|
#
|
26
26
|
# @param [Class] The class of the subplot to be created (Subplot by default)
|
27
27
|
# @return [Subplot]
|
28
|
-
def branch subplot_class
|
29
|
-
subplot = subplot_class.new(self, &block)
|
28
|
+
def branch subplot_class, feature:nil, &block
|
29
|
+
subplot = subplot_class.new(self, feature: feature, &block)
|
30
30
|
p_subplots.push subplot
|
31
31
|
subplot
|
32
32
|
end
|
@@ -39,13 +39,14 @@ module Gamefic
|
|
39
39
|
|
40
40
|
attr_reader :plot, :entities, :players
|
41
41
|
|
42
|
-
def initialize plot
|
42
|
+
def initialize plot, feature:nil
|
43
43
|
@plot = plot
|
44
44
|
@entities = []
|
45
45
|
@players = []
|
46
46
|
@concluded = false
|
47
47
|
post_initialize
|
48
48
|
yield(self) if block_given?
|
49
|
+
introduce feature unless feature.nil?
|
49
50
|
end
|
50
51
|
def post_initialize
|
51
52
|
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: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|