gamefic-sdk 1.1.0 → 1.2.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
  SHA1:
3
- metadata.gz: 3b6246feb78b9dfe2668e0409dad7e9c5866a248
4
- data.tar.gz: c847fab4182447f1980d429e401af4543cd0a5ab
3
+ metadata.gz: 081a0f681badbcefc16326db3a53df75173afb59
4
+ data.tar.gz: 32377e4aac6d78e3a83fd21d3bfb82e9e9d57e08
5
5
  SHA512:
6
- metadata.gz: d8ceec5b5493b56cd852794e192774a77405147e930fe3e0696a48df1142777cc336e84de889c49c5098b68842653bb04d4cdf46160fec5e53dd732eb56a006a
7
- data.tar.gz: 0c3062e078cf8639569d5bffce9a4f8fa53f735973a446cf785dbc5ab3915a543925927d247ec90ed484365337e687427529a8fb447c6dd2a20f97300fa7c5fc
6
+ metadata.gz: 7ebc6cf34dfe63068722c297787af128150a7aadb537c7279cfd0c58f53c203e5afdb8ea6e4b1594f8ffece0e4e691451c54ceb7e9450748123cbcc93991a86b
7
+ data.tar.gz: 7b4091417b2d45ea4c26970a266d626810cdbf5d7093bf37af9bfff68f97014d47fae8fb5cf1888a0280fc85c1491716cb8137d9c4b3235082e6c7369a4e2952
data/bin/gfk CHANGED
@@ -1,16 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'gamefic'
4
- require 'gamefic/shell'
5
3
  require 'gamefic-sdk'
6
4
  require 'gamefic-sdk/shell'
7
5
 
8
- shell = Gamefic::Shell.new
9
-
10
- shell.register "init", Gamefic::Sdk::Shell::Command::Init
11
- shell.register "create", Gamefic::Sdk::Shell::Command::Init
12
- shell.register "build", Gamefic::Sdk::Shell::Command::Build
13
- shell.register "clean", Gamefic::Sdk::Shell::Command::Clean
14
- shell.register "test", Gamefic::Sdk::Shell::Command::Test
15
-
16
- shell.execute
6
+ Gamefic::Sdk::Shell.start(ARGV)
@@ -1,30 +1,28 @@
1
1
  require 'gamefic'
2
2
  require 'gamefic-sdk'
3
- #require 'rubygems'
4
- #gem 'opal', '>= 0.9', '< 0.10'
5
3
  require 'opal'
6
4
 
7
5
  module Gamefic::Sdk
8
6
 
9
7
  class Platform::Web < Platform::Base
10
8
  autoload :AppConfig, 'gamefic-sdk/platform/web/app_config'
11
-
9
+
12
10
  def defaults
13
11
  @defaults ||= {
14
12
  'html_skin' => 'standard',
15
13
  'with_media' => true
16
14
  }
17
15
  end
18
-
16
+
19
17
  def app_config
20
18
  @app_config ||= AppConfig.new source_dir, config
21
19
  end
22
-
20
+
23
21
  def build
24
22
  target_dir = config['target_dir']
25
23
  build_dir = config['build_dir']
26
24
  html_dir = app_config.html_dir
27
-
25
+
28
26
  FileUtils.mkdir_p target_dir
29
27
  copy_html_files target_dir
30
28
  build_opal_js build_dir
@@ -34,17 +32,17 @@ module Gamefic::Sdk
34
32
  render_index target_dir
35
33
  copy_assets build_dir, target_dir
36
34
  copy_media source_dir, target_dir
37
-
35
+
38
36
  end
39
-
37
+
40
38
  def clean
41
39
  FileUtils.remove_entry_secure config['build_dir'] if File.exist?(config['build_dir'])
42
40
  FileUtils.mkdir_p config['build_dir']
43
41
  puts "#{config['build_dir']} cleaned."
44
42
  end
45
-
43
+
46
44
  private
47
-
45
+
48
46
  def resolve filename, paths
49
47
  absolute = nil
