gamefic-standard 3.2.0 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93e0b9232ad79263ae86444d04d4c9a4fefa4f1b4502d2fcb8275263fc6a9401
4
- data.tar.gz: 0fcd39f5dbdd99d94fd9525d188e29ada3d89d0545e6dc2455d695e5faf060ea
3
+ metadata.gz: 934c9793a332bc51d87f3643530112bf53930955a012cbaaa8c20b9b652347f1
4
+ data.tar.gz: 5d7afbc7b668390a80ed5784921f872dacf5c51a741b0bf0b2a584b152e156d2
5
5
  SHA512:
6
- metadata.gz: 8d500f2938e3475dea1e00c926b3dcec159ba76565c435f8590a317a316883b3c5ad2e7a8e01dc26eff1f9393680af8c925db42e26e57ba2d31aebcf2c5b3071
7
- data.tar.gz: 34bb09d0c1a814c6e2f6febc04a1e8b959b78d8b0a1a17ffb42477ba110f4880ff24707f62255cc9c73c6602476d63abb79d496d79dafe394d3af3b6d4a36389
6
+ metadata.gz: 19c479b2c1c2f6ca1deae46644056c3ee24e9a5b19f084b758e2caeaff3e13e149593deaf0d9b37af2c8b04b1fe42dfe51567b6712b3a2c2b18d3910eb416d32
7
+ data.tar.gz: 928429f5cb51bec69403e17797f9117368b9e847973a1c430b180b2d3567ac9b1d97948908c7f7ccf7221627452aaa160fd528a89a12346cde74dc9cc5737bce
@@ -22,7 +22,7 @@ jobs:
22
22
  runs-on: ubuntu-latest
23
23
  strategy:
24
24
  matrix:
25
- ruby-version: ['2.7', '3.0', '3.1']
25
+ ruby-version: ['2.7', '3.0', '3.1', '3.3']
26
26
 
27
27
  steps:
28
28
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- ## 3.2.0
1
+ ## 3.2.2 - September 1, 2024
2
+ - Move help commands to their own extension
3
+ - get inside -> enter
4
+ - Use definite names in leave error
5
+ - Report commands that do not accept arguments
6
+ - Require gamefic ~> 3.3
7
+
8
+ ## 3.2.1 - July 23, 2024
9
+ - Help actions are meta
10
+ - Ignore empty commands
11
+
12
+ ## 3.2.0 - July 10, 2024
2
13
  - Recognize pronouns in commands
3
14
 
4
15
  ## 3.1.0 - April 8, 2024
Binary file
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.required_ruby_version = '>= 2.7.0'
39
39
 
40
- spec.add_dependency 'gamefic', '~> 3.1'
40
+ spec.add_dependency 'gamefic', '~> 3.3'
41
41
 
42
42
  spec.add_development_dependency 'opal', '~> 1.7'
43
43
  spec.add_development_dependency 'opal-rspec', '~> 1.0'
@@ -24,6 +24,7 @@ module Gamefic
24
24
 
25
25
  interpret "get on :thing", "enter :thing"
26
26
  interpret "get in :thing", "enter :thing"
27
+ interpret "get inside :thing", "enter :thing"
27
28
  interpret "sit on :thing", "enter :thing"
28
29
  interpret "sit in :thing", "enter :thing"
29
30
  interpret "lie on :thing", "enter :thing"
@@ -22,7 +22,7 @@ module Gamefic
22
22
  elsif portals.length == 1
23
23
  actor.execute :go, portals[0]
24
24
  else
25
- actor.tell "I don't know which way you want to go: #{portals.join_or}."
25
+ actor.tell "I don't know which way you want to go: #{portals.map(&:definitely).join_or}."
26
26
  end
27
27
  end
28
28
 
@@ -1,24 +1,54 @@
1
1
  Gamefic::Standard.script do
2
2
  meta nil, plaintext do |actor, string|
3
+ next if string.strip.empty?
4
+
3
5
  words = string.keywords
4
6
  list = actor.epic.synonyms
5
7
  if list.include?(words[0]&.to_sym)
6
8
  if words.length > 1
7
- found = []
9
+ result = myself.query(actor, words[1..-1].join(' '))
10
+ found = [result.match].compact
8
11
  avail = available(ambiguous: true)
9
- result = avail.query(actor, words[1..-1].join(' '))
12
+ result = avail.query(actor, result.remainder)
10
13
  until result.match.nil?
11
14
  found.concat result.match
12
15
  result = avail.query(actor, result.remainder)
13
16
  end
14
17
  if found.empty?
