gamefic-sdk 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +146 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gamefic-sdk.gemspec +42 -0
- data/lib/gamefic-sdk/version.rb +1 -1
- data/scaffolds/library/Gemfile +3 -0
- data/scaffolds/library/__name__.gemspec.gf.erb +14 -0
- data/scaffolds/library/lib/__name__.rb +5 -0
- data/scaffolds/project/.gitignore +2 -0
- data/scaffolds/project/Gemfile +12 -0
- data/scaffolds/project/Rakefile +6 -0
- data/scaffolds/project/main.rb.gf.erb +9 -0
- data/scaffolds/react/.babelrc +3 -0
- data/scaffolds/react/package.json.gf.erb +34 -0
- data/scaffolds/react/web/public/index.html.gf.erb +11 -0
- data/scaffolds/react/web/src/driver/development.js +4 -0
- data/scaffolds/react/web/src/driver/opal.rb +7 -0
- data/scaffolds/react/web/src/driver/production.js +5 -0
- data/scaffolds/react/web/src/index.js +17 -0
- data/scaffolds/react/web/src/style.css +3 -0
- data/scaffolds/react/webpack.config.js +69 -0
- metadata +27 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab948f913c148992dc91b0ec1b4c5b8a605661b4f542bb17b7eee91648d17fd2
|
4
|
+
data.tar.gz: 2bc3d80372c32eaaa9106f4aa1dc57aacf211745d7f902c660d58ab9ffed69b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af98a3ceedfed1d026b848950eb4eeadd17ab84d5c0f61675e5500d2a6cf36e69e2f7bf38a5e435c831b828b7fc0f5dc2ab048661373c7751b38f4ec49229358
|
7
|
+
data.tar.gz: ba3a8485e4a5f240d63238fa8498cab2e8495f5fd92d16b7394a249708b6b57f5d32df7e48fcdbe757048f149c808826e13576a8ec4cbe33b3073c3738368c06
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Fred Snyder
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
# Gamefic SDK
|
2
|
+
|
3
|
+
**A Ruby Interactive Fiction Framework**
|
4
|
+
|
5
|
+
The Gamefic SDK provides development tools for writing games and interactive fiction with Gamefic.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
$ gem install gamefic-sdk
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
This section provides a fast and simple introduction to using the SDK. Go to
|
16
|
+
the [Gamefic website](https://gamefic.com) for in-depth guides and
|
17
|
+
documentation.
|
18
|
+
|
19
|
+
### Creating a New Project
|
20
|
+
|
21
|
+
Create a new project and go to its directory:
|
22
|
+
|
23
|
+
$ gamefic init my_game
|
24
|
+
$ cd my_game
|
25
|
+
|
26
|
+
Test the project by running the game on the command line:
|
27
|
+
|
28
|
+
$ rake ruby:run
|
29
|
+
|
30
|
+
The Ruby game works like a traditional text adventure:
|
31
|
+
|
32
|
+
Hello, world!
|
33
|
+
>
|
34
|
+
|
35
|
+
You can enter commands at the `>` prompt, but you haven't written any content,
|
36
|
+
so there's not much to do yet. Enter `QUIT` to exit the game.
|
37
|
+
|
38
|
+
### The Script Code
|
39
|
+
|
40
|
+
The main script for your narrative is `main.rb` in your project's root
|
41
|
+
directory. It should look something like this:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
GAMEFIC_UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
45
|
+
require 'gamefic-standard'
|
46
|
+
|
47
|
+
Gamefic.script do
|
48
|
+
introduction do |actor|
|
49
|
+
actor.tell "Hello, world!"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
`GAMEFIC_UUID` is a globally unique identifier. It can be useful if you want to
|
55
|
+
add your game to online catalogs, such as the [Interactive Fiction Database](https://ifdb.tads.org/),
|
56
|
+
but it's safe to delete if you don't need it.
|
57
|
+
|
58
|
+
['gamefic-standard'](https://github.com/castwide/gamefic-standard) is a collection
|
59
|
+
of baseline features that are frequently useful for interactive fiction. [Inform](http://inform7.com/)
|
60
|
+
developers should find it similar to Inform's Standard Rules. It defines common
|
61
|
+
components like Rooms and Characters, along with in-game commands like `GO`,
|
62
|
+
`GET`, and `DROP` to enable basic interactivity.
|
63
|
+
|
64
|
+
`Gamefic.script` is where you write the story itself. In the starter project,
|
65
|
+
the only thing in the script is an introductory message.
|
66
|
+
|
67
|
+
### Modifying the Script
|
68
|
+
|
69
|
+
Replace the contents of `main.rb` with the following:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require 'gamefic-standard'
|
73
|
+
|
74
|
+
Gamefic.script do
|
75
|
+
@living_room = make Room, name: 'living room', description: 'This is your living room.'
|
76
|
+
@bedroom = make Room, name: 'bedroom', description: 'This is your bedroom.'
|
77
|
+
@living_room.connect @bedroom, 'north'
|
78
|
+
@backpack = make Room, name: 'backpack', description: 'Your trusty backpack.', parent: @bedroom
|
79
|
+
@book = make Room, name: 'book', description: 'Your favorite novel.', parent: @living_room
|
80
|
+
|
81
|
+
introduction do |actor|
|
82
|
+
actor.parent = @living_room
|
83
|
+
actor.tell "You're in your house."
|
84
|
+
end
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
Enter `rake ruby:run` to test the game. Now that it has rooms and objects, you
|
89
|
+
can perform in-game commands like `LOOK AROUND`, `GO NORTH`, and `TAKE THE BACKPACK`.
|
90
|
+
|
91
|
+
### Making Games for the Web
|
92
|
+
|
93
|
+
The default game project includes tasks for building "web" apps using HTML,
|
94
|
+
CSS, and JavaScript. Generate the code for a web build with the following
|
95
|
+
command:
|
96
|
+
|
97
|
+
```
|
98
|
+
$ rake web:generate
|
99
|
+
```
|
100
|
+
|
101
|
+
Test the game in a browser by starting a server:
|
102
|
+
|
103
|
+
```
|
104
|
+
$ rake web:run
|
105
|
+
```
|
106
|
+
|
107
|
+
Open `http://localhost:4342` to run the game in debug mode.
|
108
|
+
|
109
|
+
Build a standalone web game:
|
110
|
+
|
111
|
+
```
|
112
|
+
$ rake web:build
|
113
|
+
```
|
114
|
+
|
115
|
+
The game's HTML file and related assets will be generated in the
|
116
|
+
`builds/web/production` directory. The SDK uses
|
117
|
+
[opal](https://github.com/opal/opal) to compile Ruby code to JavaScript, so the
|
118
|
+
web build does not require a Ruby interpreter. Open `index.html` in a browser
|
119
|
+
to play the game.
|
120
|
+
|
121
|
+
Note: building the web app requires [Node.js](https://nodejs.org).
|
122
|
+
|
123
|
+
### Example Projects
|
124
|
+
|
125
|
+
The gamefic-sdk repo includes several example projects that provide more
|
126
|
+
more complete demonstrations of Gamefic's features. To run an example, copy
|
127
|
+
its `main.rb` file to your own project.
|
128
|
+
|
129
|
+
### Learning More
|
130
|
+
|
131
|
+
Go to the [Gamefic website](https://gamefic.com) for more information about
|
132
|
+
developing and building apps with Gamefic.
|
133
|
+
|
134
|
+
## Development
|
135
|
+
|
136
|
+
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.
|
137
|
+
|
138
|
+
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
139
|
+
|
140
|
+
## Contributing
|
141
|
+
|
142
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/castwide/gamefic-sdk.
|
143
|
+
|
144
|
+
## License
|
145
|
+
|
146
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gamefic/sdk"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/gamefic-sdk.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'gamefic-sdk/version'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'gamefic-sdk'
|
8
|
+
s.version = Gamefic::Sdk::VERSION
|
9
|
+
s.date = Date.today.strftime("%Y-%m-%d")
|
10
|
+
s.summary = "Gamefic SDK"
|
11
|
+
s.description = "Development and command-line tools for Gamefic"
|
12
|
+
s.authors = ["Fred Snyder"]
|
13
|
+
s.email = 'fsnyder@gamefic.com'
|
14
|
+
s.homepage = 'http://gamefic.com'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples|guides)/}) }
|
21
|
+
end
|
22
|
+
s.executables = ['gamefic']
|
23
|
+
s.require_paths = ['lib']
|
24
|
+
|
25
|
+
s.required_ruby_version = '>= 2.3.0'
|
26
|
+
|
27
|
+
s.add_runtime_dependency 'gamefic', '~> 2.0'
|
28
|
+
s.add_runtime_dependency 'gamefic-standard', '~> 2.0'
|
29
|
+
s.add_runtime_dependency 'gamefic-tty', '~> 2.0'
|
30
|
+
s.add_runtime_dependency 'listen', '~> 3.0'
|
31
|
+
s.add_runtime_dependency 'opal', '~> 1.0'
|
32
|
+
s.add_runtime_dependency 'sinatra', '~> 2'
|
33
|
+
s.add_runtime_dependency 'thor', '~> 1.0'
|
34
|
+
|
35
|
+
s.add_development_dependency "bundler", "~> 2.0"
|
36
|
+
s.add_development_dependency 'capybara', '~> 3.3'
|
37
|
+
s.add_development_dependency 'puma', '~> 3'
|
38
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
39
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
s.add_development_dependency 'selenium-webdriver', '~> 3.13'
|
41
|
+
s.add_development_dependency 'simplecov', '~> 0.14'
|
42
|
+
end
|
data/lib/gamefic-sdk/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = '<%= name %>'
|
3
|
+
spec.version = '1.0.0'
|
4
|
+
spec.summary = 'A Gamefic library'
|
5
|
+
spec.authors = ['Anomynous']
|
6
|
+
spec.license = 'MIT'
|
7
|
+
spec.files = Dir['lib/**/*.rb']
|
8
|
+
|
9
|
+
spec.add_runtime_dependency 'gamefic', '~> 2.0'
|
10
|
+
spec.add_runtime_dependency 'gamefic-standard', '~> 2.0'
|
11
|
+
|
12
|
+
spec.add_development_dependency 'gamefic-sdk', '~> 2.0'
|
13
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"name": "<%= name %>",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "A Gamefic web app",
|
5
|
+
"keywords": [],
|
6
|
+
"author": "Anonymous",
|
7
|
+
"license": "UNLICENSED",
|
8
|
+
"private": true,
|
9
|
+
"scripts": {
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
11
|
+
"build": "webpack --env=production -p",
|
12
|
+
"develop": "webpack --env=development -d"
|
13
|
+
},
|
14
|
+
"devDependencies": {
|
15
|
+
"babel-core": "^6.26.3",
|
16
|
+
"babel-loader": "^7.1.5",
|
17
|
+
"babel-preset-env": "^1.7.0",
|
18
|
+
"babel-preset-react": "^6.24.1",
|
19
|
+
"copy-webpack-plugin": "^4.5.3",
|
20
|
+
"css-loader": "^1.0.0",
|
21
|
+
"file-loader": "^3.0.1",
|
22
|
+
"opal-webpack-bundler": "^0.0.1",
|
23
|
+
"style-loader": "^0.23.1",
|
24
|
+
"url-loader": "^1.1.2",
|
25
|
+
"webpack": "^4.20.2",
|
26
|
+
"webpack-cli": "^3.1.2"
|
27
|
+
},
|
28
|
+
"dependencies": {
|
29
|
+
"gamefic-driver": "^0.2.0",
|
30
|
+
"react": "^16.5.2",
|
31
|
+
"react-dom": "^16.5.2",
|
32
|
+
"react-gamefic": "^0.2.0"
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { render } from 'react-dom';
|
3
|
+
import { Console, Terminal } from 'react-gamefic';
|
4
|
+
import { driver } from 'driver';
|
5
|
+
import 'react-gamefic/styles/ebook';
|
6
|
+
import './style.css';
|
7
|
+
|
8
|
+
render(
|
9
|
+
<Console driver={driver}>
|
10
|
+
<Terminal />
|
11
|
+
</Console>,
|
12
|
+
document.getElementById('root')
|
13
|
+
);
|
14
|
+
|
15
|
+
driver.start().then((state) => {
|
16
|
+
driver.notify(state);
|
17
|
+
});
|
@@ -0,0 +1,69 @@
|
|
1
|
+
const path = require('path');
|
2
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
3
|
+
|
4
|
+
module.exports = (env) => {
|
5
|
+
var config = {
|
6
|
+
entry: path.resolve(__dirname, 'web', 'src', 'index.js'),
|
7
|
+
output: {
|
8
|
+
filename: 'bundle.js',
|
9
|
+
path: path.resolve(__dirname, "builds", "web", env)
|
10
|
+
},
|
11
|
+
resolve: {
|
12
|
+
alias: {
|
13
|
+
driver: path.join(__dirname, 'web', 'src', 'driver', env)
|
14
|
+
}
|
15
|
+
},
|
16
|
+
plugins: [
|
17
|
+
new CopyWebpackPlugin([
|
18
|
+
{
|
19
|
+
from: path.resolve(__dirname, 'web', 'public')
|
20
|
+
},
|
21
|
+
])
|
22
|
+
],
|
23
|
+
module: {
|
24
|
+
rules: [
|
25
|
+
{
|
26
|
+
test: /\.css$/,
|
27
|
+
use: ['style-loader', 'css-loader']
|
28
|
+
},
|
29
|
+
{
|
30
|
+
test: /\.(png|jp(e*)g|svg)$/,
|
31
|
+
use: [{
|
32
|
+
loader: 'url-loader',
|
33
|
+
options: {
|
34
|
+
limit: 8000, // Convert images < 8kb to base64 strings
|
35
|
+
name: 'images/[hash]-[name].[ext]'
|
36
|
+
}
|
37
|
+
}]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
test: /\.jsx?/,
|
41
|
+
include: path.resolve(__dirname, 'web'),
|
42
|
+
use: 'babel-loader'
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
if (env == 'production') {
|
49
|
+
config.module.rules.push(
|
50
|
+
{
|
51
|
+
// opal-webpack-bundler will compile and include ruby files in the pack
|
52
|
+
test: /\.rb$/,
|
53
|
+
use: [
|
54
|
+
{
|
55
|
+
loader: 'opal-webpack-bundler',
|
56
|
+
options: {
|
57
|
+
useBundler: true,
|
58
|
+
paths: [path.resolve(__dirname), path.resolve(__dirname, 'lib')],
|
59
|
+
sourceMap: false,
|
60
|
+
root: path.resolve(__dirname)
|
61
|
+
}
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
);
|
66
|
+
}
|
67
|
+
|
68
|
+
return config;
|
69
|
+
};
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamefic-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
@@ -213,7 +213,17 @@ executables:
|
|
213
213
|
extensions: []
|
214
214
|
extra_rdoc_files: []
|
215
215
|
files:
|
216
|
+
- ".gitignore"
|
217
|
+
- ".rspec"
|
218
|
+
- ".travis.yml"
|
219
|
+
- Gemfile
|
220
|
+
- LICENSE.txt
|
221
|
+
- README.md
|
222
|
+
- Rakefile
|
223
|
+
- bin/console
|
216
224
|
- bin/gamefic
|
225
|
+
- bin/setup
|
226
|
+
- gamefic-sdk.gemspec
|
217
227
|
- lib/gamefic-sdk.rb
|
218
228
|
- lib/gamefic-sdk/diagram.rb
|
219
229
|
- lib/gamefic-sdk/scaffold.rb
|
@@ -224,6 +234,22 @@ files:
|
|
224
234
|
- lib/gamefic-sdk/tasks/ruby.rb
|
225
235
|
- lib/gamefic-sdk/tasks/web.rb
|
226
236
|
- lib/gamefic-sdk/version.rb
|
237
|
+
- scaffolds/library/Gemfile
|
238
|
+
- scaffolds/library/__name__.gemspec.gf.erb
|
239
|
+
- scaffolds/library/lib/__name__.rb
|
240
|
+
- scaffolds/project/.gitignore
|
241
|
+
- scaffolds/project/Gemfile
|
242
|
+
- scaffolds/project/Rakefile
|
243
|
+
- scaffolds/project/main.rb.gf.erb
|
244
|
+
- scaffolds/react/.babelrc
|
245
|
+
- scaffolds/react/package.json.gf.erb
|
246
|
+
- scaffolds/react/web/public/index.html.gf.erb
|
247
|
+
- scaffolds/react/web/src/driver/development.js
|
248
|
+
- scaffolds/react/web/src/driver/opal.rb
|
249
|
+
- scaffolds/react/web/src/driver/production.js
|
250
|
+
- scaffolds/react/web/src/index.js
|
251
|
+
- scaffolds/react/web/src/style.css
|
252
|
+
- scaffolds/react/webpack.config.js
|
227
253
|
homepage: http://gamefic.com
|
228
254
|
licenses:
|
229
255
|
- MIT
|