50
48
  paths.each { |path|
@@ -79,26 +77,27 @@ module Gamefic::Sdk
79
77
  end
80
78
  end
81
79
  end
82
-
80
+
83
81
  def build_gamefic_js build_dir
84
82
  # Gamefic core
85
- Opal.append_path Gamefic::Sdk::LIB_PATH
83
+ Opal.use_gem 'gamefic'
86
84
  if !File.exist?(build_dir + "/core/gamefic.js")
87
85
  File.open(build_dir + "/core/gamefic.js", "w") do |file|
88
86
  file << Opal::Builder.build('gamefic').to_s
89
87
  end
90
88
  end
91
89
  end
92
-
90
+
93
91
  def build_static_js build_dir
94
92
  # GameficOpal
93
+ Opal.append_path Gamefic::Sdk::LIB_PATH
95
94
  if !File.exist?(build_dir + "/core/static.js")
96
95
  File.open(build_dir + "/core/static.js", "w") do |file|
97
96
  file << Opal::Builder.build('gamefic-sdk/platform/web/gamefic_opal')
98
97
  end
99
98
  end
100
99
  end
101
-
100
+
102
101
  def build_scripts_js build_dir
103
102
  # Plot scripts
104
103
  File.open("#{build_dir}/scripts.rb", 'w') do |file|
@@ -116,14 +115,14 @@ module Gamefic::Sdk
116
115
  file << Opal::Builder.build('scripts')
117
116
  end
118
117
  end
119
-
118
+
120
119
  def render_index target_dir
121
120
  # Render index
122
121
  File.open(target_dir + "/index.html", "w") do |file|
123
122
  file << app_config.render
124
123
  end
125
124
  end
126
-
125
+
127
126
  def copy_assets build_dir, target_dir
128
127
  paths = app_config.resource_paths
129
128
  paths.push build_dir
@@ -138,7 +137,7 @@ module Gamefic::Sdk
138
137
  FileUtils.cp_r absolute, target_dir + "/" + css
139
138
  }
140
139
  end
141
-
140
+
142
141
  def copy_media source_dir, target_dir
143
142
  # Copy media
144
143
  pc = PlotConfig.new "#{source_dir}/config.yaml"
@@ -154,7 +153,7 @@ module Gamefic::Sdk
154
153
  end
155
154
  }
156
155
  end
157
-
156
+
158
157
  def metadata_code
159
158
  "\nGameficOpal.static_plot.metadata = JSON.parse('#{metadata.to_json}')"
160
159
  end
@@ -22,7 +22,7 @@ module GameficOpal
22
22
  # Stub
23
23
  end
24
24
  end
25
-
25
+
26
26
  class WebUser < Gamefic::User
27
27
  def save filename, data
28
28
  data[:metadata] = character.plot.metadata
@@ -1,5 +1,53 @@
1
- require 'gamefic/shell'
1
+ require 'thor'
2
+ require 'gamefic-sdk/build'
2
3
 
3
- class Gamefic::Sdk::Shell < Gamefic::Shell
4
- autoload :Command, 'gamefic-sdk/shell/command'
4
+ module Gamefic
5
+ module Sdk
6
+ class Shell < Thor
7
+ autoload :Init, 'gamefic-sdk/shell/init'
8
+ autoload :Test, 'gamefic-sdk/shell/test'
9
+
10
+ map %w[--version -v] => :version
11
+ map [:create, :new] => :init
12
+
13
+ desc "--version, -v", "Print the version"
14
+ def version
15
+ puts "gamefic-sdk #{Gamefic::Sdk::VERSION}"
16
+ puts "gamefic #{Gamefic::VERSION}"
17
+ end
18
+
19
+ desc 'init DIRECTORY_NAME', 'Initialize a new game in DIRECTORY_NAME'
20
+ option :quiet, type: :boolean, aliases: :q, desc: 'Suppress output'
21
+ option :standard, type: :boolean, default: true, desc: 'Include the standard script'
22
+ option :scripts, type: :array, aliases: [:s, :script], desc: 'Additional scripts'
23
+ option :webskin, default: 'standard', aliases: [:w], desc: 'Skin to use for the Web platform'
24
+ def init(directory_name)
25
+ Gamefic::Sdk::Shell::Init.new(directory: directory_name,
26
+ quiet: options[:quiet], scripts: options[:scripts], webskin: options[:webskin]).run
27
+ end
28
+
29
+ desc 'test DIRECTORY_NAME', 'Play the game in DIRECTORY_NAME'
30
+ def test(directory_name)
31
+ Gamefic::Sdk::Shell::Test.new(directory: directory_name).run
32
+ end
33
+
34
+ desc 'build DIRECTORY_NAME', 'Build the game for specified platforms in DIRECTORY_NAME'
35
+ option :quiet, type: :boolean, aliases: :q, desc: 'Suppress output'
36
+ def build(directory_name)
37
+ Gamefic::Sdk::Build.release(directory_name, options[:quiet])
38
+ end
39
+
40
+ desc 'clean DIRECTORY_NAME', 'Perform cleanup of DIRECTORY_NAME'
41
+ def clean(directory_name)
42
+ Gamefic::Sdk::Build.clean(directory_name)
43
+ end
44
+
45
+ desc 'webskins', 'List the available skins for the Web platform'
46
+ def webskins
47
+ Dir[File.join(Gamefic::Sdk::HTML_TEMPLATE_PATH, 'skins', '*')].sort.each { |d|
48
+ puts File.basename(d)
49
+ }
50
+ end
51
+ end
52
+ end
5
53
  end
