gamefic-sdk 1.3.1 → 1.4.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: cd21c94408ecfc19f905b8344363c15a3164c4a2
4
- data.tar.gz: 662d9daeb9161d2622aa8361d816c91fdc16eae9
3
+ metadata.gz: 6cc2343107a5dea13bfcba8360aedc82ddb160c0
4
+ data.tar.gz: c05803ac75db4669c5ad9bca1be55c25fe18cf2b
5
5
  SHA512:
6
- metadata.gz: 860ff80c0a31476a00a96b7bd8b7c5722cb3ff417e0e2d230b6de621d03d3fbde197eb370b22abeafe11cad82b97a6b9342ac7d9962b6998aaf71cdeeceff643
7
- data.tar.gz: 3f4132cc5907ee65e5e3c9ac0ccd57da00c5a7885a640002722354d44020a7c84d82769e79fa63ea02c5116921a370f8bdf8c415fcc2b34c385a7df44ecd647d
6
+ metadata.gz: a79a03c3289a33bc3265003397b907dfb4a490e1f507ba8ab280250cc64523117b570f86801645935633c38c66a26ec735f11617c2310ed6c4592a4a4b8510b2
7
+ data.tar.gz: 88592b51eacef05cdf084fb60a3d67b12a4af437ed7611cb1b3333676b255be580e53e9a9acff9bb983eed904d4d334f26aaac80d28ebff32f2aa3dda71d766c
data/html/core/engine.js CHANGED
@@ -7,11 +7,11 @@ var Gamefic = (function() {
7
7
  var lastPrompt = null;
8
8
  var getResponse = function(withOutput) {
9
9
  var r = {
10
- output: (withOutput ? Opal.GameficOpal.$static_player().$state().$output() : null),
11
- state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_player().$character().$scene()).$state(),
10
+ output: (withOutput ? Opal.GameficOpal.$static_user().$flush() : null),
11
+ state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$type(),
12
12
  prompt: lastPrompt,
13
13
  input: lastInput,
14
- testing: (Opal.GameficOpal.$static_player().$test_queue().$length() > 0)
14
+ testing: (Opal.GameficOpal.$static_character().$queue().$length() > 0)
15
15
  }
16
16
  return r;
17
17
  }
@@ -26,9 +26,9 @@ var Gamefic = (function() {
26
26
  }
27
27
  return {
28
28
  start: function() {
29
- Opal.GameficOpal.$load_scripts();
30
- Opal.GameficOpal.$static_plot().$introduce(Opal.GameficOpal.$static_player().$character());
31
- lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_player().$character().$scene()).$prompt();
29
+ Opal.GameficOpal.$load_scripts();
30
+ Opal.GameficOpal.$static_plot().$introduce(Opal.GameficOpal.$static_character());
31
+ lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
32
32
  var response = getResponse(true);
33
33
  doReady(response);
34
34
  handle(response);
@@ -38,7 +38,7 @@ var Gamefic = (function() {
38
38
  },
39
39
  update: function(input) {
40
40
  if (input != null) {
41
- Opal.GameficOpal.$static_player().$character().$queue().$push(input);
41
+ Opal.GameficOpal.$static_character().$queue().$push(input);
42
42
  }
43
43
  lastInput = input;
44
44
  var response = getResponse(false);
@@ -47,20 +47,23 @@ var Gamefic = (function() {
47
47
  });
48
48
  Opal.GameficOpal.$static_plot().$update();
49
49
  Opal.GameficOpal.$static_plot().$ready();
50
- lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_player().$character().$scene()).$prompt();
50
+ lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
51
51
  response = getResponse(true);
52
52
  var updateResponse = response;
53
53
  doReady(response);
54
- lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_player().$character().$scene()).$prompt();
54
+ lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
55
55
  response = getResponse(true);
56
56
  response.output = updateResponse.output + response.output;
57
57
  handle(response);
58
58
  finishCallbacks.forEach(function(callback) {
59
59
  callback(response);
60
60
  });
61
- var testCommand = Opal.GameficOpal.$static_player().$test_queue().$shift();
61
+ /*var testCommand = Opal.GameficOpal.$static_character().$queue().$shift();
62
62
  if (typeof testCommand == 'string') {
63
63
  setTimeout("Gamefic.update(" + JSON.stringify(testCommand) + ");", 1);
64
+ }*/
65
+ if (Opal.GameficOpal.$static_character().$queue().$length() > 0) {
66
+ setTimeout("Gamefic.update();", 1);
64
67
  }
65
68
  },
66
69
  onStart: function(callback) {
@@ -78,14 +81,14 @@ var Gamefic = (function() {
78
81
  save: function(filename, data) {
79
82
  var json = Opal.JSON.$generate(data);
80
83
  localStorage.setItem(filename, json);
81
- Opal.GameficOpal.$static_player().$character().$tell('Game saved.');
84
+ Opal.GameficOpal.$static_character().$tell('Game saved.');
82
85
  },
83
86
  restore: function(filename) {
84
87
  var data = Opal.JSON.$parse(localStorage.getItem(filename));
85
88
  var metadata = data.$fetch('metadata');
86
89
  // HACK Converting hashes to strings for JavaScript comparison
87
90
  if (metadata.$to_s() != Opal.GameficOpal.$static_plot().$metadata().$to_s()) {
88
- Opal.GameficOpal.$static_player().$character().$tell('The saved data is not compatible with this version of the game.');
91
+ Opal.GameficOpal.$static_character().$tell('The saved data is not compatible with this version of the game.');
89
92
  return Opal.nil;
90
93
  } else {
91
94
  return data;
@@ -83,7 +83,7 @@ module Gamefic::Sdk
83
83
  Opal.use_gem 'gamefic'
84
84
  if !File.exist?(build_dir + "/core/gamefic.js")
85
85
  File.open(build_dir + "/core/gamefic.js", "w") do |file|
86
- file << Opal::Builder.build('gamefic').to_s
86
+ file << Opal::Builder.build('gamefic').to_s
87
87
  end
88
88
  end
89
89
  end
@@ -2,7 +2,6 @@
2
2
  require 'gamefic/query/expression'
3
3
  require 'gamefic/query/matches'
4
4
  require 'gamefic/grammar/verb_set'
5
- require 'gamefic/scene/multiple_choice/input'
6
5
 
7
6
  # HACK Opal doesn't recognize classes and modules declared from scripts
8
7
  def Object.const_missing sym
@@ -13,19 +12,25 @@ module GameficOpal
13
12
  def self.static_plot
14
13
  @@static_plot ||= WebPlot.new(Gamefic::Source::Text.new)
15
14
  end
16
- def self.static_player
17
- @@static_player ||= WebUser.new(GameficOpal.static_plot)
15
+ def self.static_character
16
+ if @@static_character.nil?
17
+ @@static_character = static_plot.make Gamefic::Character, name: 'player', synonyms: 'me you myself yourself self'
18
+ @@static_character.connect static_user
19
+ end
20
+ @@static_character
21
+ end
22
+ def self.static_user
23
+ @@static_user ||= WebUser.new
18
24
  end
19
-
20
25
  class WebPlot < Gamefic::Plot
21
26
  def script path
22
27
  # Stub
23
28
  end
24
29
  end
25
30
 
26
- class WebUser < Gamefic::User
31
+ class WebUser < Gamefic::User::Base
27
32
  def save filename, data
28
- data[:metadata] = character.plot.metadata
33
+ data[:metadata] = GameficOpal.static_character.plot.metadata
29
34
  `Gamefic.save(filename, data);`
30
35
  end
31
36
  def restore filename
@@ -33,9 +38,7 @@ module GameficOpal
33
38
  return data
34
39
  end
35
40
  def test_queue
36
- character[:test_queue] || []
41
+ GameficOpal.static_character[:test_queue] || []
37
42
  end
38
43
  end
39
44
  end
40
-
41
- GameficOpal.static_plot.script 'main'
@@ -16,7 +16,8 @@ module Gamefic
16
16
  plot = Gamefic::Sdk::Debug::Plot.new Source::File.new(*paths)
17
17
  plot.script 'main'
18
18
  plot.script 'debug'
19
- engine = Tty::Engine.new plot
19
+ engine = Engine::Tty.new plot
20
+ engine.connect
20
21
  puts "\n"
21
22
  engine.run
22
23
  end
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.3.1'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
- yes_or_no :confirm_quit, "Are you sure you want to quit?" do |actor, input|
2
- if input == "yes"
1
+ yes_or_no :confirm_quit, 'Are you sure you want to quit?' do |actor, data|
2
+ if data.yes?
3
3
  actor.cue :concluded
4
4
  else
5
5
  actor.cue :active
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: 1.3.1
4
+ version: 1.4.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: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic