gamefic 0.0.3 → 0.0.4

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: 455d6e35dc1a52a6bb5199fc7149ed0fa63a78b6
4
- data.tar.gz: e9fca3998e0753390c5e10e83c2ecfee28313f8f
3
+ metadata.gz: 19a80c1e4f84828c7b2bf27709fbb2c37c90100b
4
+ data.tar.gz: 63e7a3a0062cb167a9b363083bf34700783240b8
5
5
  SHA512:
6
- metadata.gz: cbcfef9ac4c0ae7b970048c13c2a5fb8a0efd636918d41e0aedc2a64956a3576ce07ebaf163a199a70df6f7fedc550c074f90fa1e9ec3fb732c3aa060968ddb9
7
- data.tar.gz: 6200517ed19c41d98a9d881b799cf843211a1a20128852a194ad22a775fc7b2b9761ab7c7a07cdf4f0b299fc7a18acd28f7bbacd341edb5953ad82436ceeb923
6
+ metadata.gz: e570aa3a5de2f2e321593e2eeb9fc239d12e30fecf2f9a235fe02fca947c084cf99c152c6f7ece6bf10dcc8bc1c9f0879aa0ddf82185b4cadd2d397d129278d1
7
+ data.tar.gz: 43ea2d63958bd7570b3c955dc5b364da94c8a3cb1314e32730e0252ca9508205cd450884b1d2dda0cb756df67e97d539277f0f78379baf47c4db42a5354f6602
@@ -1,9 +1,12 @@
1
1
  module Gamefic
2
2
 
3
3
  class Action
4
- attr_reader :command
4
+ attr_reader :command, :order_key
5
5
  @@defaults = Array.new
6
+ @@order_key_seed = 0
6
7
  def initialize(story, command, *queries, &proc)
8
+ @order_key = @@order_key_seed
9
+ @@order_key_seed += 1
7
10
  if (command.kind_of?(Symbol) == false)
8
11
  raise "Action commands must be symbols"
9
12
  end
@@ -1,7 +1,7 @@
1
1
  module Gamefic
2
2
 
3
3
  class Character < Entity
4
- attr_reader :state, :queue, :user
4
+ attr_reader :state, :queue, :user, :last_command
5
5
  def initialize(plot, args = {})
6
6
  @state = CharacterState.new(self)
7
7
  @queue = Array.new
@@ -18,6 +18,7 @@ module Gamefic
18
18
  #if command != nil
19
19
  # @queue.push command
20
20
  #end
21
+ @last_command = command
21
22
  if state.busy? == false
22
23
  Director.dispatch(self, command)
23
24
  else
data/lib/gamefic/plot.rb CHANGED
@@ -136,12 +136,13 @@ module Gamefic
136
136
  end
137
137
  @commands[action.command].unshift action
138
138
  @commands[action.command].sort! { |a, b|
139
- if a.specificity == b.specificity
140
- # For actions of the same length, creation order takes precedence
141
- 0
142
- else
143
- b.specificity <=> a.specificity
144
- end
139
+ if a.specificity == b.specificity
140
+ # Newer action takes precedence
141
+ b.order_key <=> a.order_key
142
+ else
143
+ # Higher specificity takes precedence
144
+ b.specificity <=> a.specificity
145
+ end
145
146
  }
146
147
  user_friendly = action.command.to_s.sub(/_/, ' ')
147
148
  args = Array.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An adventure game engine
14
14
  email: fsnyder@gamefic.com