@@ -0,0 +1,92 @@
1
+ require 'securerandom'
2
+ require 'fileutils'
3
+
4
+ module Gamefic
5
+ module Sdk
6
+ class Shell
7
+ class Init
8
+ def initialize(directory:, standard: true, quiet: false, scripts: [], webskin: 'standard')
9
+ @quiet = quiet
10
+ @directory = directory
11
+ @html = webskin
12
+ @scripts = []
13
+ @scripts.push('standard') if standard
14
+ @scripts += scripts if scripts
15
+ @platforms = ['Gfic', 'Web']
16
+ end
17
+
18
+ def run
19
+ make_game_directories
20
+ write_main_script
21
+ write_test_script
22
+ write_build_yaml
23
+ write_config_yaml
24
+ write_uuid_file
25
+ copy_html_skin
26
+ puts "Game directory '#{@directory}' initialized." unless @quiet
27
+ end
28
+
29
+ private
30
+
31
+ def make_game_directories
32
+ if File.exist?(@directory)
33
+ raise "#{@directory} is a file." if File.file?(@directory)
34
+ raise "#{@directory} is not an empty directory." unless Dir["#{@directory}/*"].empty?
35
+ else
36
+ Dir.mkdir(@directory)
37
+ end
38
+
39
+ Dir.mkdir(File.join(@directory, 'scripts'))
40
+ Dir.mkdir(File.join(@directory, 'media'))
41
+ end
42
+
43
+ def write_main_script
44
+ main_file = File.join(@directory, 'scripts', 'main.plot.rb')
45
+ File.open(main_file, 'w') do |file|
46
+ @scripts.each do |script|
47
+ file.puts "script '#{script}'"
48
+ end
49
+ end
50
+ end
51
+
52
+ def write_test_script
53
+ File.open("#{@directory}/scripts/test.plot.rb", 'w') do |file|
54
+ file.puts "script 'standard/test'"
55
+ end
56
+ end
57
+
58
+ def write_build_yaml
59
+ File.open("#{@directory}/build.yaml", 'w') do |file|
60
+ file.puts "web:",
61
+ " platform: Web",
62
+ "gfic:",
63
+ " platform: Gfic",
64
+ " filename: game.gfic"
65
+ end
66
+ end
67
+
68
+ def write_config_yaml
69
+ File.open("#{@directory}/config.yaml", 'w') do |file|
70
+ file.puts "title: Untitled",
71
+ "author: Anonymous",
72
+ "",
73
+ "script_paths:",
74
+ " - ./scripts",
75
+ "media_paths:",
76
+ " - ./media"
77
+ end
78
+ end
79
+
80
+ def write_uuid_file
81
+ uuid = SecureRandom.uuid
82
+ File.open("#{@directory}/.uuid", "w") { |f| f.write uuid }
83
+ end
84
+
85
+ def copy_html_skin
86
+ Dir.mkdir("#{@directory}/html")
87
+ FileUtils.cp_r(Dir[Gamefic::Sdk::HTML_TEMPLATE_PATH + '/skins/' + @html + '/*'], "#{@directory}/html")
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,36 @@
1
+ require 'gamefic-sdk/plot_config'
2
+ require 'gamefic/engine/tty'
3
+
4
+ module Gamefic
5
+ module Sdk
6
+ class Shell
7
+ class Test
8
+ def initialize(directory:)
9
+ @path = directory
10
+ raise "Invalid path: #{@path}" unless File.exist?(@path)
11
+ puts "Loading..."
12
+ end
13
+
14
+ def run
15
+ paths = config_path.script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
16
+ plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
17
+ plot.script 'main'
18
+ plot.script 'debug'
19
+ engine = Tty::Engine.new plot
20
+ puts "\n"
21
+ engine.run
22
+ end
23
+
24
+ private
25
+
26
+ def config_path
27
+ if File.directory?(@path)
28
+ PlotConfig.new File.join(@path, 'config.yaml')
29
+ else
30
+ PlotConfig.new
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
@@ -31,6 +31,7 @@ class Gamefic::Room < Gamefic::Entity
31
31
  end
