gamefic-standard 3.2.4 → 4.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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Rakefile +11 -5
  4. data/gamefic-standard.gemspec +15 -13
  5. data/lib/gamefic/standard/actions/attack.rb +32 -0
  6. data/lib/gamefic/standard/actions/close.rb +24 -0
  7. data/lib/gamefic/standard/actions/drop.rb +39 -0
  8. data/lib/gamefic/standard/actions/enter.rb +34 -0
  9. data/lib/gamefic/standard/actions/give.rb +38 -0
  10. data/lib/gamefic/standard/actions/go.rb +63 -0
  11. data/lib/gamefic/standard/actions/insert.rb +53 -0
  12. data/lib/gamefic/standard/actions/inventory.rb +20 -0
  13. data/lib/gamefic/standard/actions/leave.rb +57 -0
  14. data/lib/gamefic/standard/actions/lock.rb +31 -0
  15. data/lib/gamefic/standard/actions/look.rb +149 -0
  16. data/lib/gamefic/standard/actions/mount.rb +29 -0
  17. data/lib/gamefic/standard/actions/move.rb +28 -0
  18. data/lib/gamefic/standard/actions/nil.rb +37 -0
  19. data/lib/gamefic/standard/actions/open.rb +39 -0
  20. data/lib/gamefic/standard/actions/place.rb +39 -0
  21. data/lib/gamefic/standard/actions/pronouns.rb +34 -0
  22. data/lib/gamefic/standard/actions/quit.rb +24 -0
  23. data/lib/gamefic/standard/actions/repeat.rb +28 -0
  24. data/lib/gamefic/standard/actions/save-restore-undo.rb +26 -0
  25. data/lib/gamefic/standard/actions/search.rb +36 -0
  26. data/lib/gamefic/standard/actions/take.rb +54 -0
  27. data/lib/gamefic/standard/actions/talk.rb +51 -0
  28. data/lib/gamefic/standard/actions/unlock.rb +35 -0
  29. data/lib/gamefic/standard/actions/wait.rb +17 -0
  30. data/lib/gamefic/standard/actions.rb +57 -0
  31. data/lib/gamefic/standard/articles.rb +52 -0
  32. data/lib/gamefic/standard/enterable.rb +13 -0
  33. data/lib/gamefic/standard/entities/character.rb +14 -0
  34. data/lib/gamefic/standard/entities/container.rb +16 -0
  35. data/lib/gamefic/standard/entities/door.rb +46 -0
  36. data/lib/gamefic/standard/entities/fixture.rb +8 -0
  37. data/lib/gamefic/standard/entities/item.rb +11 -0
  38. data/lib/gamefic/standard/entities/portal.rb +50 -0
  39. data/lib/gamefic/standard/entities/receptacle.rb +9 -0
  40. data/lib/gamefic/standard/entities/room.rb +55 -0
  41. data/lib/gamefic/standard/entities/rubble.rb +16 -0
  42. data/lib/gamefic/standard/entities/scenery.rb +13 -0
  43. data/lib/gamefic/standard/entities/supporter.rb +9 -0
  44. data/lib/gamefic/standard/entities/thing.rb +9 -0
  45. data/lib/gamefic/standard/entities.rb +18 -0
  46. data/lib/gamefic/standard/introduction.rb +18 -0
  47. data/lib/gamefic/standard/lockable.rb +44 -0
  48. data/lib/gamefic/standard/openable.rb +33 -0
  49. data/lib/gamefic/standard/pathfinder.rb +82 -0
  50. data/lib/gamefic/standard/queries.rb +24 -0
  51. data/lib/gamefic/standard/standardized.rb +65 -0
  52. data/lib/{gamefic-standard → gamefic/standard}/version.rb +1 -1
  53. data/lib/gamefic/standard.rb +32 -0
  54. data/lib/gamefic-standard.rb +1 -27
  55. metadata +83 -58
  56. data/lib/gamefic-standard/actions/attack.rb +0 -28
  57. data/lib/gamefic-standard/actions/close.rb +0 -18
  58. data/lib/gamefic-standard/actions/drop.rb +0 -24
  59. data/lib/gamefic-standard/actions/enter.rb +0 -36
  60. data/lib/gamefic-standard/actions/go.rb +0 -59
  61. data/lib/gamefic-standard/actions/insert.rb +0 -39
  62. data/lib/gamefic-standard/actions/inventory.rb +0 -15
  63. data/lib/gamefic-standard/actions/leave.rb +0 -50
  64. data/lib/gamefic-standard/actions/lock.rb +0 -25
  65. data/lib/gamefic-standard/actions/look.rb +0 -133
  66. data/lib/gamefic-standard/actions/move.rb +0 -24
  67. data/lib/gamefic-standard/actions/nil.rb +0 -60
  68. data/lib/gamefic-standard/actions/open.rb +0 -29
  69. data/lib/gamefic-standard/actions/place.rb +0 -24
  70. data/lib/gamefic-standard/actions/pronouns.rb +0 -28
  71. data/lib/gamefic-standard/actions/quit.rb +0 -10
  72. data/lib/gamefic-standard/actions/repeat.rb +0 -14
  73. data/lib/gamefic-standard/actions/save-restore-undo.rb +0 -18
  74. data/lib/gamefic-standard/actions/search.rb +0 -26
  75. data/lib/gamefic-standard/actions/take.rb +0 -40
  76. data/lib/gamefic-standard/actions/talk.rb +0 -37
  77. data/lib/gamefic-standard/actions/unlock.rb +0 -25
  78. data/lib/gamefic-standard/actions/wait.rb +0 -7
  79. data/lib/gamefic-standard/actions.rb +0 -23
  80. data/lib/gamefic-standard/articles.rb +0 -42
  81. data/lib/gamefic-standard/entities/character.rb +0 -2
  82. data/lib/gamefic-standard/entities/container.rb +0 -8
  83. data/lib/gamefic-standard/entities/door.rb +0 -42
  84. data/lib/gamefic-standard/entities/fixture.rb +0 -4
  85. data/lib/gamefic-standard/entities/item.rb +0 -7
  86. data/lib/gamefic-standard/entities/portal.rb +0 -46
  87. data/lib/gamefic-standard/entities/receptacle.rb +0 -5
  88. data/lib/gamefic-standard/entities/room.rb +0 -46
  89. data/lib/gamefic-standard/entities/rubble.rb +0 -12
  90. data/lib/gamefic-standard/entities/scenery.rb +0 -9
  91. data/lib/gamefic-standard/entities/supporter.rb +0 -5
  92. data/lib/gamefic-standard/entities/thing.rb +0 -9
  93. data/lib/gamefic-standard/entities.rb +0 -12
  94. data/lib/gamefic-standard/give.rb +0 -21
  95. data/lib/gamefic-standard/grammar/attributes.rb +0 -37
  96. data/lib/gamefic-standard/grammar/pronoun.rb +0 -101
  97. data/lib/gamefic-standard/grammar.rb +0 -2
  98. data/lib/gamefic-standard/introduction.rb +0 -8
  99. data/lib/gamefic-standard/modules/enterable.rb +0 -9
  100. data/lib/gamefic-standard/modules/lockable.rb +0 -34
  101. data/lib/gamefic-standard/modules/openable.rb +0 -19
  102. data/lib/gamefic-standard/modules/standardized.rb +0 -57
  103. data/lib/gamefic-standard/modules.rb +0 -6
  104. data/lib/gamefic-standard/pathfinder.rb +0 -62
  105. data/lib/gamefic-standard/queries.rb +0 -12
  106. data/spec-opal/spec_helper.rb +0 -32
  107. /data/lib/{gamefic-standard → gamefic/standard}/direction.rb +0 -0
