gamefic-sdk 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/html/core/engine.js +16 -61
- data/html/sinatra/engine.js +51 -0
- data/html/skins/standard/index.html.erb +1 -1
- data/html/skins/standard/play.js +20 -4
- data/html/skins/standard/style.css +3 -0
- data/lib/gamefic-sdk.rb +2 -2
- data/lib/gamefic-sdk/debug/plot.rb +1 -1
- data/lib/gamefic-sdk/platform.rb +1 -0
- data/lib/gamefic-sdk/platform/sinatra.rb +100 -0
- data/lib/gamefic-sdk/platform/web.rb +19 -12
- data/lib/gamefic-sdk/platform/web/app_config.rb +5 -6
- data/lib/gamefic-sdk/platform/web/engine.rb +41 -0
- data/lib/gamefic-sdk/platform/web/user.rb +19 -0
- data/lib/gamefic-sdk/server.rb +67 -0
- data/lib/gamefic-sdk/shell.rb +50 -10
- data/lib/gamefic-sdk/shell/init.rb +7 -2
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scripts/autosuggest.plot.rb +5 -11
- data/scripts/clothing/actions/wear.plot.rb +1 -1
- data/scripts/clothing/entities/clothing.plot.rb +1 -1
- data/scripts/clothing/entities/coat.plot.rb +1 -1
- data/scripts/clothing/entities/gloves.plot.rb +1 -1
- data/scripts/clothing/entities/hat.plot.rb +1 -1
- data/scripts/clothing/entities/pants.plot.rb +1 -1
- data/scripts/clothing/entities/shirt.plot.rb +1 -1
- data/scripts/clothing/entities/shoes.plot.rb +1 -1
- data/scripts/save-restore.plot.rb +1 -0
- data/scripts/snapshots.plot.rb +1 -1
- data/scripts/standard.plot.rb +1 -1
- data/scripts/standard/actions/close.plot.rb +2 -2
- data/scripts/standard/actions/drop.plot.rb +6 -2
- data/scripts/standard/actions/give.plot.rb +12 -17
- data/scripts/standard/actions/go.plot.rb +7 -6
- data/scripts/standard/actions/lock.plot.rb +3 -3
- data/scripts/standard/actions/look-under.plot.rb +1 -1
- data/scripts/standard/actions/look.plot.rb +13 -8
- data/scripts/standard/actions/nil.plot.rb +1 -1
- data/scripts/standard/actions/place.plot.rb +2 -1
- data/scripts/standard/actions/read.plot.rb +1 -1
- data/scripts/standard/actions/search.plot.rb +1 -0
- data/scripts/standard/actions/take.plot.rb +1 -1
- data/scripts/standard/actions/talk.plot.rb +4 -4
- data/scripts/standard/actions/unlock.plot.rb +6 -6
- data/scripts/standard/actions/use.plot.rb +4 -4
- data/scripts/standard/entities/character.plot.rb +0 -2
- data/scripts/standard/entities/container.plot.rb +1 -4
- data/scripts/standard/entities/door.plot.rb +1 -3
- data/scripts/standard/entities/entity.plot.rb +0 -1
- data/scripts/standard/entities/exterior.plot.rb +1 -1
- data/scripts/standard/entities/fixture.plot.rb +1 -1
- data/scripts/standard/entities/item.plot.rb +1 -1
- data/scripts/standard/entities/portal.plot.rb +2 -3
- data/scripts/standard/entities/receptacle.plot.rb +1 -2
- data/scripts/standard/entities/room.plot.rb +4 -6
- data/scripts/standard/entities/rubble.plot.rb +1 -1
- data/scripts/standard/entities/scenery.plot.rb +1 -1
- data/scripts/standard/entities/supporter.plot.rb +2 -2
- data/scripts/standard/modules/attachable.plot.rb +1 -1
- data/scripts/standard/modules/auto_takes.plot.rb +1 -1
- data/scripts/standard/modules/darkenable.plot.rb +1 -1
- data/scripts/standard/modules/enterable.plot.rb +1 -1
- data/scripts/standard/modules/explicit_exits.plot.rb +1 -1
- data/scripts/standard/modules/itemizable.plot.rb +1 -1
- data/scripts/standard/modules/lockable.plot.rb +1 -1
- data/scripts/standard/modules/openable.plot.rb +4 -1
- data/scripts/standard/modules/parent-room.plot.rb +1 -1
- data/scripts/standard/modules/portable.plot.rb +1 -1
- data/scripts/standard/modules/transparent.plot.rb +1 -1
- data/scripts/standard/plural/actions/place.plot.rb +2 -2
- data/scripts/standard/queries.plot.rb +21 -4
- data/scripts/standard/use.plot.rb +26 -8
- data/scripts/suggestible.plot.rb +17 -17
- metadata +58 -10
- data/lib/gamefic-sdk/platform/web/gamefic_opal.rb +0 -45
- data/scripts/standard/queries/from_expression.plot.rb +0 -16
- data/scripts/standard/queries/reachable.plot.rb +0 -48
- data/scripts/standard/queries/room.plot.rb +0 -17
- data/scripts/standard/queries/visible.plot.rb +0 -45
@@ -17,12 +17,12 @@ respond :place, Use.any_expression, Use.ambiguous_children, Use.reachable(Suppor
|
|
17
17
|
actor.perform :place, children, supporter
|
18
18
|
end
|
19
19
|
|
20
|
-
respond :place, Use.text(
|
20
|
+
respond :place, Use.text(/(all|everything)/), Use.reachable(Supporter) do |actor, _, supporter|
|
21
21
|
children = Use.children.context_from(actor).that_are_not(:attached?)
|
22
22
|
actor.perform :place, children, supporter
|
23
23
|
end
|
24
24
|
|
25
|
-
respond :place, Use.text(
|
25
|
+
respond :place, Use.text(/(all|everything)/), Use.text(/(except|but)/), Use.ambiguous_children, Use.reachable(Supporter) do |actor, _, _, exceptions, supporter|
|
26
26
|
children = Use.children.context_from(actor).that_are_not(:attached?)
|
27
27
|
actor.perform :place, children - exceptions, supporter
|
28
28
|
end
|
@@ -1,4 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
class Gamefic::Query::Available < Gamefic::Query::Base
|
2
|
+
def context_from(subject)
|
3
|
+
result = []
|
4
|
+
top = subject.room || subject.parent
|
5
|
+
unless top.nil?
|
6
|
+
result.concat subquery_accessible(top)
|
7
|
+
end
|
8
|
+
result.delete subject
|
9
|
+
subject.children.each { |c|
|
10
|
+
result.push c
|
11
|
+
result.concat subquery_accessible(c)
|
12
|
+
}
|
13
|
+
result
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Gamefic::Query::Room < Gamefic::Query::Base
|
18
|
+
def context_from(subject)
|
19
|
+
subject.room ? [subject.room] : []
|
20
|
+
end
|
21
|
+
end
|
@@ -2,28 +2,46 @@ module Gamefic::Use
|
|
2
2
|
def self.children *args
|
3
3
|
Gamefic::Query::Children.new *args
|
4
4
|
end
|
5
|
+
|
5
6
|
def self.family *args
|
6
7
|
Gamefic::Query::Family.new *args
|
7
8
|
end
|
9
|
+
|
8
10
|
def self.parent *args
|
9
11
|
Gamefic::Query::Parent.new *args
|
10
12
|
end
|
13
|
+
|
11
14
|
def self.siblings *args
|
12
15
|
Gamefic::Query::Siblings.new *args
|
13
16
|
end
|
17
|
+
|
14
18
|
def self.text *args
|
15
19
|
Gamefic::Query::Text.new *args
|
16
20
|
end
|
17
|
-
|
18
|
-
|
21
|
+
|
22
|
+
# @todo This query is a candidate for deprecation. It's probably not worth
|
23
|
+
# the trouble to maintain a separate query just for transparent containers.
|
24
|
+
#
|
25
|
+
def self.visible *args
|
26
|
+
Gamefic::Query::Family.new *args
|
27
|
+
end
|
28
|
+
|
29
|
+
# @todo This query is a candidate for deprecation. For now it's an alias for
|
30
|
+
# Use.available.
|
31
|
+
#
|
32
|
+
def self.reachable *args
|
33
|
+
Gamefic::Query::Available.new *args
|
19
34
|
end
|
20
|
-
|
21
|
-
|
35
|
+
|
36
|
+
def self.available *args
|
37
|
+
Gamefic::Query::Available.new *args
|
22
38
|
end
|
23
|
-
|
24
|
-
|
39
|
+
|
40
|
+
def self.room *args
|
41
|
+
Gamefic::Query::Room.new *args
|
25
42
|
end
|
26
|
-
|
27
|
-
|
43
|
+
|
44
|
+
def self.itself *args
|
45
|
+
Gamefic::Query::Room.new *args
|
28
46
|
end
|
29
47
|
end
|
data/scripts/suggestible.plot.rb
CHANGED
@@ -3,20 +3,19 @@ class Gamefic::Suggestions
|
|
3
3
|
@current ||= []
|
4
4
|
end
|
5
5
|
|
6
|
-
def
|
7
|
-
@
|
6
|
+
def previous
|
7
|
+
@previous ||= []
|
8
8
|
end
|
9
9
|
|
10
10
|
def update
|
11
|
+
previous.clear
|
12
|
+
previous.concat current
|
11
13
|
current.clear
|
12
|
-
current.concat future
|
13
|
-
puts current.join(',')
|
14
|
-
future.clear
|
15
14
|
end
|
16
15
|
|
17
16
|
def clear
|
17
|
+
previous.clear
|
18
18
|
current.clear
|
19
|
-
future.clear
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -26,28 +25,29 @@ module Gamefic::Suggestible
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def suggest command
|
29
|
-
suggestions.
|
28
|
+
suggestions.current.push command unless suggestions.current.include? command
|
29
|
+
end
|
30
|
+
|
31
|
+
def state
|
32
|
+
super.merge(suggestions: suggestions.current.map{|s| s.cap_first})
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
class Gamefic::Character
|
34
37
|
include Suggestible
|
35
|
-
serialize :suggestions
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
}
|
40
|
+
before_player_update do |player|
|
41
|
+
if player.scene == default_scene or player.next_scene == default_scene
|
42
|
+
player.suggestions.update
|
43
|
+
else
|
44
|
+
player.suggestions.clear
|
45
|
+
end
|
46
46
|
end
|
47
47
|
|
48
48
|
respond :suggest do |actor|
|
49
49
|
actor.stream '<ul>'
|
50
|
-
actor.suggestions.
|
50
|
+
actor.suggestions.previous.sort.each { |s|
|
51
51
|
actor.stream "<li>#{s}</li>"
|
52
52
|
}
|
53
53
|
actor.stream '</ul>'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.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: 2017-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gamefic
|
@@ -44,6 +44,34 @@ dependencies:
|
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.10.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: uglifier
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.2'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.2'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: sinatra
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.4'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.4'
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
76
|
name: rspec
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,19 +93,39 @@ dependencies:
|
|
65
93
|
- !ruby/object:Gem::Version
|
66
94
|
version: 3.5.0
|
67
95
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
96
|
+
name: capybara
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.0'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.0'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '2.0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: selenium-webdriver
|
69
117
|
requirement: !ruby/object:Gem::Requirement
|
70
118
|
requirements:
|
71
119
|
- - "~>"
|
72
120
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
121
|
+
version: '3.4'
|
74
122
|
type: :development
|
75
123
|
prerelease: false
|
76
124
|
version_requirements: !ruby/object:Gem::Requirement
|
77
125
|
requirements:
|
78
126
|
- - "~>"
|
79
127
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
128
|
+
version: '3.4'
|
81
129
|
description: Development tools for Gamefic
|
82
130
|
email: fsnyder@gamefic.com
|
83
131
|
executables:
|
@@ -91,6 +139,7 @@ files:
|
|
91
139
|
- html/core/jquery.modal.css
|
92
140
|
- html/core/jquery.modal.js
|
93
141
|
- html/core/js.cookie.js
|
142
|
+
- html/sinatra/engine.js
|
94
143
|
- html/skins/hypertext/compass.png
|
95
144
|
- html/skins/hypertext/index.html
|
96
145
|
- html/skins/hypertext/style.css
|
@@ -115,10 +164,13 @@ files:
|
|
115
164
|
- lib/gamefic-sdk/platform.rb
|
116
165
|
- lib/gamefic-sdk/platform/base.rb
|
117
166
|
- lib/gamefic-sdk/platform/gfic.rb
|
167
|
+
- lib/gamefic-sdk/platform/sinatra.rb
|
118
168
|
- lib/gamefic-sdk/platform/web.rb
|
119
169
|
- lib/gamefic-sdk/platform/web/app_config.rb
|
120
|
-
- lib/gamefic-sdk/platform/web/
|
170
|
+
- lib/gamefic-sdk/platform/web/engine.rb
|
171
|
+
- lib/gamefic-sdk/platform/web/user.rb
|
121
172
|
- lib/gamefic-sdk/plot_config.rb
|
173
|
+
- lib/gamefic-sdk/server.rb
|
122
174
|
- lib/gamefic-sdk/shell.rb
|
123
175
|
- lib/gamefic-sdk/shell/init.rb
|
124
176
|
- lib/gamefic-sdk/shell/test.rb
|
@@ -218,10 +270,6 @@ files:
|
|
218
270
|
- scripts/standard/plural/queries/not_expression.plot.rb
|
219
271
|
- scripts/standard/plural/queries/plural_visible.plot.rb
|
220
272
|
- scripts/standard/queries.plot.rb
|
221
|
-
- scripts/standard/queries/from_expression.plot.rb
|
222
|
-
- scripts/standard/queries/reachable.plot.rb
|
223
|
-
- scripts/standard/queries/room.plot.rb
|
224
|
-
- scripts/standard/queries/visible.plot.rb
|
225
273
|
- scripts/standard/test.plot.rb
|
226
274
|
- scripts/standard/use.plot.rb
|
227
275
|
- scripts/suggestible.plot.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# HACK Explicit requires to fix Opal's failure to resolve autoloads
|
2
|
-
require 'gamefic/query/expression'
|
3
|
-
require 'gamefic/query/matches'
|
4
|
-
require 'gamefic/grammar/verb_set'
|
5
|
-
require 'gamefic/plot/playbook'
|
6
|
-
|
7
|
-
# HACK Opal doesn't recognize classes and modules declared from scripts
|
8
|
-
def Object.const_missing sym
|
9
|
-
Gamefic.const_get sym
|
10
|
-
end
|
11
|
-
|
12
|
-
module GameficOpal
|
13
|
-
def self.static_plot
|
14
|
-
@@static_plot ||= WebPlot.new(Gamefic::Source::Text.new)
|
15
|
-
end
|
16
|
-
def self.static_character
|
17
|
-
if @@static_character.nil?
|
18
|
-
@@static_character = static_plot.make Gamefic::Character, name: 'player', synonyms: 'me you myself yourself self'
|
19
|
-
@@static_character.connect static_user
|
20
|
-
end
|
21
|
-
@@static_character
|
22
|
-
end
|
23
|
-
def self.static_user
|
24
|
-
@@static_user ||= WebUser.new
|
25
|
-
end
|
26
|
-
class WebPlot < Gamefic::Plot
|
27
|
-
def script path
|
28
|
-
# Stub
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class WebUser < Gamefic::User::Base
|
33
|
-
def save filename, data
|
34
|
-
data[:metadata] = GameficOpal.static_plot.metadata
|
35
|
-
`Gamefic.save(filename, data);`
|
36
|
-
end
|
37
|
-
def restore filename
|
38
|
-
data = `Gamefic.restore(filename);`
|
39
|
-
return data
|
40
|
-
end
|
41
|
-
def test_queue
|
42
|
-
GameficOpal.static_character[:test_queue] || []
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Gamefic::Query::FromExpression < Gamefic::Query::Expression
|
2
|
-
def initialize
|
3
|
-
super(
|
4
|
-
/^(from|in|of|inside|on)$/
|
5
|
-
)
|
6
|
-
end
|
7
|
-
def signature
|
8
|
-
"#{self.class}"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module Gamefic::Use
|
13
|
-
def self.from_expression
|
14
|
-
Gamefic::Query::FromExpression.new
|
15
|
-
end
|
16
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# This query filters for objects that the player might be able to handle or
|
2
|
-
# manipulate, including the following:
|
3
|
-
#
|
4
|
-
# * Siblings (other entities with the same parent)
|
5
|
-
# * The subject's children
|
6
|
-
# * Entities on reachable supporters
|
7
|
-
# * Entities in reachable open containers
|
8
|
-
# * Entities attached to reachable entities
|
9
|
-
#
|
10
|
-
# It excludes anything that may be visible but are not reachable:
|
11
|
-
# * Entities inside closed transparent containers
|
12
|
-
# * Entities that share the same room as the subject, but not the same parent.
|
13
|
-
|
14
|
-
module Gamefic::Query
|
15
|
-
class Reachable < Family
|
16
|
-
def context_from(subject)
|
17
|
-
array = super
|
18
|
-
if subject.parent.kind_of?(Container) || subject.parent.kind_of?(Supporter)
|
19
|
-
array.push subject.parent
|
20
|
-
end
|
21
|
-
if subject.parent != subject.room
|
22
|
-
array += subject.room.children
|
23
|
-
end
|
24
|
-
array.each { |thing|
|
25
|
-
if thing.kind_of?(Container)
|
26
|
-
if thing.open?
|
27
|
-
array += thing.children.that_are_not(:attached?)
|
28
|
-
end
|
29
|
-
elsif thing.kind_of?(Supporter) or thing.kind_of?(Receptacle) or thing == subject
|
30
|
-
array += thing.children.that_are_not(:attached?)
|
31
|
-
end
|
32
|
-
thing.children.that_are(:attached?).each { |att|
|
33
|
-
array.push att
|
34
|
-
if att.kind_of?(Supporter) or (att.kind_of?(Container) and att.open?)
|
35
|
-
array += att.children
|
36
|
-
end
|
37
|
-
}
|
38
|
-
}
|
39
|
-
array.uniq - [subject]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Gamefic::Use
|
45
|
-
def self.reachable *args
|
46
|
-
Gamefic::Query::Reachable.new *args
|
47
|
-
end
|
48
|
-
end
|