gamefic-sdk 3.0.0 → 3.1.0

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: a65534f07f1678a5e82275ec3a8e8158e8d96096d4adcf8e1d4277ab8961a5dd
4
- data.tar.gz: fd315e465a03350354a2c0f795088d63d14b16ec55a83a7025eef28dca35017f
3
+ metadata.gz: a1a52e09b3e29c8c869f67561d732d54493043a4ee04e75a49eade71d4396ddf
4
+ data.tar.gz: 8085b05a412924f4c4783bdcc09d9a6f9e97ef5aadc719257ed9a34b0a77e5a0
5
5
  SHA512:
6
- metadata.gz: 452327933e7a5f43100f4331a324b77b45e585187d9f470e15c4c4fb4cf3414105551430e340c4ae07f9e9c73ff082444d6840940a039478282cf71f517e8193
7
- data.tar.gz: 6f2dacd9c0f9273baebb359a25397ac5e3589c85ae1081a9e12d5472ee4f575d7edc6cab940654b2581ac75076bda01aaf92be56215707dbbcf37141e36c92a1
6
+ metadata.gz: 4b0f9ac162876dd92ed56ae979d9f4fcaa16ae49e0aa1550be1f5c61a82ba486190c22cff45b1617eb1e275af4141cef4393a6c352dd26e2e356f51ab06a33c8
7
+ data.tar.gz: d263b78b4dca96bb0994bc8a9b3ff1d9734ac84380e312e3987f3ac7747f9374660c64ccda2c642a72e8c86dd33bb08d9e3557b9f29d2485984809bd403a70f7
data/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
+ ## 3.1.0 - July 13, 2024
2
+ - Plot and Subplot classes in scaffold
3
+ - Scaffold requires ostruct
4
+ - Support for lib path in web project
5
+
6
+ ## 3.0.1 - April 10, 2024
7
+ - Updates to README in project scaffold
8
+
1
9
  ## 3.0.0 - January 27, 2024
2
10
  - Deprecate broken/redundant commands
3
11
  - Improved serialization
4
12
  - Queries use proxies for static entities
5
13
  - All scripted blocks get evaluated on stage
6
- - Use create-react-gamefic for web scaffolds
14
+ - Use react-gamefic for web scaffolds
7
15
  - Modular projects and libraries
8
16
  - New project scaffold
9
17
 
data/README.md CHANGED
@@ -37,21 +37,26 @@ so there's not much to do yet. Enter `QUIT` to exit the game.
37
37
 
38
38
  ### The Script Code
39
39
 
40
- The main script for your narrative is `main.rb` in your project's root
41
- directory. It should look something like this:
40
+ The plot for your narrative is defined in the `plot.rb` file. It should look
41
+ something like this:
42
42
 
43
43
  ```ruby
44
- GAMEFIC_UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
45
- require 'gamefic-standard'
44
+ module Example
45
+ class Plot < Gamefic::Plot
46
+ UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
46
47
 
47
- Gamefic.script do
48
- introduction do |actor|
49
- actor.tell "Hello, world!"
48
+ include Gamefic::Standard
49
+
50
+ script do
51
+ introduction do |actor|
52
+ actor.tell "Hello, world!"
53
+ end
54
+ end
50
55
  end
51
56
  end
52
57
  ```
53
58
 
