Allowing daemon export
[cartagena.git] / test / libcartagena_test.rb
1 # == Synopsis
2 #
3 # Unit tests for the libcartagena library
4 #
5 # == Author
6 # Neil Smith
7 #
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21 # == Change history
22 # Version 1.0:: 5 Dec 2008
23 # => * Initial build
24
25
26 $:.unshift File.join(File.dirname(__FILE__),'..','lib', 'libcartagena')
27
28 require 'test/unit'
29 require File.join(File.dirname(__FILE__), '..', 'lib', 'libcartagena')
30
31 class TileTest < Test::Unit::TestCase
32 def test_tile_init
33 front = [:hat, :keys, :gun, :bottle, :skull, :dagger]
34 back = [:gun, :hat, :dagger, :skull, :bottle, :keys]
35 assert_nothing_raised { Tile.new(front, back) }
36 tile = Tile.new(front, back)
37
38 assert_equal 6, tile.front.length
39 assert_equal 6, tile.back.length
40 assert_equal 6, tile.exposed.length
41 assert_equal front, tile.front.map {|p| p.symbol}
42 assert_equal back, tile.back.map {|p| p.symbol}
43 assert_equal front, tile.exposed.map {|p| p.symbol}
44
45 tile.flip!
46 assert_equal 6, tile.front.length
47 assert_equal 6, tile.back.length
48 assert_equal 6, tile.exposed.length
49 assert_equal front, tile.front.map {|p| p.symbol}
50 assert_equal back, tile.back.map {|p| p.symbol}
51 assert_equal back, tile.exposed.map {|p| p.symbol}
52
53 tile.flip!
54 assert_equal 6, tile.front.length
55 assert_equal 6, tile.back.length
56 assert_equal 6, tile.exposed.length
57 assert_equal front, tile.front.map {|p| p.symbol}
58 assert_equal back, tile.back.map {|p| p.symbol}
59 assert_equal front, tile.exposed.map {|p| p.symbol}
60
61 tile.flip!
62 tile.reverse!
63 assert_equal 6, tile.front.length
64 assert_equal 6, tile.back.length
65 assert_equal 6, tile.exposed.length
66 assert_equal front, tile.front.map {|p| p.symbol}
67 assert_equal back, tile.back.map {|p| p.symbol}
68 assert_equal back.reverse, tile.exposed.map {|p| p.symbol}
69
70 tile.flip!
71 assert_equal 6, tile.front.length
72 assert_equal 6, tile.back.length
73 assert_equal 6, tile.exposed.length
74 assert_equal front, tile.front.map {|p| p.symbol}
75 assert_equal back, tile.back.map {|p| p.symbol}
76 assert_equal front, tile.exposed.map {|p| p.symbol}
77
78 tile.reverse!
79 assert_equal 6, tile.front.length
80 assert_equal 6, tile.back.length
81 assert_equal 6, tile.exposed.length
82 assert_equal front, tile.front.map {|p| p.symbol}
83 assert_equal back, tile.back.map {|p| p.symbol}
84 assert_equal front.reverse, tile.exposed.map {|p| p.symbol}
85
86 end
87 end
88
89 class BoardTest < Test::Unit::TestCase
90 def test_board_init
91 assert_nothing_raised { Board.new(6) }
92 board = Board.new(1)
93 assert_equal 1, board.tiles.length
94 assert_equal 8, board.positions.length
95
96 board = Board.new(6)
97 assert_equal 6, board.tiles.length
98 assert_equal 38, board.positions.length
99
100 0.upto(5) do |i|
101 start = i * 6 + 1
102 slice = board.positions[start..(start+5)]
103 $SYMBOLS.each do |tile|
104 assert_equal 1, (slice.find_all {|p| p.symbol == tile}).length
105 end
106 end
107 end
108 end
109
110
111 class GameTest < Test::Unit::TestCase
112 def test_game_init
113 assert_nothing_raised { Game.new }
114
115 game = Game.new(6)
116 assert_equal 6, game.players.length
117 0.upto(5) do |i|
118 assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
119 end
120 assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 6 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
121 end
122
123 def test_game_setting
124 game = Game.new(5,6,6)
125 game.set_testing_game!
126 game.pieces.each do |player|
127 player.each do |piece|
128 assert_equal game.board.positions[0], piece.position
129 end
130 end
131 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
132 :keys, :dagger, :skull, :hat, :gun, :bottle,
133 :dagger, :bottle, :keys, :gun, :hat, :skull,
134 :dagger, :skull, :bottle, :gun, :keys, :hat,
135 :hat, :dagger, :keys, :bottle, :gun, :skull,
136 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
137 game.board.positions.collect {|p| p.symbol}
138 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
139 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
140 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
141 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
142 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
143 # assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
144 assert_equal 5, game.players_cards.length
145 assert_equal 5, game.players.length
146 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
147 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
148 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
149 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
150 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
151 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
152 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
153 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
154 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
155 :gun, :skull, :keys, :bottle, :skull],
156 game.deck
157 assert_equal 0, game.moves_by_current_player
158 assert_equal 18, game.possible_moves.length
159 game.apply_move!(game.possible_moves[0])
160 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
161 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
162 assert_equal 87, game.deck.length
163
164 assert_equal 1, game.moves_by_current_player
165 assert_equal 12, game.possible_moves.length
166 game.apply_move!(game.possible_moves[3])
167 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
168 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
169 assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
170 assert_equal 87, game.deck.length
171
172 assert_equal 2, game.moves_by_current_player
173 assert_equal 7, game.possible_moves.length
174 game.apply_move!(game.possible_moves[2])
175 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
176 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
177 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
178 assert_equal 86, game.deck.length
179
180 game.reset_current_player 0 # Needed to prevent errors below
181
182 assert_equal 0, game.moves_by_current_player
183 assert_equal 12, game.possible_moves.length
184 game.apply_move!(game.possible_moves[-1])
185 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
186 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
187 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
188 assert_equal 5, game.board.positions.index(game.pieces[0][5].position)
189 assert_equal 86, game.deck.length
190
191 assert_equal 1, game.moves_by_current_player
192 assert_equal 7, game.possible_moves.length
193 game.apply_move!(game.possible_moves[-1])
194 assert_equal [:bottle, :hat, :keys], game.players_cards[0].sort_by {|c| c.to_s}
195 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
196 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
197 assert_equal 1, game.board.positions.index(game.pieces[0][5].position)
198 assert_equal 84, game.deck.length
199 end
200
201 def test_game_termination
202 game = Game.new(6)
203 game.set_testing_game!
204 assert_equal 0, game.moves_by_current_player
205
206 game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[0], game.board.positions[36]), 0, false)
207 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
208 assert game.board.positions[36].contains.include?(game.pieces[0][0])
209 assert game.board.positions[0].contains.include?(game.pieces[0][1])
210 assert game.board.positions[0].contains.include?(game.pieces[0][2])
211 assert game.board.positions[0].contains.include?(game.pieces[0][3])
212 assert game.board.positions[0].contains.include?(game.pieces[0][4])
213 assert game.board.positions[0].contains.include?(game.pieces[0][5])
214 assert_equal 18, game.possible_moves.length
215
216 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[0], game.board.positions[35]), 0, false)
217 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
218 assert game.board.positions[36].contains.include?(game.pieces[0][0])
219 assert game.board.positions[35].contains.include?(game.pieces[0][1])
220 assert game.board.positions[0].contains.include?(game.pieces[0][2])
221 assert game.board.positions[0].contains.include?(game.pieces[0][3])
222 assert game.board.positions[0].contains.include?(game.pieces[0][4])
223 assert game.board.positions[0].contains.include?(game.pieces[0][5])
224 assert_equal 19, game.possible_moves.length
225
226 game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[0], game.board.positions[34]), 0, false)
227 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
228 assert game.board.positions[36].contains.include?(game.pieces[0][0])
229 assert game.board.positions[35].contains.include?(game.pieces[0][1])
230 assert game.board.positions[34].contains.include?(game.pieces[0][2])
231 assert game.board.positions[0].contains.include?(game.pieces[0][3])
232 assert game.board.positions[0].contains.include?(game.pieces[0][4])
233 assert game.board.positions[0].contains.include?(game.pieces[0][5])
234 assert_equal 20, game.possible_moves.length
235
236 game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[0], game.board.positions[33]), 0, false)
237 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
238 assert game.board.positions[36].contains.include?(game.pieces[0][0])
239 assert game.board.positions[35].contains.include?(game.pieces[0][1])
240 assert game.board.positions[34].contains.include?(game.pieces[0][2])
241 assert game.board.positions[33].contains.include?(game.pieces[0][3])
242 assert game.board.positions[0].contains.include?(game.pieces[0][4])
243 assert game.board.positions[0].contains.include?(game.pieces[0][5])
244 assert_equal 21, game.possible_moves.length
245
246 game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[0], game.board.positions[32]), 0, false)
247 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
248 assert game.board.positions[36].contains.include?(game.pieces[0][0])
249 assert game.board.positions[35].contains.include?(game.pieces[0][1])
250 assert game.board.positions[34].contains.include?(game.pieces[0][2])
251 assert game.board.positions[33].contains.include?(game.pieces[0][3])
252 assert game.board.positions[32].contains.include?(game.pieces[0][4])
253 assert game.board.positions[0].contains.include?(game.pieces[0][5])
254 assert_equal 22, game.possible_moves.length
255
256 game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[0], game.board.positions[31]), 0, false)
257 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
258 assert game.board.positions[36].contains.include?(game.pieces[0][0])
259 assert game.board.positions[35].contains.include?(game.pieces[0][1])
260 assert game.board.positions[34].contains.include?(game.pieces[0][2])
261 assert game.board.positions[33].contains.include?(game.pieces[0][3])
262 assert game.board.positions[32].contains.include?(game.pieces[0][4])
263 assert game.board.positions[31].contains.include?(game.pieces[0][5])
264 assert_equal 23, game.possible_moves.length
265
266 # Now start moving pices onto the boat
267 game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[31], game.board.positions[37]), 0, false)
268 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
269 assert game.board.positions[36].contains.include?(game.pieces[0][0])
270 assert game.board.positions[35].contains.include?(game.pieces[0][1])
271 assert game.board.positions[34].contains.include?(game.pieces[0][2])
272 assert game.board.positions[33].contains.include?(game.pieces[0][3])
273 assert game.board.positions[32].contains.include?(game.pieces[0][4])
274 assert game.board.positions[37].contains.include?(game.pieces[0][5])
275 assert_equal 20, game.possible_moves.length
276
277 game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[32], game.board.positions[37]), 0, false)
278 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
279 assert game.board.positions[36].contains.include?(game.pieces[0][0])
280 assert game.board.positions[35].contains.include?(game.pieces[0][1])
281 assert game.board.positions[34].contains.include?(game.pieces[0][2])
282 assert game.board.positions[33].contains.include?(game.pieces[0][3])
283 assert game.board.positions[37].contains.include?(game.pieces[0][4])
284 assert game.board.positions[37].contains.include?(game.pieces[0][5])
285 assert_equal 17, game.possible_moves.length
286
287 game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[33], game.board.positions[37]), 0, false)
288 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
289 assert game.board.positions[36].contains.include?(game.pieces[0][0])
290 assert game.board.positions[35].contains.include?(game.pieces[0][1])
291 assert game.board.positions[34].contains.include?(game.pieces[0][2])
292 assert game.board.positions[37].contains.include?(game.pieces[0][3])
293 assert game.board.positions[37].contains.include?(game.pieces[0][4])
294 assert game.board.positions[37].contains.include?(game.pieces[0][5])
295 assert_equal 14, game.possible_moves.length
296
297 game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[34], game.board.positions[37]), 0, false)
298 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
299 assert game.board.positions[36].contains.include?(game.pieces[0][0])
300 assert game.board.positions[35].contains.include?(game.pieces[0][1])
301 assert game.board.positions[37].contains.include?(game.pieces[0][2])
302 assert game.board.positions[37].contains.include?(game.pieces[0][3])
303 assert game.board.positions[37].contains.include?(game.pieces[0][4])
304 assert game.board.positions[37].contains.include?(game.pieces[0][5])
305 assert_equal 11, game.possible_moves.length
306
307 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[35], game.board.positions[37]), 0, false)
308 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
309 assert game.board.positions[36].contains.include?(game.pieces[0][0])
310 assert game.board.positions[37].contains.include?(game.pieces[0][1])
311 assert game.board.positions[37].contains.include?(game.pieces[0][2])
312 assert game.board.positions[37].contains.include?(game.pieces[0][3])
313 assert game.board.positions[37].contains.include?(game.pieces[0][4])
314 assert game.board.positions[37].contains.include?(game.pieces[0][5])
315 assert_equal 8, game.possible_moves.length
316
317 assert_raise(GameWonNotice) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[36], game.board.positions[37]), 0, false)}
318
319 end
320
321 def test_retreats
322 game = Game.new(5,6,6)
323 game.set_testing_game!
324
325 game.pieces.each do |player|
326 player.each do |piece|
327 assert_equal game.board.positions[0], piece.position
328 end
329 end
330 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
331 :keys, :dagger, :skull, :hat, :gun, :bottle,
332 :dagger, :bottle, :keys, :gun, :hat, :skull,
333 :dagger, :skull, :bottle, :gun, :keys, :hat,
334 :hat, :dagger, :keys, :bottle, :gun, :skull,
335 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
336 game.board.positions.collect {|p| p.symbol}
337 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
338 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
339 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
340 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
341 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
342 # assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
343 assert_equal 5, game.players_cards.length
344 assert_equal 5, game.players.length
345 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
346 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
347 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
348 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
349 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
350 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
351 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
352 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
353 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
354 :gun, :skull, :keys, :bottle, :skull],
355 game.deck
356 assert_equal 0, game.moves_by_current_player
357 assert_equal 18, game.possible_moves.length
358 game.apply_move!(game.possible_moves[0])
359 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
360 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
361 assert_equal 87, game.deck.length
362
363 assert_equal 1, game.moves_by_current_player
364 assert_equal 12, game.possible_moves.length
365 game.apply_move!(game.possible_moves[3])
366 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
367 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
368 assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
369 assert_equal 87, game.deck.length
370
371 # Test can't retreat into the cell
372 assert_equal 2, game.moves_by_current_player
373 assert_equal 7, game.possible_moves.length
374 assert_raise(InvalidMoveError) do
375 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[5], game.board.positions[0]))
376 end
377 end
378
379 # Test invalid move error trapping
380 def test_invalid_move_error_trapping
381 game = Game.new(5,6,6)
382 game.set_testing_game!
383
384 game.pieces.each do |player|
385 player.each do |piece|
386 assert_equal game.board.positions[0], piece.position
387 end
388 end
389 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
390 :keys, :dagger, :skull, :hat, :gun, :bottle,
391 :dagger, :bottle, :keys, :gun, :hat, :skull,
392 :dagger, :skull, :bottle, :gun, :keys, :hat,
393 :hat, :dagger, :keys, :bottle, :gun, :skull,
394 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
395 game.board.positions.collect {|p| p.symbol}
396 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
397 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
398 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
399 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
400 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
401 assert_equal 5, game.players_cards.length
402 assert_equal 5, game.players.length
403 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
404 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
405 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
406 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
407 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
408 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
409 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
410 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
411 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
412 :gun, :skull, :keys, :bottle, :skull],
413 game.deck
414 assert_equal 0, game.moves_by_current_player
415
416 # Test if can move to a space without the right card
417 assert_raise(InvalidMoveError) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[2], game.board.positions[0]))}
418
419
420 # Apply a series of moves to get an interesting game state
421 game.apply_move!('0 0 5'.to_move(game))
422 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
423 game.apply_move!('0 0 4'.to_move(game))
424 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
425 game.apply_move!('0 5 4'.to_move(game))
426 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
427
428 game.next_player!
429 assert_equal 1, game.current_player
430 game.apply_move!('1 0 2'.to_move(game))
431 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
432 game.apply_move!('1 0 7'.to_move(game))
433 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
434 game.apply_move!('1 7 4'.to_move(game))
435 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
436
437 game.next_player!
438 assert_equal 2, game.current_player
439 game.apply_move!('2 0 7'.to_move(game))
440 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
441 game.apply_move!('2 0 10'.to_move(game))
442 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
443 game.apply_move!('2 0 6'.to_move(game))
444 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
445
446 game.next_player!
447 assert_equal 3, game.current_player
448 game.apply_move!('3 0 12'.to_move(game))
449 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
450 game.apply_move!('3 12 10'.to_move(game))
451 assert_equal [:skull, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
452 game.apply_move!('3 0 5'.to_move(game))
453 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
454
455 game.next_player!
456 assert_equal 4, game.current_player
457 game.apply_move!('4 0 12'.to_move(game))
458 assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
459 game.apply_move!('4 12 10'.to_move(game))
460 assert_equal [:dagger, :gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
461 game.apply_move!('4 0 3'.to_move(game))
462 assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
463
464 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
465 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
466 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
467 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
468 assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
469
470 game.next_player!
471 assert_equal 0, game.current_player
472
473 game.apply_move!('0 0 9'.to_move(game))
474 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
475 game.apply_move!('0 0 1'.to_move(game))
476 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
477 game.apply_move!('0 9 7'.to_move(game))
478 assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
479
480 game.next_player!
481 assert_equal 1, game.current_player
482 game.apply_move!('1 0 12'.to_move(game))
483 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
484 game.apply_move!('1 0 14'.to_move(game))
485 assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
486 game.apply_move!('1 12 7'.to_move(game))
487 assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
488
489 game.next_player!
490 assert_equal 2, game.current_player
491 game.apply_move!('2 6 5'.to_move(game))
492 assert_equal [:gun], game.players_cards[2].sort_by {|c| c.to_s}
493 game.apply_move!('2 0 11'.to_move(game))
494 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
495 game.apply_move!('2 11 5'.to_move(game))
496 assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
497
498 game.next_player!
499 assert_equal 3, game.current_player
500 game.apply_move!('3 0 9'.to_move(game))
501 assert_equal [:skull], game.players_cards[3].sort_by {|c| c.to_s}
502 game.apply_move!('3 0 18'.to_move(game))
503 assert_equal [], game.players_cards[3].sort_by {|c| c.to_s}
504 game.apply_move!('3 18 14'.to_move(game))
505 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
506
507 game.next_player!
508 assert_equal 4, game.current_player
509 game.apply_move!('4 0 11'.to_move(game))
510 assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
511 game.apply_move!('4 0 16'.to_move(game))
512 assert_equal [:gun], game.players_cards[4].sort_by {|c| c.to_s}
513 game.apply_move!('4 16 14'.to_move(game))
514 assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
515
516 assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
517 assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
518 assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
519 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
520 assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
521
522 game.next_player!
523 assert_equal 0, game.current_player
524
525 game.apply_move!('0 0 15'.to_move(game))
526 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
527 game.apply_move!('0 15 11'.to_move(game))
528 assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
529 game.apply_move!('0 11 9'.to_move(game))
530 assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
531
532 game.next_player!
533 assert_equal 1, game.current_player
534 game.apply_move!('1 0 15'.to_move(game))
535 assert_equal [:hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
536 game.apply_move!('1 0 17'.to_move(game))
537 assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
538 game.apply_move!('1 17 15'.to_move(game))
539 assert_equal [:keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
540
541 game.next_player!
542 assert_equal 2, game.current_player
543 game.apply_move!('2 0 23'.to_move(game))
544 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
545 game.apply_move!('2 23 15'.to_move(game))
546 assert_equal [:bottle, :dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
547 game.apply_move!('2 0 17'.to_move(game))
548 assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
549
550 game.next_player!
551 assert_equal 3, game.current_player
552 game.apply_move!('3 10 9'.to_move(game))
553 assert_equal [:bottle, :dagger, :hat], game.players_cards[3].sort_by {|c| c.to_s}
554 game.apply_move!('3 0 24'.to_move(game))
555 assert_equal [:bottle, :dagger], game.players_cards[3].sort_by {|c| c.to_s}
556 game.apply_move!('3 0 8'.to_move(game))
557 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
558
559 game.next_player!
560 assert_equal 4, game.current_player
561 game.apply_move!('4 0 16'.to_move(game))
562 assert_equal [:keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
563 game.apply_move!('4 16 11'.to_move(game))
564 assert_equal [:keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
565 game.apply_move!('4 11 10'.to_move(game))
566 assert_equal [:dagger, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
567
568 assert_equal 2, game.board.positions[ 0].contains.length
569 assert_equal 1, game.board.positions[ 1].contains.length
570 assert_equal 1, game.board.positions[ 2].contains.length
571 assert_equal 1, game.board.positions[ 3].contains.length
572 assert_equal 3, game.board.positions[ 4].contains.length
573 assert_equal 3, game.board.positions[ 5].contains.length
574 assert_equal 0, game.board.positions[ 6].contains.length
575 assert_equal 3, game.board.positions[ 7].contains.length
576 assert_equal 1, game.board.positions[ 8].contains.length
577 assert_equal 3, game.board.positions[ 9].contains.length
578 assert_equal 3, game.board.positions[10].contains.length
579 assert_equal 1, game.board.positions[11].contains.length
580 assert_equal 0, game.board.positions[12].contains.length
581 assert_equal 0, game.board.positions[13].contains.length
582 assert_equal 3, game.board.positions[14].contains.length
583 assert_equal 3, game.board.positions[15].contains.length
584 assert_equal 0, game.board.positions[16].contains.length
585 assert_equal 1, game.board.positions[17].contains.length
586 assert_equal 0, game.board.positions[18].contains.length
587 assert_equal 0, game.board.positions[19].contains.length
588 assert_equal 0, game.board.positions[20].contains.length
589 assert_equal 0, game.board.positions[21].contains.length
590 assert_equal 0, game.board.positions[22].contains.length
591 assert_equal 0, game.board.positions[23].contains.length
592 assert_equal 1, game.board.positions[24].contains.length
593 assert_equal 0, game.board.positions[25].contains.length
594 assert_equal 0, game.board.positions[26].contains.length
595 assert_equal 0, game.board.positions[27].contains.length
596 assert_equal 0, game.board.positions[28].contains.length
597 assert_equal 0, game.board.positions[29].contains.length
598 assert_equal 0, game.board.positions[30].contains.length
599 assert_equal 0, game.board.positions[31].contains.length
600 assert_equal 0, game.board.positions[32].contains.length
601 assert_equal 0, game.board.positions[33].contains.length
602 assert_equal 0, game.board.positions[34].contains.length
603 assert_equal 0, game.board.positions[35].contains.length
604 assert_equal 0, game.board.positions[36].contains.length
605 assert_equal 0, game.board.positions[37].contains.length
606
607 assert_raise(InvalidMoveError) {game.apply_move!('0 7 6'.to_move(game))} # can't retreat into an empty space
608 assert_raise(InvalidMoveError) {game.apply_move!('0 7 5'.to_move(game))} # can't retreat into a space with three men
609 assert_raise(InvalidMoveError) {game.apply_move!('0 1 0'.to_move(game))} # can't retreat into the boat
610 assert_raise(InvalidMoveError) {game.apply_move!('0 1 12'.to_move(game))} # can't skip a vacant space of this type
611 assert_raise(InvalidMoveError) {game.apply_move!('0 1 5'.to_move(game))} # can't advance to a space with three pirates
612 assert_raise(InvalidMoveError) {game.apply_move!('0 2 6'.to_move(game))} # can't move another's piece
613 assert_raise(InvalidMoveError) {game.apply_move!('0 9 9'.to_move(game))} # can't advance the same square
614 assert_raise(InvalidMoveError) {game.apply_move!('0 9 20'.to_move(game))} # can't skip a vacant space of this type
615
616 game.next_player!
617 assert_equal 0, game.current_player
618
619 game.apply_move!('0 0 18'.to_move(game))
620 assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
621 game.apply_move!('0 7 12'.to_move(game))
622 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
623 game.apply_move!('0 12 11'.to_move(game))
624 assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
625
626 game.next_player!
627 assert_equal 1, game.current_player
628 game.apply_move!('1 14 11'.to_move(game))
629 assert_equal [:dagger, :keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
630 game.apply_move!('1 2 23'.to_move(game))
631 assert_equal [:dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
632 game.apply_move!('1 15 14'.to_move(game))
633 assert_equal [:bottle, :bottle, :dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
634
635 game.next_player!
636 assert_equal 2, game.current_player
637 game.apply_move!('2 17 15'.to_move(game))
638 assert_equal [:bottle, :dagger, :dagger, :keys], game.players_cards[2].sort_by {|c| c.to_s}
639 game.apply_move!('2 5 27'.to_move(game))
640 assert_equal [:bottle, :dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
641 game.apply_move!('2 5 13'.to_move(game))
642 assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
643
644 game.next_player!
645 assert_equal 3, game.current_player
646 game.apply_move!('3 8 7'.to_move(game))
647 assert_equal [:bottle, :bottle, :hat], game.players_cards[3].sort_by {|c| c.to_s}
648 game.apply_move!('3 5 17'.to_move(game))
649 assert_equal [:bottle, :bottle], game.players_cards[3].sort_by {|c| c.to_s}
650 game.apply_move!('3 7 12'.to_move(game))
651 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
652
653 game.next_player!
654 assert_equal 4, game.current_player
655 game.apply_move!('4 0 8'.to_move(game))
656 assert_equal [:dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
657 game.apply_move!('4 8 7'.to_move(game))
658 assert_equal [:bottle, :dagger, :keys, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
659 game.apply_move!('4 3 31'.to_move(game))
660 assert_equal [:bottle, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
661
662
663 game.next_player!
664 assert_equal 0, game.current_player
665
666 game.apply_move!('0 18 17'.to_move(game))
667 assert_equal [:dagger, :gun], game.players_cards[0].sort_by {|c| c.to_s}
668 game.apply_move!('0 1 16'.to_move(game))
669 assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
670 game.apply_move!('0 17 16'.to_move(game))
671 assert_equal [:dagger, :skull], game.players_cards[0].sort_by {|c| c.to_s}
672
673 game.next_player!
674 assert_equal 1, game.current_player
675 game.apply_move!('1 4 37 keys'.to_move(game))
676 assert_equal [:bottle, :bottle, :dagger, :keys], game.players_cards[1].sort_by {|c| c.to_s}
677 game.apply_move!('1 7 4'.to_move(game))
678 assert_equal [:bottle, :bottle, :bottle, :dagger, :hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
679 game.apply_move!('1 4 37 keys'.to_move(game))
680 assert_equal [:bottle, :bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
681
682 game.next_player!
683 assert_equal 2, game.current_player
684 game.apply_move!('2 7 21'.to_move(game))
685 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
686 game.apply_move!('2 13 12'.to_move(game))
687 assert_equal [:dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
688 game.apply_move!('2 10 13'.to_move(game))
689 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
690
691 game.next_player!
692 assert_equal 3, game.current_player
693 game.apply_move!('3 17 16'.to_move(game))
694 assert_equal [:bottle, :hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
695 game.apply_move!('3 9 28'.to_move(game))
696 assert_equal [:hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
697 game.apply_move!('3 9 18'.to_move(game))
698 assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
699
700 game.next_player!
701 assert_equal 4, game.current_player
702 game.apply_move!('4 7 37 keys'.to_move(game))
703 assert_equal [:bottle, :dagger, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
704 game.apply_move!('4 11 10'.to_move(game))
705 assert_equal [:bottle, :dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
706 game.apply_move!('4 10 32'.to_move(game))
707 assert_equal [:dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
708
709
710 game.next_player!
711 assert_equal 0, game.current_player
712
713 game.apply_move!('0 11 10'.to_move(game))
714 assert_equal [:bottle, :dagger, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
715 game.apply_move!('0 4 8'.to_move(game))
716 assert_equal [:bottle, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
717 game.apply_move!('0 4 17'.to_move(game))
718 assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
719
720 game.next_player!
721 assert_equal 1, game.current_player
722 game.apply_move!('1 11 37 bottle'.to_move(game))
723 assert_equal [:bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
724 game.apply_move!('1 14 37 bottle'.to_move(game))
725 assert_equal [:bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
726 game.apply_move!('1 15 37 bottle'.to_move(game))
727 assert_equal [:dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
728
729 game.next_player!
730 assert_equal 2, game.current_player
731 game.apply_move!('2 13 12'.to_move(game))
732 assert_equal [:dagger, :gun, :hat], game.players_cards[2].sort_by {|c| c.to_s}
733 game.apply_move!('2 12 22 gun'.to_move(game))
734 assert_equal [:dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
735 game.apply_move!('2 12 25 hat'.to_move(game))
736 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
737
738 game.next_player!
739 assert_equal 3, game.current_player
740 game.apply_move!('3 16 15'.to_move(game))
741 assert_equal [:dagger, :gun, :hat], game.players_cards[3].sort_by {|c| c.to_s}
742 game.apply_move!('3 12 35 hat'.to_move(game))
743 assert_equal [:dagger, :gun], game.players_cards[3].sort_by {|c| c.to_s}
744 game.apply_move!('3 14 29 gun'.to_move(game))
745 assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
746
747 game.next_player!
748 assert_equal 4, game.current_player
749 game.apply_move!('4 10 20 skull'.to_move(game))
750 assert_equal [:dagger, :dagger, :gun, :skull], game.players_cards[4].sort_by {|c| c.to_s}
751 game.apply_move!('4 10 30 skull'.to_move(game))
752 assert_equal [:dagger, :dagger, :gun], game.players_cards[4].sort_by {|c| c.to_s}
753 game.apply_move!('4 14 36 gun'.to_move(game))
754 assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
755
756
757 game.next_player!
758 assert_equal 0, game.current_player
759
760 game.apply_move!('0 17 16'.to_move(game))
761 assert_equal [:bottle, :gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
762 game.apply_move!('0 8 33 skull'.to_move(game))
763 assert_equal [:bottle, :gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
764 game.apply_move!('0 9 17 hat'.to_move(game))
765 assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
766
767 game.next_player!
768 assert_equal 1, game.current_player
769 assert_raise(GameWonNotice) {game.apply_move!('1 23 37 hat'.to_move(game))}
770 assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
771
772 assert_equal 0, game.board.positions[ 0].contains.length
773 assert_equal 0, game.board.positions[ 1].contains.length
774 assert_equal 0, game.board.positions[ 2].contains.length
775 assert_equal 0, game.board.positions[ 3].contains.length
776 assert_equal 0, game.board.positions[ 4].contains.length
777 assert_equal 0, game.board.positions[ 5].contains.length
778 assert_equal 0, game.board.positions[ 6].contains.length
779 assert_equal 0, game.board.positions[ 7].contains.length
780 assert_equal 0, game.board.positions[ 8].contains.length
781 assert_equal 0, game.board.positions[ 9].contains.length
782 assert_equal 1, game.board.positions[10].contains.length
783 assert_equal 0, game.board.positions[11].contains.length
784 assert_equal 0, game.board.positions[12].contains.length
785 assert_equal 0, game.board.positions[13].contains.length
786 assert_equal 0, game.board.positions[14].contains.length
787 assert_equal 3, game.board.positions[15].contains.length
788 assert_equal 3, game.board.positions[16].contains.length
789 assert_equal 1, game.board.positions[17].contains.length
790 assert_equal 1, game.board.positions[18].contains.length
791 assert_equal 0, game.board.positions[19].contains.length
792 assert_equal 1, game.board.positions[20].contains.length
793 assert_equal 1, game.board.positions[21].contains.length
794 assert_equal 1, game.board.positions[22].contains.length
795 assert_equal 0, game.board.positions[23].contains.length
796 assert_equal 1, game.board.positions[24].contains.length
797 assert_equal 1, game.board.positions[25].contains.length
798 assert_equal 0, game.board.positions[26].contains.length
799 assert_equal 1, game.board.positions[27].contains.length
800 assert_equal 1, game.board.positions[28].contains.length
801 assert_equal 1, game.board.positions[29].contains.length
802 assert_equal 1, game.board.positions[30].contains.length
803 assert_equal 1, game.board.positions[31].contains.length
804 assert_equal 1, game.board.positions[32].contains.length
805 assert_equal 1, game.board.positions[33].contains.length
806 assert_equal 0, game.board.positions[34].contains.length
807 assert_equal 1, game.board.positions[35].contains.length
808 assert_equal 1, game.board.positions[36].contains.length
809 assert_equal 7, game.board.positions[37].contains.length
810
811 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
812 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
813 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
814 :hat, :gun, :skull, :keys, :gun, :skull, :gun],
815 game.deck
816
817 assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
818 assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
819 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
820 assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
821 assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
822
823 end
824 #
825 # : move without a card
826 # move to an occupied space
827 # retreat to an emtpy space
828 # retreat to an overfull space
829 # retreat to the cell with one pirate already in it
830
831
832 # Test current player switching
833
834 # Test undo moves
835
836 # Test file reading
837 # (need a full game file to read)
838
839 def test_undo
840 game = Game.new(5,6,6)
841 game.set_testing_game!
842 game.pieces.each do |player|
843 player.each do |piece|
844 assert_equal game.board.positions[0], piece.position
845 end
846 end
847 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
848 :keys, :dagger, :skull, :hat, :gun, :bottle,
849 :dagger, :bottle, :keys, :gun, :hat, :skull,
850 :dagger, :skull, :bottle, :gun, :keys, :hat,
851 :hat, :dagger, :keys, :bottle, :gun, :skull,
852 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
853 game.board.positions.collect {|p| p.symbol}
854 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
855 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
856 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
857 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
858 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
859 assert_equal 5, game.players_cards.length
860 assert_equal 5, game.players.length
861 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
862 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
863 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
864 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
865 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
866 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
867 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
868 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
869 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
870 :gun, :skull, :keys, :bottle, :skull],
871 game.deck
872
873 assert_equal 0, game.history.length
874
875 game.apply_move!('0 0 5'.to_move(game))
876 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
877 assert_equal 1, game.history.length
878 game.apply_move!('0 0 4'.to_move(game))
879 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
880 assert_equal 2, game.history.length
881 game.apply_move!('0 5 4'.to_move(game))
882 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
883 assert_equal 3, game.history.length
884
885 game.next_player!
886 assert_equal 1, game.current_player
887 assert_equal 3, game.history.length
888 game.apply_move!('1 0 2'.to_move(game))
889 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
890 assert_equal 4, game.history.length
891 game.apply_move!('1 0 7'.to_move(game))
892 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
893 assert_equal 5, game.history.length
894 game.apply_move!('1 7 4'.to_move(game))
895 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
896 assert_equal 6, game.history.length
897 assert_equal 1, game.current_player
898 assert_equal 3, game.moves_by_current_player
899
900 assert_equal 26, game.board.positions[ 0].contains.length
901 assert_equal 0, game.board.positions[ 1].contains.length
902 assert_equal 1, game.board.positions[ 2].contains.length
903 assert_equal 0, game.board.positions[ 3].contains.length
904 assert_equal 3, game.board.positions[ 4].contains.length
905 assert_equal 0, game.board.positions[ 5].contains.length
906 assert_equal 0, game.board.positions[ 6].contains.length
907 assert_equal 0, game.board.positions[ 7].contains.length
908 assert_equal 0, game.board.positions[ 8].contains.length
909 assert_equal 0, game.board.positions[ 9].contains.length
910 assert_equal 0, game.board.positions[10].contains.length
911 assert_equal 0, game.board.positions[11].contains.length
912 assert_equal 0, game.board.positions[12].contains.length
913 assert_equal 0, game.board.positions[13].contains.length
914 assert_equal 0, game.board.positions[14].contains.length
915 assert_equal 0, game.board.positions[15].contains.length
916 assert_equal 0, game.board.positions[16].contains.length
917 assert_equal 0, game.board.positions[17].contains.length
918 assert_equal 0, game.board.positions[18].contains.length
919 assert_equal 0, game.board.positions[19].contains.length
920 assert_equal 0, game.board.positions[20].contains.length
921 assert_equal 0, game.board.positions[21].contains.length
922 assert_equal 0, game.board.positions[22].contains.length
923 assert_equal 0, game.board.positions[23].contains.length
924 assert_equal 0, game.board.positions[24].contains.length
925 assert_equal 0, game.board.positions[25].contains.length
926 assert_equal 0, game.board.positions[26].contains.length
927 assert_equal 0, game.board.positions[27].contains.length
928 assert_equal 0, game.board.positions[28].contains.length
929 assert_equal 0, game.board.positions[29].contains.length
930 assert_equal 0, game.board.positions[30].contains.length
931 assert_equal 0, game.board.positions[31].contains.length
932 assert_equal 0, game.board.positions[32].contains.length
933 assert_equal 0, game.board.positions[33].contains.length
934 assert_equal 0, game.board.positions[34].contains.length
935 assert_equal 0, game.board.positions[35].contains.length
936 assert_equal 0, game.board.positions[36].contains.length
937 assert_equal 0, game.board.positions[37].contains.length
938
939 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
940 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
941 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
942 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
943 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
944 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
945 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
946 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
947 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
948 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
949 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
950 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
951 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
952 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
953 :gun, :skull],
954 game.deck
955
956 game.undo_move! # player 1's third move
957
958 assert_equal 5, game.history.length
959
960 assert_equal 26, game.board.positions[ 0].contains.length
961 assert_equal 0, game.board.positions[ 1].contains.length
962 assert_equal 1, game.board.positions[ 2].contains.length
963 assert_equal 0, game.board.positions[ 3].contains.length
964 assert_equal 2, game.board.positions[ 4].contains.length
965 assert_equal 0, game.board.positions[ 5].contains.length
966 assert_equal 0, game.board.positions[ 6].contains.length
967 assert_equal 1, game.board.positions[ 7].contains.length
968 assert_equal 0, game.board.positions[ 8].contains.length
969 assert_equal 0, game.board.positions[ 9].contains.length
970 assert_equal 0, game.board.positions[10].contains.length
971 assert_equal 0, game.board.positions[11].contains.length
972 assert_equal 0, game.board.positions[12].contains.length
973 assert_equal 0, game.board.positions[13].contains.length
974 assert_equal 0, game.board.positions[14].contains.length
975 assert_equal 0, game.board.positions[15].contains.length
976 assert_equal 0, game.board.positions[16].contains.length
977 assert_equal 0, game.board.positions[17].contains.length
978 assert_equal 0, game.board.positions[18].contains.length
979 assert_equal 0, game.board.positions[19].contains.length
980 assert_equal 0, game.board.positions[20].contains.length
981 assert_equal 0, game.board.positions[21].contains.length
982 assert_equal 0, game.board.positions[22].contains.length
983 assert_equal 0, game.board.positions[23].contains.length
984 assert_equal 0, game.board.positions[24].contains.length
985 assert_equal 0, game.board.positions[25].contains.length
986 assert_equal 0, game.board.positions[26].contains.length
987 assert_equal 0, game.board.positions[27].contains.length
988 assert_equal 0, game.board.positions[28].contains.length
989 assert_equal 0, game.board.positions[29].contains.length
990 assert_equal 0, game.board.positions[30].contains.length
991 assert_equal 0, game.board.positions[31].contains.length
992 assert_equal 0, game.board.positions[32].contains.length
993 assert_equal 0, game.board.positions[33].contains.length
994 assert_equal 0, game.board.positions[34].contains.length
995 assert_equal 0, game.board.positions[35].contains.length
996 assert_equal 0, game.board.positions[36].contains.length
997 assert_equal 0, game.board.positions[37].contains.length
998
999 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1000 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
1001 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1002 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1003 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1004 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1005 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1006 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1007 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1008 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1009 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1010 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1011 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1012 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1013 :gun, :skull, :keys, :bottle],
1014 game.deck
1015 assert_equal 1, game.current_player
1016 assert_equal 2, game.moves_by_current_player
1017
1018 # Re-apply player 1's third move
1019 game.apply_move!('1 7 4'.to_move(game))
1020 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1021
1022 game.next_player!
1023 assert_equal 2, game.current_player
1024 game.apply_move!('2 0 7'.to_move(game))
1025 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
1026 game.apply_move!('2 0 10'.to_move(game))
1027 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
1028
1029 assert_equal 8, game.history.length
1030
1031 assert_equal 24, game.board.positions[ 0].contains.length
1032 assert_equal 0, game.board.positions[ 1].contains.length
1033 assert_equal 1, game.board.positions[ 2].contains.length
1034 assert_equal 0, game.board.positions[ 3].contains.length
1035 assert_equal 3, game.board.positions[ 4].contains.length
1036 assert_equal 0, game.board.positions[ 5].contains.length
1037 assert_equal 0, game.board.positions[ 6].contains.length
1038 assert_equal 1, game.board.positions[ 7].contains.length
1039 assert_equal 0, game.board.positions[ 8].contains.length
1040 assert_equal 0, game.board.positions[ 9].contains.length
1041 assert_equal 1, game.board.positions[10].contains.length
1042 assert_equal 0, game.board.positions[11].contains.length
1043 assert_equal 0, game.board.positions[12].contains.length
1044 assert_equal 0, game.board.positions[13].contains.length
1045 assert_equal 0, game.board.positions[14].contains.length
1046 assert_equal 0, game.board.positions[15].contains.length
1047 assert_equal 0, game.board.positions[16].contains.length
1048 assert_equal 0, game.board.positions[17].contains.length
1049 assert_equal 0, game.board.positions[18].contains.length
1050 assert_equal 0, game.board.positions[19].contains.length
1051 assert_equal 0, game.board.positions[20].contains.length
1052 assert_equal 0, game.board.positions[21].contains.length
1053 assert_equal 0, game.board.positions[22].contains.length
1054 assert_equal 0, game.board.positions[23].contains.length
1055 assert_equal 0, game.board.positions[24].contains.length
1056 assert_equal 0, game.board.positions[25].contains.length
1057 assert_equal 0, game.board.positions[26].contains.length
1058 assert_equal 0, game.board.positions[27].contains.length
1059 assert_equal 0, game.board.positions[28].contains.length
1060 assert_equal 0, game.board.positions[29].contains.length
1061 assert_equal 0, game.board.positions[30].contains.length
1062 assert_equal 0, game.board.positions[31].contains.length
1063 assert_equal 0, game.board.positions[32].contains.length
1064 assert_equal 0, game.board.positions[33].contains.length
1065 assert_equal 0, game.board.positions[34].contains.length
1066 assert_equal 0, game.board.positions[35].contains.length
1067 assert_equal 0, game.board.positions[36].contains.length
1068 assert_equal 0, game.board.positions[37].contains.length
1069
1070 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1071 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1072 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
1073 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1074 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1075 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1076 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1077 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1078 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1079 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1080 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1081 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1082 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1083 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1084 :gun, :skull],
1085 game.deck
1086 assert_equal 2, game.current_player
1087 assert_equal 2, game.moves_by_current_player
1088
1089 game.undo_move! # player 2's second move
1090
1091 assert_equal 7, game.history.length
1092
1093 assert_equal 25, game.board.positions[ 0].contains.length
1094 assert_equal 0, game.board.positions[ 1].contains.length
1095 assert_equal 1, game.board.positions[ 2].contains.length
1096 assert_equal 0, game.board.positions[ 3].contains.length
1097 assert_equal 3, game.board.positions[ 4].contains.length
1098 assert_equal 0, game.board.positions[ 5].contains.length
1099 assert_equal 0, game.board.positions[ 6].contains.length
1100 assert_equal 1, game.board.positions[ 7].contains.length
1101 assert_equal 0, game.board.positions[ 8].contains.length
1102 assert_equal 0, game.board.positions[ 9].contains.length
1103 assert_equal 0, game.board.positions[10].contains.length
1104 assert_equal 0, game.board.positions[11].contains.length
1105 assert_equal 0, game.board.positions[12].contains.length
1106 assert_equal 0, game.board.positions[13].contains.length
1107 assert_equal 0, game.board.positions[14].contains.length
1108 assert_equal 0, game.board.positions[15].contains.length
1109 assert_equal 0, game.board.positions[16].contains.length
1110 assert_equal 0, game.board.positions[17].contains.length
1111 assert_equal 0, game.board.positions[18].contains.length
1112 assert_equal 0, game.board.positions[19].contains.length
1113 assert_equal 0, game.board.positions[20].contains.length
1114 assert_equal 0, game.board.positions[21].contains.length
1115 assert_equal 0, game.board.positions[22].contains.length
1116 assert_equal 0, game.board.positions[23].contains.length
1117 assert_equal 0, game.board.positions[24].contains.length
1118 assert_equal 0, game.board.positions[25].contains.length
1119 assert_equal 0, game.board.positions[26].contains.length
1120 assert_equal 0, game.board.positions[27].contains.length
1121 assert_equal 0, game.board.positions[28].contains.length
1122 assert_equal 0, game.board.positions[29].contains.length
1123 assert_equal 0, game.board.positions[30].contains.length
1124 assert_equal 0, game.board.positions[31].contains.length
1125 assert_equal 0, game.board.positions[32].contains.length
1126 assert_equal 0, game.board.positions[33].contains.length
1127 assert_equal 0, game.board.positions[34].contains.length
1128 assert_equal 0, game.board.positions[35].contains.length
1129 assert_equal 0, game.board.positions[36].contains.length
1130 assert_equal 0, game.board.positions[37].contains.length
1131
1132 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1133 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1134 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
1135 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1136 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1137 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1138 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1139 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1140 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1141 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1142 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1143 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1144 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1145 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1146 :gun, :skull],
1147 game.deck
1148 assert_equal 2, game.current_player
1149 assert_equal 1, game.moves_by_current_player
1150
1151
1152 game.undo_move! # Player 2's first move
1153
1154 assert_equal 6, game.history.length
1155
1156 assert_equal 26, game.board.positions[ 0].contains.length
1157 assert_equal 0, game.board.positions[ 1].contains.length
1158 assert_equal 1, game.board.positions[ 2].contains.length
1159 assert_equal 0, game.board.positions[ 3].contains.length
1160 assert_equal 3, game.board.positions[ 4].contains.length
1161 assert_equal 0, game.board.positions[ 5].contains.length
1162 assert_equal 0, game.board.positions[ 6].contains.length
1163 assert_equal 0, game.board.positions[ 7].contains.length
1164 assert_equal 0, game.board.positions[ 8].contains.length
1165 assert_equal 0, game.board.positions[ 9].contains.length
1166 assert_equal 0, game.board.positions[10].contains.length
1167 assert_equal 0, game.board.positions[11].contains.length
1168 assert_equal 0, game.board.positions[12].contains.length
1169 assert_equal 0, game.board.positions[13].contains.length
1170 assert_equal 0, game.board.positions[14].contains.length
1171 assert_equal 0, game.board.positions[15].contains.length
1172 assert_equal 0, game.board.positions[16].contains.length
1173 assert_equal 0, game.board.positions[17].contains.length
1174 assert_equal 0, game.board.positions[18].contains.length
1175 assert_equal 0, game.board.positions[19].contains.length
1176 assert_equal 0, game.board.positions[20].contains.length
1177 assert_equal 0, game.board.positions[21].contains.length
1178 assert_equal 0, game.board.positions[22].contains.length
1179 assert_equal 0, game.board.positions[23].contains.length
1180 assert_equal 0, game.board.positions[24].contains.length
1181 assert_equal 0, game.board.positions[25].contains.length
1182 assert_equal 0, game.board.positions[26].contains.length
1183 assert_equal 0, game.board.positions[27].contains.length
1184 assert_equal 0, game.board.positions[28].contains.length
1185 assert_equal 0, game.board.positions[29].contains.length
1186 assert_equal 0, game.board.positions[30].contains.length
1187 assert_equal 0, game.board.positions[31].contains.length
1188 assert_equal 0, game.board.positions[32].contains.length
1189 assert_equal 0, game.board.positions[33].contains.length
1190 assert_equal 0, game.board.positions[34].contains.length
1191 assert_equal 0, game.board.positions[35].contains.length
1192 assert_equal 0, game.board.positions[36].contains.length
1193 assert_equal 0, game.board.positions[37].contains.length
1194
1195 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1196 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1197 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1198 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1199 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1200 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1201 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1202 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1203 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1204 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1205 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1206 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1207 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1208 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1209 :gun, :skull],
1210 game.deck
1211 assert_equal 2, game.current_player
1212 assert_equal 0, game.moves_by_current_player
1213
1214
1215 game.undo_move! # Player 1's third move
1216
1217 assert_equal 5, game.history.length
1218
1219 assert_equal 26, game.board.positions[ 0].contains.length
1220 assert_equal 0, game.board.positions[ 1].contains.length
1221 assert_equal 1, game.board.positions[ 2].contains.length
1222 assert_equal 0, game.board.positions[ 3].contains.length
1223 assert_equal 2, game.board.positions[ 4].contains.length
1224 assert_equal 0, game.board.positions[ 5].contains.length
1225 assert_equal 0, game.board.positions[ 6].contains.length
1226 assert_equal 1, game.board.positions[ 7].contains.length
1227 assert_equal 0, game.board.positions[ 8].contains.length
1228 assert_equal 0, game.board.positions[ 9].contains.length
1229 assert_equal 0, game.board.positions[10].contains.length
1230 assert_equal 0, game.board.positions[11].contains.length
1231 assert_equal 0, game.board.positions[12].contains.length
1232 assert_equal 0, game.board.positions[13].contains.length
1233 assert_equal 0, game.board.positions[14].contains.length
1234 assert_equal 0, game.board.positions[15].contains.length
1235 assert_equal 0, game.board.positions[16].contains.length
1236 assert_equal 0, game.board.positions[17].contains.length
1237 assert_equal 0, game.board.positions[18].contains.length
1238 assert_equal 0, game.board.positions[19].contains.length
1239 assert_equal 0, game.board.positions[20].contains.length
1240 assert_equal 0, game.board.positions[21].contains.length
1241 assert_equal 0, game.board.positions[22].contains.length
1242 assert_equal 0, game.board.positions[23].contains.length
1243 assert_equal 0, game.board.positions[24].contains.length
1244 assert_equal 0, game.board.positions[25].contains.length
1245 assert_equal 0, game.board.positions[26].contains.length
1246 assert_equal 0, game.board.positions[27].contains.length
1247 assert_equal 0, game.board.positions[28].contains.length
1248 assert_equal 0, game.board.positions[29].contains.length
1249 assert_equal 0, game.board.positions[30].contains.length
1250 assert_equal 0, game.board.positions[31].contains.length
1251 assert_equal 0, game.board.positions[32].contains.length
1252 assert_equal 0, game.board.positions[33].contains.length
1253 assert_equal 0, game.board.positions[34].contains.length
1254 assert_equal 0, game.board.positions[35].contains.length
1255 assert_equal 0, game.board.positions[36].contains.length
1256 assert_equal 0, game.board.positions[37].contains.length
1257
1258 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1259 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
1260 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1261 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1262 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1263 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1264 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1265 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1266 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1267 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1268 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1269 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1270 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1271 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1272 :gun, :skull, :keys, :bottle],
1273 game.deck
1274 assert_equal 1, game.current_player
1275 assert_equal 2, game.moves_by_current_player
1276
1277 end
1278
1279 def test_apply_moves
1280 game = Game.new(5,6,6)
1281 game.set_testing_game!
1282 game.pieces.each do |player|
1283 player.each do |piece|
1284 assert_equal game.board.positions[0], piece.position
1285 end
1286 end
1287 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
1288 :keys, :dagger, :skull, :hat, :gun, :bottle,
1289 :dagger, :bottle, :keys, :gun, :hat, :skull,
1290 :dagger, :skull, :bottle, :gun, :keys, :hat,
1291 :hat, :dagger, :keys, :bottle, :gun, :skull,
1292 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
1293 game.board.positions.collect {|p| p.symbol}
1294 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1295 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1296 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1297 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1298 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1299 assert_equal 5, game.players_cards.length
1300 assert_equal 5, game.players.length
1301 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1302 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1303 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1304 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1305 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1306 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1307 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1308 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1309 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1310 :gun, :skull, :keys, :bottle, :skull],
1311 game.deck
1312
1313 assert_equal 0, game.history.length
1314
1315 game.apply_move!('0 0 5'.to_move(game))
1316 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
1317 assert_equal 1, game.history.length
1318 game.apply_move!('0 0 4'.to_move(game))
1319 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
1320 assert_equal 2, game.history.length
1321 game.apply_move!('0 5 4'.to_move(game))
1322 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1323 assert_equal 3, game.history.length
1324
1325 game.next_player!
1326 assert_equal 1, game.current_player
1327 assert_equal 3, game.history.length
1328 game.apply_move!('1 0 2'.to_move(game))
1329 end
1330
1331 def test_read_game_lines
1332 gamelines1 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1333 "keys", "dagger", "skull", "hat", "gun", "bottle",
1334 "dagger", "bottle", "keys", "gun", "hat", "skull",
1335 "dagger", "skull", "bottle", "gun", "keys", "hat",
1336 "hat", "dagger", "keys", "bottle", "gun", "skull",
1337 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1338 "1 0 5 skull", "1 0 4 hat",
1339 "1",
1340 "dagger"]
1341 assert_nothing_raised {Game.read_game(gamelines1)}
1342 game, moves = Game.read_game(gamelines1)
1343 assert_equal 2, game.history.length
1344 assert_equal 0, game.current_player
1345 assert_equal 2, game.moves_by_current_player
1346 assert_equal 1, game.players_cards[0].length
1347 assert_equal 3, game.players_cards[1].length
1348 assert_equal 3, game.players_cards[2].length
1349 assert_equal 3, game.players_cards[3].length
1350 assert_equal 3, game.players_cards[4].length
1351 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 15, game.deck.length
1352
1353 game.apply_move!('0 5 4'.to_move(game))
1354 assert_equal 3, game.history.length
1355 assert_equal 0, game.current_player
1356 assert_equal 3, game.moves_by_current_player
1357 assert_equal 2, game.players_cards[0].length
1358 assert_equal 3, game.players_cards[1].length
1359 assert_equal 3, game.players_cards[2].length
1360 assert_equal 3, game.players_cards[3].length
1361 assert_equal 3, game.players_cards[4].length
1362 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1363
1364 gamelines2 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1365 "keys", "dagger", "skull", "hat", "gun", "bottle",
1366 "dagger", "bottle", "keys", "gun", "hat", "skull",
1367 "dagger", "skull", "bottle", "gun", "keys", "hat",
1368 "hat", "dagger", "keys", "bottle", "gun", "skull",
1369 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1370 "1 0 5", "1 0 4", "1 5 4",
1371 "2",
1372 "dagger", "hat", "keys"]
1373 assert_nothing_raised {Game.read_game(gamelines2)}
1374 game, moves = Game.read_game(gamelines2)
1375 assert_equal 3, game.history.length
1376 assert_equal 1, game.current_player
1377 assert_equal 0, game.moves_by_current_player
1378 assert_equal 2, game.players_cards[0].length
1379 assert_equal 3, game.players_cards[1].length
1380 assert_equal 3, game.players_cards[2].length
1381 assert_equal 3, game.players_cards[3].length
1382 assert_equal 3, game.players_cards[4].length
1383 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1384
1385 game.apply_move!('1 0 2'.to_move(game))
1386 assert_equal 4, game.history.length
1387 assert_equal 1, game.current_player
1388 assert_equal 1, game.moves_by_current_player
1389 assert_equal 2, game.players_cards[0].length
1390 assert_equal 2, game.players_cards[1].length
1391 assert_equal 3, game.players_cards[2].length
1392 assert_equal 3, game.players_cards[3].length
1393 assert_equal 3, game.players_cards[4].length
1394 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1395
1396 gamelines3 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1397 "keys", "dagger", "skull", "hat", "gun", "bottle",
1398 "dagger", "bottle", "keys", "gun", "hat", "skull",
1399 "dagger", "skull", "bottle", "gun", "keys", "hat",
1400 "hat", "dagger", "keys", "bottle", "gun", "skull",
1401 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1402 "1 0 5", "1 0 4", "1 5 4", "2 0 2",
1403 "2",
1404 "dagger", "keys"]
1405 assert_nothing_raised {Game.read_game(gamelines3)}
1406 game, moves = Game.read_game(gamelines3)
1407 assert_equal 4, game.history.length
1408 assert_equal 1, game.current_player
1409 assert_equal 1, game.moves_by_current_player
1410 assert_equal 2, game.players_cards[0].length
1411 assert_equal 2, game.players_cards[1].length
1412 assert_equal 3, game.players_cards[2].length
1413 assert_equal 3, game.players_cards[3].length
1414 assert_equal 3, game.players_cards[4].length
1415 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1416
1417 game.apply_move!('1 0 7'.to_move(game))
1418 assert_equal 5, game.history.length
1419 assert_equal 1, game.current_player
1420 assert_equal 2, game.moves_by_current_player
1421 assert_equal 2, game.players_cards[0].length
1422 assert_equal 1, game.players_cards[1].length
1423 assert_equal 3, game.players_cards[2].length
1424 assert_equal 3, game.players_cards[3].length
1425 assert_equal 3, game.players_cards[4].length
1426 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1427
1428 gamelines4 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1429 "keys", "dagger", "skull", "hat", "gun", "bottle",
1430 "dagger", "bottle", "keys", "gun", "hat", "skull",
1431 "dagger", "skull", "bottle", "gun", "keys", "hat",
1432 "hat", "dagger", "keys", "bottle", "gun", "skull",
1433 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1434 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7",
1435 "2",
1436 "dagger"]
1437 assert_nothing_raised {Game.read_game(gamelines4)}
1438 game, moves = Game.read_game(gamelines4)
1439 assert_equal 5, game.history.length
1440 assert_equal 1, game.current_player
1441 assert_equal 2, game.moves_by_current_player
1442 assert_equal 2, game.players_cards[0].length
1443 assert_equal 1, game.players_cards[1].length
1444 assert_equal 3, game.players_cards[2].length
1445 assert_equal 3, game.players_cards[3].length
1446 assert_equal 3, game.players_cards[4].length
1447 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1448
1449 game.apply_move!('1 7 4'.to_move(game))
1450 assert_equal 6, game.history.length
1451 assert_equal 1, game.current_player
1452 assert_equal 3, game.moves_by_current_player
1453 assert_equal 2, game.players_cards[0].length
1454 assert_equal 3, game.players_cards[1].length
1455 assert_equal 3, game.players_cards[2].length
1456 assert_equal 3, game.players_cards[3].length
1457 assert_equal 3, game.players_cards[4].length
1458 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1459
1460 gamelines5 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1461 "keys", "dagger", "skull", "hat", "gun", "bottle",
1462 "dagger", "bottle", "keys", "gun", "hat", "skull",
1463 "dagger", "skull", "bottle", "gun", "keys", "hat",
1464 "hat", "dagger", "keys", "bottle", "gun", "skull",
1465 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1466 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
1467 "2",
1468 "bottle", "hat", "keys"]
1469 assert_nothing_raised {Game.read_game(gamelines5)}
1470 game, moves = Game.read_game(gamelines5)
1471 assert_equal 6, game.history.length
1472 assert_equal 1, game.current_player
1473 assert_equal 3, game.moves_by_current_player
1474 assert_equal 2, game.players_cards[0].length
1475 assert_equal 3, game.players_cards[1].length
1476 assert_equal 3, game.players_cards[2].length
1477 assert_equal 3, game.players_cards[3].length
1478 assert_equal 3, game.players_cards[4].length
1479 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1480
1481 game.players_cards[2] << :keys
1482 game.players_cards[2] << :hat
1483 game.apply_move!('3 0 7'.to_move(game, true), 2)
1484 assert_equal 7, game.history.length
1485 assert_equal 2, game.current_player
1486 assert_equal 1, game.moves_by_current_player
1487 game.apply_move!('3 0 10'.to_move(game, true))
1488 assert_equal 8, game.history.length
1489 assert_equal 2, game.current_player
1490 assert_equal 2, game.moves_by_current_player
1491
1492 gamelines6 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1493 "keys", "dagger", "skull", "hat", "gun", "bottle",
1494 "dagger", "bottle", "keys", "gun", "hat", "skull",
1495 "dagger", "skull", "bottle", "gun", "keys", "hat",
1496 "hat", "dagger", "keys", "bottle", "gun", "skull",
1497 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1498 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
1499 "3",
1500 "bottle", "hat", "keys"]
1501 assert_nothing_raised {Game.read_game(gamelines6)}
1502 game, moves = Game.read_game(gamelines6)
1503 assert_equal 6, game.history.length
1504 assert_equal 2, game.current_player
1505 assert_equal 0, game.moves_by_current_player
1506 assert_equal 2, game.players_cards[0].length
1507 assert_equal 3, game.players_cards[1].length
1508 assert_equal 3, game.players_cards[2].length
1509 assert_equal 3, game.players_cards[3].length
1510 assert_equal 3, game.players_cards[4].length
1511 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1512
1513 game.apply_move!('2 0 7'.to_move(game))
1514 assert_equal 7, game.history.length
1515 assert_equal 2, game.current_player
1516 assert_equal 1, game.moves_by_current_player
1517 assert_equal 2, game.players_cards[0].length
1518 assert_equal 3, game.players_cards[1].length
1519 assert_equal 2, game.players_cards[2].length
1520 assert_equal 3, game.players_cards[3].length
1521 assert_equal 3, game.players_cards[4].length
1522 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1523
1524 game.apply_move!('2 0 10'.to_move(game))
1525 assert_equal 8, game.history.length
1526 assert_equal 2, game.current_player
1527 assert_equal 2, game.moves_by_current_player
1528 assert_equal 2, game.players_cards[0].length
1529 assert_equal 3, game.players_cards[1].length
1530 assert_equal 1, game.players_cards[2].length
1531 assert_equal 3, game.players_cards[3].length
1532 assert_equal 3, game.players_cards[4].length
1533 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1534
1535 # Need to do a test with a very long sequence of moves,
1536 # to test that the card dealing works properly when the deck is exhausted
1537
1538 end
1539
1540 def test_dealing
1541 game = Game.new(5,6,6)
1542 game.set_testing_game!
1543 0.upto(4) do |i|
1544 assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
1545 end
1546 assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 5 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
1547 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1548 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1549 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1550 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1551 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1552 assert_equal 5, game.players_cards.length
1553 assert_equal 5, game.players.length
1554 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1555 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1556 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1557 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1558 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1559 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1560 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1561 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1562 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1563 :gun, :skull, :keys, :bottle, :skull],
1564 game.deck
1565 game.deal_cards!(86, 0)
1566 assert_equal 89, game.players_cards[0].length
1567 assert_equal 1, game.deck.length
1568 assert_equal [:hat], game.deck
1569
1570 game.players_cards[0] = [:hat, :hat, :hat, :hat, :hat]
1571 game.players_cards[1] = [:keys, :keys, :keys]
1572 game.players_cards[2] = [:bottle, :dagger, :skull]
1573 game.players_cards[3] = []
1574 game.players_cards[4] = []
1575 game.deal_cards!(1, 3)
1576
1577 assert_equal [:hat, :hat, :hat, :hat, :hat], game.players_cards[0].sort_by {|c| c.to_s}
1578 assert_equal [:keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1579 assert_equal [:bottle, :dagger, :skull], game.players_cards[2].sort_by {|c| c.to_s}
1580 assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
1581 assert_equal [], game.players_cards[4].sort_by {|c| c.to_s}
1582 assert_equal [], game.deck
1583
1584 game.deal_cards!(1, 4)
1585 assert_equal [:keys], game.players_cards[4].sort_by {|c| c.to_s}
1586 assert_equal $CARDS_PER_SYMBOL - 6, game.deck.select {|c| c == :hat}.length
1587 assert_equal $CARDS_PER_SYMBOL - 4, game.deck.select {|c| c == :keys}.length
1588 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :bottle}.length
1589 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :dagger}.length
1590 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :skull}.length
1591 assert_equal $CARDS_PER_SYMBOL, game.deck.select {|c| c == :gun}.length
1592 assert_equal $CARDS_PER_SYMBOL * 6 - 13, game.deck.length
1593
1594 end
1595
1596 def test_long_deal
1597 gamelines0 = ["3", "cell",
1598 "gun", "keys", "dagger", "hat", "skull", "bottle",
1599 "keys", "dagger", "skull", "hat", "gun", "bottle",
1600 "dagger", "bottle", "keys", "gun", "hat", "skull",
1601 "dagger", "skull", "bottle", "gun", "keys", "hat",
1602 "hat", "dagger", "keys", "bottle", "gun", "skull",
1603 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1604 "1",
1605 "hat", "skull", "bottle"]
1606 assert_nothing_raised {Game.read_game(gamelines0)}
1607 game, moves = Game.read_game(gamelines0)
1608 assert_equal 0, game.history.length
1609 assert_equal 0, game.current_player
1610 assert_equal 0, game.moves_by_current_player
1611 assert_equal 3, game.players_cards[0].length
1612 assert_equal 3, game.players_cards[1].length
1613 assert_equal 3, game.players_cards[2].length
1614 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
1615 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1616 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length, unplayed_cards.length
1617 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
1618 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
1619 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
1620 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :gun}).length
1621 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
1622 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :keys}).length
1623 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
1624
1625 gamelines1 = ["3", "cell",
1626 "gun", "keys", "dagger", "hat", "skull", "bottle",
1627 "keys", "dagger", "skull", "hat", "gun", "bottle",
1628 "dagger", "bottle", "keys", "gun", "hat", "skull",
1629 "dagger", "skull", "bottle", "gun", "keys", "hat",
1630 "hat", "dagger", "keys", "bottle", "gun", "skull",
1631 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1632 "1 0 1 gun", "1 0 2 keys", "1 2 1",
1633 "2",
1634 "hat", "skull", "bottle"]
1635 assert_nothing_raised {Game.read_game(gamelines1)}
1636 game, moves = Game.read_game(gamelines1)
1637 assert_equal 3, game.history.length
1638 assert_equal 1, game.current_player
1639 assert_equal 0, game.moves_by_current_player
1640 assert_equal 2, game.players_cards[0].length
1641 assert_equal 3, game.players_cards[1].length
1642 assert_equal 3, game.players_cards[2].length
1643 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
1644 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1645 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 2, unplayed_cards.length
1646 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
1647 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
1648 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
1649 assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :gun}).length
1650 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
1651 assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :keys}).length
1652 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
1653
1654 gamelines2 = ["3", "cell",
1655 "gun", "keys", "dagger", "hat", "skull", "bottle",
1656 "keys", "dagger", "skull", "hat", "gun", "bottle",
1657 "dagger", "bottle", "keys", "gun", "hat", "skull",
1658 "dagger", "skull", "bottle", "gun", "keys", "hat",
1659 "hat", "dagger", "keys", "bottle", "gun", "skull",
1660 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1661 "1 0 1", "1 0 2", "1 2 1",
1662 "2 0 2", "2 0 3", "2 3 2",
1663 "3 0 3", "3 0 4", "3 4 3",
1664 "1 0 4", "1 0 5", "1 5 4",
1665 "2 0 5", "2 0 6", "2 6 5",
1666 "3 0 6", "3 0 11", "3 11 6",
1667 "1",
1668 "hat"]
1669 assert_nothing_raised {Game.read_game(gamelines2)}
1670 game, moves = Game.read_game(gamelines2)
1671 assert_equal 18, game.history.length
1672 assert_equal 0, game.current_player
1673 assert_equal 0, game.moves_by_current_player
1674 assert_equal 1, game.players_cards[0].length
1675 assert_equal 1, game.players_cards[1].length
1676 assert_equal 1, game.players_cards[2].length
1677 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
1678 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1679 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 12, unplayed_cards.length
1680 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
1681 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :bottle}).length
1682 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :dagger}).length
1683 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :gun}).length
1684 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :hat}).length
1685 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :keys}).length
1686 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :skull}).length
1687
1688 gamelines2 = ["3", "cell",
1689 "gun", "keys", "dagger", "hat", "skull", "bottle",
1690 "keys", "dagger", "skull", "hat", "gun", "bottle",
1691 "dagger", "bottle", "keys", "gun", "hat", "skull",
1692 "dagger", "skull", "bottle", "gun", "keys", "hat",
1693 "hat", "dagger", "keys", "bottle", "gun", "skull",
1694 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1695 "1 0 1", "1 0 2", "1 2 1",
1696 "2 0 2", "2 0 3", "2 3 2",
1697 "3 0 3", "3 0 4", "3 4 3",
1698 "1 0 4", "1 0 5", "1 5 4",
1699 "2 0 5", "2 0 6", "2 6 5",
1700 "3 0 6", "3 0 11", "3 11 6",
1701 "1 0 7", "1 7 6",
1702 "2 0 8", "2 8 5",
1703 "3 0 9", "3 9 4",
1704 "1 0 10", "1 10 3",
1705 "2 0 11", "2 11 2",
1706 "3 0 12", "3 12 1",
1707 "1",
1708 "hat", "skull", "bottle"]
1709 assert_nothing_raised {Game.read_game(gamelines2)}
1710 game, moves = Game.read_game(gamelines2)
1711 assert_equal 30, game.history.length
1712 assert_equal 0, game.current_player
1713 assert_equal 0, game.moves_by_current_player
1714 assert_equal 3, game.players_cards[0].length
1715 assert_equal 3, game.players_cards[1].length
1716 assert_equal 3, game.players_cards[2].length
1717 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
1718 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1719 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, unplayed_cards.length
1720 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
1721 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :bottle}).length
1722 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :dagger}).length
1723 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :gun}).length
1724 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :hat}).length
1725 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :keys}).length
1726 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :skull}).length
1727
1728 gamelines3 = ["3", "cell",
1729 "gun", "keys", "dagger", "hat", "skull", "bottle",
1730 "keys", "dagger", "skull", "hat", "gun", "bottle",
1731 "dagger", "bottle", "keys", "gun", "hat", "skull",
1732 "dagger", "skull", "bottle", "gun", "keys", "hat",
1733 "hat", "dagger", "keys", "bottle", "gun", "skull",
1734 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1735 "1 0 1", "1 0 2", "1 2 1",
1736 "2 0 2", "2 0 3", "2 3 2",
1737 "3 0 3", "3 0 4", "3 4 3",
1738 "1 0 4", "1 0 5", "1 5 4",
1739 "2 0 5", "2 0 6", "2 6 5",
1740 "3 0 6", "3 0 11", "3 11 6",
1741 "1 0 7", "1 7 6",
1742 "2 0 8", "2 8 5",
1743 "3 0 9", "3 9 4",
1744 "1 0 10", "1 10 3",
1745 "2 0 11", "2 11 2",
1746 "3 0 12", "3 12 1",
1747 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1748 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1749 "1",
1750 "hat", "skull", "bottle", "gun", "dagger"]
1751 assert_nothing_raised {Game.read_game(gamelines3)}
1752 game, moves = Game.read_game(gamelines3)
1753 assert_equal 42, game.history.length
1754 assert_equal 0, game.current_player
1755 assert_equal 0, game.moves_by_current_player
1756 assert_equal 5, game.players_cards[0].length
1757 assert_equal 5, game.players_cards[1].length
1758 assert_equal 5, game.players_cards[2].length
1759 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
1760 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1761 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 24, unplayed_cards.length
1762 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
1763 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :bottle}).length
1764 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :dagger}).length
1765 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :gun}).length
1766 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :hat}).length
1767 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :keys}).length
1768 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :skull}).length
1769
1770 gamelines4 = ["3", "cell",
1771 "gun", "keys", "dagger", "hat", "skull", "bottle",
1772 "keys", "dagger", "skull", "hat", "gun", "bottle",
1773 "dagger", "bottle", "keys", "gun", "hat", "skull",
1774 "dagger", "skull", "bottle", "gun", "keys", "hat",
1775 "hat", "dagger", "keys", "bottle", "gun", "skull",
1776 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1777 "1 0 1", "1 0 2", "1 2 1",
1778 "2 0 2", "2 0 3", "2 3 2",
1779 "3 0 3", "3 0 4", "3 4 3",
1780 "1 0 4", "1 0 5", "1 5 4",
1781 "2 0 5", "2 0 6", "2 6 5",
1782 "3 0 6", "3 0 11", "3 11 6",
1783 "1 0 7", "1 7 6",
1784 "2 0 8", "2 8 5",
1785 "3 0 9", "3 9 4",
1786 "1 0 10", "1 10 3",
1787 "2 0 11", "2 11 2",
1788 "3 0 12", "3 12 1",
1789 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1790 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1791 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1792 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1793 "1",
1794 "hat", "skull", "bottle", "gun", "dagger", "keys", "hat"]
1795 assert_nothing_raised {Game.read_game(gamelines4)}
1796 game, moves = Game.read_game(gamelines4)
1797 assert_equal 54, game.history.length
1798 assert_equal 0, game.current_player
1799 assert_equal 0, game.moves_by_current_player
1800 assert_equal 7, game.players_cards[0].length
1801 assert_equal 7, game.players_cards[1].length
1802 assert_equal 7, game.players_cards[2].length
1803 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
1804 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1805 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 30, unplayed_cards.length
1806 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
1807 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :bottle}).length
1808 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :dagger}).length
1809 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :gun}).length
1810 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :hat}).length
1811 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :keys}).length
1812 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :skull}).length
1813
1814
1815 gamelines5 = ["3", "cell",
1816 "gun", "keys", "dagger", "hat", "skull", "bottle",
1817 "keys", "dagger", "skull", "hat", "gun", "bottle",
1818 "dagger", "bottle", "keys", "gun", "hat", "skull",
1819 "dagger", "skull", "bottle", "gun", "keys", "hat",
1820 "hat", "dagger", "keys", "bottle", "gun", "skull",
1821 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1822 "1 0 1", "1 0 2", "1 2 1",
1823 "2 0 2", "2 0 3", "2 3 2",
1824 "3 0 3", "3 0 4", "3 4 3",
1825 "1 0 4", "1 0 5", "1 5 4",
1826 "2 0 5", "2 0 6", "2 6 5",
1827 "3 0 6", "3 0 11", "3 11 6",
1828 "1 0 7", "1 7 6",
1829 "2 0 8", "2 8 5",
1830 "3 0 9", "3 9 4",
1831 "1 0 10", "1 10 3",
1832 "2 0 11", "2 11 2",
1833 "3 0 12", "3 12 1",
1834 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1835 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1836 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1837 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1838 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1839 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1840 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1841 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1842 "1",
1843 "hat", "skull", "bottle", "gun", "dagger", "keys", "hat", "skull", "bottle", "gun", "dagger"]
1844 assert_nothing_raised {Game.read_game(gamelines5)}
1845 game, moves = Game.read_game(gamelines5)
1846 assert_equal 78, game.history.length
1847 assert_equal 0, game.current_player
1848 assert_equal 0, game.moves_by_current_player
1849 assert_equal 11, game.players_cards[0].length
1850 assert_equal 11, game.players_cards[1].length
1851 assert_equal 11, game.players_cards[2].length
1852 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
1853 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1854 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 42, unplayed_cards.length
1855 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
1856 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :bottle}).length
1857 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :dagger}).length
1858 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :gun}).length
1859 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :hat}).length
1860 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :keys}).length
1861 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :skull}).length
1862
1863 gamelines6 = ["3", "cell",
1864 "gun", "keys", "dagger", "hat", "skull", "bottle",
1865 "keys", "dagger", "skull", "hat", "gun", "bottle",
1866 "dagger", "bottle", "keys", "gun", "hat", "skull",
1867 "dagger", "skull", "bottle", "gun", "keys", "hat",
1868 "hat", "dagger", "keys", "bottle", "gun", "skull",
1869 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1870 "1 0 1", "1 0 2", "1 2 1",
1871 "2 0 2", "2 0 3", "2 3 2",
1872 "3 0 3", "3 0 4", "3 4 3",
1873 "1 0 4", "1 0 5", "1 5 4",
1874 "2 0 5", "2 0 6", "2 6 5",
1875 "3 0 6", "3 0 11", "3 11 6",
1876 "1 0 7", "1 7 6",
1877 "2 0 8", "2 8 5",
1878 "3 0 9", "3 9 4",
1879 "1 0 10", "1 10 3",
1880 "2 0 11", "2 11 2",
1881 "3 0 12", "3 12 1",
1882 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1883 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1884 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1885 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1886 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1887 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1888 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1889 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1890 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1891 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1892 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1893 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1894 "1",
1895 "hat", "skull", "bottle", "gun", "dagger", "keys",
1896 "hat", "skull", "bottle", "gun", "dagger", "keys",
1897 "hat", "skull", "bottle"]
1898 assert_nothing_raised {Game.read_game(gamelines6)}
1899 game, moves = Game.read_game(gamelines6)
1900 assert_equal 102, game.history.length
1901 assert_equal 0, game.current_player
1902 assert_equal 0, game.moves_by_current_player
1903 assert_equal 15, game.players_cards[0].length
1904 assert_equal 15, game.players_cards[1].length
1905 assert_equal 15, game.players_cards[2].length
1906 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
1907 assert_equal 3, game.deck.length
1908 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1909 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 54, unplayed_cards.length
1910 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
1911 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
1912 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
1913 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
1914 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
1915 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :keys}).length
1916 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
1917
1918 gamelines7 = ["3", "cell",
1919 "gun", "keys", "dagger", "hat", "skull", "bottle",
1920 "keys", "dagger", "skull", "hat", "gun", "bottle",
1921 "dagger", "bottle", "keys", "gun", "hat", "skull",
1922 "dagger", "skull", "bottle", "gun", "keys", "hat",
1923 "hat", "dagger", "keys", "bottle", "gun", "skull",
1924 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1925 "1 0 1", "1 0 2", "1 2 1",
1926 "2 0 2", "2 0 3", "2 3 2",
1927 "3 0 3", "3 0 4", "3 4 3",
1928 "1 0 4", "1 0 5", "1 5 4",
1929 "2 0 5", "2 0 6", "2 6 5",
1930 "3 0 6", "3 0 11", "3 11 6",
1931 "1 0 7", "1 7 6",
1932 "2 0 8", "2 8 5",
1933 "3 0 9", "3 9 4",
1934 "1 0 10", "1 10 3",
1935 "2 0 11", "2 11 2",
1936 "3 0 12", "3 12 1",
1937 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1938 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1939 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1940 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1941 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1942 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1943 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1944 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1945 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1946 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1947 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1948 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1949 "1 1 7", "1 7 1",
1950 "1",
1951 "hat", "skull", "bottle", "gun", "dagger", "keys",
1952 "hat", "skull", "bottle", "gun", "dagger", "keys",
1953 "hat", "skull", "bottle", "gun"]
1954 assert_nothing_raised {Game.read_game(gamelines7)}
1955 game, moves = Game.read_game(gamelines7)
1956 assert_equal 104, game.history.length
1957 assert_equal 0, game.current_player
1958 assert_equal 2, game.moves_by_current_player
1959 assert_equal 16, game.players_cards[0].length
1960 assert_equal 15, game.players_cards[1].length
1961 assert_equal 15, game.players_cards[2].length
1962 assert_equal 1, game.deck.length
1963 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1964 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 55, unplayed_cards.length
1965 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
1966 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
1967 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
1968 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
1969 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
1970 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
1971
1972 gamelines8 = ["3", "cell",
1973 "gun", "keys", "dagger", "hat", "skull", "bottle",
1974 "keys", "dagger", "skull", "hat", "gun", "bottle",
1975 "dagger", "bottle", "keys", "gun", "hat", "skull",
1976 "dagger", "skull", "bottle", "gun", "keys", "hat",
1977 "hat", "dagger", "keys", "bottle", "gun", "skull",
1978 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1979 "1 0 1", "1 0 2", "1 2 1",
1980 "2 0 2", "2 0 3", "2 3 2",
1981 "3 0 3", "3 0 4", "3 4 3",
1982 "1 0 4", "1 0 5", "1 5 4",
1983 "2 0 5", "2 0 6", "2 6 5",
1984 "3 0 6", "3 0 11", "3 11 6",
1985 "1 0 7", "1 7 6",
1986 "2 0 8", "2 8 5",
1987 "3 0 9", "3 9 4",
1988 "1 0 10", "1 10 3",
1989 "2 0 11", "2 11 2",
1990 "3 0 12", "3 12 1",
1991 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1992 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1993 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1994 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1995 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1996 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1997 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1998 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1999 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2000 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2001 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2002 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2003 "1 1 7", "1 7 1", "1 1 10",
2004 "1",
2005 "hat", "skull", "bottle", "gun", "dagger", "keys",
2006 "hat", "skull", "bottle", "gun", "dagger", "keys",
2007 "skull", "bottle", "dagger"]
2008 assert_nothing_raised {Game.read_game(gamelines8)}
2009 game, moves = Game.read_game(gamelines8)
2010 assert_equal 105, game.history.length
2011 assert_equal 0, game.current_player
2012 assert_equal 3, game.moves_by_current_player
2013 assert_equal 15, game.players_cards[0].length
2014 assert_equal 15, game.players_cards[1].length
2015 assert_equal 15, game.players_cards[2].length
2016 assert_equal 1, game.deck.length
2017 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2018 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 56, unplayed_cards.length
2019 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
2020 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
2021 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
2022 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :hat}).length
2023 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
2024 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
2025
2026
2027 gamelines9 = ["3", "cell",
2028 "gun", "keys", "dagger", "hat", "skull", "bottle",
2029 "keys", "dagger", "skull", "hat", "gun", "bottle",
2030 "dagger", "bottle", "keys", "gun", "hat", "skull",
2031 "dagger", "skull", "bottle", "gun", "keys", "hat",
2032 "hat", "dagger", "keys", "bottle", "gun", "skull",
2033 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2034 "1 0 1", "1 0 2", "1 2 1",
2035 "2 0 2", "2 0 3", "2 3 2",
2036 "3 0 3", "3 0 4", "3 4 3",
2037 "1 0 4", "1 0 5", "1 5 4",
2038 "2 0 5", "2 0 6", "2 6 5",
2039 "3 0 6", "3 0 11", "3 11 6",
2040 "1 0 7", "1 7 6",
2041 "2 0 8", "2 8 5",
2042 "3 0 9", "3 9 4",
2043 "1 0 10", "1 10 3",
2044 "2 0 11", "2 11 2",
2045 "3 0 12", "3 12 1",
2046 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2047 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2048 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2049 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2050 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2051 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2052 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2053 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2054 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2055 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2056 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2057 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2058 "1 1 7", "1 7 1", "1 1 10",
2059 "2 2 12", "2 12 10",
2060 "2",
2061 "hat", "skull", "bottle", "gun", "dagger", "keys",
2062 "hat", "skull", "bottle", "gun", "dagger", "keys",
2063 "hat", "skull", "bottle"]
2064 assert_nothing_raised {Game.read_game(gamelines9)}
2065 game, moves = Game.read_game(gamelines9)
2066 assert_equal 107, game.history.length
2067 assert_equal 1, game.current_player
2068 assert_equal 2, game.moves_by_current_player
2069 assert_equal 15, game.players_cards[0].length
2070 assert_equal 15, game.players_cards[1].length
2071 assert_equal 15, game.players_cards[2].length
2072 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 45, game.deck.length
2073 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2074 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 0, unplayed_cards.length
2075 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
2076 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
2077 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :gun}).length
2078 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
2079 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :keys}).length
2080 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
2081
2082 gamelines10 = ["3", "cell",
2083 "gun", "keys", "dagger", "hat", "skull", "bottle",
2084 "keys", "dagger", "skull", "hat", "gun", "bottle",
2085 "dagger", "bottle", "keys", "gun", "hat", "skull",
2086 "dagger", "skull", "bottle", "gun", "keys", "hat",
2087 "hat", "dagger", "keys", "bottle", "gun", "skull",
2088 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2089 "1 0 1", "1 0 2", "1 2 1",
2090 "2 0 2", "2 0 3", "2 3 2",
2091 "3 0 3", "3 0 4", "3 4 3",
2092 "1 0 4", "1 0 5", "1 5 4",
2093 "2 0 5", "2 0 6", "2 6 5",
2094 "3 0 6", "3 0 11", "3 11 6",
2095 "1 0 7", "1 7 6",
2096 "2 0 8", "2 8 5",
2097 "3 0 9", "3 9 4",
2098 "1 0 10", "1 10 3",
2099 "2 0 11", "2 11 2",
2100 "3 0 12", "3 12 1",
2101 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2102 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2103 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2104 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2105 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2106 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2107 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2108 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2109 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2110 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2111 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2112 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2113 "1 1 7", "1 7 1", "1 1 10",
2114 "1",
2115 "hat", "skull", "bottle", "gun", "dagger", "keys",
2116 "hat", "hat", "hat", "hat", "hat", "hat",
2117 "hat", "hat", "hat"]
2118 assert_raise(InvalidMoveError) {Game.read_game(gamelines10)} # Not enough skull cards to go round
2119
2120 gamelines11 = ["3", "cell",
2121 "gun", "keys", "dagger", "hat", "skull", "bottle",
2122 "keys", "dagger", "skull", "hat", "gun", "bottle",
2123 "dagger", "bottle", "keys", "gun", "hat", "skull",
2124 "dagger", "skull", "bottle", "gun", "keys", "hat",
2125 "hat", "dagger", "keys", "bottle", "gun", "skull",
2126 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2127 "1 0 1", "1 0 2", "1 2 1",
2128 "2 0 2", "2 0 3", "2 3 2",
2129 "3 0 3", "3 0 4", "3 4 3",
2130 "1 0 4", "1 0 5", "1 5 4",
2131 "2 0 5", "2 0 6", "2 6 5",
2132 "3 0 6", "3 0 11", "3 11 6",
2133 "1 0 7", "1 7 6",
2134 "2 0 8", "2 8 5",
2135 "3 0 9", "3 9 4",
2136 "1 0 10", "1 10 3",
2137 "2 0 11", "2 11 2",
2138 "3 0 12", "3 12 1",
2139 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2140 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2141 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2142 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2143 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2144 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2145 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2146 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2147 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2148 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2149 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2150 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2151 "1 1 7", "1 7 1", "1 1 10",
2152 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2153 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2154 "1",
2155 "hat", "skull", "bottle", "gun", "dagger", "keys",
2156 "hat", "skull", "bottle", "gun", "dagger", "keys",
2157 "skull", "bottle", "dagger"]
2158 assert_nothing_raised {Game.read_game(gamelines11)}
2159 game, moves = Game.read_game(gamelines11)
2160 assert_equal 111, game.history.length
2161 assert_equal 0, game.current_player
2162 assert_equal 0, game.moves_by_current_player
2163 assert_equal 15, game.players_cards[0].length
2164 assert_equal 12, game.players_cards[1].length
2165 assert_equal 12, game.players_cards[2].length
2166 assert_equal 1, game.deck.length
2167 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2168 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 62, unplayed_cards.length
2169 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
2170 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2171 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2172 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :hat}).length
2173 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
2174 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2175
2176 gamelines12 = ["3", "cell",
2177 "gun", "keys", "dagger", "hat", "skull", "bottle",
2178 "keys", "dagger", "skull", "hat", "gun", "bottle",
2179 "dagger", "bottle", "keys", "gun", "hat", "skull",
2180 "dagger", "skull", "bottle", "gun", "keys", "hat",
2181 "hat", "dagger", "keys", "bottle", "gun", "skull",
2182 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2183 "1 0 1", "1 0 2", "1 2 1",
2184 "2 0 2", "2 0 3", "2 3 2",
2185 "3 0 3", "3 0 4", "3 4 3",
2186 "1 0 4", "1 0 5", "1 5 4",
2187 "2 0 5", "2 0 6", "2 6 5",
2188 "3 0 6", "3 0 11", "3 11 6",
2189 "1 0 7", "1 7 6",
2190 "2 0 8", "2 8 5",
2191 "3 0 9", "3 9 4",
2192 "1 0 10", "1 10 3",
2193 "2 0 11", "2 11 2",
2194 "3 0 12", "3 12 1",
2195 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2196 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2197 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2198 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2199 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2200 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2201 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2202 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2203 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2204 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2205 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2206 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2207 "1 1 7", "1 7 1", "1 1 10",
2208 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2209 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2210 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2211 "2",
2212 "hat", "skull", "bottle", "gun", "dagger", "keys",
2213 "hat", "skull", "bottle", "gun", "dagger", "keys"]
2214 assert_nothing_raised {Game.read_game(gamelines12)}
2215 game, moves = Game.read_game(gamelines12)
2216 assert_equal 114, game.history.length
2217 assert_equal 1, game.current_player
2218 assert_equal 0, game.moves_by_current_player
2219 assert_equal 12, game.players_cards[0].length
2220 assert_equal 12, game.players_cards[1].length
2221 assert_equal 12, game.players_cards[2].length
2222 assert_equal 1, game.deck.length
2223 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2224 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 65, unplayed_cards.length
2225 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
2226 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2227 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2228 assert_equal $CARDS_PER_SYMBOL - 14, (unplayed_cards.select {|c| c == :hat}).length
2229 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
2230 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2231
2232 gamelines13 = ["3", "cell",
2233 "gun", "keys", "dagger", "hat", "skull", "bottle",
2234 "keys", "dagger", "skull", "hat", "gun", "bottle",
2235 "dagger", "bottle", "keys", "gun", "hat", "skull",
2236 "dagger", "skull", "bottle", "gun", "keys", "hat",
2237 "hat", "dagger", "keys", "bottle", "gun", "skull",
2238 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2239 "1 0 1", "1 0 2", "1 2 1",
2240 "2 0 2", "2 0 3", "2 3 2",
2241 "3 0 3", "3 0 4", "3 4 3",
2242 "1 0 4", "1 0 5", "1 5 4",
2243 "2 0 5", "2 0 6", "2 6 5",
2244 "3 0 6", "3 0 11", "3 11 6",
2245 "1 0 7", "1 7 6",
2246 "2 0 8", "2 8 5",
2247 "3 0 9", "3 9 4",
2248 "1 0 10", "1 10 3",
2249 "2 0 11", "2 11 2",
2250 "3 0 12", "3 12 1",
2251 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2252 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2253 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2254 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2255 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2256 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2257 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2258 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2259 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2260 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2261 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2262 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2263 "1 1 7", "1 7 1", "1 1 10",
2264 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2265 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2266 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2267 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2268 "3",
2269 "skull", "skull", "bottle", "gun", "dagger", "keys",
2270 "bottle", "skull", "bottle", "gun", "dagger", "keys"]
2271 assert_nothing_raised {Game.read_game(gamelines13)}
2272 game, moves = Game.read_game(gamelines13)
2273 assert_equal 117, game.history.length
2274 assert_equal 2, game.current_player
2275 assert_equal 0, game.moves_by_current_player
2276 assert_equal 12, game.players_cards[0].length
2277 assert_equal 9, game.players_cards[1].length
2278 assert_equal 12, game.players_cards[2].length
2279 assert_equal 1, game.deck.length
2280 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2281 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 68, unplayed_cards.length
2282 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
2283 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2284 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2285 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2286 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
2287 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2288
2289 gamelines14 = ["3", "cell",
2290 "gun", "keys", "dagger", "hat", "skull", "bottle",
2291 "keys", "dagger", "skull", "hat", "gun", "bottle",
2292 "dagger", "bottle", "keys", "gun", "hat", "skull",
2293 "dagger", "skull", "bottle", "gun", "keys", "hat",
2294 "hat", "dagger", "keys", "bottle", "gun", "skull",
2295 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2296 "1 0 1", "1 0 2", "1 2 1",
2297 "2 0 2", "2 0 3", "2 3 2",
2298 "3 0 3", "3 0 4", "3 4 3",
2299 "1 0 4", "1 0 5", "1 5 4",
2300 "2 0 5", "2 0 6", "2 6 5",
2301 "3 0 6", "3 0 11", "3 11 6",
2302 "1 0 7", "1 7 6",
2303 "2 0 8", "2 8 5",
2304 "3 0 9", "3 9 4",
2305 "1 0 10", "1 10 3",
2306 "2 0 11", "2 11 2",
2307 "3 0 12", "3 12 1",
2308 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2309 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2310 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2311 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2312 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2313 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2314 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2315 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2316 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2317 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2318 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2319 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2320 "1 1 7", "1 7 1", "1 1 10",
2321 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2322 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2323 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2324 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2325 "3 4 37",
2326 "3",
2327 "skull", "skull", "bottle", "gun", "dagger", "keys",
2328 "bottle", "skull", "bottle", "gun", "dagger"]
2329 assert_raise(InvalidMoveError) {Game.read_game(gamelines14)}
2330
2331 gamelines15 = ["3", "cell",
2332 "gun", "keys", "dagger", "hat", "skull", "bottle",
2333 "keys", "dagger", "skull", "hat", "gun", "bottle",
2334 "dagger", "bottle", "keys", "gun", "hat", "skull",
2335 "dagger", "skull", "bottle", "gun", "keys", "hat",
2336 "hat", "dagger", "keys", "bottle", "gun", "skull",
2337 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2338 "1 0 1", "1 0 2", "1 2 1",
2339 "2 0 2", "2 0 3", "2 3 2",
2340 "3 0 3", "3 0 4", "3 4 3",
2341 "1 0 4", "1 0 5", "1 5 4",
2342 "2 0 5", "2 0 6", "2 6 5",
2343 "3 0 6", "3 0 11", "3 11 6",
2344 "1 0 7", "1 7 6",
2345 "2 0 8", "2 8 5",
2346 "3 0 9", "3 9 4",
2347 "1 0 10", "1 10 3",
2348 "2 0 11", "2 11 2",
2349 "3 0 12", "3 12 1",
2350 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2351 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2352 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2353 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2354 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2355 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2356 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2357 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2358 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2359 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2360 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2361 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2362 "1 1 7", "1 7 1", "1 1 10",
2363 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2364 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2365 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2366 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2367 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2368 "1",
2369 "skull", "skull", "bottle", "gun", "dagger", "keys",
2370 "bottle", "skull", "bottle", "gun", "dagger", "keys"]
2371 assert_nothing_raised {Game.read_game(gamelines15)}
2372 game, moves = Game.read_game(gamelines15)
2373 assert_equal 120, game.history.length
2374 assert_equal 0, game.current_player
2375 assert_equal 0, game.moves_by_current_player
2376 assert_equal 12, game.players_cards[0].length
2377 assert_equal 9, game.players_cards[1].length
2378 assert_equal 9, game.players_cards[2].length
2379 assert_equal 1, game.deck.length
2380 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2381 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 71, unplayed_cards.length
2382 assert_equal $CARDS_PER_SYMBOL - 13, (unplayed_cards.select {|c| c == :bottle}).length
2383 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2384 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2385 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2386 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
2387 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2388
2389 gamelines16 = ["3", "cell",
2390 "gun", "keys", "dagger", "hat", "skull", "bottle",
2391 "keys", "dagger", "skull", "hat", "gun", "bottle",
2392 "dagger", "bottle", "keys", "gun", "hat", "skull",
2393 "dagger", "skull", "bottle", "gun", "keys", "hat",
2394 "hat", "dagger", "keys", "bottle", "gun", "skull",
2395 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2396 "1 0 1", "1 0 2", "1 2 1",
2397 "2 0 2", "2 0 3", "2 3 2",
2398 "3 0 3", "3 0 4", "3 4 3",
2399 "1 0 4", "1 0 5", "1 5 4",
2400 "2 0 5", "2 0 6", "2 6 5",
2401 "3 0 6", "3 0 11", "3 11 6",
2402 "1 0 7", "1 7 6",
2403 "2 0 8", "2 8 5",
2404 "3 0 9", "3 9 4",
2405 "1 0 10", "1 10 3",
2406 "2 0 11", "2 11 2",
2407 "3 0 12", "3 12 1",
2408 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2409 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2410 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2411 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2412 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2413 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2414 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2415 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2416 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2417 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2418 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2419 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2420 "1 1 7", "1 7 1", "1 1 10",
2421 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2422 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2423 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2424 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2425 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2426 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2427 "2",
2428 "skull", "skull", "keys", "gun", "dagger", "keys",
2429 "skull", "skull", "skull"]
2430 assert_nothing_raised {Game.read_game(gamelines16)}
2431 game, moves = Game.read_game(gamelines16)
2432 assert_equal 123, game.history.length
2433 assert_equal 1, game.current_player
2434 assert_equal 0, game.moves_by_current_player
2435 assert_equal 9, game.players_cards[0].length
2436 assert_equal 9, game.players_cards[1].length
2437 assert_equal 9, game.players_cards[2].length
2438 assert_equal 1, game.deck.length
2439 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2440 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 74, unplayed_cards.length
2441 assert_equal $CARDS_PER_SYMBOL - 16, (unplayed_cards.select {|c| c == :bottle}).length
2442 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2443 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2444 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2445 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
2446 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2447
2448 gamelines17 = ["3", "cell",
2449 "gun", "keys", "dagger", "hat", "skull", "bottle",
2450 "keys", "dagger", "skull", "hat", "gun", "bottle",
2451 "dagger", "bottle", "keys", "gun", "hat", "skull",
2452 "dagger", "skull", "bottle", "gun", "keys", "hat",
2453 "hat", "dagger", "keys", "bottle", "gun", "skull",
2454 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2455 "1 0 1", "1 0 2", "1 2 1",
2456 "2 0 2", "2 0 3", "2 3 2",
2457 "3 0 3", "3 0 4", "3 4 3",
2458 "1 0 4", "1 0 5", "1 5 4",
2459 "2 0 5", "2 0 6", "2 6 5",
2460 "3 0 6", "3 0 11", "3 11 6",
2461 "1 0 7", "1 7 6",
2462 "2 0 8", "2 8 5",
2463 "3 0 9", "3 9 4",
2464 "1 0 10", "1 10 3",
2465 "2 0 11", "2 11 2",
2466 "3 0 12", "3 12 1",
2467 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2468 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2469 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2470 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2471 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2472 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2473 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2474 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2475 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2476 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2477 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2478 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2479 "1 1 7", "1 7 1", "1 1 10",
2480 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2481 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2482 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2483 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2484 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2485 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2486 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2487 "3",
2488 "skull", "skull", "keys", "gun", "dagger", "keys",
2489 "skull", "skull", "skull"]
2490 assert_nothing_raised {Game.read_game(gamelines17)}
2491 game, moves = Game.read_game(gamelines17)
2492 assert_equal 126, game.history.length
2493 assert_equal 2, game.current_player
2494 assert_equal 0, game.moves_by_current_player
2495 assert_equal 9, game.players_cards[0].length
2496 assert_equal 6, game.players_cards[1].length
2497 assert_equal 9, game.players_cards[2].length
2498 assert_equal 1, game.deck.length
2499 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2500 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 77, unplayed_cards.length
2501 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2502 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2503 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2504 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2505 assert_equal $CARDS_PER_SYMBOL - 13, (unplayed_cards.select {|c| c == :keys}).length
2506 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
2507
2508 gamelines18 = ["3", "cell",
2509 "gun", "keys", "dagger", "hat", "skull", "bottle",
2510 "keys", "dagger", "skull", "hat", "gun", "bottle",
2511 "dagger", "bottle", "keys", "gun", "hat", "skull",
2512 "dagger", "skull", "bottle", "gun", "keys", "hat",
2513 "hat", "dagger", "keys", "bottle", "gun", "skull",
2514 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2515 "1 0 1", "1 0 2", "1 2 1",
2516 "2 0 2", "2 0 3", "2 3 2",
2517 "3 0 3", "3 0 4", "3 4 3",
2518 "1 0 4", "1 0 5", "1 5 4",
2519 "2 0 5", "2 0 6", "2 6 5",
2520 "3 0 6", "3 0 11", "3 11 6",
2521 "1 0 7", "1 7 6",
2522 "2 0 8", "2 8 5",
2523 "3 0 9", "3 9 4",
2524 "1 0 10", "1 10 3",
2525 "2 0 11", "2 11 2",
2526 "3 0 12", "3 12 1",
2527 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2528 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2529 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2530 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2531 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2532 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2533 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2534 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2535 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2536 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2537 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2538 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2539 "1 1 7", "1 7 1", "1 1 10",
2540 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2541 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2542 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2543 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2544 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2545 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2546 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2547 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2548 "1",
2549 "skull", "skull", "keys", "gun", "dagger", "keys",
2550 "skull", "skull", "skull"]
2551 assert_nothing_raised {Game.read_game(gamelines18)}
2552 game, moves = Game.read_game(gamelines18)
2553 assert_equal 129, game.history.length
2554 assert_equal 0, game.current_player
2555 assert_equal 0, game.moves_by_current_player
2556 assert_equal 9, game.players_cards[0].length
2557 assert_equal 6, game.players_cards[1].length
2558 assert_equal 6, game.players_cards[2].length
2559 assert_equal 1, game.deck.length
2560 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2561 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 80, unplayed_cards.length
2562 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2563 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2564 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2565 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2566 assert_equal $CARDS_PER_SYMBOL - 15, (unplayed_cards.select {|c| c == :keys}).length
2567 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :skull}).length
2568
2569 gamelines19 = ["3", "cell",
2570 "gun", "keys", "dagger", "hat", "skull", "bottle",
2571 "keys", "dagger", "skull", "hat", "gun", "bottle",
2572 "dagger", "bottle", "keys", "gun", "hat", "skull",
2573 "dagger", "skull", "bottle", "gun", "keys", "hat",
2574 "hat", "dagger", "keys", "bottle", "gun", "skull",
2575 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2576 "1 0 1", "1 0 2", "1 2 1",
2577 "2 0 2", "2 0 3", "2 3 2",
2578 "3 0 3", "3 0 4", "3 4 3",
2579 "1 0 4", "1 0 5", "1 5 4",
2580 "2 0 5", "2 0 6", "2 6 5",
2581 "3 0 6", "3 0 11", "3 11 6",
2582 "1 0 7", "1 7 6",
2583 "2 0 8", "2 8 5",
2584 "3 0 9", "3 9 4",
2585 "1 0 10", "1 10 3",
2586 "2 0 11", "2 11 2",
2587 "3 0 12", "3 12 1",
2588 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2589 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2590 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2591 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2592 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2593 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2594 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2595 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2596 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2597 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2598 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2599 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2600 "1 1 7", "1 7 1", "1 1 10",
2601 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2602 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2603 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2604 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2605 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2606 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2607 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2608 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2609 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2610 "2",
2611 "skull", "skull", "gun", "gun", "dagger", "gun"]
2612 assert_nothing_raised {Game.read_game(gamelines19)}
2613 game, moves = Game.read_game(gamelines19)
2614 assert_equal 132, game.history.length
2615 assert_equal 1, game.current_player
2616 assert_equal 0, game.moves_by_current_player
2617 assert_equal 6, game.players_cards[0].length
2618 assert_equal 6, game.players_cards[1].length
2619 assert_equal 6, game.players_cards[2].length
2620 assert_equal 1, game.deck.length
2621 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2622 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 83, unplayed_cards.length
2623 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2624 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2625 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
2626 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2627 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
2628 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :skull}).length
2629
2630 gamelines20 = ["3", "cell",
2631 "gun", "keys", "dagger", "hat", "skull", "bottle",
2632 "keys", "dagger", "skull", "hat", "gun", "bottle",
2633 "dagger", "bottle", "keys", "gun", "hat", "skull",
2634 "dagger", "skull", "bottle", "gun", "keys", "hat",
2635 "hat", "dagger", "keys", "bottle", "gun", "skull",
2636 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2637 "1 0 1", "1 0 2", "1 2 1",
2638 "2 0 2", "2 0 3", "2 3 2",
2639 "3 0 3", "3 0 4", "3 4 3",
2640 "1 0 4", "1 0 5", "1 5 4",
2641 "2 0 5", "2 0 6", "2 6 5",
2642 "3 0 6", "3 0 11", "3 11 6",
2643 "1 0 7", "1 7 6",
2644 "2 0 8", "2 8 5",
2645 "3 0 9", "3 9 4",
2646 "1 0 10", "1 10 3",
2647 "2 0 11", "2 11 2",
2648 "3 0 12", "3 12 1",
2649 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2650 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2651 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2652 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2653 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2654 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2655 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2656 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2657 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2658 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2659 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2660 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2661 "1 1 7", "1 7 1", "1 1 10",
2662 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2663 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2664 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2665 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2666 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2667 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2668 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2669 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2670 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2671 "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
2672 "3",
2673 "skull", "skull", "gun", "gun", "dagger", "gun"]
2674 assert_nothing_raised {Game.read_game(gamelines20)}
2675 game, moves = Game.read_game(gamelines20)
2676 assert_equal 135, game.history.length
2677 assert_equal 2, game.current_player
2678 assert_equal 0, game.moves_by_current_player
2679 assert_equal 6, game.players_cards[0].length
2680 assert_equal 3, game.players_cards[1].length
2681 assert_equal 6, game.players_cards[2].length
2682 assert_equal 1, game.deck.length
2683 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2684 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 86, unplayed_cards.length
2685 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2686 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2687 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
2688 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2689 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
2690 assert_equal $CARDS_PER_SYMBOL - 14, (unplayed_cards.select {|c| c == :skull}).length
2691
2692 gamelines21 = ["3", "cell",
2693 "gun", "keys", "dagger", "hat", "skull", "bottle",
2694 "keys", "dagger", "skull", "hat", "gun", "bottle",
2695 "dagger", "bottle", "keys", "gun", "hat", "skull",
2696 "dagger", "skull", "bottle", "gun", "keys", "hat",
2697 "hat", "dagger", "keys", "bottle", "gun", "skull",
2698 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2699 "1 0 1", "1 0 2", "1 2 1",
2700 "2 0 2", "2 0 3", "2 3 2",
2701 "3 0 3", "3 0 4", "3 4 3",
2702 "1 0 4", "1 0 5", "1 5 4",
2703 "2 0 5", "2 0 6", "2 6 5",
2704 "3 0 6", "3 0 11", "3 11 6",
2705 "1 0 7", "1 7 6",
2706 "2 0 8", "2 8 5",
2707 "3 0 9", "3 9 4",
2708 "1 0 10", "1 10 3",
2709 "2 0 11", "2 11 2",
2710 "3 0 12", "3 12 1",
2711 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2712 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2713 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2714 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2715 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2716 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2717 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2718 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2719 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2720 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2721 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2722 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2723 "1 1 7", "1 7 1", "1 1 10",
2724 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2725 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2726 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2727 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2728 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2729 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2730 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2731 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2732 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2733 "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
2734 "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
2735 "1",
2736 "gun", "gun", "gun", "gun", "gun", "gun"]
2737 assert_nothing_raised {Game.read_game(gamelines21)}
2738 game, moves = Game.read_game(gamelines21)
2739 assert_equal 138, game.history.length
2740 assert_equal 0, game.current_player
2741 assert_equal 0, game.moves_by_current_player
2742 assert_equal 6, game.players_cards[0].length
2743 assert_equal 3, game.players_cards[1].length
2744 assert_equal 3, game.players_cards[2].length
2745 assert_equal 1, game.deck.length
2746 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2747 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 89, unplayed_cards.length
2748 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2749 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2750 assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
2751 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2752 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
2753 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :skull}).length
2754
2755 gamelines22 = ["3", "cell",
2756 "gun", "keys", "dagger", "hat", "skull", "bottle",
2757 "keys", "dagger", "skull", "hat", "gun", "bottle",
2758 "dagger", "bottle", "keys", "gun", "hat", "skull",
2759 "dagger", "skull", "bottle", "gun", "keys", "hat",
2760 "hat", "dagger", "keys", "bottle", "gun", "skull",
2761 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2762 "1 0 1", "1 0 2", "1 2 1",
2763 "2 0 2", "2 0 3", "2 3 2",
2764 "3 0 3", "3 0 4", "3 4 3",
2765 "1 0 4", "1 0 5", "1 5 4",
2766 "2 0 5", "2 0 6", "2 6 5",
2767 "3 0 6", "3 0 11", "3 11 6",
2768 "1 0 7", "1 7 6",
2769 "2 0 8", "2 8 5",
2770 "3 0 9", "3 9 4",
2771 "1 0 10", "1 10 3",
2772 "2 0 11", "2 11 2",
2773 "3 0 12", "3 12 1",
2774 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2775 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2776 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2777 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2778 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2779 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2780 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2781 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2782 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2783 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2784 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2785 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2786 "1 1 7", "1 7 1", "1 1 10",
2787 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2788 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2789 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2790 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2791 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2792 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2793 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2794 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2795 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2796 "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
2797 "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
2798 "1 35 37 gun",
2799 "1",
2800 "gun", "gun", "gun", "gun", "gun"]
2801 assert_nothing_raised {Game.read_game(gamelines22)}
2802 game, moves = Game.read_game(gamelines22)
2803 assert_equal 139, game.history.length
2804 assert_equal 0, game.current_player
2805 assert_equal 1, game.moves_by_current_player
2806 assert_equal 5, game.players_cards[0].length
2807 assert_equal 3, game.players_cards[1].length
2808 assert_equal 3, game.players_cards[2].length
2809 assert_equal 1, game.deck.length
2810 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2811 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 90, unplayed_cards.length
2812 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
2813 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
2814 assert_equal $CARDS_PER_SYMBOL - 12, (unplayed_cards.select {|c| c == :gun}).length
2815 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
2816 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
2817 assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :skull}).length
2818
2819 assert_raise(GameWonNotice) {game.apply_move!("1 36 37 gun".to_move(game, true))}
2820 assert_raise(InvalidMoveError) {game.apply_move!("1 36 37".to_move(game, true))}
2821
2822 gamelines23 = ["3", "cell",
2823 "gun", "keys", "dagger", "hat", "skull", "bottle",
2824 "keys", "dagger", "skull", "hat", "gun", "bottle",
2825 "dagger", "bottle", "keys", "gun", "hat", "skull",
2826 "dagger", "skull", "bottle", "gun", "keys", "hat",
2827 "hat", "dagger", "keys", "bottle", "gun", "skull",
2828 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2829 "1 0 1", "1 0 2", "1 2 1",
2830 "2 0 2", "2 0 3", "2 3 2",
2831 "3 0 3", "3 0 4", "3 4 3",
2832 "1 0 4", "1 0 5", "1 5 4",
2833 "2 0 5", "2 0 6", "2 6 5",
2834 "3 0 6", "3 0 11", "3 11 6",
2835 "1 0 7", "1 7 6",
2836 "2 0 8", "2 8 5",
2837 "3 0 9", "3 9 4",
2838 "1 0 10", "1 10 3",
2839 "2 0 11", "2 11 2",
2840 "3 0 12", "3 12 1",
2841 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2842 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2843 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2844 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2845 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2846 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2847 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2848 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2849 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2850 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2851 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2852 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2853 "1 1 7", "1 7 1", "1 1 10",
2854 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2855 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2856 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2857 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2858 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2859 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2860 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2861 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2862 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2863 "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
2864 "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
2865 "1 35 37 gun", "1 36 37 gun",
2866 "1",
2867 "gun", "gun", "gun", "gun"]
2868 assert_raise(GameWonNotice) {Game.read_game(gamelines23)}
2869
2870 gamelines24 = ["3", "cell",
2871 "gun", "keys", "dagger", "hat", "skull", "bottle",
2872 "keys", "dagger", "skull", "hat", "gun", "bottle",
2873 "dagger", "bottle", "keys", "gun", "hat", "skull",
2874 "dagger", "skull", "bottle", "gun", "keys", "hat",
2875 "hat", "dagger", "keys", "bottle", "gun", "skull",
2876 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2877 "1 0 1", "1 0 2", "1 2 1",
2878 "2 0 2", "2 0 3", "2 3 2",
2879 "3 0 3", "3 0 4", "3 4 3",
2880 "1 0 4", "1 0 5", "1 5 4",
2881 "2 0 5", "2 0 6", "2 6 5",
2882 "3 0 6", "3 0 11", "3 11 6",
2883 "1 0 7", "1 7 6",
2884 "2 0 8", "2 8 5",
2885 "3 0 9", "3 9 4",
2886 "1 0 10", "1 10 3",
2887 "2 0 11", "2 11 2",
2888 "3 0 12", "3 12 1",
2889 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2890 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2891 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2892 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2893 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2894 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2895 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2896 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2897 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2898 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2899 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2900 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2901 "1 1 7", "1 7 1", "1 1 10",
2902 "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
2903 "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
2904 "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
2905 "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
2906 "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
2907 "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
2908 "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
2909 "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
2910 "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
2911 "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
2912 "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
2913 "1 35 37 gun", "1 36 37 gun",
2914 "2 33 34 dagger",
2915 "2",
2916 "dagger", "dagger"]
2917 assert_raise(GameWonNotice) {Game.read_game(gamelines24)}
2918 end
2919
2920 end