32
32
  portal
33
33
  end
34
+
34
35
  def synonyms
35
36
  @synonyms.to_s + " around here room"
36
37
  end
metadata CHANGED
@@ -1,71 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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: 2016-11-27 00:00:00.000000000 Z
11
+ date: 2016-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.2'
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: '0'
26
+ version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.10'
34
+ - - ">="
32
35
  - !ruby/object:Gem::Version
33
36
  version: 0.10.3
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - '>='
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.10'
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 0.10.3
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rspec
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '3.5'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.5.0
48
57
  type: :development
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - '>='
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '3.5'
64
+ - - ">="
53
65
  - !ruby/object:Gem::Version
54
- version: '0'
66
+ version: 3.5.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: poltergeist
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
- - - '>='
71
+ - - "~>"
60
72
  - !ruby/object:Gem::Version
61
- version: '0'
73
+ version: '1.11'
62
74
  type: :development
63
75
  prerelease: false
64
76
  version_requirements: !ruby/object:Gem::Requirement
65
77
  requirements:
66
- - - '>='
78
+ - - "~>"
67
79
  - !ruby/object:Gem::Version
68
- version: '0'
80
+ version: '1.11'
69
81
  description: Development tools for Gamefic
70
82
  email: fsnyder@gamefic.com
71
83
  executables:
@@ -108,11 +120,8 @@ files:
108
120
  - lib/gamefic-sdk/platform/web/gamefic_opal.rb
109
121
  - lib/gamefic-sdk/plot_config.rb
110
122
  - lib/gamefic-sdk/shell.rb
111
- - lib/gamefic-sdk/shell/command.rb
112
- - lib/gamefic-sdk/shell/command/build.rb
113
- - lib/gamefic-sdk/shell/command/clean.rb
114
- - lib/gamefic-sdk/shell/command/init.rb
115
- - lib/gamefic-sdk/shell/command/test.rb
123
+ - lib/gamefic-sdk/shell/init.rb
124
+ - lib/gamefic-sdk/shell/test.rb
116
125
  - lib/gamefic-sdk/version.rb
117
126
  - scripts/ansi.plot.rb
118
127
  - scripts/autosuggest.plot.rb
@@ -228,19 +237,18 @@ require_paths:
228
237
  - lib
229
238
  required_ruby_version: !ruby/object:Gem::Requirement
230
239
  requirements:
231
- - - '>='
240
+ - - ">="
232
241
  - !ruby/object:Gem::Version
233
- version: 2.0.0
242
+ version: 2.1.0
234
243
  required_rubygems_version: !ruby/object:Gem::Requirement
235
244
  requirements:
236
- - - '>='
245
+ - - ">="
237
246
  - !ruby/object:Gem::Version
238
247
  version: '0'
239
248
  requirements: []
240
249
  rubyforge_project:
241
- rubygems_version: 2.6.8
250
+ rubygems_version: 2.5.1
242
251
  signing_key:
243
252
  specification_version: 4
244
253
  summary: Gamefic SDK
245
254
  test_files: []
