gameworks 1.0.1 → 2.0.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: df917ca798961d763e0a0767a16e65754d6d6153
4
- data.tar.gz: 4a5afc01de838e342c9fee794ba576741ee3002a
3
+ metadata.gz: 8af89aede594bc27285d2a3c08d9e02257a6b184
4
+ data.tar.gz: d12c91d8de8d29b506f03c1450c0e68059a73854
5
5
  SHA512:
6
- metadata.gz: 82b73405e851e4e98a1758a2b42e2baf122243c8b93b611f7c57579bf0f3d75d5e558cc2b16e6250670ec6e2c7749768420e4d5046ed13cbaec32d257ca2b645
7
- data.tar.gz: 45115aec3dd59ea486da297686beaede76c34c3b08020605df97022dabe379d3b9c17ab3e1c0893580465f517ec9653f23f9d056efbcfb80a3d53f41bebb64d7
6
+ metadata.gz: 8cc7293bf7d3b9db2bfc1b0876124d0bf96dcf6484a3b00d965ae0852179a1fb4dc8734d206b2361445eebc3ad0acc0c4a1030f58da3d50bc45cceb85b814e9c
7
+ data.tar.gz: 51bf5e753319b8726d6fd22d4838703d0466fc4126037eec5b5bb3c6fd2ed646dc46ac8823ca04d3975ebd402d33110e5222c368176d756b5678dafdedf08c3c
data/README CHANGED
@@ -21,9 +21,11 @@ name of the new player. the game engine may extend this.
21
21
  == Player (response)
22
22
 
23
23
  {name: <string>,
24
- score: <integer> or 'disqualified'}
24
+ score: <integer>,
25
+ disqualified: <boolean>}
25
26
 
26
- name and current score of the player. the game engine may extend this.
27
+ name, current score, and disqualified status of the player. the game engine may
28
+ extend this.
27
29
 
28
30
  == New Game (request)
29
31
 
@@ -110,6 +110,8 @@ module Gameworks
110
110
  active_players.each do |player|
111
111
  token = generate_uuid
112
112
  @turns[token] = player
113
+ # This may no longer be necessary, since we abort the players' fuses
114
+ # when they submit turns in #add_move.
113
115
  @fuses[player].abort if @fuses[player]
114
116
  @fuses[player] = Gameworks::Fuse.new(TURN_TIME_LIMIT) { disqualify(player) }
115
117
  player.signal_turn(token)
@@ -121,6 +123,8 @@ module Gameworks
121
123
  end
122
124
 
123
125
  def add_move(payload, player)
126
+ @fuses[player].abort
127
+
124
128
  move, error = build_move(payload, player)
125
129
  return false, error unless move
126
130
  legal, error = move_legal?(move, player)
@@ -145,7 +149,7 @@ module Gameworks
145
149
  end
146
150
 
147
151
  def disqualify(player)
148
- player.score = 'disqualified'
152
+ player.disqualify!
149
153
  update_observers
150
154
  if @players.select { |p| !p.disqualified? }.size < 2
151
155
  end_game
@@ -4,6 +4,7 @@ module Gameworks
4
4
  class Player
5
5
  attr_reader :name
6
6
  attr_accessor :score
7
+ attr_reader :disqualified
7
8
 
8
9
  def initialize(payload={})
9
10
  unless payload.is_a?(Hash) &&
@@ -15,6 +16,7 @@ module Gameworks
15
16
 
16
17
  @name = payload['name']
17
18
  @score = 0
19
+ @disqualified = false
18
20
 
19
21
  # used for evented "block until it's my turn". the game will push a token
20
22
  # on this queue when it's the player's turn, or will push a nil when the
@@ -26,8 +28,10 @@ module Gameworks
26
28
  !@invalid
27
29
  end
28
30
 
29
- def disqualified?
30
- @score == 'disqualified'
31
+ alias_method :disqualified?, :disqualified
32
+
33
+ def disqualify!
34
+ @disqualified = true
31
35
  end
32
36
 
33
37
  def signal_turn(token)
@@ -39,8 +43,9 @@ module Gameworks
39
43
  end
40
44
 
41
45
  def as_json(for_player=nil)
42
- { :name => @name,
43
- :score => @score }
46
+ { name: name,
47
+ score: score,
48
+ disqualified: disqualified }
44
49
  end
45
50
 
46
51
  def to_json(for_player=nil)
@@ -1,3 +1,3 @@
1
1
  module Gameworks
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gameworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Palmer