15
- actor.tell %(I recognize "#{words[0]}" as a verb but don't know what you mean by "#{words[1..-1].join(' ')}.")
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
16
28
  elsif result.remainder != ''
17
29
  actor.tell %(I recognize "#{words[0]}" as a verb but was confused by "#{result.remainder}.")
18
30
  elsif found.one?
19
- actor.tell %(I recognize "#{words[0]}" and "#{found.first.name}" but could not understand them together.)
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
20
41
  else
21
- actor.tell %(I recognize "#{words[0]}" but I'm not sure if "#{words[1..-1].join(' ')}" means #{found.map(&:definitely).join_or}.)
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
22
52
  end
23
53
  else
24
54
  actor.tell %(I recognize "#{words[0]}" as a verb but could not understand it in this context.)
@@ -19,6 +19,5 @@ require 'gamefic-standard/actions/move'
19
19
  require 'gamefic-standard/actions/talk'
20
20
  require 'gamefic-standard/actions/wait'
21
21
  require 'gamefic-standard/actions/repeat'
22
- require 'gamefic-standard/actions/help'
23
22
  require 'gamefic-standard/actions/save-restore-undo'
24
23
  require 'gamefic-standard/actions/pronouns'
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # An entity that provides access from one room to another.
4
+ #
3
5
  class Portal < Thing
4
6
  # @return [Gamefic::Entity]
5
7
  attr_accessor :destination
@@ -19,6 +21,7 @@ class Portal < Thing
19
21
  # @return [Room, nil]
20
22
  def reverse
21
23
  return nil if destination.nil?
24
+
22
25
  destination.children.that_are(Portal).find do |portal|
23
26
  portal.destination == parent
24
27
  end
@@ -30,7 +33,7 @@ class Portal < Thing
30
33
  end
31
34
 
32
35
  def name
33
- @name || (direction.nil? ? destination.name : direction.name)
36
+ @name || direction&.name || destination.name
34
37
  end
35
38
 
36
39
  def instruction
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gamefic
4
4
  module Standard
5
- VERSION = '3.2.0'
5
+ VERSION = '3.2.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2024-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '3.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -115,6 +115,7 @@ files:
115
115
  - Rakefile
116
116
  - bin/console
117
117
  - bin/setup
118
+ - gamefic-standard-3.2.1.gem
118
119
  - gamefic-standard.gemspec
119
120
  - lib/gamefic-standard.rb
120
121
  - lib/gamefic-standard/actions.rb
@@ -123,7 +124,6 @@ files:
123
124
  - lib/gamefic-standard/actions/drop.rb
124
125
  - lib/gamefic-standard/actions/enter.rb
125
126
  - lib/gamefic-standard/actions/go.rb
126
- - lib/gamefic-standard/actions/help.rb
127
127
  - lib/gamefic-standard/actions/insert.rb
128
128
  - lib/gamefic-standard/actions/inventory.rb
129
129
  - lib/gamefic-standard/actions/leave.rb
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Gamefic
4
- module Standard
5
- script do
6
- respond :verbs do |actor|
7
- list = rulebook.synonyms.reject { |syn| syn.to_s.start_with?('_') }
8
- .map { |syn| "<kbd>#{syn}</kbd>"}
9
- .join_and
10
- actor.tell "I understand the following commands: #{list}."
11
- actor.tell "Try using commands in plain sentences like <kbd>go north</kbd> or <kbd>take the coin</kbd>."
12
- actor.tell "For more information about a specific command, try <kbd>help [command]</kbd>, e.g., <kbd>help go</kbd>."
13
- end
14
-
15
- interpret 'commands', 'verbs'
16
- interpret 'help', 'verbs'
17
-
18
- respond :help, plaintext do |actor, command|
19
- if rulebook.synonyms.include?(command.to_sym) && !command.start_with?('_')
20
- available = rulebook.syntaxes.select { |syntax| syntax.synonym == command.to_sym }
21
- .uniq(&:signature)
22
- examples = available.map(&:template)
23
- .map do |tmpl|
24
- tmpl.text
25
- .gsub(/:character/i, '[someone]')
26
- .gsub(/:var[0-9]?/i, '[something]')
27
- .gsub(/:([a-z0-9]+)/i, "[\\1]")
28
- end
29
- .reject { |tmpl| tmpl.include?('[something] [something]') }
30
- actor.tell 'Examples:'
31
- actor.stream '<ul>'
32
- examples.each do |xmpl|
33
- actor.stream "<li><kbd>#{xmpl}</kbd></li>"
34
- end
35
- actor.stream '</ul>'
36
- related = available.map(&:verb)
37
- .uniq
38
- .that_are_not(command.to_sym)
39
- .sort
40
- .map { |sym| "<kbd>#{sym}</kbd>"}
41
- next if related.empty?
42
-
43
- actor.tell "Related: #{related.join(', ')}"
44
- elsif command =~ /[^a-z]/i
45
- actor.tell "Try asking for help with a specific command, e.g., <kbd>help go</kbd>"
46
- else
47
- actor.tell "\"#{command.cap_first}\" is not a verb I understand."
48
- end
49
- end
50
- end
51
- end
52
- end