gamefic 0.2.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gamefic/action.rb +87 -56
- data/lib/gamefic/ansi.rb +55 -0
- data/lib/gamefic/character.rb +130 -76
- data/lib/gamefic/command.rb +19 -0
- data/lib/gamefic/core_ext/array.rb +51 -40
- data/lib/gamefic/core_ext/string.rb +4 -0
- data/lib/gamefic/describable.rb +108 -46
- data/lib/gamefic/direction.rb +46 -0
- data/lib/gamefic/director/delegate.rb +91 -0
- data/lib/gamefic/director/order.rb +10 -0
- data/lib/gamefic/director/parser.rb +119 -0
- data/lib/gamefic/director.rb +16 -197
- data/lib/gamefic/engine/cgi.rb +221 -0
- data/lib/gamefic/engine/tty.rb +237 -0
- data/lib/gamefic/engine.rb +88 -67
- data/lib/gamefic/entity.rb +96 -69
- data/lib/gamefic/grammar/conjugator.rb +20 -0
- data/lib/gamefic/grammar/gender.rb +11 -0
- data/lib/gamefic/grammar/person.rb +10 -0
- data/lib/gamefic/grammar/plural.rb +13 -0
- data/lib/gamefic/grammar/pronouns.rb +60 -0
- data/lib/gamefic/grammar/tense.rb +6 -0
- data/lib/gamefic/grammar/verb_set.rb +43 -0
- data/lib/gamefic/grammar/verbs.rb +25 -0
- data/lib/gamefic/grammar/word_adapter.rb +36 -0
- data/lib/gamefic/grammar.rb +13 -0
- data/lib/gamefic/html.rb +53 -0
- data/lib/gamefic/keywords.rb +51 -33
- data/lib/gamefic/node.rb +65 -58
- data/lib/gamefic/plot/article_mount.rb +22 -0
- data/lib/gamefic/plot/command_mount.rb +88 -0
- data/lib/gamefic/plot/entity_mount.rb +45 -0
- data/lib/gamefic/plot/query_mount.rb +9 -0
- data/lib/gamefic/plot/scene_mount.rb +181 -0
- data/lib/gamefic/plot/you_mount.rb +22 -0
- data/lib/gamefic/plot.rb +296 -247
- data/lib/gamefic/query/ambiguous_children.rb +5 -0
- data/lib/gamefic/query/base.rb +265 -0
- data/lib/gamefic/query/children.rb +10 -0
- data/lib/gamefic/query/expression.rb +47 -0
- data/lib/gamefic/query/family.rb +10 -0
- data/lib/gamefic/query/many_children.rb +7 -0
- data/lib/gamefic/query/matches.rb +11 -0
- data/lib/gamefic/query/parent.rb +10 -0
- data/lib/gamefic/query/plural_children.rb +14 -0
- data/lib/gamefic/query/self.rb +10 -0
- data/lib/gamefic/query/siblings.rb +10 -0
- data/lib/gamefic/query/text.rb +43 -0
- data/lib/gamefic/query.rb +19 -203
- data/lib/gamefic/rule.rb +18 -0
- data/lib/gamefic/scene/active.rb +25 -0
- data/lib/gamefic/scene/concluded.rb +22 -0
- data/lib/gamefic/scene/multiplechoice.rb +74 -0
- data/lib/gamefic/scene/paused.rb +26 -0
- data/lib/gamefic/scene/yesorno.rb +43 -0
- data/lib/gamefic/scene.rb +125 -0
- data/lib/gamefic/script/base.rb +33 -0
- data/lib/gamefic/script/file.rb +14 -0
- data/lib/gamefic/script/text.rb +14 -0
- data/lib/gamefic/script.rb +9 -0
- data/lib/gamefic/serialized.rb +24 -0
- data/lib/gamefic/shell.rb +9 -247
- data/lib/gamefic/snapshots.rb +134 -0
- data/lib/gamefic/source/base.rb +12 -0
- data/lib/gamefic/source/file.rb +23 -0
- data/lib/gamefic/source/text.rb +16 -0
- data/lib/gamefic/source.rb +9 -0
- data/lib/gamefic/stage.rb +75 -0
- data/lib/gamefic/syntax.rb +106 -124
- data/lib/gamefic/tester.rb +20 -0
- data/lib/gamefic/version.rb +3 -0
- data/lib/gamefic.rb +18 -12
- metadata +102 -70
- data/lib/gamefic/base.rb +0 -10
- data/lib/gamefic/before.rb +0 -12
- data/lib/gamefic/import/basics/actions/close.rb +0 -16
- data/lib/gamefic/import/basics/actions/commands.rb +0 -3
- data/lib/gamefic/import/basics/actions/drop-in.rb +0 -17
- data/lib/gamefic/import/basics/actions/drop-on.rb +0 -16
- data/lib/gamefic/import/basics/actions/drop.rb +0 -30
- data/lib/gamefic/import/basics/actions/enter.rb +0 -16
- data/lib/gamefic/import/basics/actions/go.rb +0 -35
- data/lib/gamefic/import/basics/actions/inventory.rb +0 -8
- data/lib/gamefic/import/basics/actions/leave.rb +0 -29
- data/lib/gamefic/import/basics/actions/look-in-at.rb +0 -27
- data/lib/gamefic/import/basics/actions/look-under.rb +0 -3
- data/lib/gamefic/import/basics/actions/look.rb +0 -71
- data/lib/gamefic/import/basics/actions/nil.rb +0 -25
- data/lib/gamefic/import/basics/actions/open.rb +0 -23
- data/lib/gamefic/import/basics/actions/quit.rb +0 -3
- data/lib/gamefic/import/basics/actions/take.rb +0 -107
- data/lib/gamefic/import/basics/entities/container.rb +0 -8
- data/lib/gamefic/import/basics/entities/entity.rb +0 -11
- data/lib/gamefic/import/basics/entities/fixture.rb +0 -5
- data/lib/gamefic/import/basics/entities/item.rb +0 -5
- data/lib/gamefic/import/basics/entities/portal.rb +0 -40
- data/lib/gamefic/import/basics/entities/room.rb +0 -30
- data/lib/gamefic/import/basics/entities/scenery.rb +0 -5
- data/lib/gamefic/import/basics/entities/supporter.rb +0 -6
- data/lib/gamefic/import/basics/entities/thing.rb +0 -16
- data/lib/gamefic/import/basics/queries/reachable.rb +0 -38
- data/lib/gamefic/import/basics/queries/room.rb +0 -8
- data/lib/gamefic/import/basics/queries/visible.rb +0 -32
- data/lib/gamefic/import/basics/rules/has-enough-light.rb +0 -14
- data/lib/gamefic/import/basics.old/actions/container.rb +0 -112
- data/lib/gamefic/import/basics.old/actions/inventory.rb +0 -50
- data/lib/gamefic/import/basics.old/actions/look.rb +0 -53
- data/lib/gamefic/import/basics.old/actions/meta.rb +0 -6
- data/lib/gamefic/import/basics.old/actions/traversal.rb +0 -35
- data/lib/gamefic/import/basics.old/actions.rb +0 -1
- data/lib/gamefic/import/basics.old/entities/container.rb +0 -3
- data/lib/gamefic/import/basics.old/entities/fixture.rb +0 -3
- data/lib/gamefic/import/basics.old/entities/item.rb +0 -3
- data/lib/gamefic/import/basics.old/entities/portal.rb +0 -43
- data/lib/gamefic/import/basics.old/entities/room.rb +0 -27
- data/lib/gamefic/import/basics.old/entities/scenery.rb +0 -3
- data/lib/gamefic/import/basics.old/entities/supporter.rb +0 -3
- data/lib/gamefic/import/basics.old/entities.rb +0 -1
- data/lib/gamefic/import/basics.old/room_modes.rb +0 -48
- data/lib/gamefic/import/basics.rb +0 -6
- data/lib/gamefic/import/room_modes.rb +0 -48
- data/lib/gamefic/import/standard.rb +0 -1
- data/lib/gamefic/meta.rb +0 -12
- data/lib/gamefic/optionset.rb +0 -114
- data/lib/gamefic/requirement.rb +0 -14
- data/lib/gamefic/story.rb +0 -14
- data/lib/gamefic/thing.rb +0 -7
@@ -1,112 +0,0 @@
|
|
1
|
-
respond :look, Query::Family.new(Container) do |actor, thing|
|
2
|
-
passthru
|
3
|
-
if thing.closeable?
|
4
|
-
actor.tell "#{thing.longname.specify.cap_first} is #{thing.closed? ? 'closed' : 'open'}."
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
respond :look_inside, Query::Family.new(Container) do |actor, container|
|
9
|
-
if container.closed?
|
10
|
-
actor.tell "#{container.longname.cap_first.specify} is closed."
|
11
|
-
else
|
12
|
-
if container.children.length == 0
|
13
|
-
actor.tell "You don't find anything."
|
14
|
-
else
|
15
|
-
if container.children.length == 1
|
16
|
-
actor.tell "#{container.longname.specify.cap_first} contains #{container.children[0].longname}."
|
17
|
-
else
|
18
|
-
actor.tell "#{container.longname.specify.cap_first} contains: #{container.children.join_and(', ')}."
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
xlate "look inside :container", :look_inside, :container
|
24
|
-
xlate "search :container", :look_inside, :container
|
25
|
-
xlate "look in :container", :look_inside, :container
|
26
|
-
|
27
|
-
respond :look_in_at, Query::Family.new(Container), Query::Subquery.new(Entity) do |actor, container, item|
|
28
|
-
if container.closed?
|
29
|
-
actor.tell "#{container.longname.cap_first.specify} is closed."
|
30
|
-
else
|
31
|
-
actor.tell item.description
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
respond :look_in_at, Query::Family.new(Container), Query::Text.new() do |actor, container, item|
|
36
|
-
if container.closed?
|
37
|
-
actor.tell "#{container.longname.cap_first.specify} is closed."
|
38
|
-
else
|
39
|
-
passthru
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
xlate "look at :item in :container", :look_in_at, :container, :item
|
44
|
-
xlate "look :item in :container", :look_in_at, :container, :item
|
45
|
-
|
46
|
-
respond :take_from, Query::Family.new(Container), Query::Subquery.new(Thing) do |actor, container, item|
|
47
|
-
# TODO: Make sure thing is portable
|
48
|
-
if container.closed?
|
49
|
-
actor.tell "#{container.longname.cap_first.specify} is closed."
|
50
|
-
else
|
51
|
-
item.parent = actor
|
52
|
-
actor.tell "You take #{item.longname} from #{container.longname.specify}."
|
53
|
-
end
|
54
|
-
end
|
55
|
-
xlate "take :item from :container", :take_from, :container, :item
|
56
|
-
xlate "get :item from :container", :take_from, :container, :item
|
57
|
-
xlate "remove :item from :container", :take_from, :container, :item
|
58
|
-
|
59
|
-
respond :drop_in, Query::Family.new(Container), Query::Children.new() do |actor, container, item|
|
60
|
-
if container.closed?
|
61
|
-
actor.tell "#{container.longname.cap_first.specify} is closed."
|
62
|
-
else
|
63
|
-
item.parent = container
|
64
|
-
actor.tell "You put #{item.longname} in #{container.longname}."
|
65
|
-
end
|
66
|
-
end
|
67
|
-
xlate "drop :item in :container", :drop_in, :container, :item
|
68
|
-
xlate "put :item in :container", :drop_in, :container, :item
|
69
|
-
xlate "place :item in :container", :drop_in, :container, :item
|
70
|
-
|
71
|
-
respond :open, Query::Text.new() do |actor, string|
|
72
|
-
actor.tell "You don't see any \"#{string}\" here."
|
73
|
-
end
|
74
|
-
|
75
|
-
respond :open, Query::Family.new(Entity) do |actor, thing|
|
76
|
-
actor.tell "You can't open #{thing.longname.specify}."
|
77
|
-
end
|
78
|
-
|
79
|
-
respond :open, Query::Family.new(Container) do |actor, container|
|
80
|
-
if container.closeable?
|
81
|
-
if container.closed?
|
82
|
-
actor.tell "You open #{container.longname.specify}."
|
83
|
-
container.closed = false
|
84
|
-
actor.perform "look inside #{container.longname}"
|
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
|
-
respond :close, Query::Text.new() do |actor, string|
|
94
|
-
actor.tell "You don't see any \"#{string}\" here."
|
95
|
-
end
|
96
|
-
|
97
|
-
respond :close, Query::Family.new(Entity) do |actor, thing|
|
98
|
-
actor.tell "You can't close #{thing.longname.specify}."
|
99
|
-
end
|
100
|
-
|
101
|
-
respond :close, Query::Family.new(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
|
@@ -1,50 +0,0 @@
|
|
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::Siblings.new(Thing) do |actor, thing|
|
11
|
-
# TODO: Make sure the thing is portable or whatever
|
12
|
-
thing.parent = actor
|
13
|
-
actor.tell "You take #{the thing}.", true
|
14
|
-
end
|
15
|
-
|
16
|
-
respond :take, Query::Siblings.new() do |actor, thing|
|
17
|
-
actor.tell "You can't carry #{the thing}."
|
18
|
-
end
|
19
|
-
|
20
|
-
respond :take, Query::Text.new() do |actor, thing|
|
21
|
-
containers = actor.children.that_are(Container)
|
22
|
-
containers = containers + actor.parent.children.that_are(Container)
|
23
|
-
found = false
|
24
|
-
containers.each { |container|
|
25
|
-
if container.closed? == false
|
26
|
-
query = Query::Children.new(Portable)
|
27
|
-
result = query.execute(container, thing)
|
28
|
-
if result.objects.length == 1
|
29
|
-
found = true
|
30
|
-
actor.perform "take #{result.objects[0].name} from #{container.name}"
|
31
|
-
break
|
32
|
-
end
|
33
|
-
end
|
34
|
-
}
|
35
|
-
if found == false
|
36
|
-
actor.tell "You don't see any \"#{thing}\" here."
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
respond :drop, Query::Children.new() do |actor, thing|
|
41
|
-
thing.parent = actor.parent
|
42
|
-
actor.tell "You drop #{the thing}.", true
|
43
|
-
end
|
44
|
-
|
45
|
-
xlate "get :thing", :take, :thing
|
46
|
-
xlate "pick :thing up", :take, :thing
|
47
|
-
xlate "pick up :thing", :take, :thing
|
48
|
-
|
49
|
-
xlate "put down :thing", :drop, :thing
|
50
|
-
xlate "put :thing down", :drop, :thing
|
@@ -1,53 +0,0 @@
|
|
1
|
-
OptionSet.new(Thing, :itemized)
|
2
|
-
|
3
|
-
respond :look, Query::Parent.new() do |actor, room|
|
4
|
-
actor.tell actor.parent.name.cap_first
|
5
|
-
actor.tell actor.parent.description
|
6
|
-
chars = actor.parent.children.that_are(Character) - [actor]
|
7
|
-
if chars.length > 0
|
8
|
-
actor.tell "Others here: #{chars.join(", ")}"
|
9
|
-
end
|
10
|
-
items = actor.parent.children.that_are(:itemized) - [actor]
|
11
|
-
if items.length > 0
|
12
|
-
actor.tell "Visible items: #{items.join(", ")}"
|
13
|
-
end
|
14
|
-
portals = actor.parent.children.that_are(Portal)
|
15
|
-
if portals.length > 0
|
16
|
-
actor.tell "Obvious exits: #{portals.join(', ')}"
|
17
|
-
else
|
18
|
-
actor.tell "Obvious exits: none"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
xlate "look", :look, "around"
|
22
|
-
|
23
|
-
respond :look, Query::Family.new() do |actor, thing|
|
24
|
-
actor.tell thing.description
|
25
|
-
end
|
26
|
-
|
27
|
-
respond :look, Query::Text.new() do |actor, string|
|
28
|
-
containers = actor.children.that_are(Container)
|
29
|
-
containers = containers + actor.parent.children.that_are(Container)
|
30
|
-
found = false
|
31
|
-
containers.each { |container|
|
32
|
-
if container.closed? == false
|
33
|
-
query = Query::Children.new(Portable)
|
34
|
-
result = query.execute(container, string)
|
35
|
-
if result.objects.length == 1
|
36
|
-
found = true
|
37
|
-
actor.tell "You look at #{result.objects[0].name.specify} in #{container.name.specify}."
|
38
|
-
actor.perform "look #{result.objects[0].name} in #{container.name}"
|
39
|
-
break
|
40
|
-
end
|
41
|
-
end
|
42
|
-
}
|
43
|
-
if found == false
|
44
|
-
actor.tell "You don't see any \"#{string}\" here."
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
xlate "look at :thing", :look, :thing
|
49
|
-
xlate "l", :look
|
50
|
-
xlate "l :thing", :look, :thing
|
51
|
-
xlate "examine :thing", :look, :thing
|
52
|
-
xlate "exam :thing", :look, :thing
|
53
|
-
xlate "x :thing", :look, :thing
|
@@ -1,35 +0,0 @@
|
|
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 +0,0 @@
|
|
1
|
-
import 'basics/actions/*'
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class Portal < Entity
|
2
|
-
attr_accessor :destination
|
3
|
-
#def initialize
|
4
|
-
# super
|
5
|
-
# @destination = nil
|
6
|
-
#end
|
7
|
-
def find_reverse
|
8
|
-
rev = Portal.reverse(self.name)
|
9
|
-
if rev != nil
|
10
|
-
destination.children.that_are(Portal).each { |c|
|
11
|
-
if c.name == rev
|
12
|
-
return c
|
13
|
-
end
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
def self.reverse(direction)
|
18
|
-
case direction.downcase
|
19
|
-
when "north"
|
20
|
-
"south"
|
21
|
-
when "south"
|
22
|
-
"north"
|
23
|
-
when "west"
|
24
|
-
"east"
|
25
|
-
when "east"
|
26
|
-
"west"
|
27
|
-
when "northwest"
|
28
|
-
"southeast"
|
29
|
-
when "southeast"
|
30
|
-
"northwest"
|
31
|
-
when "northeast"
|
32
|
-
"southwest"
|
33
|
-
when "southwest"
|
34
|
-
"northeast"
|
35
|
-
when "up"
|
36
|
-
"down"
|
37
|
-
when "down"
|
38
|
-
"up"
|
39
|
-
else
|
40
|
-
nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import 'basics/entities/portal'
|
2
|
-
|
3
|
-
class Room < Entity
|
4
|
-
def connect(destination, direction, type = Portal, two_way = true)
|
5
|
-
portal = type.new self.plot, :name => direction, :parent => self, :destination => destination
|
6
|
-
if two_way == true
|
7
|
-
reverse = Portal.reverse(direction)
|
8
|
-
if reverse == nil
|
9
|
-
raise "\"#{direction.cap_first}\" does not have an opposite direction"
|
10
|
-
end
|
11
|
-
portal2 = type.new(self.plot, {
|
12
|
-
:name => reverse,
|
13
|
-
:parent => destination,
|
14
|
-
:destination => self
|
15
|
-
})
|
16
|
-
end
|
17
|
-
portal
|
18
|
-
end
|
19
|
-
def synonyms
|
20
|
-
super.to_s + " around"
|
21
|
-
end
|
22
|
-
def tell(message, refresh = false)
|
23
|
-
children.each { |c|
|
24
|
-
c.tell message, refresh
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import 'basics/entities/*'
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module RoomModes
|
2
|
-
attr_writer :description_mode
|
3
|
-
def description_seen
|
4
|
-
@description_seen ||= Array.new
|
5
|
-
end
|
6
|
-
def description_seen=(value)
|
7
|
-
if value.kind_of?(Array)
|
8
|
-
@description_seen = value
|
9
|
-
else
|
10
|
-
raise "Character#description_seen must be an Array"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
def description_mode
|
14
|
-
@description_mode ||= "verbose"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Character
|
19
|
-
include RoomModes
|
20
|
-
end
|
21
|
-
|
22
|
-
respond :go, Query::Siblings.new(Portal) do |actor, portal|
|
23
|
-
actor.tell "You go #{portal.name}."
|
24
|
-
actor.parent = portal.destination
|
25
|
-
if actor.description_mode == "superbrief" or (actor.description_mode == "brief" and actor.description_seen.include?(actor.parent))
|
26
|
-
actor.tell actor.parent.longname.cap_first
|
27
|
-
else
|
28
|
-
actor.perform "look"
|
29
|
-
end
|
30
|
-
if actor.description_seen.include?(actor.parent) == false
|
31
|
-
actor.description_seen.push actor.parent
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
respond :brief do |actor|
|
36
|
-
actor.description_mode = "brief"
|
37
|
-
actor.tell "You are now in BRIEF mode. Detailed descriptions of rooms will only be displayed the first time you visit them. Other options are SUPERBRIEF and VERBOSE."
|
38
|
-
end
|
39
|
-
|
40
|
-
respond :verbose do |actor|
|
41
|
-
actor.description_mode = "verbose"
|
42
|
-
actor.tell "You are now in VERBOSE mode. Detailed descriptions will be displayed every time you enter a room. Other options are BRIEF and SUPERBRIEF."
|
43
|
-
end
|
44
|
-
|
45
|
-
respond :superbrief do |actor|
|
46
|
-
actor.description_mode = "superbrief"
|
47
|
-
actor.tell "You are now in SUPERBRIEF mode. Detailed room descriptions will never be displayed unless you LOOK AROUND. Other options are BRIEF and VERBOSE."
|
48
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
module RoomModes
|
2
|
-
attr_writer :description_mode
|
3
|
-
def description_seen
|
4
|
-
@description_seen ||= Array.new
|
5
|
-
end
|
6
|
-
def description_seen=(value)
|
7
|
-
if value.kind_of?(Array)
|
8
|
-
@description_seen = value
|
9
|
-
else
|
10
|
-
raise "Character#description_seen must be an Array"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
def description_mode
|
14
|
-
@description_mode ||= "verbose"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Character
|
19
|
-
include RoomModes
|
20
|
-
end
|
21
|
-
|
22
|
-
respond :go, Query::Siblings.new(Portal) do |actor, portal|
|
23
|
-
actor.tell "You go #{portal.name}."
|
24
|
-
actor.parent = portal.destination
|
25
|
-
if actor.description_mode == "superbrief" or (actor.description_mode == "brief" and actor.description_seen.include?(actor.parent))
|
26
|
-
actor.tell actor.parent.name.cap_first
|
27
|
-
else
|
28
|
-
actor.perform "look"
|
29
|
-
end
|
30
|
-
if actor.description_seen.include?(actor.parent) == false
|
31
|
-
actor.description_seen.push actor.parent
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
respond :brief do |actor|
|
36
|
-
actor.description_mode = "brief"
|
37
|
-
actor.tell "You are now in BRIEF mode. Detailed descriptions of rooms will only be displayed the first time you visit them. Other options are SUPERBRIEF and VERBOSE."
|
38
|
-
end
|
39
|
-
|
40
|
-
respond :verbose do |actor|
|
41
|
-
actor.description_mode = "verbose"
|
42
|
-
actor.tell "You are now in VERBOSE mode. Detailed descriptions will be displayed every time you enter a room. Other options are BRIEF and SUPERBRIEF."
|
43
|
-
end
|
44
|
-
|
45
|
-
respond :superbrief do |actor|
|
46
|
-
actor.description_mode = "superbrief"
|
47
|
-
actor.tell "You are now in SUPERBRIEF mode. Detailed room descriptions will never be displayed unless you LOOK AROUND. Other options are BRIEF and VERBOSE."
|
48
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
import 'basics'
|
data/lib/gamefic/meta.rb
DELETED
data/lib/gamefic/optionset.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
class OptionSet
|
2
|
-
attr_accessor :options
|
3
|
-
attr_reader :default
|
4
|
-
def initialize *args
|
5
|
-
@options = args
|
6
|
-
if @options.length == 0
|
7
|
-
raise "No options defined"
|
8
|
-
end
|
9
|
-
if @options.length == 1
|
10
|
-
raise "Option sets require at least 2 options"
|
11
|
-
end
|
12
|
-
@default = @options[0]
|
13
|
-
end
|
14
|
-
def default=(val)
|
15
|
-
if @options.include?(val) == false
|
16
|
-
raise "Option #{val} not available"
|
17
|
-
end
|
18
|
-
@default = val
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module OptionMap
|
23
|
-
def option_map
|
24
|
-
@option_map ||= Hash.new
|
25
|
-
end
|
26
|
-
def options cls, *args
|
27
|
-
os = OptionSet.new *args
|
28
|
-
option_map[cls] ||= {}
|
29
|
-
os.options.each { |o|
|
30
|
-
if option_map[cls][o] != nil
|
31
|
-
raise "Option #{o} already exists"
|
32
|
-
end
|
33
|
-
option_map[cls][o] = os
|
34
|
-
}
|
35
|
-
os
|
36
|
-
end
|
37
|
-
def get_default_for(cls, opt)
|
38
|
-
os = get_option_set_for(cls, opt)
|
39
|
-
if os == nil
|
40
|
-
raise "Option does not exist"
|
41
|
-
end
|
42
|
-
return os.default
|
43
|
-
end
|
44
|
-
def set_default_for(cls, opt)
|
45
|
-
os = get_option_set_for(cls, opt)
|
46
|
-
os.default = opt
|
47
|
-
end
|
48
|
-
def get_all_option_sets_for(cls)
|
49
|
-
all = []
|
50
|
-
option_map.each_value { |s|
|
51
|
-
s.each_key { |o|
|
52
|
-
set = get_option_set_for(cls, o, false)
|
53
|
-
if set != nil
|
54
|
-
all.push set
|
55
|
-
end
|
56
|
-
}
|
57
|
-
}
|
58
|
-
all.uniq
|
59
|
-
end
|
60
|
-
def get_option_set_for(cls, opt, create_if_inherited = true)
|
61
|
-
if option_map[cls] and option_map[cls][opt]
|
62
|
-
return option_map[cls][opt]
|
63
|
-
elsif cls.superclass
|
64
|
-
os = get_option_set_for(cls.superclass, opt, false)
|
65
|
-
if os != nil and create_if_inherited == true
|
66
|
-
os = options(cls, *os.options)
|
67
|
-
end
|
68
|
-
return os
|
69
|
-
end
|
70
|
-
return nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
module OptionSettings
|
75
|
-
attr_reader :option_mapper
|
76
|
-
def option_array
|
77
|
-
@option_array ||= []
|
78
|
-
end
|
79
|
-
def option_select(opt)
|
80
|
-
if option_array.include?(opt) == false
|
81
|
-
set = option_mapper.get_option_set_for(self.class, opt)
|
82
|
-
if set == nil
|
83
|
-
raise "Invalid option #{opt}"
|
84
|
-
end
|
85
|
-
(set.options - [opt]).each { |o|
|
86
|
-
option_array.delete o
|
87
|
-
}
|
88
|
-
option_array.push opt
|
89
|
-
end
|
90
|
-
end
|
91
|
-
def option_unselect(opt)
|
92
|
-
set = option_mapper.get_option_set_for(self.class, opt)
|
93
|
-
if set == nil
|
94
|
-
raise "Invalid option #{opt}"
|
95
|
-
end
|
96
|
-
option_array.delete opt
|
97
|
-
end
|
98
|
-
def option_selected?(opt)
|
99
|
-
set = option_mapper.get_option_set_for(self.class, opt)
|
100
|
-
return false if set.nil?
|
101
|
-
return true if option_array.include?(opt)
|
102
|
-
other = set.options & option_array
|
103
|
-
if other.length == 0 and set.default == opt
|
104
|
-
return true
|
105
|
-
end
|
106
|
-
return false
|
107
|
-
end
|
108
|
-
def is(opt)
|
109
|
-
option_select opt
|
110
|
-
end
|
111
|
-
def is?(opt)
|
112
|
-
option_selected?(opt)
|
113
|
-
end
|
114
|
-
end
|
data/lib/gamefic/requirement.rb
DELETED
data/lib/gamefic/story.rb
DELETED