gamefic-overlookable 1.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/.rspec +3 -0
- data/CHANGELOG.md +2 -0
- data/README.md +94 -0
- data/Rakefile +18 -0
- data/gamefic-overlookable.gemspec +45 -0
- data/lib/gamefic/overlookable/version.rb +7 -0
- data/lib/gamefic/overlookable.rb +75 -0
- data/lib/gamefic-overlookable.rb +3 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d34800f5435fde01526243b4afab76c49afda7ab897d30d18f14863c86aa77f
|
4
|
+
data.tar.gz: 531614b78db5b10c3f4c8c4cfb535aa666e42f788a6eebcf90fc3ddb41272a84
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7fc86bae56c7b3db1b660abef4c3950771910014b55d231ee36a690cae72ece8f2aede83dd96b6f6a2839ca9ebbf77a3940b43bcb1e6cd4de20a93bdcbcbb5db
|
7
|
+
data.tar.gz: 38efa05328c17c4f868680b45133ee1465688d15c2a43ced27d348229634e88a3fd2944ef4051fde2318c183291267f0e80bca2f547fa11fe89d83527bfd8f86
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# gamefic-overlookable
|
2
|
+
|
3
|
+
A Gamefic library for easy implementation of insignificant entities.
|
4
|
+
|
5
|
+
It's good practice to implement nouns that players receive in descriptions, even if they're irrelevant to the game.
|
6
|
+
|
7
|
+
Bad:
|
8
|
+
|
9
|
+
> look around
|
10
|
+
|
11
|
+
You're in a room with four walls.
|
12
|
+
|
13
|
+
> examine walls
|
14
|
+
|
15
|
+
I recognize "examine" as a verb but don't know what you mean by "walls."
|
16
|
+
|
17
|
+
Better:
|
18
|
+
|
19
|
+
> examine walls
|
20
|
+
|
21
|
+
There's nothing special about the four walls.
|
22
|
+
|
23
|
+
The `gamefic-overlookable` library simplifies the process of creating `Scenery` entities that provide a default response to unimplemented nouns.
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Add the library to your Gamefic project's Gemfile:
|
28
|
+
|
29
|
+
```
|
30
|
+
gem 'gamefic-overlookable'
|
31
|
+
```
|
32
|
+
|
33
|
+
Run `bundle install`.
|
34
|
+
|
35
|
+
Add the requirement to your project's code (typically in `main.rb`):
|
36
|
+
|
37
|
+
```
|
38
|
+
require 'gamefic-overlookable'
|
39
|
+
```
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
Entities gain an `overlook` method that lets you easily add scenery with a default description.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
MyGame.seed do
|
47
|
+
@room = make Room, name: 'room', description: "You're in a room with four walls."
|
48
|
+
@room.overlook 'four walls'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
> look around
|
53
|
+
|
54
|
+
You're in a room with four walls.
|
55
|
+
|
56
|
+
> examine walls
|
57
|
+
|
58
|
+
There's nothing special about the four walls.
|
59
|
+
|
60
|
+
The `overlook` method can also accept multiple names:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
MyGame.seed do
|
64
|
+
@room = make Room, name: 'room', description: 'A room with a tall ceiling and a wooden floor.'
|
65
|
+
@room.overlook 'tall ceiling', 'wooden floor'
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
Separate names from synonyms with two slashes:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
MyGame.seed do
|
73
|
+
@room = make Room, name: 'room', description: 'A room with a tall ceiling and a dark wooden floor.'
|
74
|
+
@room.overlook 'ceiling//tall', 'floor//dark wooden'
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
You can also add overlookable entities with the `rubble` and `scenery` parameters in `make`:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
make Room, name: 'room', description: 'A room with a tall ceiling.', scenery: ['ceiling//tall']
|
82
|
+
|
83
|
+
make Thing, name: 'dining set', description: 'A plate and a fork.', rubble: ['plate', 'fork']
|
84
|
+
```
|
85
|
+
|
86
|
+
## Development
|
87
|
+
|
88
|
+
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.
|
89
|
+
|
90
|
+
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).
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/castwide/gamefic-overlookable.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
+
Opal.use_gem 'gamefic-standard'
|
15
|
+
config.default_path = 'spec'
|
16
|
+
config.pattern = 'spec/**/*_spec.rb'
|
17
|
+
config.requires = ['opal_helper']
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/gamefic/overlookable/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gamefic-overlookable"
|
7
|
+
spec.version = Gamefic::Overlookable::VERSION
|
8
|
+
spec.authors = ["Fred Snyder"]
|
9
|
+
spec.email = ["fsnyder@castwide.com"]
|
10
|
+
|
11
|
+
spec.summary = "A Gamefic library for easy implementation of insignificant entities."
|
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"] = 'https://gamefic.com'
|
19
|
+
spec.metadata["source_code_uri"] = 'https://github.com/castwide/gamefic-overlookable'
|
20
|
+
spec.metadata["changelog_uri"] = 'https://github.com/castwide/gamefic-overlookable/blob/master/CHANGELOG.md'
|
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.0'
|
37
|
+
spec.add_dependency 'gamefic-standard', '~> 3.0'
|
38
|
+
|
39
|
+
spec.add_development_dependency 'opal-rspec', '~> 1.0'
|
40
|
+
spec.add_development_dependency 'opal-sprockets', '~> 1.0'
|
41
|
+
spec.add_development_dependency 'simplecov', '~> 0.22'
|
42
|
+
|
43
|
+
# For more information and examples about making a new gem, check out our
|
44
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
45
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'gamefic'
|
4
|
+
require 'gamefic-standard'
|
5
|
+
|
6
|
+
require_relative 'overlookable/version'
|
7
|
+
|
8
|
+
module Gamefic
|
9
|
+
# A mixin for implementing nouns as Scenery with a default description.
|
10
|
+
#
|
11
|
+
module Overlookable
|
12
|
+
# Create Scenery that provides a default description for unimplemented words.
|
13
|
+
# Names can include two slashes (//) to add a list of synonyms.
|
14
|
+
#
|
15
|
+
# The type of overlookable entity can be modified with the `type` parameter.
|
16
|
+
# For compatibility with the gamefic-standard library, it is recommended to
|
17
|
+
# use either `Scenery` or `Rubble`.
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# thing = make Thing, name: 'table', description: 'A table with cups and white china plates.'
|
21
|
+
# thing.overlook 'cups', 'plates//white china'
|
22
|
+
#
|
23
|
+
# # > look table
|
24
|
+
# #
|
25
|
+
# # A table with cups and white china plates.
|
26
|
+
# #
|
27
|
+
# # > look cups
|
28
|
+
# #
|
29
|
+
# # There's nothing special about the cups.
|
30
|
+
# #
|
31
|
+
# # > look china
|
32
|
+
# #
|
33
|
+
# # There's nothing special about the plates.
|
34
|
+
#
|
35
|
+
# @param names [Array<String>] Names or name/synonym arrays
|
36
|
+
# @param type [Class<Entity>] The type of overlookable entity (default is Scenery)
|
37
|
+
# @return [Array<Entity>]
|
38
|
+
def overlook *names, type: Scenery
|
39
|
+
names.map do |input|
|
40
|
+
parts = input.split('//')
|
41
|
+
name = parts[0].to_s.strip
|
42
|
+
synonyms = parts[1].to_s.strip
|
43
|
+
type.new(name: name, synonyms: synonyms, parent: self)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# A shortcut to overlookable Scenery that can be called from `make` parameters.
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# make Thing, name: 'table',
|
51
|
+
# description: 'A table with a checkered design.',
|
52
|
+
# scenery: ['checkered design']
|
53
|
+
#
|
54
|
+
# @param [Array<String>]
|
55
|
+
# @return [void]
|
56
|
+
def scenery= names
|
57
|
+
overlook(*names, type: Scenery)
|
58
|
+
end
|
59
|
+
|
60
|
+
# A shortcut to overlookable Rubble that can be called from `make` parameters.
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# make Thing, name: 'table',
|
64
|
+
# description: 'A table with a plate on it.',
|
65
|
+
# rubble: ['plate']
|
66
|
+
#
|
67
|
+
# @param [Array<String>]
|
68
|
+
# @return [void]
|
69
|
+
def rubble= names
|
70
|
+
overlook(*names, type: Rubble)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Gamefic::Entity.include Gamefic::Overlookable
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gamefic-overlookable
|
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-08-07 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.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gamefic-standard
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opal-rspec
|
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: opal-sprockets
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.22'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.22'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- fsnyder@castwide.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".rspec"
|
91
|
+
- CHANGELOG.md
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- gamefic-overlookable.gemspec
|
95
|
+
- lib/gamefic-overlookable.rb
|
96
|
+
- lib/gamefic/overlookable.rb
|
97
|
+
- lib/gamefic/overlookable/version.rb
|
98
|
+
homepage: https://gamefic.com
|
99
|
+
licenses: []
|
100
|
+
metadata:
|
101
|
+
homepage_uri: https://gamefic.com
|
102
|
+
source_code_uri: https://github.com/castwide/gamefic-overlookable
|
103
|
+
changelog_uri: https://github.com/castwide/gamefic-overlookable/blob/master/CHANGELOG.md
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.6.0
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubygems_version: 3.3.7
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: A Gamefic library for easy implementation of insignificant entities.
|
123
|
+
test_files: []
|