54
- `GAMEFIC_UUID` is a globally unique identifier. It can be useful if you want to
59
+ `UUID` is a globally unique identifier. It can be useful if you want to
55
60
  add your game to online catalogs, such as the [Interactive Fiction Database](https://ifdb.tads.org/),
56
61
  but it's safe to delete if you don't need it.
57
62
 
@@ -61,26 +66,34 @@ developers should find it similar to Inform's Standard Rules. It defines common
61
66
  components like Rooms and Characters, along with in-game commands like `GO`,
62
67
  `GET`, and `DROP` to enable basic interactivity.
63
68
 
64
- `Gamefic.script` is where you write the story itself. In the starter project,
69
+ `script` is where you write the story itself. In the starter project,
65
70
  the only thing in the script is an introductory message.
66
71
 
67
72
  ### Modifying the Script
68
73
 
69
- Replace the contents of `main.rb` with the following:
74
+ Replace the contents of `plot.rb` with the following:
70
75
 
71
76
  ```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
- connect @living_room, @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."
77
+ module Example
78
+ class Plot < Gamefic::Plot
79
+ UUID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
80
+
81
+ include Gamefic::Standard
82
+
83
+ seed do
84
+ @living_room = make Room, name: 'living room', description: 'This is your living room.'
85
+ @bedroom = make Room, name: 'bedroom', description: 'This is your bedroom.'
86
+ connect @living_room, @bedroom, 'north'
87
+ @backpack = make Room, name: 'backpack', description: 'Your trusty backpack.', parent: @bedroom
88
+ @book = make Room, name: 'book', description: 'Your favorite novel.', parent: @living_room
89
+ end
90
+
91
+ script do
92
+ introduction do |actor|
93
+ actor.parent = @living_room
94
+ actor.tell "You're in your house."
95
+ end
96
+ end
84
97
  end
85
98
  end
86
99
  ```
@@ -104,7 +117,7 @@ Test the game in a browser by starting a server:
104
117
  $ rake web:run
105
118
  ```
106
119
 
107
- Open `http://localhost:4342` to run the game in debug mode.
120
+ Open `http://localhost:9000` to run the game in debug mode.
108
121
 
109
122
  Build a standalone web game:
110
123
 
@@ -113,10 +126,9 @@ $ rake web:build
113
126
  ```
114
127
 
115
128
  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.
129
+ `web/build` directory. The SDK uses opal](https://github.com/opal/opal)
130
+ to compile Ruby code to JavaScript, so the web build does not require a
131
+ Ruby interpreter. Open `index.html` in a browser to play the game.
120
132
 
121
133
  Note: building the web app requires [Node.js](https://nodejs.org).
122
134
 
@@ -124,7 +136,7 @@ Note: building the web app requires [Node.js](https://nodejs.org).
124
136
 
125
137
  The gamefic-sdk repo includes several example projects that provide more
126
138
  complete demonstrations of Gamefic's features. To run an example, copy
127
- its `main.rb` file to your own project.
139
+ its `plot.rb` file to your own project.
128
140
 
129
141
  ### Learning More
130
142
 
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
+ require 'ostruct'
3
4
  require 'pathname'
4
5
  require 'securerandom'
5
6
  require 'shellwords'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'gamefic-tty'
2
4
  require 'tmpdir'
3
5
  require 'zlib'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'listen'
2
4
 
3
5
  module Gamefic
@@ -16,7 +18,7 @@ module Gamefic
16
18
  FileUtils.mkdir_p web_path
17
19
  Dir.chdir web_path do
18
20
  name = File.basename(absolute_path)
19
- system 'npx', 'react-gamefic', '--name', name, '--class', 'GAMEFIC_PLOT_CLASS'
21
+ system 'npx', 'react-gamefic', '--name', name, '--class', 'GAMEFIC_PLOT_CLASS', '--path', '../lib'
20
22
  puts 'The web app is ready.'
21
23
  puts 'Run `rake web:run` to start the app in dev mode.'
22
24
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Gamefic
2
4
  module Sdk
3
- VERSION = '3.0.0'
5
+ VERSION = '3.1.0'
4
6
  end
5
7
  end
@@ -1,2 +1,2 @@
1
- builds
1
+ build
2
2
  node_modules
@@ -31,7 +31,7 @@ To run the app in debug mode:
31
31
 
32
32
  $ rake web:run
33
33
 
34
- Open http://localhost:4342 in a browser.
34
+ Open http://localhost:9000 in a browser.
35
35
 
36
36
  ## Building a Web Game
37
37
 
@@ -3,7 +3,7 @@
3
3
  module <%= camelcase(name) %>
4
4
  # The base subplot.
5
5
  #
6
- # Authors should extend subclasses to create subplots that the plot can
6
+ # Authors should extend this class to create subplots that the plot can
7
7
  # branch.
8
8
  #
9
9
  class Subplot < Gamefic::Subplot
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ lib = File.expand_path('./lib', File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
3
6
  require 'gamefic'
4
7
  require 'gamefic-standard'
5
8
 
6
- require_relative '<%= name %>/plot'
7
- require_relative '<%= name %>/subplot'
9
+ require '<%= name %>/plot'
10
+ require '<%= name %>/subplot'
8
11
 
9
12
  # The Gamefic SDK uses this constant to select the main Plot for game engines.
10
13
  GAMEFIC_PLOT_CLASS = <%= camelcase(name) %>::Plot
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.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-01-27 00:00:00.000000000 Z
11
+ date: 2024-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
@@ -245,8 +245,8 @@ files:
245
245
  - scaffolds/project/Gemfile
246
246
  - scaffolds/project/README.md.gf.erb
247
247
  - scaffolds/project/Rakefile
248
- - scaffolds/project/__name__/plot.rb.gf.erb
249
- - scaffolds/project/__name__/subplot.rb.gf.erb
248
+ - scaffolds/project/lib/__name__/plot.rb.gf.erb
249
+ - scaffolds/project/lib/__name__/subplot.rb.gf.erb
250
250
  - scaffolds/project/main.rb.gf.erb
251
251
  homepage: http://gamefic.com
252
252
  licenses: