gamefic-sdk 1.4.1 → 1.5.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: 642000755606d5f202c09b54f2a11c5fb238601e
4
- data.tar.gz: 9040ce5b78583d05074cd808719ee60f0ddef910
3
+ metadata.gz: f20b6887b332594e4cde84b2d7f0d9025a166c0b
4
+ data.tar.gz: 05c6b161dd96f67108d10eb8feeeae723f118f82
5
5
  SHA512:
6
- metadata.gz: 9b4aea3ba1aa82775669c862679de3cbf36b1aa1eb38fa63355ba49f0916d1972f25212f4626b3890fe66168aff5cbd422aea042970f7969abbbcca6c44a10c5
7
- data.tar.gz: dcbc83828cdba3f965aa1256e42406a0e664b9bc50b3dc31f2e0bbededdfdf4e7af5640544cec5be389c33714cae3990a957a06621d47e2ed82197550c109ad8
6
+ metadata.gz: c12d01760d7f7867221d9dc2edc6b6a6d03466d1135f12d57e5adc780de09ea851f0b966b1e502163c2f6125ace483dc047d3e165d41bb7d8f20728acca45a58
7
+ data.tar.gz: 46b23e73019583f9ff5abb4943c6e401fc27b82bd9432386ed93005c9842797f05847193168f3aa57e8037ff4b804591342895af2506fa8b6ab5cf6ccbe82669
data/html/core/engine.js CHANGED
@@ -8,7 +8,8 @@ var Gamefic = (function() {
8
8
  var getResponse = function(withOutput) {
9
9
  var r = {
10
10
  output: (withOutput ? Opal.GameficOpal.$static_user().$flush() : null),
11
- state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$type(),
11
+ //state: Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$type(),
12
+ state: Opal.GameficOpal.$static_character().$scene().$type(),
12
13
  prompt: lastPrompt,
13
14
  input: lastInput,
14
15
  testing: (Opal.GameficOpal.$static_character().$queue().$length() > 0)
@@ -28,7 +29,7 @@ var Gamefic = (function() {
28
29
  start: function() {
29
30
  Opal.GameficOpal.$load_scripts();
30
31
  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
+ lastPrompt = Opal.GameficOpal.$static_character().$prompt();
32
33
  this.update('');
33
34
  },
34
35
  update: function(input) {
@@ -42,11 +43,11 @@ var Gamefic = (function() {
42
43
  });
43
44
  Opal.GameficOpal.$static_plot().$update();
44
45
  Opal.GameficOpal.$static_plot().$ready();
45
- lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
46
+ lastPrompt = Opal.GameficOpal.$static_character().$prompt();
46
47
  response = getResponse(true);
47
48
  var updateResponse = response;
48
49
  doReady(response);
49
- lastPrompt = Opal.GameficOpal.$static_plot().$scenes().$fetch(Opal.GameficOpal.$static_character().$scene()).$prompt_for(Opal.GameficOpal.$static_character());
50
+ lastPrompt = Opal.GameficOpal.$static_character().$prompt();
50
51
  response = getResponse(true);
51
52
  response.output = updateResponse.output + response.output;
52
53
  handle(response);
data/lib/gamefic-sdk.rb CHANGED
@@ -20,7 +20,7 @@ class Class
20
20
  end
21
21
  end
22
22
 
23
- class Entity
23
+ class Gamefic::Entity
24
24
  def self.names
25
25
  result = []
26
26
  Entity.descendants.each { |e| result << e.to_s.split('::').last }
@@ -16,7 +16,7 @@ module Gamefic::Sdk::Debug
16
16
  end
17
17
  def action(command, *queries, &proc)
18
18
  act = Gamefic::Sdk::Debug::Action.new(command, *queries, &proc)
19
- add_action act
19
+ playbook.send :add_action, act
20
20
  act
21
21
  end
22
22
  end
@@ -2,6 +2,7 @@
2
2
  require 'gamefic/query/expression'
3
3
  require 'gamefic/query/matches'
4
4
  require 'gamefic/grammar/verb_set'
5
+ require 'gamefic/plot/playbook'
5
6
 
6
7
  # HACK Opal doesn't recognize classes and modules declared from scripts
7
8
  def Object.const_missing sym
@@ -30,7 +31,7 @@ module GameficOpal
30
31
 
31
32
  class WebUser < Gamefic::User::Base
32
33
  def save filename, data
33
- data[:metadata] = GameficOpal.static_character.plot.metadata
34
+ data[:metadata] = GameficOpal.static_plot.metadata
34
35
  `Gamefic.save(filename, data);`
35
36
  end
36
37
  def restore filename
@@ -1,5 +1,5 @@
1
1
  module Gamefic
2
2
  module Sdk
3
- VERSION = '1.4.1'
3
+ VERSION = '1.5.0'
4
4
  end
5
5
  end
@@ -15,5 +15,5 @@ end
15
15
 
16
16
  respond :eat, Use.reachable(:edible?) do |actor, item|
17
17
  actor.tell "You eat #{the item}."
18
- item.destroy
18
+ destroy item
19
19
  end
@@ -5,8 +5,8 @@
5
5
 
6
6
  script 'standard/use'
7
7
  script 'standard/modules'
8
+ script 'standard/direction'
8
9
  script 'standard/entities'
9
10
  script 'standard/queries'
10
11
  script 'standard/actions'
11
- script 'standard/rules'
12
12
  script 'standard/pathfinder'
@@ -1,6 +1,7 @@
1
1
  meta nil, Query::Text.new() do |actor, string|
2
2
  words = string.split_words
3
- if commandwords.include?(words[0])
3
+ list = verbs(to_s: true)
4
+ if list.include?(words[0])
4
5
  if words.length > 1
5
6
  actor.tell "I recognize '#{words[0]}' as a verb but could not understand the rest of your sentence."
6
7
  else
@@ -8,7 +9,7 @@ meta nil, Query::Text.new() do |actor, string|
8
9
  end
9
10
  else
10
11
  found = []
11
- commandwords.each { |c|
12
+ list.each { |c|
12
13
  next if c.include?('_')
13
14
  if c.length > words[0].length and c.start_with?(words[0])
14
15
  found.push c
@@ -27,7 +28,7 @@ end
27
28
 
28
29
  meta nil, Query::Text.new("it") do |actor, string|
29
30
  words = string.split_words
30
- if commandwords.include?(words[0])
31
+ if verbs(to_s: true).include?(words[0])
31
32
  actor.tell "I'm not sure what you mean by \"it.\""
32
33
  else
33
34
  actor.proceed
@@ -1,11 +1,11 @@
1
- yes_or_no :confirm_quit, 'Are you sure you want to quit?' do |actor, data|
1
+ confirm_quit = yes_or_no 'Are you sure you want to quit?' do |actor, data|
2
2
  if data.yes?
3
- actor.cue :concluded
3
+ actor.cue default_conclusion
4
4
  else
5
- actor.cue :active
5
+ actor.cue default_scene
6
6
  end
7
7
  end
8
8
 
9
9
  meta :quit do |actor|
10
- actor.cue :confirm_quit
10
+ actor.cue confirm_quit
11
11
  end
@@ -0,0 +1,56 @@
1
+ class ::Gamefic::Direction
2
+ attr_accessor :name, :adjective, :adverb, :reverse
3
+
4
+ def initialize args = {}
5
+ args.each { |key, value|
6
+ send "#{key}=", value
7
+ }
8
+ if !reverse.nil?
9
+ reverse.reverse = self
10
+ end
11
+ end
12
+
13
+ def adjective
14
+ @adjective || @name
15
+ end
16
+
17
+ def adverb
18
+ @adverb || @name
19
+ end
20
+
21
+ def reverse=(dir)
22
+ @reverse = dir
23
+ end
24
+
25
+ def synonyms
26
+ "#{adjective} #{adverb}"
27
+ end
28
+
29
+ def to_s
30
+ @name
31
+ end
32
+
33
+ class << self
34
+ def compass
35
+ if @compass.nil?
36
+ @compass = {}
37
+ @compass[:north] = Direction.new(:name => 'north', :adjective => 'northern')
38
+ @compass[:south] = Direction.new(:name => 'south', :adjective => 'southern', :reverse => @compass[:north])
39
+ @compass[:west] = Direction.new(:name => 'west', :adjective => 'western')
40
+ @compass[:east] = Direction.new(:name => 'east', :adjective => 'eastern', :reverse => @compass[:west])
41
+ @compass[:northwest] = Direction.new(:name => 'northwest', :adjective => 'northwestern')
42
+ @compass[:southeast] = Direction.new(:name => 'southeast', :adjective => 'southeastern', :reverse => @compass[:northwest])
43
+ @compass[:northeast] = Direction.new(:name => 'northeast', :adjective => 'northeastern')
44
+ @compass[:southwest] = Direction.new(:name => 'southwest', :adjective => 'southwestern', :reverse => @compass[:northeast])
45
+ @compass[:up] = Direction.new(:name => 'up', :adjective => 'upwards')
46
+ @compass[:down] = Direction.new(:name => 'down', :adjective => 'downwards', :reverse => @compass[:up])
47
+ end
48
+ @compass
49
+ end
50
+
51
+ def find(dir)
52
+ compass[dir.to_s.downcase.to_sym]
53
+ end
54
+ end
55
+
56
+ end
@@ -1,5 +1,5 @@
1
1
  class Gamefic::Portal < Gamefic::Entity
2
- attr_accessor :destination, :direction
2
+ attr_accessor :destination
3
3
  serialize :destination, :direction
4
4
 
5
5
  # Find the portal in the destination that returns to this portal's parent
@@ -27,6 +27,10 @@ class Gamefic::Portal < Gamefic::Entity
27
27
  @direction
28
28
  end
29
29
 
30
+ def direction= d
31
+ @direction = Direction.find(d)
32
+ end
33
+
30
34
  def name
31
35
  @name || direction.name
32
36
  end
@@ -31,22 +31,22 @@ class Gamefic::Room < Gamefic::Entity
31
31
  private
32
32
  def connect2 destination, direction:nil, type:Portal, two_way:true
33
33
  if direction.nil?
34
- portal = type.new self.plot, :parent => self, :destination => destination, :name => destination.definitely
34
+ portal = type.new :parent => self, :destination => destination, :name => destination.definitely
35
35
  if two_way == true
36
- portal2 = type.new self.plot, :parent => destination, :destination => self, :name => self.definitely
36
+ portal2 = type.new :parent => destination, :destination => self, :name => self.definitely
37
37
  end
38
38
  else
39
39
  if direction.kind_of?(String)
40
40
  direction = Direction.find(direction)
41
41
  end
42
- portal = type.new self.plot, :direction => direction, :parent => self, :destination => destination
42
+ portal = type.new :direction => direction, :parent => self, :destination => destination
43
43
  portal.proper_named = true if type == Portal
44
44
  if two_way == true
45
45
  reverse = direction.reverse
46
46
  if reverse == nil
47
47
  raise "#{direction.name.cap_first} does not have an opposite direction"
48
48
  end
49
- portal2 = type.new(self.plot, {
49
+ portal2 = type.new({
50
50
  :direction => reverse,
51
51
  :parent => destination,
52
52
  :destination => self
@@ -1,7 +1,7 @@
1
1
  class Gamefic::Supporter < Gamefic::Entity
2
2
  include Enterable
3
3
  serialize :enterable?
4
- def initialize(plot, args = {})
4
+ def initialize(args = {})
5
5
  self.enter_verb = "get on"
6
6
  self.leave_verb = "get off"
7
7
  self.inside_verb = "be on"
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.1
4
+ version: 1.5.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-02-02 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gamefic
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '1.5'
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: '1.2'
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +177,7 @@ files:
177
177
  - scripts/standard/actions/unlock.plot.rb
178
178
  - scripts/standard/actions/use.plot.rb
179
179
  - scripts/standard/actions/wait.plot.rb
180
+ - scripts/standard/direction.plot.rb
180
181
  - scripts/standard/entities.plot.rb
181
182
  - scripts/standard/entities/character.plot.rb
182
183
  - scripts/standard/entities/container.plot.rb
@@ -221,8 +222,6 @@ files:
221
222
  - scripts/standard/queries/reachable.plot.rb
222
223
  - scripts/standard/queries/room.plot.rb
223
224
  - scripts/standard/queries/visible.plot.rb
224
- - scripts/standard/rules.plot.rb
225
- - scripts/standard/rules/has-enough-light.plot.rb
226
225
  - scripts/standard/test.plot.rb
227
226
  - scripts/standard/use.plot.rb
228
227
  - scripts/suggestible.plot.rb
@@ -1 +0,0 @@
1
- script 'standard/rules/has-enough-light'
@@ -1,12 +0,0 @@
1
- assert_action :has_enough_light do |actor, action|
2
- if !actor.nil? or actor.room.is? :lighted
3
- true
4
- else
5
- if action == :go
6
- true
7
- else
8
- actor.tell "It's too dark in here."
9
- false
10
- end
11
- end
12
- end