gamefic-standard 2.0.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.vscode/launch.json +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +60 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gamefic-standard.gemspec +44 -0
- data/lib/gamefic-standard.rb +10 -0
- data/lib/gamefic-standard/actions.rb +13 -0
- data/lib/gamefic-standard/actions/drop.rb +21 -0
- data/lib/gamefic-standard/actions/enter.rb +21 -0
- data/lib/gamefic-standard/actions/go.rb +56 -0
- data/lib/gamefic-standard/actions/insert.rb +38 -0
- data/lib/gamefic-standard/actions/inventory.rb +11 -0
- data/lib/gamefic-standard/actions/leave.rb +32 -0
- data/lib/gamefic-standard/actions/look.rb +117 -0
- data/lib/gamefic-standard/actions/nil.rb +38 -0
- data/lib/gamefic-standard/actions/place.rb +43 -0
- data/lib/gamefic-standard/actions/quit.rb +14 -0
- data/lib/gamefic-standard/actions/take.rb +33 -0
- data/lib/gamefic-standard/actions/talk.rb +29 -0
- data/lib/gamefic-standard/actions/wait.rb +5 -0
- data/lib/gamefic-standard/articles.rb +50 -0
- data/lib/gamefic-standard/clothing.rb +4 -0
- data/lib/gamefic-standard/clothing/actions.rb +4 -0
- data/lib/gamefic-standard/clothing/actions/doff.rb +14 -0
- data/lib/gamefic-standard/clothing/actions/drop.rb +10 -0
- data/lib/gamefic-standard/clothing/actions/inventory.rb +16 -0
- data/lib/gamefic-standard/clothing/actions/wear.rb +22 -0
- data/lib/gamefic-standard/clothing/entities.rb +7 -0
- data/lib/gamefic-standard/clothing/entities/clothing.rb +5 -0
- data/lib/gamefic-standard/clothing/entities/coat.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/gloves.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/hat.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/pants.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/shirt.rb +3 -0
- data/lib/gamefic-standard/clothing/entities/shoes.rb +3 -0
- data/lib/gamefic-standard/container.rb +27 -0
- data/lib/gamefic-standard/direction.rb +55 -0
- data/lib/gamefic-standard/edible.rb +23 -0
- data/lib/gamefic-standard/entities.rb +10 -0
- data/lib/gamefic-standard/entities/character.rb +11 -0
- data/lib/gamefic-standard/entities/fixture.rb +3 -0
- data/lib/gamefic-standard/entities/item.rb +5 -0
- data/lib/gamefic-standard/entities/portal.rb +44 -0
- data/lib/gamefic-standard/entities/receptacle.rb +3 -0
- data/lib/gamefic-standard/entities/room.rb +79 -0
- data/lib/gamefic-standard/entities/rubble.rb +11 -0
- data/lib/gamefic-standard/entities/scenery.rb +7 -0
- data/lib/gamefic-standard/entities/supporter.rb +7 -0
- data/lib/gamefic-standard/entities/thing.rb +72 -0
- data/lib/gamefic-standard/give.rb +27 -0
- data/lib/gamefic-standard/grammar.rb +2 -0
- data/lib/gamefic-standard/grammar/attributes.rb +37 -0
- data/lib/gamefic-standard/grammar/pronoun.rb +101 -0
- data/lib/gamefic-standard/lockable.rb +93 -0
- data/lib/gamefic-standard/modules.rb +7 -0
- data/lib/gamefic-standard/modules/enterable.rb +19 -0
- data/lib/gamefic-standard/modules/use.rb +45 -0
- data/lib/gamefic-standard/openable.rb +49 -0
- data/lib/gamefic-standard/pathfinder.rb +65 -0
- data/lib/gamefic-standard/queries.rb +25 -0
- data/lib/gamefic-standard/test.rb +36 -0
- data/lib/gamefic-standard/version.rb +5 -0
- metadata +182 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
meta nil, Gamefic::Query::Text.new() do |actor, string|
|
3
|
+
words = string.split_words
|
4
|
+
list = verbs
|
5
|
+
if list.include?(words[0])
|
6
|
+
if words.length > 1
|
7
|
+
actor.tell "I recognize '#{words[0]}' as a verb but could not understand the rest of your sentence."
|
8
|
+
else
|
9
|
+
actor.tell "I recognize '#{words[0]}' as a verb but could not understand it in this context."
|
10
|
+
end
|
11
|
+
else
|
12
|
+
found = []
|
13
|
+
list.each { |c|
|
14
|
+
next if c.include?('_')
|
15
|
+
if c.length > words[0].length and c.start_with?(words[0])
|
16
|
+
found.push c
|
17
|
+
end
|
18
|
+
}
|
19
|
+
if found.length == 1
|
20
|
+
words[0] = found[0]
|
21
|
+
actor.perform words.join(' ')
|
22
|
+
elsif found.length > 1 and words[0].length > 2
|
23
|
+
actor.tell "I'm not sure if #{words[0]} means #{found.join_and(', ', ' or ')}."
|
24
|
+
else
|
25
|
+
actor.tell "I don't recognize '#{words[0]}' as a verb."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
meta nil, Gamefic::Query::Text.new(/^it$/) do |actor, string|
|
31
|
+
words = string.split_words
|
32
|
+
if verbs(to_s: true).include?(words[0])
|
33
|
+
actor.tell "I'm not sure what you mean by \"it.\""
|
34
|
+
else
|
35
|
+
actor.proceed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :place, Use.children, Use.reachable do |actor, thing, supporter|
|
3
|
+
actor.tell "You can't put #{the thing} on #{the supporter}."
|
4
|
+
end
|
5
|
+
|
6
|
+
respond :place, Use.visible, Use.reachable(Supporter) do |actor, thing, supporter|
|
7
|
+
if thing.parent != actor
|
8
|
+
actor.perform :take, thing
|
9
|
+
end
|
10
|
+
if thing.parent == actor
|
11
|
+
thing.parent = supporter
|
12
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
respond :place, Use.children, Use.reachable(Supporter) do |actor, thing, supporter|
|
17
|
+
if thing.sticky?
|
18
|
+
actor.tell thing.sticky_message || "You need to keep #{the thing} for now."
|
19
|
+
else
|
20
|
+
thing.parent = supporter
|
21
|
+
actor.tell "You put #{the thing} on #{the supporter}."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
respond :place, Use.visible, Use.text do |actor, thing, supporter|
|
26
|
+
actor.tell "You don't see anything called \"#{supporter}\" here."
|
27
|
+
end
|
28
|
+
|
29
|
+
respond :place, Use.text, Use.visible do |actor, thing, supporter|
|
30
|
+
actor.tell "You don't see anything called \"#{thing}\" here."
|
31
|
+
end
|
32
|
+
|
33
|
+
respond :place, Use.text, Use.text do |actor, thing, supporter|
|
34
|
+
actor.tell "I don't know what you mean by \"#{thing}\" or \"#{supporter}.\""
|
35
|
+
end
|
36
|
+
|
37
|
+
xlate "put :thing on :supporter", "place :thing :supporter"
|
38
|
+
xlate "put :thing down on :supporter", "place :thing :supporter"
|
39
|
+
xlate "set :thing on :supporter", "place :thing :supporter"
|
40
|
+
xlate "set :thing down on :supporter", "place :thing :supporter"
|
41
|
+
xlate "drop :thing on :supporter", "place :thing :supporter"
|
42
|
+
xlate "place :thing on :supporter", "place :thing :supporter"
|
43
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
confirm_quit = yes_or_no do |actor, data|
|
3
|
+
if data.yes?
|
4
|
+
actor.cue default_conclusion
|
5
|
+
else
|
6
|
+
actor.cue default_scene
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
meta :quit do |actor|
|
11
|
+
actor.tell "Are you sure you want to quit?"
|
12
|
+
actor.cue confirm_quit
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :take, Use.text do |actor, text|
|
3
|
+
actor.tell "You don't see any \"#{text}\" here."
|
4
|
+
end
|
5
|
+
|
6
|
+
respond :take, Use.available do |actor, thing|
|
7
|
+
if thing.parent == actor
|
8
|
+
actor.tell "You're already carrying #{the thing}."
|
9
|
+
elsif thing.portable?
|
10
|
+
if actor.parent != thing.parent
|
11
|
+
actor.tell "You take #{the thing} from #{the thing.parent}."
|
12
|
+
else
|
13
|
+
actor.tell "You take #{the thing}."
|
14
|
+
end
|
15
|
+
thing.parent = actor
|
16
|
+
else
|
17
|
+
actor.tell "You can't take #{the thing}."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
respond :take, Use.available(:attached?) do |actor, thing|
|
22
|
+
actor.tell "#{The thing} is attached to #{the thing.parent}."
|
23
|
+
end
|
24
|
+
|
25
|
+
respond :take, Use.available(Rubble) do |actor, rubble|
|
26
|
+
actor.tell "You don't have any use for #{the rubble}."
|
27
|
+
end
|
28
|
+
|
29
|
+
interpret "get :thing", "take :thing"
|
30
|
+
interpret "pick up :thing", "take :thing"
|
31
|
+
interpret "pick :thing up", "take :thing"
|
32
|
+
interpret "carry :thing", "take :thing"
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :talk do |actor|
|
3
|
+
actor.tell "You talk to yourself."
|
4
|
+
end
|
5
|
+
|
6
|
+
respond :talk, Use.itself do |actor, yourself|
|
7
|
+
actor.perform :talk
|
8
|
+
end
|
9
|
+
|
10
|
+
respond :talk, Use.available do |actor, thing|
|
11
|
+
actor.tell "Nothing happens."
|
12
|
+
end
|
13
|
+
|
14
|
+
respond :talk, Use.available(Character) do |actor, character|
|
15
|
+
if actor == character
|
16
|
+
actor.perform :talk
|
17
|
+
else
|
18
|
+
actor.tell "#{The character} has nothing to say."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
interpret "talk to :character", "talk :character"
|
23
|
+
interpret "talk to :character about :subject", "talk :character :subject"
|
24
|
+
interpret "ask :character :subject", "talk :character :subject"
|
25
|
+
interpret "ask :character about :subject", "talk :character :subject"
|
26
|
+
interpret "tell :character :subject", "talk :character :subject"
|
27
|
+
interpret "tell :character about :subject", "talk :character :subject"
|
28
|
+
interpret "ask :character for :subject", "talk :character :subject"
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Articles
|
2
|
+
# Get a name for the entity with an indefinite article (unless the entity
|
3
|
+
# has a proper name).
|
4
|
+
#
|
5
|
+
# @param entity [Gamefic::Entity]
|
6
|
+
# @return [String]
|
7
|
+
def a(entity)
|
8
|
+
entity.indefinitely
|
9
|
+
end
|
10
|
+
alias an a
|
11
|
+
|
12
|
+
# Get a name for the entity with a definite article (unless the entity has
|
13
|
+
# a proper name).
|
14
|
+
#
|
15
|
+
# @param entity [Gamefic::Entity]
|
16
|
+
# @return [String]
|
17
|
+
def the(entity)
|
18
|
+
entity.definitely
|
19
|
+
end
|
20
|
+
|
21
|
+
# Get a capitalized name for the entity with an indefinite article (unless
|
22
|
+
# the entity has a proper name).
|
23
|
+
#
|
24
|
+
# @param entity [Gamefic::Entity]
|
25
|
+
# @return [String]
|
26
|
+
def a_(entity)
|
27
|
+
entity.indefinitely.cap_first
|
28
|
+
end
|
29
|
+
alias an_ a_
|
30
|
+
alias A a_
|
31
|
+
alias An a_
|
32
|
+
|
33
|
+
# Get a capitalized name for the entity with a definite article (unless
|
34
|
+
# the entity has a proper name).
|
35
|
+
#
|
36
|
+
# @param entity [Gamefic::Entity]
|
37
|
+
# @return [String]
|
38
|
+
def the_(entity)
|
39
|
+
entity.definitely.cap_first
|
40
|
+
end
|
41
|
+
alias The the_
|
42
|
+
end
|
43
|
+
|
44
|
+
class Gamefic::Plot
|
45
|
+
include Articles
|
46
|
+
end
|
47
|
+
|
48
|
+
class Gamefic::Subplot
|
49
|
+
include Articles
|
50
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :doff, Gamefic::Query::Children.new(Clothing) do |actor, clothing|
|
3
|
+
if !clothing.attached?
|
4
|
+
actor.tell "You're not wearing #{the clothing}."
|
5
|
+
else
|
6
|
+
clothing.attached = false
|
7
|
+
actor.tell "You take off #{the clothing}."
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
xlate "remove :clothing", "doff :clothing"
|
12
|
+
xlate "take off :clothing", "doff :clothing"
|
13
|
+
xlate "take :clothing off", "doff :clothing"
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :inventory do |actor|
|
3
|
+
if actor.children.length > 0
|
4
|
+
carried = actor.children.that_are_not(:attached?)
|
5
|
+
worn = actor.children.that_are(:attached?)
|
6
|
+
if carried.length > 0
|
7
|
+
actor.tell "You are carrying #{carried.join_and}."
|
8
|
+
end
|
9
|
+
if worn.length > 0
|
10
|
+
actor.tell "You are wearing #{worn.join_and}."
|
11
|
+
end
|
12
|
+
else
|
13
|
+
actor.tell "You aren't carrying anything."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Gamefic.script do
|
2
|
+
respond :wear, Use.available(Clothing) do |actor, clothing|
|
3
|
+
if clothing.parent != actor
|
4
|
+
actor.tell "You don't have #{the clothing}."
|
5
|
+
end
|
6
|
+
if clothing.attached?
|
7
|
+
actor.tell "You're already wearing #{the clothing}."
|
8
|
+
else
|
9
|
+
already = actor.children.that_are(clothing.class).that_are(:attached?)
|
10
|
+
if already.length == 0
|
11
|
+
clothing.attached = true
|
12
|
+
actor.tell "You put on #{the clothing}."
|
13
|
+
else
|
14
|
+
actor.tell "You're already wearing #{an already[0]}."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
xlate "put on :clothing", "wear :clothing"
|
20
|
+
xlate "put :clothing on", "wear :clothing"
|
21
|
+
xlate "don :clothing", "wear :clothing"
|
22
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require 'gamefic-standard/clothing/entities/clothing'
|
2
|
+
require 'gamefic-standard/clothing/entities/coat'
|
3
|
+
require 'gamefic-standard/clothing/entities/gloves'
|
4
|
+
require 'gamefic-standard/clothing/entities/hat'
|
5
|
+
require 'gamefic-standard/clothing/entities/pants'
|
6
|
+
require 'gamefic-standard/clothing/entities/shirt'
|
7
|
+
require 'gamefic-standard/clothing/entities/shoes'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# @gamefic.script standard/container
|
2
|
+
|
3
|
+
require 'gamefic-standard/openable'
|
4
|
+
require 'gamefic-standard/lockable'
|
5
|
+
|
6
|
+
class Container < Receptacle
|
7
|
+
include Openable
|
8
|
+
include Lockable
|
9
|
+
end
|
10
|
+
|
11
|
+
Gamefic.script do
|
12
|
+
respond :insert, Use.available, Use.available(Container) do |actor, thing, container|
|
13
|
+
if container.open?
|
14
|
+
actor.proceed
|
15
|
+
else
|
16
|
+
actor.tell "#{The container} is closed."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
respond :leave, Use.parent(Container, :enterable?, :closed?) do |actor, container|
|
21
|
+
actor.tell "#{The container} is closed."
|
22
|
+
end
|
23
|
+
|
24
|
+
respond :enter, Use.siblings(Container, :enterable?, :closed?) do |actor, container|
|
25
|
+
actor.tell "#{The container} is closed."
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Direction
|
2
|
+
attr_accessor :name, :adjective, :adverb, :reverse
|
3
|
+
|
4
|
+
def initialize args = {}
|
5
|
+
args.each { |key, value|
|
6
|
+
send "#{key}=", value
|
7
|
+
}
|
8
|
+
if !reverse.nil?
|
9
|
+
reverse.reverse = self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def adjective
|
14
|
+
@adjective || @name
|
15
|
+
end
|
16
|
+
|
17
|
+
def adverb
|
18
|
+
@adverb || @name
|
19
|
+
end
|
20
|
+
|
21
|
+
def reverse=(dir)
|
22
|
+
@reverse = dir
|
23
|
+
end
|
24
|
+
|
25
|
+
def synonyms
|
26
|
+
"#{adjective} #{adverb}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
@name
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def compass
|
35
|
+
if @compass.nil?
|
36
|
+
@compass = {}
|
37
|
+
@compass[:north] = Direction.new(:name => 'north', :adjective => 'northern')
|
38
|
+
@compass[:south] = Direction.new(:name => 'south', :adjective => 'southern', :reverse => @compass[:north])
|
39
|
+
@compass[:west] = Direction.new(:name => 'west', :adjective => 'western')
|
40
|
+
@compass[:east] = Direction.new(:name => 'east', :adjective => 'eastern', :reverse => @compass[:west])
|
41
|
+
@compass[:northwest] = Direction.new(:name => 'northwest', :adjective => 'northwestern')
|
42
|
+
@compass[:southeast] = Direction.new(:name => 'southeast', :adjective => 'southeastern', :reverse => @compass[:northwest])
|
43
|
+
@compass[:northeast] = Direction.new(:name => 'northeast', :adjective => 'northeastern')
|
44
|
+
@compass[:southwest] = Direction.new(:name => 'southwest', :adjective => 'southwestern', :reverse => @compass[:northeast])
|
45
|
+
@compass[:up] = Direction.new(:name => 'up', :adjective => 'upwards')
|
46
|
+
@compass[:down] = Direction.new(:name => 'down', :adjective => 'downwards', :reverse => @compass[:up])
|
47
|
+
end
|
48
|
+
@compass
|
49
|
+
end
|
50
|
+
|
51
|
+
def find(dir)
|
52
|
+
compass[dir.to_s.downcase.to_sym]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# @gamefic.script standard/edible
|
2
|
+
|
3
|
+
module Edibility
|
4
|
+
attr_writer :edible
|
5
|
+
def edible?
|
6
|
+
@edible ||= false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Thing
|
11
|
+
include Edibility
|
12
|
+
end
|
13
|
+
|
14
|
+
Gamefic.script do
|
15
|
+
respond :eat, Use.available do |actor, item|
|
16
|
+
actor.tell "You can't eat #{the item}."
|
17
|
+
end
|
18
|
+
|
19
|
+
respond :eat, Use.available(:edible?) do |actor, item|
|
20
|
+
actor.tell "You eat #{the item}."
|
21
|
+
destroy item
|
22
|
+
end
|
23
|
+
end
|