gamefic 0.0.4 → 0.0.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 +4 -4
- data/lib/gamefic/action_ext/container.rb +89 -11
- data/lib/gamefic/action_ext/inventory.rb +21 -5
- data/lib/gamefic/action_ext/look.rb +1 -1
- data/lib/gamefic/character.rb +8 -1
- data/lib/gamefic/core_ext/string.rb +3 -3
- data/lib/gamefic/director.rb +6 -1
- data/lib/gamefic/engine.rb +1 -1
- data/lib/gamefic/entity_ext/container.rb +19 -0
- data/lib/gamefic/plot.rb +1 -0
- data/lib/gamefic/user.rb +6 -4
- 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: 20c3e34c3d13071e770eda8495d563a655dcbeb1
|
4
|
+
data.tar.gz: e426f447d23f070f3e8ba86e53869dfd1a1bbbaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3021ba57098702d8432f469a5df40a69b18560cb51680bec94a5eae0dd55291432c1191faec2456554e42a53027f4a8e6439e5b7a5b509827181e34469228ca
|
7
|
+
data.tar.gz: 83877a6aef2eb5150087840fdd4f8349bf489e21b3b0516484f6a25a3d07ecadf2861ddedc6192afdad9ebfe67ba5c0713e5dc711074c410b654dba12b9fa215
|
@@ -1,36 +1,114 @@
|
|
1
1
|
module Gamefic
|
2
2
|
|
3
|
+
Action.new nil, :look, Query.new(:family, Container) do |actor, thing|
|
4
|
+
passthru
|
5
|
+
if thing.closeable?
|
6
|
+
actor.tell "#{thing.longname.specify.cap_first} is #{thing.closed? ? 'closed' : 'open'}."
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
3
10
|
Action.new nil, :look_inside, Query.new(:family, Container) do |actor, container|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
if container.closed?
|
12
|
+
actor.tell "#{container.longname.cap_first.specify} is closed."
|
13
|
+
else
|
14
|
+
if container.children.length == 0
|
15
|
+
actor.tell "You don't find anything."
|
16
|
+
else
|
17
|
+
if container.children.length == 1
|
18
|
+
actor.tell "#{container.longname.specify.cap_first} contains #{container.children[0].longname}."
|
19
|
+
else
|
20
|
+
actor.tell "#{container.longname.specify.cap_first} contains: #{container.children.join_and(', ')}."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
9
24
|
end
|
10
25
|
Syntax.new nil, "look inside :container", :look_inside, :container
|
11
26
|
Syntax.new nil, "search :container", :look_inside, :container
|
12
27
|
Syntax.new nil, "look in :container", :look_inside, :container
|
13
28
|
|
14
29
|
Action.new nil, :look_in_at, Query.new(:family, Container), Subquery.new(:children, Entity) do |actor, container, item|
|
15
|
-
|
30
|
+
if container.closed?
|
31
|
+
actor.tell "#{container.longname.cap_first.specify} is closed."
|
32
|
+
else
|
33
|
+
actor.tell item.description
|
34
|
+
end
|
16
35
|
end
|
36
|
+
|
37
|
+
Action.new nil, :look_in_at, Query.new(:family, Container), Query.new(:string) do |actor, container, item|
|
38
|
+
if container.closed?
|
39
|
+
actor.tell "#{container.longname.cap_first.specify} is closed."
|
40
|
+
else
|
41
|
+
passthru
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
17
45
|
Syntax.new nil, "look at :item in :container", :look_in_at, :container, :item
|
18
46
|
Syntax.new nil, "look :item in :container", :look_in_at, :container, :item
|
19
47
|
|
20
|
-
Action.new nil, :take_from, Query.new(:family, Container), Subquery.new(:children,
|
21
|
-
|
22
|
-
|
48
|
+
Action.new nil, :take_from, Query.new(:family, Container), Subquery.new(:children, Portable) do |actor, container, item|
|
49
|
+
if container.closed?
|
50
|
+
actor.tell "#{container.longname.cap_first.specify} is closed."
|
51
|
+
else
|
52
|
+
item.parent = actor
|
53
|
+
actor.tell "You take #{item.longname} from #{container.longname.specify}."
|
54
|
+
end
|
23
55
|
end
|
24
56
|
Syntax.new nil, "take :item from :container", :take_from, :container, :item
|
25
57
|
Syntax.new nil, "get :item from :container", :take_from, :container, :item
|
26
58
|
Syntax.new nil, "remove :item from :container", :take_from, :container, :item
|
27
59
|
|
28
60
|
Action.new nil, :drop_in, Query.new(:family, Container), Query.new(:children) do |actor, container, item|
|
29
|
-
|
30
|
-
|
61
|
+
if container.closed?
|
62
|
+
actor.tell "#{container.longname.cap_first.specify} is closed."
|
63
|
+
else
|
64
|
+
item.parent = container
|
65
|
+
actor.tell "You put #{item.longname} in #{container.longname}."
|
66
|
+
end
|
31
67
|
end
|
32
68
|
Syntax.new nil, "drop :item in :container", :drop_in, :container, :item
|
33
69
|
Syntax.new nil, "put :item in :container", :drop_in, :container, :item
|
34
70
|
Syntax.new nil, "place :item in :container", :drop_in, :container, :item
|
71
|
+
|
72
|
+
Action.new nil, :open, Query.new(:string) do |actor, string|
|
73
|
+
actor.tell "You don't see any \"#{string}\" here."
|
74
|
+
end
|
75
|
+
|
76
|
+
Action.new nil, :open, Query.new(:family, Entity) do |actor, thing|
|
77
|
+
actor.tell "You can't open #{thing.longname.specify}."
|
78
|
+
end
|
79
|
+
|
80
|
+
Action.new nil, :open, Query.new(:family, Container) do |actor, container|
|
81
|
+
if container.closeable?
|
82
|
+
if container.closed?
|
83
|
+
actor.tell "You open #{container.longname.specify}."
|
84
|
+
container.closed = false
|
85
|
+
else
|
86
|
+
actor.tell "It's already open."
|
87
|
+
end
|
88
|
+
else
|
89
|
+
actor.tell "You can't open #{container.longname.specify}."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
Action.new nil, :close, Query.new(:string) do |actor, string|
|
94
|
+
actor.tell "You don't see any \"#{string}\" here."
|
95
|
+
end
|
35
96
|
|
97
|
+
Action.new nil, :close, Query.new(:family, Entity) do |actor, thing|
|
98
|
+
actor.tell "You can't close #{thing.longname.specify}."
|
99
|
+
end
|
100
|
+
|
101
|
+
Action.new nil, :close, Query.new(:family, Container) do |actor, container|
|
102
|
+
if container.closeable?
|
103
|
+
if container.closed?
|
104
|
+
actor.tell "It's already closed."
|
105
|
+
else
|
106
|
+
actor.tell "You close #{container.longname.specify}."
|
107
|
+
container.closed = true
|
108
|
+
end
|
109
|
+
else
|
110
|
+
actor.tell "You can't close #{container.longname.specify}."
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
36
114
|
end
|
@@ -11,20 +11,36 @@ module Gamefic
|
|
11
11
|
|
12
12
|
Action.new nil, :take, Query.new(:siblings, Portable) do |actor, thing|
|
13
13
|
thing.parent = actor
|
14
|
-
actor.tell "You take #{thing.longname}.", true
|
14
|
+
actor.tell "You take #{thing.longname.specify}.", true
|
15
15
|
end
|
16
16
|
|
17
17
|
Action.new nil, :take, Query.new(:siblings) do |actor, thing|
|
18
|
-
actor.tell "You can't carry #{thing.longname}."
|
18
|
+
actor.tell "You can't carry #{thing.longname.specify}."
|
19
19
|
end
|
20
20
|
|
21
|
-
Action.new nil, :take,
|
22
|
-
|
21
|
+
Action.new nil, :take, Query.new(:string) do |actor, thing|
|
22
|
+
containers = actor.children.that_are(Container)
|
23
|
+
containers = containers + actor.parent.children.that_are(Container)
|
24
|
+
found = false
|
25
|
+
containers.each { |container|
|
26
|
+
if container.closed? == false
|
27
|
+
query = Query.new(:children, Portable)
|
28
|
+
result = query.execute(container, thing)
|
29
|
+
if result.objects.length == 1
|
30
|
+
found = true
|
31
|
+
actor.perform "take #{result.objects[0].longname} from #{container.longname}"
|
32
|
+
break
|
33
|
+
end
|
34
|
+
end
|
35
|
+
}
|
36
|
+
if found == false
|
37
|
+
actor.tell "You don't see anything called \"#{thing}\" here."
|
38
|
+
end
|
23
39
|
end
|
24
40
|
|
25
41
|
Action.new nil, :drop, Query.new(:children) do |actor, thing|
|
26
42
|
thing.parent = actor.parent
|
27
|
-
actor.tell "You drop #{thing.longname}.", true
|
43
|
+
actor.tell "You drop #{thing.longname.specify}.", true
|
28
44
|
end
|
29
45
|
|
30
46
|
Syntax.new nil, "get :thing", :take, :thing
|
@@ -9,7 +9,7 @@ module Gamefic
|
|
9
9
|
end
|
10
10
|
|
11
11
|
Action.new nil, :itemize_room, Query.new(:string) do |actor, option|
|
12
|
-
actor.tell "#{actor.parent.longname.cap_first}"
|
12
|
+
actor.tell "## #{actor.parent.longname.cap_first}"
|
13
13
|
if option == "full"
|
14
14
|
actor.tell actor.parent.description
|
15
15
|
end
|
data/lib/gamefic/character.rb
CHANGED
@@ -7,12 +7,12 @@ class String
|
|
7
7
|
end
|
8
8
|
def specify
|
9
9
|
if self[0,2] == 'a ' or self[0,3] == 'an '
|
10
|
-
"the #{self.split(' ').
|
10
|
+
return "the #{self.split(' ')[1..-1].join(' ')}"
|
11
11
|
end
|
12
12
|
if self[0,2] == 'A ' or self[0,3] == 'An '
|
13
|
-
"The #{self.split(' ').
|
13
|
+
return "The #{self.split(' ')[1..-1].join(' ')}"
|
14
14
|
end
|
15
|
-
|
15
|
+
return self
|
16
16
|
end
|
17
17
|
def terminalize
|
18
18
|
output = ''
|
data/lib/gamefic/director.rb
CHANGED
@@ -31,7 +31,12 @@ module Gamefic
|
|
31
31
|
}
|
32
32
|
options.push([
|
33
33
|
Proc.new { |actor|
|
34
|
-
|
34
|
+
first = Keywords.new(command)[0]
|
35
|
+
if actor.plot.commandwords.include?(first)
|
36
|
+
actor.tell "I know the verb '#{first}' but couldn't understand the rest of your sentence."
|
37
|
+
else
|
38
|
+
actor.tell "I don't understand '#{first}' as a command."
|
39
|
+
end
|
35
40
|
}, [actor], -1
|
36
41
|
])
|
37
42
|
del = Delegate.new(options)
|
data/lib/gamefic/engine.rb
CHANGED
@@ -4,6 +4,25 @@ module Gamefic
|
|
4
4
|
|
5
5
|
class Container < Entity
|
6
6
|
include Itemized
|
7
|
+
def closeable=(bool)
|
8
|
+
@closeable = bool
|
9
|
+
end
|
10
|
+
def closeable?
|
11
|
+
@closeable ||= false
|
12
|
+
if (@closeable == true && @closed == nil)
|
13
|
+
@closed = false
|
14
|
+
end
|
15
|
+
@closeable
|
16
|
+
end
|
17
|
+
def closed?
|
18
|
+
(@closed == true)
|
19
|
+
end
|
20
|
+
def closed=(bool)
|
21
|
+
if bool == true
|
22
|
+
@closeable = true
|
23
|
+
end
|
24
|
+
@closed = bool
|
25
|
+
end
|
7
26
|
end
|
8
27
|
|
9
28
|
end
|
data/lib/gamefic/plot.rb
CHANGED
data/lib/gamefic/user.rb
CHANGED
@@ -35,9 +35,10 @@ module Gamefic
|
|
35
35
|
def send(data)
|
36
36
|
print data
|
37
37
|
end
|
38
|
-
def select
|
39
|
-
print
|
40
|
-
|
38
|
+
def select(prompt)
|
39
|
+
print prompt
|
40
|
+
line = STDIN.gets
|
41
|
+
@queue.push line.strip
|
41
42
|
end
|
42
43
|
def recv
|
43
44
|
@queue.shift
|
@@ -56,7 +57,8 @@ module Gamefic
|
|
56
57
|
def update
|
57
58
|
line = @user.stream.recv
|
58
59
|
if line != nil
|
59
|
-
|
60
|
+
#@user.character.perform line
|
61
|
+
@user.character.queue.push line
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
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: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: An adventure game engine
|
14
14
|
email: fsnyder@gamefic.com
|