gamefic-tty 2.0.3 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b2a931bad1826a68d5ea3c05cb14bc94c09ca413b78b5f1cec1828701378b21
4
- data.tar.gz: ef18db71f5cf27a8b4ed5bb8fdbd0f915908778e1ffc09a26100ed30d1a62223
3
+ metadata.gz: 7727ff76e6d99f185d104a500d1da91868062c852ae8fc340026ac0829b5d4a9
4
+ data.tar.gz: 718beb405d92d0b45bf551f3dca48ae54538c35afa2873e97fda9c559a4909e0
5
5
  SHA512:
6
- metadata.gz: b9ba54220845810c548151bf7ef97e49998ba659bb3dede18acce84d80d65ef35dd5569b2fc7641e6162eeb1b335d9f0f246c27982f9049bfb5d1b0c2b874af8
7
- data.tar.gz: b3b49ef2cdee7e17f073de39315cc4f36204078c479dae64fa4654040fbd63c35e854b62e2faffc4b43bc160c70e30f7cef883eb2f2fb74f338907e2f6c31fee
6
+ metadata.gz: 55ecfab661beff414d0bf7a06178ef23802206e03b0cf85fc2fb109342d4a6c45ea674807a5e912422fe9e9b412bcd5ab54081b6b49b114f3867bc0574588206
7
+ data.tar.gz: bae7168adddd34eb26291aeb1f64ec450ca5be09007c57ec1c3e6d08243874e7101bc3d645c079a4607a2c1e777711635040be5159d70497475f330f433f322a
@@ -0,0 +1,37 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with rspec.
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: RSpec
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ test:
21
+
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ ruby-version: ['2.7', '3.0', '3.1']
26
+
27
+ steps:
28
+ - uses: actions/checkout@v3
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: false
34
+ - name: Install dependencies
35
+ run: bundle install
36
+ - name: Run Ruby tests
37
+ run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.0.0 - January 27, 2024
2
+ - Updates for Gamefic 3.0
3
+
1
4
  ## 2.0.3 - December 26, 2022
2
5
  - Dependency update
3
6
 
