gamefic-what 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +2 -0
- data/README.md +70 -0
- data/Rakefile +17 -0
- data/gamefic-what.gemspec +46 -0
- data/lib/gamefic/what/askable.rb +19 -0
- data/lib/gamefic/what/version.rb +7 -0
- data/lib/gamefic/what.rb +25 -0
- data/lib/gamefic-what.rb +4 -0
- data/sig/gamefic/what.rbs +6 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 26184e189b91fc9cb8e92ac66c9c26d3f76366128bfaab70a2e5c45ad48578ff
|
4
|
+
data.tar.gz: 5d3c2424dbca05c0c97547972f4fd1d5243e437ba89d7d06427f7d9181edf384
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9dcf9bc8d1d9e7774846bc62343eb97bdae62f59f5999e01126e480bdc04fd169ffb42616700f1643ba7ad2ae0691c192c8ebf364dfd0c297691628c8805bd62
|
7
|
+
data.tar.gz: eb07db1e55f4875bc34d0080e3dbac8df9b5e40ba14ce4747e53c38b610ebafad5f4065f6ce80ce8e576d0aa184f475261190bd77bfda43a3401676d7d48c23a
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Gamefic::What
|
2
|
+
|
3
|
+
A Gamefic extension for expanding commands with an additional argument.
|
4
|
+
|
5
|
+
This extension is included in `gamefic-standard`.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the library to your Gamefic project's Gemfile:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem 'gamefic-what'
|
13
|
+
```
|
14
|
+
|
15
|
+
Run `bundle install`.
|
16
|
+
|
17
|
+
Add the requirement to your project's code (typically in `main.rb`):
|
18
|
+
|
19
|
+
```
|
20
|
+
require 'gamefic-what'
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Example code:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
class Gamefic::Actor
|
29
|
+
include Gamefic::What::Askable
|
30
|
+
end
|
31
|
+
|
32
|
+
class MyPlot < Gamefic::Plot
|
33
|
+
include Gamefic::What
|
34
|
+
|
35
|
+
attr_seed :room, Gamefic::Entity, name: 'room'
|
36
|
+
attr_seed :thing, Gamefic::Entity, name: 'thing'
|
37
|
+
|
38
|
+
introduction do |actor|
|
39
|
+
actor.parent = room
|
40
|
+
thing.parent = room
|
41
|
+
end
|
42
|
+
|
43
|
+
respond :take, available do |actor, thing|
|
44
|
+
thing.parent = actor
|
45
|
+
actor.tell "You take #{thing}."
|
46
|
+
end
|
47
|
+
|
48
|
+
respond :take do |actor|
|
49
|
+
actor.tell 'What do you want to take?'
|
50
|
+
actor.ask_for_what 'take', nil
|
51
|
+
end
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
Example gameplay:
|
56
|
+
|
57
|
+
> take
|
58
|
+
What do you want to take?
|
59
|
+
> the thing
|
60
|
+
You take a thing.
|
61
|
+
|
62
|
+
## Development
|
63
|
+
|
64
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
65
|
+
|
66
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gamefic-what.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require 'opal/rspec/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
task default: :spec
|
10
|
+
|
11
|
+
Opal::RSpec::RakeTask.new(:opal) do |_, config|
|
12
|
+
Opal.append_path File.join(__dir__, 'lib')
|
13
|
+
Opal.use_gem 'gamefic'
|
14
|
+
config.default_path = 'spec'
|
15
|
+
config.pattern = 'spec/**/*_spec.rb'
|
16
|
+
config.requires = ['opal_helper']
|
17
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/gamefic/what/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gamefic-what"
|
7
|
+
spec.version = Gamefic::What::VERSION
|
8
|
+
spec.authors = ["Fred Snyder"]
|
9
|
+
spec.email = ["fsnyder@castwide.com"]
|
10
|
+
|
11
|
+
spec.summary = "A Gamefic extension for expanding commands with an additional argument"
|
12
|
+
# spec.description = "TODO: Write a longer description or delete this line."
|
13
|
+
spec.homepage = 'https://gamefic.com'
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
20
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) ||
|
27
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
spec.add_dependency 'gamefic', '~> 3.4'
|
37
|
+
|
38
|
+
spec.add_development_dependency 'opal-rspec', '~> 1.0'
|
39
|
+
spec.add_development_dependency 'opal-sprockets', '~> 1.0'
|
40
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
41
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
|
+
spec.add_development_dependency 'simplecov', '~> 0.22'
|
43
|
+
|
44
|
+
# For more information and examples about making a new gem, check out our
|
45
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gamefic
|
4
|
+
module What
|
5
|
+
module Askable
|
6
|
+
# @param tokens [String, Array<String, nil>]
|
7
|
+
def ask_for_what(*tokens)
|
8
|
+
@asking_for_what = [tokens].flatten
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :asked_for_what
|
12
|
+
|
13
|
+
def set_asked_for_what
|
14
|
+
@asked_for_what = @asking_for_what
|
15
|
+
@asking_for_what = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/gamefic/what.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gamefic/what/askable'
|
4
|
+
require 'gamefic/what/version'
|
5
|
+
|
6
|
+
module Gamefic
|
7
|
+
# A Gamefic extension for expanding commands with an additional argument.
|
8
|
+
#
|
9
|
+
module What
|
10
|
+
extend Gamefic::Scriptable
|
11
|
+
|
12
|
+
on_player_update(&:set_asked_for_what)
|
13
|
+
|
14
|
+
respond nil, plaintext do |actor, text|
|
15
|
+
if actor.asked_for_what
|
16
|
+
actor.perform actor.asked_for_what
|
17
|
+
.map { |part| part ? part.to_s : text }
|
18
|
+
.join(' ')
|
19
|
+
.gsub('__what__', text)
|
20
|
+
else
|
21
|
+
actor.proceed
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/gamefic-what.rb
ADDED
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gamefic-what
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fred Snyder
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gamefic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opal-rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opal-sprockets
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '13.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '13.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.22'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.22'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- fsnyder@castwide.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".rspec"
|
105
|
+
- CHANGELOG.md
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- gamefic-what.gemspec
|
109
|
+
- lib/gamefic-what.rb
|
110
|
+
- lib/gamefic/what.rb
|
111
|
+
- lib/gamefic/what/askable.rb
|
112
|
+
- lib/gamefic/what/version.rb
|
113
|
+
- sig/gamefic/what.rbs
|
114
|
+
homepage: https://gamefic.com
|
115
|
+
licenses: []
|
116
|
+
metadata:
|
117
|
+
homepage_uri: https://gamefic.com
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 2.6.0
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubygems_version: 3.3.7
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: A Gamefic extension for expanding commands with an additional argument
|
137
|
+
test_files: []
|