gamefic 0.1.1 → 0.2.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/action.rb +7 -6
- data/lib/gamefic/before.rb +12 -0
- data/lib/gamefic/character.rb +1 -1
- data/lib/gamefic/core_ext/array.rb +4 -0
- data/lib/gamefic/core_ext/string.rb +0 -31
- data/lib/gamefic/describable.rb +68 -8
- data/lib/gamefic/director.rb +108 -75
- data/lib/gamefic/engine.rb +74 -10
- data/lib/gamefic/entity.rb +3 -3
- data/lib/gamefic/import/basics/actions/close.rb +16 -0
- data/lib/gamefic/import/basics/actions/commands.rb +3 -0
- data/lib/gamefic/import/basics/actions/drop-in.rb +17 -0
- data/lib/gamefic/import/basics/actions/drop-on.rb +16 -0
- data/lib/gamefic/import/basics/actions/drop.rb +30 -0
- data/lib/gamefic/import/basics/actions/enter.rb +16 -0
- data/lib/gamefic/import/basics/actions/{traversal.rb → go.rb} +35 -35
- data/lib/gamefic/import/basics/actions/inventory.rb +8 -49
- data/lib/gamefic/import/basics/actions/leave.rb +29 -0
- data/lib/gamefic/import/basics/actions/look-in-at.rb +27 -0
- data/lib/gamefic/import/basics/actions/look-under.rb +3 -0
- data/lib/gamefic/import/basics/actions/look.rb +71 -67
- data/lib/gamefic/import/basics/actions/nil.rb +25 -0
- data/lib/gamefic/import/basics/actions/open.rb +23 -0
- data/lib/gamefic/import/basics/actions/quit.rb +3 -0
- data/lib/gamefic/import/basics/actions/take.rb +107 -0
- data/lib/gamefic/import/basics/entities/container.rb +8 -24
- data/lib/gamefic/import/basics/entities/entity.rb +11 -0
- data/lib/gamefic/import/basics/entities/fixture.rb +5 -5
- data/lib/gamefic/import/basics/entities/item.rb +5 -7
- data/lib/gamefic/import/basics/entities/portal.rb +40 -43
- data/lib/gamefic/import/basics/entities/room.rb +30 -24
- data/lib/gamefic/import/basics/entities/scenery.rb +5 -3
- data/lib/gamefic/import/basics/entities/supporter.rb +6 -0
- data/lib/gamefic/import/basics/entities/thing.rb +16 -0
- data/lib/gamefic/import/basics/queries/reachable.rb +38 -0
- data/lib/gamefic/import/basics/queries/room.rb +8 -0
- data/lib/gamefic/import/basics/queries/visible.rb +32 -0
- data/lib/gamefic/import/basics/rules/has-enough-light.rb +14 -0
- data/lib/gamefic/import/{basics → basics.old}/actions/container.rb +13 -12
- data/lib/gamefic/import/basics.old/actions/inventory.rb +50 -0
- data/lib/gamefic/import/basics.old/actions/look.rb +53 -0
- data/lib/gamefic/import/basics.old/actions/meta.rb +6 -0
- data/lib/gamefic/import/basics.old/actions/traversal.rb +35 -0
- data/lib/gamefic/import/{basics → basics.old}/actions.rb +0 -0
- data/lib/gamefic/import/basics.old/entities/container.rb +3 -0
- data/lib/gamefic/import/basics.old/entities/fixture.rb +3 -0
- data/lib/gamefic/import/basics.old/entities/item.rb +3 -0
- data/lib/gamefic/import/basics.old/entities/portal.rb +43 -0
- data/lib/gamefic/import/basics.old/entities/room.rb +27 -0
- data/lib/gamefic/import/basics.old/entities/scenery.rb +3 -0
- data/lib/gamefic/import/basics.old/entities/supporter.rb +3 -0
- data/lib/gamefic/import/{basics → basics.old}/entities.rb +0 -0
- data/lib/gamefic/import/basics.old/room_modes.rb +48 -0
- data/lib/gamefic/import/basics.rb +6 -2
- data/lib/gamefic/import/{basics/room_modes.rb → room_modes.rb} +6 -6
- data/lib/gamefic/import/standard.rb +1 -0
- data/lib/gamefic/meta.rb +12 -0
- data/lib/gamefic/optionset.rb +114 -0
- data/lib/gamefic/plot.rb +54 -21
- data/lib/gamefic/query.rb +214 -188
- data/lib/gamefic/requirement.rb +14 -0
- data/lib/gamefic/shell.rb +7 -4
- data/lib/gamefic/syntax.rb +35 -18
- data/lib/gamefic/thing.rb +7 -0
- data/lib/gamefic.rb +5 -1
- metadata +46 -12
- data/lib/gamefic/import/basics/actions/meta.rb +0 -6
- data/lib/gamefic/import/basics/entities/itemized.rb +0 -3
- data/lib/gamefic/import/basics/entities/portable.rb +0 -3
- data/lib/gamefic/user.rb +0 -66
@@ -0,0 +1,30 @@
|
|
1
|
+
respond :drop, Query::Visible.new() do |actor, thing|
|
2
|
+
actor.tell "You're not carrying #{the thing}."
|
3
|
+
end
|
4
|
+
|
5
|
+
respond :drop, Query::Children.new() do |actor, thing|
|
6
|
+
thing.parent = actor.parent
|
7
|
+
actor.tell "You drop #{the thing}.", true
|
8
|
+
end
|
9
|
+
|
10
|
+
xlate "put down :thing", :drop, :thing
|
11
|
+
xlate "put :thing down", :drop, :thing
|
12
|
+
|
13
|
+
#respond :drop, Query::Family.new(Thing), Query::Reachable.new(Thing) do |actor, thing, supporter|
|
14
|
+
# actor.tell "You're not carrying #{thing}."
|
15
|
+
#end
|
16
|
+
#respond :drop, Query::Text.new(), Query::Text.new() do |actor, thing, supporter|
|
17
|
+
# actor.tell "You don't see anything called '#{thing}.'"
|
18
|
+
#end
|
19
|
+
#respond :drop, Query::Children.new(Thing), Query::Visible.new(Thing) do |actor, thing, target|
|
20
|
+
# if actor.parent != target.parent
|
21
|
+
# if actor.is?(:supported) or actor.is?(:container)
|
22
|
+
# actor.tell "You can't reach #{the target} from #{the actor.parent}."
|
23
|
+
# next
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
# passthru
|
27
|
+
#end
|
28
|
+
#respond :drop, Query::Children.new(Thing), Query::Text.new() do |actor, thing, supporter|
|
29
|
+
# actor.tell "You don't see anything called '#{supporter}.'"
|
30
|
+
#end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
respond :enter, Query::Siblings.new(Supporter, :enterable) do |actor, supporter|
|
2
|
+
actor.parent = supporter
|
3
|
+
actor.tell "You get on #{the supporter}."
|
4
|
+
end
|
5
|
+
respond :enter, Query::Siblings.new(Container, :enterable) do |actor, container|
|
6
|
+
actor.parent = container
|
7
|
+
actor.tell "You get in #{the container}."
|
8
|
+
end
|
9
|
+
respond :enter, Query::Siblings.new(Thing) do |actor, thing|
|
10
|
+
actor.tell "#{The thing} can't accommodate you."
|
11
|
+
end
|
12
|
+
xlate "sit :thing", :enter, :thing
|
13
|
+
xlate "sit on :thing", :enter, :thing
|
14
|
+
xlate "get on :thing", :enter, :thing
|
15
|
+
xlate "get in :thing", :enter, :thing
|
16
|
+
xlate "stand on :thing", :enter, :thing
|
@@ -1,35 +1,35 @@
|
|
1
|
-
respond :go, Query.new(
|
2
|
-
actor.parent = portal.destination
|
3
|
-
actor.tell "You go #{portal.name}."
|
4
|
-
actor.perform "
|
5
|
-
end
|
6
|
-
|
7
|
-
respond :go,
|
8
|
-
actor.tell "You don't see any exit \"#{string}\" from here."
|
9
|
-
end
|
10
|
-
|
11
|
-
respond :go do |actor|
|
12
|
-
actor.tell "Where do you want to go?"
|
13
|
-
end
|
14
|
-
|
15
|
-
xlate "north", :go, "north"
|
16
|
-
xlate "south", :go, "south"
|
17
|
-
xlate "west", :go, "west"
|
18
|
-
xlate "east", :go, "east"
|
19
|
-
xlate "up", :go, "up"
|
20
|
-
xlate "down", :go, "down"
|
21
|
-
xlate "northwest", :go, "northwest"
|
22
|
-
xlate "northeast", :go, "northeast"
|
23
|
-
xlate "southwest", :go, "southwest"
|
24
|
-
xlate "southeast", :go, "southeast"
|
25
|
-
|
26
|
-
xlate "n", :go, "north"
|
27
|
-
xlate "s", :go, "south"
|
28
|
-
xlate "w", :go, "west"
|
29
|
-
xlate "e", :go, "east"
|
30
|
-
xlate "u", :go, "up"
|
31
|
-
xlate "d", :go, "down"
|
32
|
-
xlate "nw", :go, "northwest"
|
33
|
-
xlate "ne", :go, "northeast"
|
34
|
-
xlate "sw", :go, "southwest"
|
35
|
-
xlate "se", :go, "southeast"
|
1
|
+
respond :go, Query::Siblings.new(Portal) do |actor, portal|
|
2
|
+
actor.parent = portal.destination
|
3
|
+
actor.tell "You go #{portal.name}."
|
4
|
+
actor.perform "look"
|
5
|
+
end
|
6
|
+
|
7
|
+
respond :go, Query::Text.new() do |actor, string|
|
8
|
+
actor.tell "You don't see any exit \"#{string}\" from here."
|
9
|
+
end
|
10
|
+
|
11
|
+
respond :go do |actor|
|
12
|
+
actor.tell "Where do you want to go?"
|
13
|
+
end
|
14
|
+
|
15
|
+
xlate "north", :go, "north"
|
16
|
+
xlate "south", :go, "south"
|
17
|
+
xlate "west", :go, "west"
|
18
|
+
xlate "east", :go, "east"
|
19
|
+
xlate "up", :go, "up"
|
20
|
+
xlate "down", :go, "down"
|
21
|
+
xlate "northwest", :go, "northwest"
|
22
|
+
xlate "northeast", :go, "northeast"
|
23
|
+
xlate "southwest", :go, "southwest"
|
24
|
+
xlate "southeast", :go, "southeast"
|
25
|
+
|
26
|
+
xlate "n", :go, "north"
|
27
|
+
xlate "s", :go, "south"
|
28
|
+
xlate "w", :go, "west"
|
29
|
+
xlate "e", :go, "east"
|
30
|
+
xlate "u", :go, "up"
|
31
|
+
xlate "d", :go, "down"
|
32
|
+
xlate "nw", :go, "northwest"
|
33
|
+
xlate "ne", :go, "northeast"
|
34
|
+
xlate "sw", :go, "southwest"
|
35
|
+
xlate "se", :go, "southeast"
|
@@ -1,49 +1,8 @@
|
|
1
|
-
respond :inventory do |actor|
|
2
|
-
if actor.children.length > 0
|
3
|
-
actor.tell actor.children.join(', ')
|
4
|
-
else
|
5
|
-
actor.tell "You aren't carrying anything."
|
6
|
-
end
|
7
|
-
end
|
8
|
-
xlate "i", :inventory
|
9
|
-
|
10
|
-
respond :take, Query.new(:siblings, Portable) do |actor, thing|
|
11
|
-
thing.parent = actor
|
12
|
-
actor.tell "You take #{thing.longname.specify}.", true
|
13
|
-
end
|
14
|
-
|
15
|
-
respond :take, Query.new(:siblings) do |actor, thing|
|
16
|
-
actor.tell "You can't carry #{thing.longname.specify}."
|
17
|
-
end
|
18
|
-
|
19
|
-
respond :take, Query.new(:string) do |actor, thing|
|
20
|
-
containers = actor.children.that_are(Container)
|
21
|
-
containers = containers + actor.parent.children.that_are(Container)
|
22
|
-
found = false
|
23
|
-
containers.each { |container|
|
24
|
-
if container.closed? == false
|
25
|
-
query = Query.new(:children, Portable)
|
26
|
-
result = query.execute(container, thing)
|
27
|
-
if result.objects.length == 1
|
28
|
-
found = true
|
29
|
-
actor.perform "take #{result.objects[0].longname} from #{container.longname}"
|
30
|
-
break
|
31
|
-
end
|
32
|
-
end
|
33
|
-
}
|
34
|
-
if found == false
|
35
|
-
actor.tell "You don't see any \"#{thing}\" here."
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
respond :drop, Query.new(:children) do |actor, thing|
|
40
|
-
thing.parent = actor.parent
|
41
|
-
actor.tell "You drop #{thing.longname.specify}.", true
|
42
|
-
end
|
43
|
-
|
44
|
-
xlate "get :thing", :take, :thing
|
45
|
-
xlate "pick :thing up", :take, :thing
|
46
|
-
xlate "pick up :thing", :take, :thing
|
47
|
-
|
48
|
-
xlate "put down :thing", :drop, :thing
|
49
|
-
xlate "put :thing down", :drop, :thing
|
1
|
+
respond :inventory do |actor|
|
2
|
+
if actor.children.length > 0
|
3
|
+
actor.tell actor.children.join(', ')
|
4
|
+
else
|
5
|
+
actor.tell "You aren't carrying anything."
|
6
|
+
end
|
7
|
+
end
|
8
|
+
xlate "i", :inventory
|
@@ -0,0 +1,29 @@
|
|
1
|
+
respond :leave, Query::Parent.new(Supporter) do |actor, supporter|
|
2
|
+
actor.parent = supporter.parent
|
3
|
+
actor.tell "You get off #{the supporter}."
|
4
|
+
end
|
5
|
+
respond :leave, Query::Parent.new(Container) do |actor, supporter|
|
6
|
+
actor.parent = supporter.parent
|
7
|
+
actor.tell "You get out of #{the supporter}."
|
8
|
+
end
|
9
|
+
respond :leave, Query::Parent.new(Room) do |actor, room|
|
10
|
+
portals = room.children.that_are(Portal)
|
11
|
+
if portals.length == 0
|
12
|
+
actor.tell "You don't see any obvious exits."
|
13
|
+
elsif portals.length == 1
|
14
|
+
actor.perform "go #{portals[0]}"
|
15
|
+
else
|
16
|
+
actor.tell "I don't know which way you want to go: #{portals.join_and(', ', ' or ')}."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
respond :leave do |actor|
|
20
|
+
actor.perform "leave #{actor.parent}"
|
21
|
+
end
|
22
|
+
xlate "exit :supporter", :leave, :supporter
|
23
|
+
xlate "get off :supporter", :leave, :supporter
|
24
|
+
xlate "get up from :supporter", :leave, :supporter
|
25
|
+
xlate "get up", :leave
|
26
|
+
xlate "stand", :leave
|
27
|
+
xlate "get off", :leave
|
28
|
+
xlate "get out :container", :leave, :container
|
29
|
+
xlate "get out of :container", :leave, :container
|
@@ -0,0 +1,27 @@
|
|
1
|
+
respond :look_in_at, Query::Text.new(), Query::Text.new() do |actor, container, thing|
|
2
|
+
actor.tell "You don't see any '#{container}' here."
|
3
|
+
end
|
4
|
+
|
5
|
+
respond :look_in_at, Query::Reachable.new(), Query::Text.new() do |actor, container, thing|
|
6
|
+
actor.tell "You don't see any '#{thing}' in #{the container}."
|
7
|
+
end
|
8
|
+
|
9
|
+
respond :look_in_at, Query::Reachable.new(), Query::Subquery.new() do |actor, container, thing|
|
10
|
+
if thing.is?(:supported) or thing.is?(:attached) or ( thing.is?(:contained) and (container.is?(:open) or container.is?(:transparent)) )
|
11
|
+
actor.perform "look #{thing}"
|
12
|
+
elsif container.is?(:closed)
|
13
|
+
actor.tell "#{The container} is closed."
|
14
|
+
else
|
15
|
+
passthru
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
xlate "look in :container at :thing", :look_in_at, :container, :thing
|
20
|
+
xlate "l in :container at :thing", :look_in_at, :container, :thing
|
21
|
+
|
22
|
+
xlate "look :thing in :container", :look_in_at, :container, :thing
|
23
|
+
xlate "look at :thing in :container", :look_in_at, :container, :thing
|
24
|
+
xlate "l :thing in :container", :look_in_at, :container, :thing
|
25
|
+
xlate "examine :thing in :container", :look_in_at, :container, :thing
|
26
|
+
xlate "exam :thing in :container", :look_in_at, :container, :thing
|
27
|
+
xlate "x :thing in :container", :look_in_at, :container, :thing
|
@@ -1,67 +1,71 @@
|
|
1
|
-
respond :look do |actor|
|
2
|
-
actor.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
actor.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
xlate "
|
1
|
+
respond :look, Query::Parent.new(Supporter) do |actor, supporter|
|
2
|
+
actor.tell supporter.description
|
3
|
+
actor.tell "You are currently on #{the supporter}."
|
4
|
+
end
|
5
|
+
|
6
|
+
respond :look, Query::Room.new(Room) do |actor, room|
|
7
|
+
actor.tell room.name.cap_first
|
8
|
+
actor.tell room.description
|
9
|
+
chars = room.children.that_are(Character) - [actor]
|
10
|
+
if chars.length > 0
|
11
|
+
actor.tell "Others here: #{chars.join(", ")}"
|
12
|
+
end
|
13
|
+
items = room.children.that_are(:itemized) - [actor]
|
14
|
+
if items.length > 0
|
15
|
+
actor.tell "You see #{items.join_and}."
|
16
|
+
end
|
17
|
+
portals = room.children.that_are(Portal)
|
18
|
+
if portals.length > 0
|
19
|
+
if portals.length == 1
|
20
|
+
actor.tell "There is an exit #{portals[0]}."
|
21
|
+
else
|
22
|
+
actor.tell "There are exits #{portals.join_and(', ')}."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
if actor.is? :supported
|
26
|
+
actor.tell "You are on #{the actor.parent}."
|
27
|
+
actor.parent.children.that_are(:supported).that_are_not(actor).each { |s|
|
28
|
+
actor.tell "#{A s} is on #{the actor.parent}."
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
xlate "look", :look, "around"
|
33
|
+
xlate "l", :look, "around"
|
34
|
+
|
35
|
+
respond :look, Query::Visible.new() do |actor, thing|
|
36
|
+
actor.tell thing.description
|
37
|
+
thing.children.that_are(:attached).that_are(:itemized).each { |item|
|
38
|
+
actor.tell "#{An item} is attached to #{the thing}."
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
respond :look, Query::Text.new() do |actor, string|
|
43
|
+
actor.tell "You don't see any \"#{string}\" here."
|
44
|
+
end
|
45
|
+
|
46
|
+
respond :look, Query::Reachable.new(Container) do |actor, container|
|
47
|
+
passthru
|
48
|
+
if container.is? :openable
|
49
|
+
actor.tell "#{The container} is #{container.is?(:open) ? 'open' : 'closed'}."
|
50
|
+
end
|
51
|
+
if container.is? :open
|
52
|
+
contents = container.children.that_are(:contained)
|
53
|
+
contents.each { |thing|
|
54
|
+
actor.tell "You see #{a thing} inside #{the container}."
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
respond :look, Query::Siblings.new(Supporter) do |actor, supporter|
|
60
|
+
passthru
|
61
|
+
supported = supporter.children.that_are(:supported)
|
62
|
+
supported.each { |thing|
|
63
|
+
actor.tell "You see #{a thing} sitting there."
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
xlate "look at :thing", :look, :thing
|
68
|
+
xlate "l :thing", :look, :thing
|
69
|
+
xlate "examine :thing", :look, :thing
|
70
|
+
xlate "x :thing", :look, :thing
|
71
|
+
xlate "search :thing", :look, :thing
|
@@ -0,0 +1,25 @@
|
|
1
|
+
respond nil, Query::Text.new() do |actor, string|
|
2
|
+
words = string.split_words
|
3
|
+
if commandwords.include?(words[0])
|
4
|
+
if words.length > 1
|
5
|
+
actor.tell "I recognize '#{words[0]}' as a verb but could not understand the rest of your sentence."
|
6
|
+
else
|
7
|
+
actor.tell "I recognize '#{words[0]}' as a verb but could not understand it in this context."
|
8
|
+
end
|
9
|
+
else
|
10
|
+
found = []
|
11
|
+
commandwords.each { |c|
|
12
|
+
if c.length > words[0].length and c.start_with?(words[0])
|
13
|
+
found.push c
|
14
|
+
end
|
15
|
+
}
|
16
|
+
if found.length == 1
|
17
|
+
words[0] = found[0]
|
18
|
+
actor.perform words.join(' ')
|
19
|
+
elsif found.length > 1
|
20
|
+
actor.tell "I'm not sure if #{words[0]} means #{found.join_and(', ', ' or ')}."
|
21
|
+
else
|
22
|
+
actor.tell "I don't know what you mean by '#{string}.'"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
respond :open, Query::Text.new() do |actor, string|
|
2
|
+
actor.tell "You don't see any \"#{string}\" here."
|
3
|
+
end
|
4
|
+
|
5
|
+
respond :open, Query::Reachable.new(Entity) do |actor, thing|
|
6
|
+
actor.tell "You can't open #{the thing}."
|
7
|
+
end
|
8
|
+
|
9
|
+
respond :open, Query::Reachable.new(Container, :openable) do |actor, container|
|
10
|
+
# Portable containers need to be picked up before they are opened.
|
11
|
+
if container.is? :portable
|
12
|
+
actor.perform "take #{container}"
|
13
|
+
if container.parent != actor
|
14
|
+
break
|
15
|
+
end
|
16
|
+
end
|
17
|
+
if container.is? :closed
|
18
|
+
actor.tell "You open #{the container}."
|
19
|
+
container.is :open
|
20
|
+
else
|
21
|
+
actor.tell "It's already open."
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
respond :take, Query::Text.new() do |actor, thing|
|
2
|
+
actor.tell "I don't see anything called '#{thing}' here."
|
3
|
+
end
|
4
|
+
|
5
|
+
respond :take, Query::Reachable.new(:not_portable) do |actor, thing|
|
6
|
+
actor.tell "You can't take #{the thing}."
|
7
|
+
end
|
8
|
+
|
9
|
+
respond :take, Query::Siblings.new(:portable) do |actor, thing|
|
10
|
+
thing.parent = actor
|
11
|
+
actor.tell "You take #{the thing}."
|
12
|
+
end
|
13
|
+
|
14
|
+
respond :take, Query::Siblings.new() do |actor, thing|
|
15
|
+
actor.tell "You can't carry #{the thing}."
|
16
|
+
end
|
17
|
+
|
18
|
+
respond :take, Query::Visible.new() do |actor, thing|
|
19
|
+
if thing.parent == actor.parent
|
20
|
+
passthru
|
21
|
+
elsif thing.parent.is?(:closed)
|
22
|
+
actor.tell "#{The thing} is inside #{the thing.parent}, which is closed."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
respond :take, Query::Visible.new() do |actor, thing|
|
27
|
+
if actor.is? :supported
|
28
|
+
if actor.parent != thing.parent and actor.parent != thing.parent.parent
|
29
|
+
actor.tell "You can't reach it from #{the actor.parent}."
|
30
|
+
end
|
31
|
+
else
|
32
|
+
passthru
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
respond :take, Query::Reachable.new(:attached) do |actor, thing|
|
37
|
+
actor.tell "#{The thing} is attached to #{the thing.parent}."
|
38
|
+
end
|
39
|
+
|
40
|
+
respond :take, Query::Reachable.new(:portable, :contained) do |actor, thing|
|
41
|
+
if thing.parent != actor.parent
|
42
|
+
if thing.parent.is?(:open) == false
|
43
|
+
if thing.parent.is?(:transparent)
|
44
|
+
actor.tell "#{The thing} is closed."
|
45
|
+
else
|
46
|
+
passthru
|
47
|
+
end
|
48
|
+
break
|
49
|
+
end
|
50
|
+
actor.tell "You take #{the thing} from #{the thing.parent}."
|
51
|
+
thing.parent = actor
|
52
|
+
else
|
53
|
+
passthru
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
respond :take, Query::Reachable.new(:portable, :supported) do |actor, thing|
|
58
|
+
actor.tell "You take #{the thing} from #{the thing.parent}."
|
59
|
+
thing.parent = actor
|
60
|
+
end
|
61
|
+
|
62
|
+
respond :take, Query::Children.new() do |actor, thing|
|
63
|
+
actor.tell "You're already carrying #{the thing}."
|
64
|
+
end
|
65
|
+
|
66
|
+
xlate "get :thing", :take, :thing
|
67
|
+
xlate "pick up :thing", :take, :thing
|
68
|
+
xlate "pick :thing up", :take, :thing
|
69
|
+
|
70
|
+
# The :take_from actions make it a little easier to disambiguate things. For
|
71
|
+
# example, if there's a green key in the room and a red key in a box, any of
|
72
|
+
# the following will understand which key you mean:
|
73
|
+
# * take green key
|
74
|
+
# * take red key
|
75
|
+
# * take key from room
|
76
|
+
# * take key from box
|
77
|
+
respond :take_from, Query::Room.new(), Query::Siblings.new() do |actor, container, thing|
|
78
|
+
actor.perform "take #{thing}"
|
79
|
+
end
|
80
|
+
respond :take_from, Query::Reachable.new(Container, :closed), Query::Text.new() do |actor, container, thing|
|
81
|
+
actor.tell "#{The container} is closed."
|
82
|
+
end
|
83
|
+
respond :take_from, Query::Reachable.new(Container, :open), Query::Subquery.new(:contained) do |actor, container, thing|
|
84
|
+
actor.perform "take #{thing}"
|
85
|
+
end
|
86
|
+
respond :take_from, Query::Reachable.new(Container, :open), Query::Subquery.new(:attached) do |actor, container, thing|
|
87
|
+
actor.tell "#{The thing} is attached to #{the container}."
|
88
|
+
end
|
89
|
+
respond :take_from, Query::Reachable.new(Supporter), Query::Subquery.new(:supported) do |actor, container, thing|
|
90
|
+
actor.perform "take #{thing}"
|
91
|
+
end
|
92
|
+
xlate "take :thing from :container", :take_from, :container, :thing
|
93
|
+
xlate "get :thing from :container", :take_from, :container, :thing
|
94
|
+
xlate "pick :thing up from :container", :take_from, :container, :thing
|
95
|
+
xlate "pick up :thing from :container", :take_from, :container, :thing
|
96
|
+
xlate "take :thing in :container", :take_from, :container, :thing
|
97
|
+
xlate "get :thing in :container", :take_from, :container, :thing
|
98
|
+
xlate "pick :thing up in :container", :take_from, :container, :thing
|
99
|
+
xlate "pick up :thing in :container", :take_from, :container, :thing
|
100
|
+
xlate "take :thing on :container", :take_from, :container, :thing
|
101
|
+
xlate "get :thing on :container", :take_from, :container, :thing
|
102
|
+
xlate "pick :thing up on :container", :take_from, :container, :thing
|
103
|
+
xlate "pick up :thing on :container", :take_from, :container, :thing
|
104
|
+
xlate "take :thing inside :container", :take_from, :container, :thing
|
105
|
+
xlate "get :thing inside :container", :take_from, :container, :thing
|
106
|
+
xlate "pick :thing up inside :container", :take_from, :container, :thing
|
107
|
+
xlate "pick up :thing inside :container", :take_from, :container, :thing
|
@@ -1,24 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@closeable ||= false
|
10
|
-
if (@closeable == true && @closed == nil)
|
11
|
-
@closed = false
|
12
|
-
end
|
13
|
-
@closeable
|
14
|
-
end
|
15
|
-
def closed?
|
16
|
-
(@closed == true)
|
17
|
-
end
|
18
|
-
def closed=(bool)
|
19
|
-
if bool == true
|
20
|
-
@closeable = true
|
21
|
-
end
|
22
|
-
@closed = bool
|
23
|
-
end
|
24
|
-
end
|
1
|
+
class Container < Thing
|
2
|
+
|
3
|
+
end
|
4
|
+
|
5
|
+
options(Container, :not_enterable, :enterable)
|
6
|
+
options(Container, :opaque, :transparent)
|
7
|
+
options(Container, :open, :closed).default = :open
|
8
|
+
options(Container, :openable, :unopenable).default = :unopenable
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Fixture < Thing
|
2
|
+
|
3
|
+
end
|
4
|
+
|
5
|
+
set_default_for(Fixture, :not_portable)
|