data/README.md CHANGED
@@ -1,55 +1,55 @@
1
- # Gamefic TTY
2
-
3
- A Gamefic engine for games that run on IO.
4
-
5
- **Features:**
6
-
7
- * Works with the `gamefic-standard` library
8
- * Converts Gamefic's default HTML output to ANSI text
9
-
10
- **Common uses:**
11
-
12
- * Run a game on the command line.
13
- * Attach IO streams to run the game over other processes.
14
-
15
- ## Installation
16
-
17
- Add this line to your application's Gemfile:
18
-
19
- ```ruby
20
- gem 'gamefic-tty'
21
- ```
22
-
23
- And then execute:
24
-
25
- $ bundle
26
-
27
- Or install it yourself as:
28
-
29
- $ gem install gamefic-tty
30
-
31
- ## Usage
32
-
33
- The easiest way to get started with Gamefic TTY is with the Gamefic SDK. See the [SDK README](https://github.com/castwide/gamefic-sdk) for more information.
34
-
35
- An example script that runs a game on the command line:
36
-
37
- ```ruby
38
- require 'gamefic-tty'
39
-
40
- Gamefic.script do
41
- introduction do |actor|
42
- actor.tell "Hello, world!"
43
- end
44
- end
45
-
46
- Gamefic::Tty::Engine.run
47
- ```
48
-
49
- ## Contributing
50
-
51
- Bug reports and pull requests are welcome on GitHub at https://github.com/castwide/gamefic-tty.
52
-
53
- ## License
54
-
55
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # Gamefic TTY
2
+
3
+ A Gamefic engine for games that run on IO.
4
+
5
+ **Features:**
6
+
7
+ * Works with the `gamefic-standard` library
8
+ * Converts Gamefic's default HTML output to ANSI text
9
+
10
+ **Common uses:**
11
+
12
+ * Run a game on the command line.
13
+ * Attach IO streams to run the game over other processes.
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'gamefic-tty'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install gamefic-tty
30
+
31
+ ## Usage
32
+
33
+ The easiest way to get started with Gamefic TTY is with the Gamefic SDK. See the [SDK README](https://github.com/castwide/gamefic-sdk) for more information.
34
+
35
+ An example script that runs a game on the command line:
36
+
37
+ ```ruby
38
+ require 'gamefic-tty'
39
+
40
+ class Example < Gamefic::Plot
41
+ introduction do |actor|
42
+ actor.tell "Hello, world!"
43
+ end
44
+ end
45
+
46
+ Gamefic::Tty::Engine.run(plot: Example.new)
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/castwide/gamefic-tty.
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/gamefic-tty.gemspec CHANGED
@@ -1,47 +1,46 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "gamefic-tty/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gamefic-tty"
8
- spec.version = Gamefic::Tty::VERSION
9
- spec.authors = ["Fred Snyder"]
10
- spec.email = ["fsnyder@castwide.com"]
11
-
12
- spec.summary = %q{Gamefic TTY engine}
13
- spec.description = %q{Components for running Gamefic om a terminal}
14
- # spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
- spec.license = "MIT"
16
-
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
-
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
- # else
26
- # raise "RubyGems 2.0 or newer is required to protect against " \
27
- # "public gem pushes."
28
- # end
29
-
30
- # Specify which files should be added to the gem when it is released.
31
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
- end
35
- # spec.bindir = "exe"
36
- # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
- spec.require_paths = ['lib']
38
-
39
- spec.add_runtime_dependency 'gamefic', '~> 2.0'
40
- spec.add_runtime_dependency 'html_to_ansi', '~> 0.1.0'
41
-
42
- spec.add_development_dependency 'bundler', '~> 2.0'
43
- spec.add_development_dependency 'rake', '~> 10.0'
44
- spec.add_development_dependency 'rexml', '~> 3.2'
45
- spec.add_development_dependency 'rspec', '~> 3.0'
46
- spec.add_development_dependency 'simplecov', '~> 0.14'
47
- end
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "gamefic-tty/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gamefic-tty"
8
+ spec.version = Gamefic::Tty::VERSION
9
+ spec.authors = ["Fred Snyder"]
10
+ spec.email = ["fsnyder@castwide.com"]
11
+
12
+ spec.summary = %q{Gamefic TTY engine}
13
+ spec.description = %q{Components for running Gamefic om a terminal}
14
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ # spec.bindir = "exe"
36
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ['lib']
38
+
39
+ spec.add_runtime_dependency 'gamefic', '~> 3.0'
40
+ spec.add_runtime_dependency 'html_to_ansi', '~> 0.2.0'
41
+
42
+ spec.add_development_dependency 'bundler', '~> 2.0'
43
+ spec.add_development_dependency 'rake', '~> 10.0'
44
+ spec.add_development_dependency 'rspec', '~> 3.0'
45
+ spec.add_development_dependency 'simplecov', '~> 0.14'
46
+ end
@@ -1,29 +1,46 @@
1
1
  module Gamefic
2
2
  module Tty
3
+ # A simple engine for running turn-based, single-character Gamefic plots.
4
+ #
3
5
  class Engine
6
+ # @return [Plot]
4
7
  attr_reader :plot
8
+
9
+ # @return [User]
5
10
  attr_reader :user
11
+
12
+ # @return [Character]
6
13
  attr_reader :character
7
14
 
15
+ # @param plot [Plot]
16
+ # @param user [User]
8
17
  def initialize(plot: Gamefic::Plot.new, user: Gamefic::Tty::User.new)
9
18
  @plot = plot
10
19
  @user = user
11
- @character = @plot.get_player_character
12
- @plot.introduce @character
20
+ @character = @plot.introduce
13
21
  @plot.ready
14
22
  end
15
23
 
24
+ # Run the plot to its conclusion.
25
+ #
16
26
  def run
17
- turn until @character.concluded?
27
+ turn until @plot.concluding?
18
28
  @user.update @character.output
19
29
  end
20
30
 
21
- def self.run **args
22
- engine = new(**args)
31
+ # Create an engine and run the plot.
32
+ #
33
+ # @param plot [Plot]
34
+ # @param user [User]
35
+ # @return [Engine]
36
+ def self.run(plot: Gamefic::Plot.new, user: Gamefic::Tty::User.new)
37
+ engine = new(plot: plot, user: user)
23
38
  engine.run
24
39
  engine
25
40
  end
26
41
 
42
+ # Run a single turn.
43
+ #
27
44
  def turn
28
45
  send_and_receive
29
46
  @plot.update
@@ -34,14 +51,9 @@ module Gamefic
34
51
 
35
52
  def send_and_receive
36
53
  @user.update @character.output
37
- until @character.queue.empty? || @character.concluded?
38
- @plot.update
39
- @plot.ready
40
- @user.update @character.output
41
- end
42
- return if @character.concluded?
43
- input = @user.query("#{@character.output[:prompt]} ")
44
- @character.queue.push input unless input.nil?
54
+ return unless @character.queue.empty?
55
+
56
+ @character.queue.push @user.query("#{@character.output[:prompt]} ")
45
57
  end
46
58
  end
47
59
  end
@@ -3,8 +3,13 @@ require 'html_to_ansi'
3
3
 
4
4
  module Gamefic
5
5
  module Tty
6
+ # An interface for passing IO between an engine and a client.
7
+ #
6
8
  class User
9
+ # @return [IO]
7
10
  attr_reader :input
11
+
12
+ # @return [IO]
8
13
  attr_reader :output
9
14
 
10
15
  # @param input [IO] The stream that receives input
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Tty
3
- VERSION = '2.0.3'.freeze
3
+ VERSION = '3.0.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic-tty
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 3.0.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: 2022-12-26 00:00:00.000000000 Z
11
+ date: 2024-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: html_to_ansi
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.0
33
+ version: 0.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.1.0
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rexml
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.2'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.2'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -115,6 +101,7 @@ executables: []
115
101
  extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
104
+ - ".github/workflows/rspec.yml"
118
105
  - ".gitignore"
119
106
  - ".rspec"
120
107
  - ".travis.yml"