246
- has_rdoc:
@@ -1,8 +0,0 @@
1
- require 'slop'
2
-
3
- module Gamefic::Sdk::Shell::Command
4
- autoload :Init, 'gamefic-sdk/shell/command/init'
5
- autoload :Build, 'gamefic-sdk/shell/command/build'
6
- autoload :Clean, 'gamefic-sdk/shell/command/clean'
7
- autoload :Test, 'gamefic-sdk/shell/command/test'
8
- end
@@ -1,12 +0,0 @@
1
- require 'gamefic-sdk/build'
2
-
3
- class Gamefic::Sdk::Shell::Command::Build < Gamefic::Shell::Command::Base
4
- def initialize
5
- options.boolean '-q', '--quiet', 'suppress output', default: false
6
- end
7
-
8
- def run input
9
- result = parse input
10
- Gamefic::Sdk::Build.release result.arguments[1], result['--quiet']
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- require 'gamefic-sdk/build'
2
-
3
- class Gamefic::Sdk::Shell::Command::Clean < Gamefic::Shell::Command::Base
4
- def initialize
5
- #options.boolean '-q', '--quiet', 'suppress output', default: false
6
- end
7
-
8
- def run input
9
- result = parse input
10
- Gamefic::Sdk::Build.clean result.arguments[1]
11
- end
12
- end
@@ -1,101 +0,0 @@
1
- require 'securerandom'
2
- require 'fileutils'
3
- require 'getoptlong'
4
-
5
- class Gamefic::Sdk::Shell::Command::Init < Gamefic::Shell::Command::Base
6
- def initialize
7
- @quiet = false
8
- @html = 'standard'
9
- @scripts = ['standard']
10
- @platforms = ['Gfic', 'Web']
11
- options.boolean '-q', '--quiet', 'suppress output', default: false
12
- end
13
-
14
- def run input
15
- get_arguments input
16
- make_game_directories
17
- write_main_script
18
- write_test_script
19
- write_build_yaml
20
- write_config_yaml
21
- write_uuid_file
22
- copy_html_skin
23
- Dir.mkdir(File.join(@directory, 'media'))
24
- puts "Game directory '#{@directory}' initialized." unless @quiet
25
- end
26
-
27
- private
28
-
29
- def get_arguments input
30
- result = parse input
31
- @quiet = result['--quiet']
32
- @directory = result.arguments[1]
33
- end
34
-
35
- def make_game_directories
36
- if @directory.to_s == ''
37
- raise "No directory specified."
38
- end
39
- if File.exist?(@directory)
40
- if File.file?(@directory)
41
- raise "#{@directory} is a file."
42
- else
43
- if !Dir['your_directory/*'].empty?
44
- raise "#{@directory} is not an empty directory."
45
- end
46
- end
47
- else
48
- Dir.mkdir(@directory)
49
- end
50
- Dir.mkdir(@directory + '/scripts')
51
- end
52
-
53
- def write_main_script
54
- main_file = File.join(@directory, 'scripts', 'main.plot.rb')
55
- File.open(main_file, 'w') do |file|
56
- @scripts.each { |script|
57
- file.puts "script '#{script}'"
58
- }
59
- end
60
- end
61
-
62
- def write_test_script
63
- File.open("#{@directory}/scripts/test.plot.rb", 'w') do |file|
64
- file.puts "script 'standard/test'"
65
- end
66
- end
67
-
68
- def write_build_yaml
69
- File.open("#{@directory}/build.yaml", 'w') do |file|
70
- file.puts "web:",
71
- " platform: Web",
72
- "gfic:",
73
- " platform: Gfic",
74
- " filename: game.gfic"
75
- end
76
- end
77
-
78
- def write_config_yaml
79
- File.open("#{@directory}/config.yaml", 'w') do |file|
80
- file.puts "title: Untitled",
81
- "author: Anonymous",
82
- "",
83
- "script_paths:",
84
- " - ./scripts",
85
- "media_paths:",
86
- " - ./media"
87
- end
88
- end
89
-
90
- def write_uuid_file
91
- uuid = SecureRandom.uuid
92
- File.open("#{@directory}/.uuid", "w") { |f| f.write uuid }
93
- end
94
-
95
- def copy_html_skin
96
- Dir.mkdir("#{@directory}/html")
97
- skin = 'standard'
98
- FileUtils.cp_r(Dir[Gamefic::Sdk::HTML_TEMPLATE_PATH + "/skins/" + @html + "/*"], "#{@directory}/html")
99
- end
100
-
101
- end
@@ -1,35 +0,0 @@
1
- require 'gamefic/shell'
2
- require 'gamefic-sdk/plot_config'
3
- require 'gamefic/engine/tty'
4
-
5
- module Gamefic
6
- module Sdk
7
-
8
- class Shell::Command::Test < Gamefic::Shell::Command::Base
9
- def run input
10
- result = parse input
11
- puts "Loading..."
12
- path = result.arguments[1]
13
- if !File.exist?(path)
14
- raise "Invalid path: #{path}"
15
- end
16
- build_file = nil
17
- main_file = path
18
- test_file = nil
19
- if File.directory?(path)
20
- config = PlotConfig.new File.join(path, 'config.yaml')
21
- else
22
- config = PlotConfig.new
23
- end
24
- paths = config.script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
25
- plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
26
- plot.script 'main'
27
- plot.script 'debug'
28
- engine = Tty::Engine.new plot
29
- puts "\n"
30
- engine.run
31
- end
32
- end
33
-
34
- end
35
- end