@@ -1,60 +0,0 @@
1
- Gamefic::Standard.script do
2
- meta nil, plaintext do |actor, string|
3
- next if string.strip.empty?
4
-
5
- words = string.keywords
6
- list = actor.epic.synonyms
7
- if list.include?(words[0]&.to_sym)
8
- if words.length > 1
9
- result = myself.query(actor, words[1..-1].join(' '))
10
- found = [result.match].compact
11
- avail = available(ambiguous: true)
12
- result = avail.query(actor, result.remainder)
13
- until result.match.nil?
14
- found.concat result.match
15
- result = avail.query(actor, result.remainder)
16
- end
17
- if found.empty?
18
- verbs = actor.epic
19
- .syntaxes
20
- .select { |syn| syn.synonym == words[0].to_sym }
21
- .map(&:verb)
22
- resps = actor.epic.responses_for(*verbs)
23
- if resps.any? { |resp| !resp.queries.empty? }
24
- actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
25
- else
26
- actor.tell %[I recognize "#{words[0]}" but not with the rest of your sentence. (Maybe it's a one-word command?)]
27
- end
28
- elsif result.remainder != ''
29
- actor.tell %(I recognize "#{words[0]}" as a verb but was confused by "#{result.remainder}.")
30
- elsif found.one?
31
- verbs = actor.epic
32
- .syntaxes
33
- .select { |syn| syn.synonym == words[0].to_sym }
34
- .map(&:verb)
35
- resps = actor.epic.responses_for(*verbs)
36
- if resps.any? { |resp| !resp.queries.empty? }
37
- actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
38
- else
39
- actor.tell %[I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together. (Maybe "#{words[0]}" is a one-word command?)]
40
- end
41
- else
42
- verbs = actor.epic
43
- .syntaxes
44
- .select { |syn| syn.synonym == words[0].to_sym }
45
- .map(&:verb)
46
- resps = actor.epic.responses_for(*verbs)
47
- if resps.any? { |resp| !resp.queries.empty? }
48
- actor.tell %(I recognize "#{words[0]}" but I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
49
- else
50
- actor.tell %[I recognize "#{words[0]}" but not with the rest of your sentence. (Maybe it's a one-word command?)]
51
- end
52
- end
53
- else
54
- actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
55
- end
56
- else
57
- actor.tell %(I don't recognize "#{words[0]}" as a verb.)
58
- end
59
- end
60
- end
@@ -1,29 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :open, available do |actor, thing|
3
- actor.tell "You can't open #{the thing}."
4
- end
5
-
6
- respond :open, available(Openable) do |actor, thing|
7
- if thing.open?
8
- actor.tell "#{The thing} is already open."
9
- else
10
- actor.tell "You open #{the thing}."
11
- thing.open = true
12
- end
13
- end
14
-
15
- respond :open, available(Lockable) do |actor, thing|
16
- if thing.locked?
17
- actor.tell "#{The thing} is locked."
18
- else
19
- actor.proceed
20
- end
21
- end
22
-
23
- respond :open, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
24
- actor.execute :unlock, thing, key
25
- actor.execute :open, thing if thing.unlocked?
26
- end
27
-
28
- interpret 'open :thing with :key', 'open :thing :key'
29
- end
@@ -1,24 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :place, children, available do |actor, thing, supporter|
3
- actor.tell "You can't put #{the thing} on #{the supporter}."
4
- end
5
-
6
- respond :place, available, available(Supporter) do |actor, thing, supporter|
7
- actor.execute :take, thing unless thing.parent == actor
8
- next unless thing.parent == actor
9
- thing.parent = supporter
10
- actor.tell "You put #{the thing} on #{the supporter}."
11
- end
12
-
13
- respond :place, children, available(Supporter) do |actor, thing, supporter|
14
- thing.parent = supporter
15
- actor.tell "You put #{the thing} on #{the supporter}."
16
- end
17
-
18
- interpret 'put :thing on :supporter', 'place :thing :supporter'
19
- interpret 'put :thing down on :supporter', 'place :thing :supporter'
20
- interpret 'set :thing on :supporter', 'place :thing :supporter'
21
- interpret 'set :thing down on :supporter', 'place :thing :supporter'
22
- interpret 'drop :thing on :supporter', 'place :thing :supporter'
23
- interpret 'place :thing on :supporter', 'place :thing :supporter'
24
- end
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gamefic::Standard.script do
4
- introduction do |actor|
5
- actor[:standard_pronoun_targets] = []
6
- end
7
-
8
- after_action do |action|
9
- next unless action.verb
10
-
11
- action.actor[:standard_pronoun_targets].replace action.arguments.that_are(Thing)
12
- end
13
-
14
- meta nil, plaintext do |actor, string|
15
- keywords = string.keywords
16
- list = actor.epic.synonyms
17
- next actor.proceed unless list.include?(keywords.first&.to_sym)
18
-
19
- xlation = keywords[1..].map do |word|
20
- next word unless %w[him her it them].include?(word)
21
-
22
- actor[:standard_pronoun_targets].find { |obj| Grammar::Pronoun.objective(obj) == word }
23
- end
24
- next actor.proceed if xlation.any?(&:nil?) || xlation.that_are(Thing).empty?
25
-
26
- actor.perform "#{keywords[0].to_sym} #{xlation.join(' ')}"
27
- end
28
- end
@@ -1,10 +0,0 @@
1
- Gamefic::Standard.script do
2
- yes_or_no :standard_confirm_quit do |actor, props|
3
- actor.cue :default_conclusion if props.yes?
4
- end
5
-
6
- meta :quit do |actor|
7
- actor.tell "Are you sure you want to quit?"
8
- actor.cue :standard_confirm_quit
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gamefic::Standard.script do
4
- meta :repeat do |actor|
5
- if actor.last_input && !actor.last_input.empty?
6
- actor.tell "Repeating <kbd>\"#{actor.last_input}\"</kbd>..."
7
- actor.queue.push actor.last_input
8
- else
9
- actor.tell "You don't have a previous command to repeat right now."
10
- end
11
- end
12
-
13
- interpret 'again', 'repeat'
14
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Gamefic::Standard.script do
4
- # Save, Restore, and Undo need to be handled by the game client. They have
5
- # default implementations here to make them available in help.
6
-
7
- meta :save do |actor|
8
- actor.tell "<kbd>Save</kbd> is not available."
9
- end
10
-
11
- meta :restore do |actor|
12
- actor.tell "<kbd>Restore</kbd> is not available."
13
- end
14
-
15
- meta :undo do |actor|
16
- actor.tell "<kbd>Undo</kbd> is not available."
17
- end
18
- end
@@ -1,26 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :search, available(Thing) do |actor, thing|
3
- actor.execute :look, thing
4
- end
5
-
6
- respond :search, available(Receptacle) do |actor, thing|
7
- if thing.accessible?
8
- itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
9
- if itemized.empty?
10
- actor.tell "There's nothing inside #{the thing}."
11
- else
12
- actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
13
- end
14
- else
15
- actor.tell "You can't see inside #{the thing}."
16
- end
17
- end
18
-
19
- respond :search, available(Container, proc(&:closed?)) do |actor, container|
20
- actor.execute :open, container
21
- actor.proceed if container.open?
22
- end
23
-
24
- interpret 'look inside :thing', 'search :thing'
25
- interpret 'look in :thing', 'search :thing'
26
- end
@@ -1,40 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :take, available do |actor, thing|
3
- if thing.parent == actor
4
- actor.tell "You're already carrying #{the thing}."
5
- elsif thing.portable?
6
- if actor.parent != thing.parent
7
- actor.tell "You take #{the thing} from #{the thing.parent}."
8
- else
9
- actor.tell "You take #{the thing}."
10
- end
11
- thing.parent = actor
12
- else
13
- actor.tell "You can't take #{the thing}."
14
- end
15
- end
16
-
17
- respond :take, available(proc(&:attached?)) do |actor, thing|
18
- actor.tell "#{The thing} is attached to #{the thing.parent}."
19
- end
20
-
21
- respond :take, available(Rubble) do |actor, rubble|
22
- actor.tell "You don't have any use for #{the rubble}."
23
- end
24
-
25
- respond :take, plaintext(/^(all|everything)$/) do |actor, _all|
26
- items = Gamefic::Scope::Family.matches(actor)
27
- .select(&:portable?)
28
- .reject { |item| actor.flatten.include?(item) }
29
- if items.empty?
30
- actor.tell "You don't see anything you can carry."
31
- else
32
- items.each { |item| actor.execute :take, item }
33
- end
34
- end
35
-
36
- interpret "get :thing", "take :thing"
37
- interpret "pick up :thing", "take :thing"
38
- interpret "pick :thing up", "take :thing"
39
- interpret "carry :thing", "take :thing"
40
- end
@@ -1,37 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :talk do |actor|
3
- actor.tell "You talk to yourself."
4
- end
5
-
6
- respond :talk, myself do |actor, yourself|
7
- actor.execute :talk
8
- end
9
-
10
- respond :talk, available do |actor, thing|
11
- actor.tell "Nothing happens."
12
- end
13
-
14
- respond :talk, Character do |actor, character|
15
- actor.tell "#{The character} has nothing to say."
16
- end
17
-
18
- respond :talk, Character, plaintext do |actor, character, text|
19
- actor.tell "#{The character} has nothing to say about #{text}."
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
- interpret "speak :character", "talk :character"
30
- interpret "speak to :character", "talk :character"
31
- interpret "speak :character :subject", "talk :character :subject"
32
- interpret "speak :character about :subject", "talk :character :subject"
33
- interpret "speak to :character about :subject", "talk :character :subject"
34
- interpret "speak to :character :subject", "talk :character :subject"
35
- interpret "discuss :subject :character", "talk :character :subject"
36
- interpret "discuss :subject with :character", "talk :character :subject"
37
- end
@@ -1,25 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :unlock, available(Lockable) do |actor, thing|
3
- if thing.has_lock_key? && actor.children.include?(thing.lock_key)
4
- actor.execute :unlock, thing, thing.lock_key
5
- else
6
- actor.tell "You can't unlock #{the thing}."
7
- end
8
- end
9
-
10
- respond :unlock, available(Lockable, proc(&:has_lock_key?)), children do |actor, thing, key|
11
- if thing.lock_key == key
12
- thing.locked = false
13
- actor.tell "You unlock #{the thing} with #{the key}."
14
- else
15
- actor.tell "You can't unlock #{the thing} with #{the key}."
16
- end
17
- end
18
-
19
- respond :unlock, available(Lockable, proc(&:has_lock_key?)), available do |actor, _thing, key|
20
- actor.execute :take, key if key.parent != actor
21
- actor.proceed if key.parent == actor
22
- end
23
-
24
- interpret "unlock :container with :key", "unlock :container :key"
25
- end
@@ -1,7 +0,0 @@
1
- Gamefic::Standard.script do
2
- respond :wait do |actor|
3
- actor.tell "Time passes."
4
- end
5
-
6
- interpret 'z', 'wait'
7
- end
@@ -1,23 +0,0 @@
1
- require 'gamefic-standard/actions/nil'
2
- require 'gamefic-standard/actions/attack'
3
- require 'gamefic-standard/actions/drop'
4
- require 'gamefic-standard/actions/enter'
5
- require 'gamefic-standard/actions/open'
6
- require 'gamefic-standard/actions/close'
7
- require 'gamefic-standard/actions/lock'
8
- require 'gamefic-standard/actions/unlock'
9
- require 'gamefic-standard/actions/go'
10
- require 'gamefic-standard/actions/insert'
11
- require 'gamefic-standard/actions/inventory'
12
- require 'gamefic-standard/actions/leave'
13
- require 'gamefic-standard/actions/look'
14
- require 'gamefic-standard/actions/search'
15
- require 'gamefic-standard/actions/place'
16
- require 'gamefic-standard/actions/quit'
17
- require 'gamefic-standard/actions/take'
18
- require 'gamefic-standard/actions/move'
19
- require 'gamefic-standard/actions/talk'
20
- require 'gamefic-standard/actions/wait'
21
- require 'gamefic-standard/actions/repeat'
22
- require 'gamefic-standard/actions/save-restore-undo'
23
- require 'gamefic-standard/actions/pronouns'
@@ -1,42 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- Character = Gamefic::Actor
2
- Character.set_default gender: :other
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # An openable and lockable receptacle.
4
- #
5
- class Container < Receptacle
6
- include Openable
7
- include Lockable
8
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # An openable portal.
4
- #
5
- class Door < Portal
6
- include Openable
7
- include Lockable
8
-
9
- def post_initialize
10
- update_reverse_open
11
- end
12
-
13
- def open= bool
14
- super
15
- update_reverse_open
16
- end
17
-
18
- def locked= bool
19
- super
20
- update_reverse_lock
21
- end
22
-
23
- def two_way_lock_key= key
24
- lock_key = key
25
- return if reverse.nil?
26
- reverse.lock_key = key
27
- end
28
-
29
- private
30
-
31
- def update_reverse_open
32
- rev = find_reverse
33
- return if rev.nil? || rev.open? == open?
34
- rev.open = open?
35
- end
36
-
37
- def update_reverse_lock
38
- rev = find_reverse
39
- return if rev.nil? || rev.locked? == locked?
40
- rev.locked = locked?
41
- end
42
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Fixture < Thing
4
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # An entity that is portable by default.
4
- #
5
- class Item < Thing
6
- set_default portable: true
7
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # An entity that provides access from one room to another.
4
- #
5
- class Portal < Thing
6
- # @return [Gamefic::Entity]
7
- attr_accessor :destination
8
-
9
- # Get the ordinal direction of this Portal
10
- # Portals have distinct direction and name properties so games can display a
11
- # bare compass direction for exits, e.g., "south" vs. "the southern door."
12
- #
13
- # A portal's destination can also be nil, in which case it can be referenced
14
- # in commands by its destination, e.g., "go to the house."
15
- #
16
- # @return [Direction, nil]
17
- attr_reader :direction
18
-
19
- # Find the portal in the destination that returns to this portal's parent
20
- #
21
- # @return [Room, nil]
22
- def reverse
23
- return nil if destination.nil?
24
-
25
- destination.children.that_are(Portal).find do |portal|
26
- portal.destination == parent
27
- end
28
- end
29
- alias find_reverse reverse
30
-
31
- def direction= dir
32
- @direction = Direction.find(dir)
33
- end
34
-
35
- def name
36
- @name || direction&.name || destination.name
37
- end
38
-
39
- def instruction
40
- direction || (destination ? "to #{destination.definitely}" : name)
41
- end
42
-
43
- def synonyms
44
- "#{super} #{@destination} #{@direction} #{!direction.nil? ? direction.synonyms : ''}"
45
- end
46
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Receptacle < Thing
4
- include Enterable
5
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Room < Thing
4
- attr_writer :explicit_exits
5
-
6
- set_default explicit_exits: true
7
-
8
- def explicit_exits?
9
- @explicit_exits
10
- end
11
-
12
- def tell(message)
13
- children.each { |c| c.tell message }
14
- end
15
-
16
- # @return [Array<Portal>]
17
- def portals
18
- children.that_are(Portal)
19
- end
20
-
21
- # @param destination [Room]
22
- # @param direction [Direction, String, nil]
23
- # @param type [Class<Portal>]
24
- # @param two_way [Boolean]
25
- # @return [Portal, Array<Portal>]
26
- def connect destination, direction: nil, type: Portal, two_way: true
27
- direction = Direction.find(direction)
28
- here = type.new(parent: self,
29
- destination: destination,
30
- direction: Direction.find(direction))
31
- return here unless two_way
32
-
33
- there = type.new(parent: destination, destination: self, direction: direction&.reverse)
34
- [here, there]
35
- end
36
-
37
- class << self
38
- def explicit_exits?
39
- default_attributes[:explicit_exits]
40
- end
41
-
42
- def explicit_exits=(bool)
43
- set_default explicit_exits: bool
44
- end
45
- end
46
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'gamefic-standard/entities/scenery'
4
-
5
- # Rubble is Scenery with slightly modified action responses.
6
- # Intended for things that might be portable but are useless.
7
- # Rule of thumb: Scenery is something that can't be carried,
8
- # like a table or the sky; and Rubble is something that might
9
- # be portable but is otherwise useless, like trash or debris.
10
- #
11
- class Rubble < Scenery
12
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Scenery is an entity that is not itemized by default. They're typically used
4
- # to provide a description for objects that can be observed but do not respond
5
- # to any other interactions.
6
- #
7
- class Scenery < Thing
8
- set_default itemized: false
9
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Supporter < Thing
4
- include Enterable
5
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Gamefic::Entity
4
- include Grammar::Attributes
5
- include Standardized
6
- end
7
-
8
- Thing = Gamefic::Entity
9
- Thing.set_default itemized: true, portable: false
@@ -1,12 +0,0 @@
1
- require 'gamefic-standard/entities/thing'
2
- require 'gamefic-standard/entities/character'
3
- require 'gamefic-standard/entities/fixture'
4
- require 'gamefic-standard/entities/item'
5
- require 'gamefic-standard/entities/portal'
6
- require 'gamefic-standard/entities/door'
7
- require 'gamefic-standard/entities/receptacle'
8
- require 'gamefic-standard/entities/container'
9
- require 'gamefic-standard/entities/room'
10
- require 'gamefic-standard/entities/scenery'
11
- require 'gamefic-standard/entities/rubble'
12
- require 'gamefic-standard/entities/supporter'
@@ -1,21 +0,0 @@
1
- module Gamefic::Standard::Give
2
- extend Gamefic::Scriptable
3
-
4
- script do
5
- respond :give, available, children do |actor, _character, _gift|
6
- actor.tell 'Nothing happens.'
7
- end
8
-
9
- respond :give, available(Character), available do |actor, character, gift|
10
- actor.tell "#{The character} doesn't want #{the gift}."
11
- end
12
-
13
- respond :give, available(Character), available do |actor, _character, gift|
14
- actor.execute :take, gift if gift.parent != actor
15
-
16
- actor.proceed if gift.parent == actor
17
- end
18
-
19
- interpret 'give :gift to :character', 'give :character :gift'
20
- end
21
- end