gamefic 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/Rakefile +4 -4
- data/lib/gamefic/active/messaging.rb +1 -0
- data/lib/gamefic/composer.rb +2 -2
- data/lib/gamefic/describable.rb +3 -2
- data/lib/gamefic/node.rb +14 -1
- data/lib/gamefic/plot.rb +2 -0
- data/lib/gamefic/query/base.rb +17 -7
- data/lib/gamefic/query/scoped.rb +0 -1
- data/lib/gamefic/query/text.rb +2 -0
- data/lib/gamefic/scriptable/proxy.rb +1 -0
- data/lib/gamefic/scriptable/scenes.rb +7 -1
- data/lib/gamefic/version.rb +1 -1
- metadata +2 -3
- data/spec-opal/spec_helper.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e6fc4d2b5c4a9abfe20cbbe17affdec1f1badb134e8cad88849a5305fb9bf0
|
4
|
+
data.tar.gz: 97a29823857d93fafa9e8a3bc4872e27a4a6da480f589535da6abf254eb5aa7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611c3b366e76a29cd2ffb95f906882a63ac9d73bfb6d1d7aaa505e4470f4526311704c2245285f908247b6248b086914d8a145e1c9b86577e197d8d77c707939
|
7
|
+
data.tar.gz: dc19cf51ab4edbc1b9f9708eb543c977527e3165a949d948782349e545d0a32fde42f8532c9071e0ddc86b521cc0d1cb778e8e88b1d7b0dcc575d547c5db1df1
|
data/.github/workflows/rspec.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 3.3.0 - September 1, 2024
|
2
|
+
- Node#take
|
3
|
+
- Node#include?
|
4
|
+
- Reject non-string tokens in Text queries
|
5
|
+
|
6
|
+
## 3.2.2 - July 21, 2024
|
7
|
+
- Describable#described?
|
8
|
+
|
1
9
|
## 3.2.1 - July 1, 2024
|
2
10
|
- MultipleChoice accepts shortened text
|
3
11
|
- Return Proxy::Agent from attr_seed and make_seed
|
data/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require "rspec/core/rake_task"
|
3
|
+
require 'bundler/gem_tasks'
|
5
4
|
require 'rspec/core/rake_task'
|
6
5
|
require 'opal/rspec/rake_task'
|
7
6
|
|
@@ -14,7 +13,8 @@ end
|
|
14
13
|
task :default => :spec
|
15
14
|
|
16
15
|
Opal::RSpec::RakeTask.new(:opal) do |_, config|
|
17
|
-
Opal.append_path File.
|
16
|
+
Opal.append_path File.join(__dir__, 'lib')
|
17
|
+
config.default_path = 'spec'
|
18
18
|
config.pattern = 'spec/**/*_spec.rb'
|
19
|
-
config.requires = ['
|
19
|
+
config.requires = ['opal_helper']
|
20
20
|
end
|
data/lib/gamefic/composer.rb
CHANGED
@@ -43,7 +43,7 @@ module Gamefic
|
|
43
43
|
arguments = []
|
44
44
|
response.queries.each_with_index do |query, idx|
|
45
45
|
result = Scanner.send(method, query.select(actor), "#{remainder} #{expression.tokens[idx]}".strip)
|
46
|
-
break unless
|
46
|
+
break unless valid_result_from_query?(result, query)
|
47
47
|
|
48
48
|
if query.ambiguous?
|
49
49
|
arguments.push result.matched
|
@@ -60,7 +60,7 @@ module Gamefic
|
|
60
60
|
|
61
61
|
# @param result [Scanner::Result]
|
62
62
|
# @param query [Query::Base]
|
63
|
-
def
|
63
|
+
def valid_result_from_query? result, query
|
64
64
|
return false if result.matched.empty?
|
65
65
|
|
66
66
|
result.matched.length == 1 || query.ambiguous?
|
data/lib/gamefic/describable.rb
CHANGED
@@ -112,10 +112,11 @@ module Gamefic
|
|
112
112
|
# Does the object have a description?
|
113
113
|
#
|
114
114
|
# @return [Boolean]
|
115
|
-
def
|
115
|
+
def described?
|
116
116
|
@description.to_s != ''
|
117
117
|
end
|
118
|
-
alias
|
118
|
+
alias description? described?
|
119
|
+
alias has_description? described?
|
119
120
|
|
120
121
|
# Get the object's description.
|
121
122
|
#
|
data/lib/gamefic/node.rb
CHANGED
@@ -42,6 +42,15 @@ module Gamefic
|
|
42
42
|
parent&.add_child self
|
43
43
|
end
|
44
44
|
|
45
|
+
# Add children to the node. Return all the node's children.
|
46
|
+
#
|
47
|
+
# @param children [Array<Node, Array<Node>>]
|
48
|
+
# @return [Array<Node>]
|
49
|
+
def take *children
|
50
|
+
children.flatten.each { |child| child.parent = self }
|
51
|
+
children
|
52
|
+
end
|
53
|
+
|
45
54
|
# Determine if external objects can interact with this object's children.
|
46
55
|
# For example, a game can designate that the contents of a bowl are
|
47
56
|
# accessible, while the contents of a locked safe are not.
|
@@ -54,10 +63,14 @@ module Gamefic
|
|
54
63
|
# True if this node is the other's parent.
|
55
64
|
#
|
56
65
|
# @param other [Node]
|
57
|
-
def
|
66
|
+
def include?(other)
|
58
67
|
other.parent == self
|
59
68
|
end
|
60
69
|
|
70
|
+
def adjacent?(other)
|
71
|
+
other.parent == parent
|
72
|
+
end
|
73
|
+
|
61
74
|
protected
|
62
75
|
|
63
76
|
def add_child(node)
|
data/lib/gamefic/plot.rb
CHANGED
data/lib/gamefic/query/base.rb
CHANGED
@@ -24,16 +24,24 @@ module Gamefic
|
|
24
24
|
@ambiguous = ambiguous
|
25
25
|
end
|
26
26
|
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
27
|
+
# Get a query result for a given subject and token.
|
28
|
+
#
|
29
|
+
# @note This method is retained as a convenience for authors. Narratives
|
30
|
+
# should use Composer to build commands, as it provides more precise
|
31
|
+
# matching of tokens to valid response arguments. Authors can use
|
32
|
+
# #query to find entities that match a token regardless of whether the
|
33
|
+
# result matches an available response.
|
34
|
+
#
|
35
|
+
# @example
|
36
|
+
# respond :reds do |actor|
|
37
|
+
# reds = available(ambiguous: true).query(actor, 'red').match
|
38
|
+
# actor.tell "The red things you can see here are #{reds.join_and}."
|
39
|
+
# end
|
32
40
|
#
|
33
41
|
# @param subject [Gamefic::Entity]
|
34
42
|
# @param token [String]
|
35
43
|
# @return [Result]
|
36
|
-
def query(
|
44
|
+
def query(_subject, _token)
|
37
45
|
raise "#query not implemented for #{self.class}"
|
38
46
|
end
|
39
47
|
|
@@ -42,7 +50,7 @@ module Gamefic
|
|
42
50
|
#
|
43
51
|
# @param subject [Entity]
|
44
52
|
# @return [Array<Entity>]
|
45
|
-
def select
|
53
|
+
def select _subject
|
46
54
|
raise "#select not implemented for #{self.class}"
|
47
55
|
end
|
48
56
|
|
@@ -88,12 +96,14 @@ module Gamefic
|
|
88
96
|
depth
|
89
97
|
end
|
90
98
|
|
99
|
+
# @param scan [Scanner::Result]
|
91
100
|
def ambiguous_result scan
|
92
101
|
return Result.new(nil, scan.token) if scan.matched.empty?
|
93
102
|
|
94
103
|
Result.new(scan.matched, scan.remainder)
|
95
104
|
end
|
96
105
|
|
106
|
+
# @param scan [Scanner::Result]
|
97
107
|
def unambiguous_result scan
|
98
108
|
return Result.new(nil, scan.token) unless scan.matched.one?
|
99
109
|
|
data/lib/gamefic/query/scoped.rb
CHANGED
data/lib/gamefic/query/text.rb
CHANGED
@@ -38,6 +38,12 @@ module Gamefic
|
|
38
38
|
end
|
39
39
|
alias scene block
|
40
40
|
|
41
|
+
def preface name, klass = Scene::Activity, &start
|
42
|
+
rulebook.scenes.add klass.new(name, rulebook.narrative, on_start: start)
|
43
|
+
name
|
44
|
+
end
|
45
|
+
alias precursor preface
|
46
|
+
|
41
47
|
# Add a block to be executed when a player is added to the game.
|
42
48
|
# Each Plot should only have one introduction.
|
43
49
|
#
|
@@ -55,7 +61,7 @@ module Gamefic
|
|
55
61
|
rulebook.scenes
|
56
62
|
.introduction Scene::Default.new nil,
|
57
63
|
rulebook.narrative,
|
58
|
-
on_start: proc { |actor, _props|
|
64
|
+
on_start: proc { |actor, _props| Stage.run(self, actor, &start) }
|
59
65
|
end
|
60
66
|
|
61
67
|
# Create a multiple-choice scene.
|
data/lib/gamefic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -195,7 +195,6 @@ files:
|
|
195
195
|
- lib/gamefic/syntax/template.rb
|
196
196
|
- lib/gamefic/vault.rb
|
197
197
|
- lib/gamefic/version.rb
|
198
|
-
- spec-opal/spec_helper.rb
|
199
198
|
homepage: https://gamefic.com
|
200
199
|
licenses:
|
201
200
|
- MIT
|
data/spec-opal/spec_helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'gamefic'
|
4
|
-
require 'ostruct'
|
5
|
-
|
6
|
-
RSpec.configure do |config|
|
7
|
-
# Run specs in random order to surface order dependencies. If you find an
|
8
|
-
# order dependency and want to debug it, you can fix the order by providing
|
9
|
-
# the seed, which is printed after each run.
|
10
|
-
# --seed 1234
|
11
|
-
# config.order = :random
|
12
|
-
|
13
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
14
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
15
|
-
# test failures related to randomization by passing the same `--seed` value
|
16
|
-
# as the one that triggered the failure.
|
17
|
-
# Kernel.srand config.seed
|
18
|
-
|
19
|
-
config.after :each do
|
20
|
-
Gamefic::Narrative.blocks.clear
|
21
|
-
Gamefic::Plot.blocks.clear
|
22
|
-
Gamefic::Subplot.blocks.clear
|
23
|
-
end
|
24
|
-
end
|