gamefic-sdk 1.4.0 → 1.4.1

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: 6cc2343107a5dea13bfcba8360aedc82ddb160c0
4
- data.tar.gz: c05803ac75db4669c5ad9bca1be55c25fe18cf2b
3
+ metadata.gz: 642000755606d5f202c09b54f2a11c5fb238601e
4
+ data.tar.gz: 9040ce5b78583d05074cd808719ee60f0ddef910
5
5
  SHA512:
6
- metadata.gz: a79a03c3289a33bc3265003397b907dfb4a490e1f507ba8ab280250cc64523117b570f86801645935633c38c66a26ec735f11617c2310ed6c4592a4a4b8510b2
7
- data.tar.gz: 88592b51eacef05cdf084fb60a3d67b12a4af437ed7611cb1b3333676b255be580e53e9a9acff9bb983eed904d4d334f26aaac80d28ebff32f2aa3dda71d766c
6
+ metadata.gz: 9b4aea3ba1aa82775669c862679de3cbf36b1aa1eb38fa63355ba49f0916d1972f25212f4626b3890fe66168aff5cbd422aea042970f7969abbbcca6c44a10c5
7
+ data.tar.gz: dcbc83828cdba3f965aa1256e42406a0e664b9bc50b3dc31f2e0bbededdfdf4e7af5640544cec5be389c33714cae3990a957a06621d47e2ed82197550c109ad8
data/html/core/engine.js CHANGED
@@ -29,12 +29,7 @@ var Gamefic = (function() {
29
29
  Opal.GameficOpal.$load_scripts();
30
30
  Opal.GameficOpal.$static_plot().$introduce(Opal.GameficOpal.$static_character());
31
31
  lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
32
- var response = getResponse(true);
33
- doReady(response);
34
- handle(response);
35
- finishCallbacks.forEach(function(callback) {
36
- callback(response);
37
- });
32
+ this.update('');
38
33
  },
39
34
  update: function(input) {
40
35
  if (input != null) {
@@ -58,10 +53,6 @@ var Gamefic = (function() {
58
53
  finishCallbacks.forEach(function(callback) {
59
54
  callback(response);
60
55
  });
61
- /*var testCommand = Opal.GameficOpal.$static_character().$queue().$shift();
62
- if (typeof testCommand == 'string') {
63
- setTimeout("Gamefic.update(" + JSON.stringify(testCommand) + ");", 1);
64
- }*/
65
56
  if (Opal.GameficOpal.$static_character().$queue().$length() > 0) {
66
57
  setTimeout("Gamefic.update();", 1);
67
58
  }
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.4.0'
3
+ VERSION = '1.4.1'
4
4
  end
5
5
  end
@@ -1,23 +1,32 @@
1
- module Gamefic::Suggestible
2
- def suggestions
3
- @suggestions ||= []
1
+ class Gamefic::Suggestions
2
+ def current
3
+ @current ||= []
4
4
  end
5
- def suggestions= arr
6
- @suggestions = arr
5
+
6
+ def future
7
+ @future ||= []
7
8
  end
8
- def suggest command
9
- if !suggestions.include?(command)
10
- suggestions.push command
11
- end
9
+
10
+ def update
11
+ current.clear
12
+ current.concat future
13
+ puts current.join(',')
14
+ future.clear
12
15
  end
13
- def self.automatic?
14
- if @automatic.nil?
15
- @automatic = false
16
- end
17
- @automatic
16
+
17
+ def clear
18
+ current.clear
19
+ future.clear
18
20
  end
19
- def self.automatic= bool
20
- @automatic = bool
21
+ end
22
+
23
+ module Gamefic::Suggestible
24
+ def suggestions
25
+ @suggestions ||= Gamefic::Suggestions.new
26
+ end
27
+
28
+ def suggest command
29
+ suggestions.future.push command unless suggestions.future.include? command
21
30
  end
22
31
  end
23
32
 
@@ -26,17 +35,20 @@ class Gamefic::Character
26
35
  serialize :suggestions
27
36
  end
28
37
 
29
- on_update do
38
+ on_ready do
30
39
  players.each { |player|
31
- if Suggestible.automatic? and player.suggestions.length > 0
32
- player.suggestions.each { |s|
33
- player.stream "<a class=\"suggestion\" href=\"#\" rel=\"gamefic\" data-command=\"#{s.cap_first}\">#{s.cap_first}</a>"
34
- }
40
+ if player.scene == :active or player.next_scene == :active
41
+ player.suggestions.update
42
+ else
43
+ player.suggestions.clear
35
44
  end
36
- #player.suggestions.clear
37
45
  }
38
46
  end
39
47
 
40
- before_player_update do |player|
41
- player.suggestions.clear
48
+ respond :suggest do |actor|
49
+ actor.stream '<ul>'
50
+ actor.suggestions.current.sort.each { |s|
51
+ actor.stream "<li>#{s}</li>"
52
+ }
53
+ actor.stream '</ul>'
42
54
  end
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.4.0
4
+ version: 1.4.1
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-02-01 00:00:00.000000000 Z
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic