Initial commit
[cartagena.git] / test / .svn / text-base / libcartagena_test.rb.netbeans-base
1 #
2 # To change this template, choose Tools | Templates
3 # and open the template in the editor.
4
5
6 $:.unshift File.join(File.dirname(__FILE__),'..','lib', 'libcartagena')
7
8 require 'test/unit'
9 require File.join(File.dirname(__FILE__), '..', 'lib', 'libcartagena')
10
11 class TileTest < Test::Unit::TestCase
12 def test_tile_init
13 front = [:hat, :keys, :gun, :bottle, :skull, :dagger]
14 back = [:gun, :hat, :dagger, :skull, :bottle, :keys]
15 assert_nothing_raised { Tile.new(front, back) }
16 tile = Tile.new(front, back)
17
18 assert_equal 6, tile.front.length
19 assert_equal 6, tile.back.length
20 assert_equal 6, tile.exposed.length
21 assert_equal front, tile.front.map {|p| p.symbol}
22 assert_equal back, tile.back.map {|p| p.symbol}
23 assert_equal front, tile.exposed.map {|p| p.symbol}
24
25 tile.flip!
26 assert_equal 6, tile.front.length
27 assert_equal 6, tile.back.length
28 assert_equal 6, tile.exposed.length
29 assert_equal front, tile.front.map {|p| p.symbol}
30 assert_equal back, tile.back.map {|p| p.symbol}
31 assert_equal back, tile.exposed.map {|p| p.symbol}
32
33 tile.flip!
34 assert_equal 6, tile.front.length
35 assert_equal 6, tile.back.length
36 assert_equal 6, tile.exposed.length
37 assert_equal front, tile.front.map {|p| p.symbol}
38 assert_equal back, tile.back.map {|p| p.symbol}
39 assert_equal front, tile.exposed.map {|p| p.symbol}
40
41 tile.flip!
42 tile.reverse!
43 assert_equal 6, tile.front.length
44 assert_equal 6, tile.back.length
45 assert_equal 6, tile.exposed.length
46 assert_equal front, tile.front.map {|p| p.symbol}
47 assert_equal back, tile.back.map {|p| p.symbol}
48 assert_equal back.reverse, tile.exposed.map {|p| p.symbol}
49
50 tile.flip!
51 assert_equal 6, tile.front.length
52 assert_equal 6, tile.back.length
53 assert_equal 6, tile.exposed.length
54 assert_equal front, tile.front.map {|p| p.symbol}
55 assert_equal back, tile.back.map {|p| p.symbol}
56 assert_equal front, tile.exposed.map {|p| p.symbol}
57
58 tile.reverse!
59 assert_equal 6, tile.front.length
60 assert_equal 6, tile.back.length
61 assert_equal 6, tile.exposed.length
62 assert_equal front, tile.front.map {|p| p.symbol}
63 assert_equal back, tile.back.map {|p| p.symbol}
64 assert_equal front.reverse, tile.exposed.map {|p| p.symbol}
65
66 end
67 end
68
69 class BoardTest < Test::Unit::TestCase
70 def test_board_init
71 assert_nothing_raised { Board.new(6) }
72 board = Board.new(1)
73 assert_equal 1, board.tiles.length
74 assert_equal 8, board.positions.length
75
76 board = Board.new(6)
77 assert_equal 6, board.tiles.length
78 assert_equal 38, board.positions.length
79
80 0.upto(5) do |i|
81 start = i * 6 + 1
82 slice = board.positions[start..(start+5)]
83 $SYMBOLS.each do |tile|
84 assert_equal 1, (slice.find_all {|p| p.symbol == tile}).length
85 end
86 end
87 end
88 end
89
90
91 class GameTest < Test::Unit::TestCase
92 def test_game_init
93 assert_nothing_raised { Game.new }
94
95 game = Game.new(6)
96 assert_equal 6, game.players.length
97 0.upto(5) do |i|
98 assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
99 end
100 assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 6 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
101 end
102
103 def test_game_setting
104 game = Game.new(5,6,6)
105 game.set_testing_game!
106 game.pieces.each do |player|
107 player.each do |piece|
108 assert_equal game.board.positions[0], piece.position
109 end
110 end
111 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
112 :keys, :dagger, :skull, :hat, :gun, :bottle,
113 :dagger, :bottle, :keys, :gun, :hat, :skull,
114 :dagger, :skull, :bottle, :gun, :keys, :hat,
115 :hat, :dagger, :keys, :bottle, :gun, :skull,
116 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
117 game.board.positions.collect {|p| p.symbol}
118 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
119 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
120 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
121 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
122 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
123 # assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
124 assert_equal 5, game.players_cards.length
125 assert_equal 5, game.players.length
126 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
127 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
128 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
129 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
130 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
131 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
132 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
133 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
134 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
135 :gun, :skull, :keys, :bottle, :skull],
136 game.deck
137 assert_equal 0, game.moves_by_current_player
138 assert_equal 18, game.possible_moves.length
139 game.apply_move!(game.possible_moves[0])
140 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
141 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
142 assert_equal 87, game.deck.length
143
144 assert_equal 1, game.moves_by_current_player
145 assert_equal 12, game.possible_moves.length
146 game.apply_move!(game.possible_moves[3])
147 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
148 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
149 assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
150 assert_equal 87, game.deck.length
151
152 assert_equal 2, game.moves_by_current_player
153 assert_equal 7, game.possible_moves.length
154 game.apply_move!(game.possible_moves[2])
155 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
156 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
157 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
158 assert_equal 86, game.deck.length
159
160 game.reset_current_player 0 # Needed to prevent errors below
161
162 assert_equal 0, game.moves_by_current_player
163 assert_equal 12, game.possible_moves.length
164 game.apply_move!(game.possible_moves[-1])
165 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
166 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
167 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
168 assert_equal 5, game.board.positions.index(game.pieces[0][5].position)
169 assert_equal 86, game.deck.length
170
171 assert_equal 1, game.moves_by_current_player
172 assert_equal 7, game.possible_moves.length
173 game.apply_move!(game.possible_moves[-1])
174 assert_equal [:bottle, :hat, :keys], game.players_cards[0].sort_by {|c| c.to_s}
175 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
176 assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
177 assert_equal 1, game.board.positions.index(game.pieces[0][5].position)
178 assert_equal 84, game.deck.length
179 end
180
181 def test_game_termination
182 game = Game.new(6)
183 game.set_testing_game!
184 assert_equal 0, game.moves_by_current_player
185
186 game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[0], game.board.positions[36]), 0, false)
187 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
188 assert game.board.positions[36].contains.include?(game.pieces[0][0])
189 assert game.board.positions[0].contains.include?(game.pieces[0][1])
190 assert game.board.positions[0].contains.include?(game.pieces[0][2])
191 assert game.board.positions[0].contains.include?(game.pieces[0][3])
192 assert game.board.positions[0].contains.include?(game.pieces[0][4])
193 assert game.board.positions[0].contains.include?(game.pieces[0][5])
194 assert_equal 18, game.possible_moves.length
195
196 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[0], game.board.positions[35]), 0, false)
197 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
198 assert game.board.positions[36].contains.include?(game.pieces[0][0])
199 assert game.board.positions[35].contains.include?(game.pieces[0][1])
200 assert game.board.positions[0].contains.include?(game.pieces[0][2])
201 assert game.board.positions[0].contains.include?(game.pieces[0][3])
202 assert game.board.positions[0].contains.include?(game.pieces[0][4])
203 assert game.board.positions[0].contains.include?(game.pieces[0][5])
204 assert_equal 19, game.possible_moves.length
205
206 game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[0], game.board.positions[34]), 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[35].contains.include?(game.pieces[0][1])
210 assert game.board.positions[34].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 20, game.possible_moves.length
215
216 game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[0], game.board.positions[33]), 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[34].contains.include?(game.pieces[0][2])
221 assert game.board.positions[33].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 21, game.possible_moves.length
225
226 game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[0], game.board.positions[32]), 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[33].contains.include?(game.pieces[0][3])
232 assert game.board.positions[32].contains.include?(game.pieces[0][4])
233 assert game.board.positions[0].contains.include?(game.pieces[0][5])
234 assert_equal 22, game.possible_moves.length
235
236 game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[0], game.board.positions[31]), 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[32].contains.include?(game.pieces[0][4])
243 assert game.board.positions[31].contains.include?(game.pieces[0][5])
244 assert_equal 23, game.possible_moves.length
245
246 # Now start moving pices onto the boat
247 game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[31], game.board.positions[37]), 0, false)
248 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
249 assert game.board.positions[36].contains.include?(game.pieces[0][0])
250 assert game.board.positions[35].contains.include?(game.pieces[0][1])
251 assert game.board.positions[34].contains.include?(game.pieces[0][2])
252 assert game.board.positions[33].contains.include?(game.pieces[0][3])
253 assert game.board.positions[32].contains.include?(game.pieces[0][4])
254 assert game.board.positions[37].contains.include?(game.pieces[0][5])
255 assert_equal 20, game.possible_moves.length
256
257 game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[32], game.board.positions[37]), 0, false)
258 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
259 assert game.board.positions[36].contains.include?(game.pieces[0][0])
260 assert game.board.positions[35].contains.include?(game.pieces[0][1])
261 assert game.board.positions[34].contains.include?(game.pieces[0][2])
262 assert game.board.positions[33].contains.include?(game.pieces[0][3])
263 assert game.board.positions[37].contains.include?(game.pieces[0][4])
264 assert game.board.positions[37].contains.include?(game.pieces[0][5])
265 assert_equal 17, game.possible_moves.length
266
267 game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[33], 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[37].contains.include?(game.pieces[0][3])
273 assert game.board.positions[37].contains.include?(game.pieces[0][4])
274 assert game.board.positions[37].contains.include?(game.pieces[0][5])
275 assert_equal 14, game.possible_moves.length
276
277 game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[34], 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[37].contains.include?(game.pieces[0][2])
282 assert game.board.positions[37].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 11, game.possible_moves.length
286
287 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[35], 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[37].contains.include?(game.pieces[0][1])
291 assert game.board.positions[37].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 8, game.possible_moves.length
296
297 assert_raise(GameWonNotice) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[36], game.board.positions[37]), 0, false)}
298
299 end
300
301 def test_retreats
302 game = Game.new(5,6,6)
303 game.set_testing_game!
304
305 game.pieces.each do |player|
306 player.each do |piece|
307 assert_equal game.board.positions[0], piece.position
308 end
309 end
310 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
311 :keys, :dagger, :skull, :hat, :gun, :bottle,
312 :dagger, :bottle, :keys, :gun, :hat, :skull,
313 :dagger, :skull, :bottle, :gun, :keys, :hat,
314 :hat, :dagger, :keys, :bottle, :gun, :skull,
315 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
316 game.board.positions.collect {|p| p.symbol}
317 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
318 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
319 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
320 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
321 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
322 # assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
323 assert_equal 5, game.players_cards.length
324 assert_equal 5, game.players.length
325 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
326 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
327 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
328 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
329 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
330 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
331 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
332 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
333 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
334 :gun, :skull, :keys, :bottle, :skull],
335 game.deck
336 assert_equal 0, game.moves_by_current_player
337 assert_equal 18, game.possible_moves.length
338 game.apply_move!(game.possible_moves[0])
339 assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
340 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
341 assert_equal 87, game.deck.length
342
343 assert_equal 1, game.moves_by_current_player
344 assert_equal 12, game.possible_moves.length
345 game.apply_move!(game.possible_moves[3])
346 assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
347 assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
348 assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
349 assert_equal 87, game.deck.length
350
351 # Test can't retreat into the cell
352 assert_equal 2, game.moves_by_current_player
353 assert_equal 7, game.possible_moves.length
354 assert_raise(InvalidMoveError) do
355 game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[5], game.board.positions[0]))
356 end
357 end
358
359 # Test invalid move error trapping
360 def test_invalid_move_error_trapping
361 game = Game.new(5,6,6)
362 game.set_testing_game!
363
364 game.pieces.each do |player|
365 player.each do |piece|
366 assert_equal game.board.positions[0], piece.position
367 end
368 end
369 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
370 :keys, :dagger, :skull, :hat, :gun, :bottle,
371 :dagger, :bottle, :keys, :gun, :hat, :skull,
372 :dagger, :skull, :bottle, :gun, :keys, :hat,
373 :hat, :dagger, :keys, :bottle, :gun, :skull,
374 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
375 game.board.positions.collect {|p| p.symbol}
376 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
377 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
378 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
379 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
380 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
381 assert_equal 5, game.players_cards.length
382 assert_equal 5, game.players.length
383 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
384 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
385 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
386 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
387 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
388 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
389 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
390 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
391 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
392 :gun, :skull, :keys, :bottle, :skull],
393 game.deck
394 assert_equal 0, game.moves_by_current_player
395
396 # Test if can move to a space without the right card
397 assert_raise(InvalidMoveError) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[2], game.board.positions[0]))}
398
399
400 # Apply a series of moves to get an interesting game state
401 game.apply_move!('0 0 5'.to_move(game))
402 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
403 game.apply_move!('0 0 4'.to_move(game))
404 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
405 game.apply_move!('0 5 4'.to_move(game))
406 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
407
408 game.next_player!
409 assert_equal 1, game.current_player
410 game.apply_move!('1 0 2'.to_move(game))
411 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
412 game.apply_move!('1 0 7'.to_move(game))
413 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
414 game.apply_move!('1 7 4'.to_move(game))
415 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
416
417 game.next_player!
418 assert_equal 2, game.current_player
419 game.apply_move!('2 0 7'.to_move(game))
420 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
421 game.apply_move!('2 0 10'.to_move(game))
422 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
423 game.apply_move!('2 0 6'.to_move(game))
424 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
425
426 game.next_player!
427 assert_equal 3, game.current_player
428 game.apply_move!('3 0 12'.to_move(game))
429 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
430 game.apply_move!('3 12 10'.to_move(game))
431 assert_equal [:skull, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
432 game.apply_move!('3 0 5'.to_move(game))
433 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
434
435 game.next_player!
436 assert_equal 4, game.current_player
437 game.apply_move!('4 0 12'.to_move(game))
438 assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
439 game.apply_move!('4 12 10'.to_move(game))
440 assert_equal [:dagger, :gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
441 game.apply_move!('4 0 3'.to_move(game))
442 assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
443
444 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
445 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
446 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
447 assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
448 assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
449
450 game.next_player!
451 assert_equal 0, game.current_player
452
453 game.apply_move!('0 0 9'.to_move(game))
454 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
455 game.apply_move!('0 0 1'.to_move(game))
456 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
457 game.apply_move!('0 9 7'.to_move(game))
458 assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
459
460 game.next_player!
461 assert_equal 1, game.current_player
462 game.apply_move!('1 0 12'.to_move(game))
463 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
464 game.apply_move!('1 0 14'.to_move(game))
465 assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
466 game.apply_move!('1 12 7'.to_move(game))
467 assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
468
469 game.next_player!
470 assert_equal 2, game.current_player
471 game.apply_move!('2 6 5'.to_move(game))
472 assert_equal [:gun], game.players_cards[2].sort_by {|c| c.to_s}
473 game.apply_move!('2 0 11'.to_move(game))
474 assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
475 game.apply_move!('2 11 5'.to_move(game))
476 assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
477
478 game.next_player!
479 assert_equal 3, game.current_player
480 game.apply_move!('3 0 9'.to_move(game))
481 assert_equal [:skull], game.players_cards[3].sort_by {|c| c.to_s}
482 game.apply_move!('3 0 18'.to_move(game))
483 assert_equal [], game.players_cards[3].sort_by {|c| c.to_s}
484 game.apply_move!('3 18 14'.to_move(game))
485 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
486
487 game.next_player!
488 assert_equal 4, game.current_player
489 game.apply_move!('4 0 11'.to_move(game))
490 assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
491 game.apply_move!('4 0 16'.to_move(game))
492 assert_equal [:gun], game.players_cards[4].sort_by {|c| c.to_s}
493 game.apply_move!('4 16 14'.to_move(game))
494 assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
495
496 assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
497 assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
498 assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
499 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
500 assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
501
502 game.next_player!
503 assert_equal 0, game.current_player
504
505 game.apply_move!('0 0 15'.to_move(game))
506 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
507 game.apply_move!('0 15 11'.to_move(game))
508 assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
509 game.apply_move!('0 11 9'.to_move(game))
510 assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
511
512 game.next_player!
513 assert_equal 1, game.current_player
514 game.apply_move!('1 0 15'.to_move(game))
515 assert_equal [:hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
516 game.apply_move!('1 0 17'.to_move(game))
517 assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
518 game.apply_move!('1 17 15'.to_move(game))
519 assert_equal [:keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
520
521 game.next_player!
522 assert_equal 2, game.current_player
523 game.apply_move!('2 0 23'.to_move(game))
524 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
525 game.apply_move!('2 23 15'.to_move(game))
526 assert_equal [:bottle, :dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
527 game.apply_move!('2 0 17'.to_move(game))
528 assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
529
530 game.next_player!
531 assert_equal 3, game.current_player
532 game.apply_move!('3 10 9'.to_move(game))
533 assert_equal [:bottle, :dagger, :hat], game.players_cards[3].sort_by {|c| c.to_s}
534 game.apply_move!('3 0 24'.to_move(game))
535 assert_equal [:bottle, :dagger], game.players_cards[3].sort_by {|c| c.to_s}
536 game.apply_move!('3 0 8'.to_move(game))
537 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
538
539 game.next_player!
540 assert_equal 4, game.current_player
541 game.apply_move!('4 0 16'.to_move(game))
542 assert_equal [:keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
543 game.apply_move!('4 16 11'.to_move(game))
544 assert_equal [:keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
545 game.apply_move!('4 11 10'.to_move(game))
546 assert_equal [:dagger, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
547
548 assert_equal 2, game.board.positions[ 0].contains.length
549 assert_equal 1, game.board.positions[ 1].contains.length
550 assert_equal 1, game.board.positions[ 2].contains.length
551 assert_equal 1, game.board.positions[ 3].contains.length
552 assert_equal 3, game.board.positions[ 4].contains.length
553 assert_equal 3, game.board.positions[ 5].contains.length
554 assert_equal 0, game.board.positions[ 6].contains.length
555 assert_equal 3, game.board.positions[ 7].contains.length
556 assert_equal 1, game.board.positions[ 8].contains.length
557 assert_equal 3, game.board.positions[ 9].contains.length
558 assert_equal 3, game.board.positions[10].contains.length
559 assert_equal 1, game.board.positions[11].contains.length
560 assert_equal 0, game.board.positions[12].contains.length
561 assert_equal 0, game.board.positions[13].contains.length
562 assert_equal 3, game.board.positions[14].contains.length
563 assert_equal 3, game.board.positions[15].contains.length
564 assert_equal 0, game.board.positions[16].contains.length
565 assert_equal 1, game.board.positions[17].contains.length
566 assert_equal 0, game.board.positions[18].contains.length
567 assert_equal 0, game.board.positions[19].contains.length
568 assert_equal 0, game.board.positions[20].contains.length
569 assert_equal 0, game.board.positions[21].contains.length
570 assert_equal 0, game.board.positions[22].contains.length
571 assert_equal 0, game.board.positions[23].contains.length
572 assert_equal 1, game.board.positions[24].contains.length
573 assert_equal 0, game.board.positions[25].contains.length
574 assert_equal 0, game.board.positions[26].contains.length
575 assert_equal 0, game.board.positions[27].contains.length
576 assert_equal 0, game.board.positions[28].contains.length
577 assert_equal 0, game.board.positions[29].contains.length
578 assert_equal 0, game.board.positions[30].contains.length
579 assert_equal 0, game.board.positions[31].contains.length
580 assert_equal 0, game.board.positions[32].contains.length
581 assert_equal 0, game.board.positions[33].contains.length
582 assert_equal 0, game.board.positions[34].contains.length
583 assert_equal 0, game.board.positions[35].contains.length
584 assert_equal 0, game.board.positions[36].contains.length
585 assert_equal 0, game.board.positions[37].contains.length
586
587 assert_raise(InvalidMoveError) {game.apply_move!('0 7 6'.to_move(game))} # can't retreat into an empty space
588 assert_raise(InvalidMoveError) {game.apply_move!('0 7 5'.to_move(game))} # can't retreat into a space with three men
589 assert_raise(InvalidMoveError) {game.apply_move!('0 1 0'.to_move(game))} # can't retreat into the boat
590 assert_raise(InvalidMoveError) {game.apply_move!('0 1 12'.to_move(game))} # can't skip a vacant space of this type
591 assert_raise(InvalidMoveError) {game.apply_move!('0 1 5'.to_move(game))} # can't advance to a space with three pirates
592 assert_raise(InvalidMoveError) {game.apply_move!('0 2 6'.to_move(game))} # can't move another's piece
593 assert_raise(InvalidMoveError) {game.apply_move!('0 9 9'.to_move(game))} # can't advance the same square
594 assert_raise(InvalidMoveError) {game.apply_move!('0 9 20'.to_move(game))} # can't skip a vacant space of this type
595
596 game.next_player!
597 assert_equal 0, game.current_player
598
599 game.apply_move!('0 0 18'.to_move(game))
600 assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
601 game.apply_move!('0 7 12'.to_move(game))
602 assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
603 game.apply_move!('0 12 11'.to_move(game))
604 assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
605
606 game.next_player!
607 assert_equal 1, game.current_player
608 game.apply_move!('1 14 11'.to_move(game))
609 assert_equal [:dagger, :keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
610 game.apply_move!('1 2 23'.to_move(game))
611 assert_equal [:dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
612 game.apply_move!('1 15 14'.to_move(game))
613 assert_equal [:bottle, :bottle, :dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
614
615 game.next_player!
616 assert_equal 2, game.current_player
617 game.apply_move!('2 17 15'.to_move(game))
618 assert_equal [:bottle, :dagger, :dagger, :keys], game.players_cards[2].sort_by {|c| c.to_s}
619 game.apply_move!('2 5 27'.to_move(game))
620 assert_equal [:bottle, :dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
621 game.apply_move!('2 5 13'.to_move(game))
622 assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
623
624 game.next_player!
625 assert_equal 3, game.current_player
626 game.apply_move!('3 8 7'.to_move(game))
627 assert_equal [:bottle, :bottle, :hat], game.players_cards[3].sort_by {|c| c.to_s}
628 game.apply_move!('3 5 17'.to_move(game))
629 assert_equal [:bottle, :bottle], game.players_cards[3].sort_by {|c| c.to_s}
630 game.apply_move!('3 7 12'.to_move(game))
631 assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
632
633 game.next_player!
634 assert_equal 4, game.current_player
635 game.apply_move!('4 0 8'.to_move(game))
636 assert_equal [:dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
637 game.apply_move!('4 8 7'.to_move(game))
638 assert_equal [:bottle, :dagger, :keys, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
639 game.apply_move!('4 3 31'.to_move(game))
640 assert_equal [:bottle, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
641
642
643 game.next_player!
644 assert_equal 0, game.current_player
645
646 game.apply_move!('0 18 17'.to_move(game))
647 assert_equal [:dagger, :gun], game.players_cards[0].sort_by {|c| c.to_s}
648 game.apply_move!('0 1 16'.to_move(game))
649 assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
650 game.apply_move!('0 17 16'.to_move(game))
651 assert_equal [:dagger, :skull], game.players_cards[0].sort_by {|c| c.to_s}
652
653 game.next_player!
654 assert_equal 1, game.current_player
655 game.apply_move!('1 4 37 keys'.to_move(game))
656 assert_equal [:bottle, :bottle, :dagger, :keys], game.players_cards[1].sort_by {|c| c.to_s}
657 game.apply_move!('1 7 4'.to_move(game))
658 assert_equal [:bottle, :bottle, :bottle, :dagger, :hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
659 game.apply_move!('1 4 37 keys'.to_move(game))
660 assert_equal [:bottle, :bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
661
662 game.next_player!
663 assert_equal 2, game.current_player
664 game.apply_move!('2 7 21'.to_move(game))
665 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
666 game.apply_move!('2 13 12'.to_move(game))
667 assert_equal [:dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
668 game.apply_move!('2 10 13'.to_move(game))
669 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
670
671 game.next_player!
672 assert_equal 3, game.current_player
673 game.apply_move!('3 17 16'.to_move(game))
674 assert_equal [:bottle, :hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
675 game.apply_move!('3 9 28'.to_move(game))
676 assert_equal [:hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
677 game.apply_move!('3 9 18'.to_move(game))
678 assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
679
680 game.next_player!
681 assert_equal 4, game.current_player
682 game.apply_move!('4 7 37 keys'.to_move(game))
683 assert_equal [:bottle, :dagger, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
684 game.apply_move!('4 11 10'.to_move(game))
685 assert_equal [:bottle, :dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
686 game.apply_move!('4 10 32'.to_move(game))
687 assert_equal [:dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
688
689
690 game.next_player!
691 assert_equal 0, game.current_player
692
693 game.apply_move!('0 11 10'.to_move(game))
694 assert_equal [:bottle, :dagger, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
695 game.apply_move!('0 4 8'.to_move(game))
696 assert_equal [:bottle, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
697 game.apply_move!('0 4 17'.to_move(game))
698 assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
699
700 game.next_player!
701 assert_equal 1, game.current_player
702 game.apply_move!('1 11 37 bottle'.to_move(game))
703 assert_equal [:bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
704 game.apply_move!('1 14 37 bottle'.to_move(game))
705 assert_equal [:bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
706 game.apply_move!('1 15 37 bottle'.to_move(game))
707 assert_equal [:dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
708
709 game.next_player!
710 assert_equal 2, game.current_player
711 game.apply_move!('2 13 12'.to_move(game))
712 assert_equal [:dagger, :gun, :hat], game.players_cards[2].sort_by {|c| c.to_s}
713 game.apply_move!('2 12 22 gun'.to_move(game))
714 assert_equal [:dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
715 game.apply_move!('2 12 25 hat'.to_move(game))
716 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
717
718 game.next_player!
719 assert_equal 3, game.current_player
720 game.apply_move!('3 16 15'.to_move(game))
721 assert_equal [:dagger, :gun, :hat], game.players_cards[3].sort_by {|c| c.to_s}
722 game.apply_move!('3 12 35 hat'.to_move(game))
723 assert_equal [:dagger, :gun], game.players_cards[3].sort_by {|c| c.to_s}
724 game.apply_move!('3 14 29 gun'.to_move(game))
725 assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
726
727 game.next_player!
728 assert_equal 4, game.current_player
729 game.apply_move!('4 10 20 skull'.to_move(game))
730 assert_equal [:dagger, :dagger, :gun, :skull], game.players_cards[4].sort_by {|c| c.to_s}
731 game.apply_move!('4 10 30 skull'.to_move(game))
732 assert_equal [:dagger, :dagger, :gun], game.players_cards[4].sort_by {|c| c.to_s}
733 game.apply_move!('4 14 36 gun'.to_move(game))
734 assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
735
736
737 game.next_player!
738 assert_equal 0, game.current_player
739
740 game.apply_move!('0 17 16'.to_move(game))
741 assert_equal [:bottle, :gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
742 game.apply_move!('0 8 33 skull'.to_move(game))
743 assert_equal [:bottle, :gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
744 game.apply_move!('0 9 17 hat'.to_move(game))
745 assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
746
747 game.next_player!
748 assert_equal 1, game.current_player
749 assert_raise(GameWonNotice) {game.apply_move!('1 23 37 hat'.to_move(game))}
750 assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
751
752 assert_equal 0, game.board.positions[ 0].contains.length
753 assert_equal 0, game.board.positions[ 1].contains.length
754 assert_equal 0, game.board.positions[ 2].contains.length
755 assert_equal 0, game.board.positions[ 3].contains.length
756 assert_equal 0, game.board.positions[ 4].contains.length
757 assert_equal 0, game.board.positions[ 5].contains.length
758 assert_equal 0, game.board.positions[ 6].contains.length
759 assert_equal 0, game.board.positions[ 7].contains.length
760 assert_equal 0, game.board.positions[ 8].contains.length
761 assert_equal 0, game.board.positions[ 9].contains.length
762 assert_equal 1, game.board.positions[10].contains.length
763 assert_equal 0, game.board.positions[11].contains.length
764 assert_equal 0, game.board.positions[12].contains.length
765 assert_equal 0, game.board.positions[13].contains.length
766 assert_equal 0, game.board.positions[14].contains.length
767 assert_equal 3, game.board.positions[15].contains.length
768 assert_equal 3, game.board.positions[16].contains.length
769 assert_equal 1, game.board.positions[17].contains.length
770 assert_equal 1, game.board.positions[18].contains.length
771 assert_equal 0, game.board.positions[19].contains.length
772 assert_equal 1, game.board.positions[20].contains.length
773 assert_equal 1, game.board.positions[21].contains.length
774 assert_equal 1, game.board.positions[22].contains.length
775 assert_equal 0, game.board.positions[23].contains.length
776 assert_equal 1, game.board.positions[24].contains.length
777 assert_equal 1, game.board.positions[25].contains.length
778 assert_equal 0, game.board.positions[26].contains.length
779 assert_equal 1, game.board.positions[27].contains.length
780 assert_equal 1, game.board.positions[28].contains.length
781 assert_equal 1, game.board.positions[29].contains.length
782 assert_equal 1, game.board.positions[30].contains.length
783 assert_equal 1, game.board.positions[31].contains.length
784 assert_equal 1, game.board.positions[32].contains.length
785 assert_equal 1, game.board.positions[33].contains.length
786 assert_equal 0, game.board.positions[34].contains.length
787 assert_equal 1, game.board.positions[35].contains.length
788 assert_equal 1, game.board.positions[36].contains.length
789 assert_equal 7, game.board.positions[37].contains.length
790
791 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
792 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
793 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
794 :hat, :gun, :skull, :keys, :gun, :skull, :gun],
795 game.deck
796
797 assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
798 assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
799 assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
800 assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
801 assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
802
803 end
804 #
805 # : move without a card
806 # move to an occupied space
807 # retreat to an emtpy space
808 # retreat to an overfull space
809 # retreat to the cell with one pirate already in it
810
811
812 # Test current player switching
813
814 # Test undo moves
815
816 # Test file reading
817 # (need a full game file to read)
818
819 def test_undo
820 game = Game.new(5,6,6)
821 game.set_testing_game!
822 game.pieces.each do |player|
823 player.each do |piece|
824 assert_equal game.board.positions[0], piece.position
825 end
826 end
827 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
828 :keys, :dagger, :skull, :hat, :gun, :bottle,
829 :dagger, :bottle, :keys, :gun, :hat, :skull,
830 :dagger, :skull, :bottle, :gun, :keys, :hat,
831 :hat, :dagger, :keys, :bottle, :gun, :skull,
832 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
833 game.board.positions.collect {|p| p.symbol}
834 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
835 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
836 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
837 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
838 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
839 assert_equal 5, game.players_cards.length
840 assert_equal 5, game.players.length
841 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
842 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
843 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
844 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
845 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
846 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
847 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
848 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
849 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
850 :gun, :skull, :keys, :bottle, :skull],
851 game.deck
852
853 assert_equal 0, game.history.length
854
855 game.apply_move!('0 0 5'.to_move(game))
856 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
857 assert_equal 1, game.history.length
858 game.apply_move!('0 0 4'.to_move(game))
859 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
860 assert_equal 2, game.history.length
861 game.apply_move!('0 5 4'.to_move(game))
862 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
863 assert_equal 3, game.history.length
864
865 game.next_player!
866 assert_equal 1, game.current_player
867 assert_equal 3, game.history.length
868 game.apply_move!('1 0 2'.to_move(game))
869 assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
870 assert_equal 4, game.history.length
871 game.apply_move!('1 0 7'.to_move(game))
872 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
873 assert_equal 5, game.history.length
874 game.apply_move!('1 7 4'.to_move(game))
875 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
876 assert_equal 6, game.history.length
877 assert_equal 1, game.current_player
878 assert_equal 3, game.moves_by_current_player
879
880 assert_equal 26, game.board.positions[ 0].contains.length
881 assert_equal 0, game.board.positions[ 1].contains.length
882 assert_equal 1, game.board.positions[ 2].contains.length
883 assert_equal 0, game.board.positions[ 3].contains.length
884 assert_equal 3, game.board.positions[ 4].contains.length
885 assert_equal 0, game.board.positions[ 5].contains.length
886 assert_equal 0, game.board.positions[ 6].contains.length
887 assert_equal 0, game.board.positions[ 7].contains.length
888 assert_equal 0, game.board.positions[ 8].contains.length
889 assert_equal 0, game.board.positions[ 9].contains.length
890 assert_equal 0, game.board.positions[10].contains.length
891 assert_equal 0, game.board.positions[11].contains.length
892 assert_equal 0, game.board.positions[12].contains.length
893 assert_equal 0, game.board.positions[13].contains.length
894 assert_equal 0, game.board.positions[14].contains.length
895 assert_equal 0, game.board.positions[15].contains.length
896 assert_equal 0, game.board.positions[16].contains.length
897 assert_equal 0, game.board.positions[17].contains.length
898 assert_equal 0, game.board.positions[18].contains.length
899 assert_equal 0, game.board.positions[19].contains.length
900 assert_equal 0, game.board.positions[20].contains.length
901 assert_equal 0, game.board.positions[21].contains.length
902 assert_equal 0, game.board.positions[22].contains.length
903 assert_equal 0, game.board.positions[23].contains.length
904 assert_equal 0, game.board.positions[24].contains.length
905 assert_equal 0, game.board.positions[25].contains.length
906 assert_equal 0, game.board.positions[26].contains.length
907 assert_equal 0, game.board.positions[27].contains.length
908 assert_equal 0, game.board.positions[28].contains.length
909 assert_equal 0, game.board.positions[29].contains.length
910 assert_equal 0, game.board.positions[30].contains.length
911 assert_equal 0, game.board.positions[31].contains.length
912 assert_equal 0, game.board.positions[32].contains.length
913 assert_equal 0, game.board.positions[33].contains.length
914 assert_equal 0, game.board.positions[34].contains.length
915 assert_equal 0, game.board.positions[35].contains.length
916 assert_equal 0, game.board.positions[36].contains.length
917 assert_equal 0, game.board.positions[37].contains.length
918
919 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
920 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
921 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
922 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
923 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
924 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
925 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
926 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
927 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
928 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
929 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
930 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
931 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
932 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
933 :gun, :skull],
934 game.deck
935
936 game.undo_move! # player 1's third move
937
938 assert_equal 5, game.history.length
939
940 assert_equal 26, game.board.positions[ 0].contains.length
941 assert_equal 0, game.board.positions[ 1].contains.length
942 assert_equal 1, game.board.positions[ 2].contains.length
943 assert_equal 0, game.board.positions[ 3].contains.length
944 assert_equal 2, game.board.positions[ 4].contains.length
945 assert_equal 0, game.board.positions[ 5].contains.length
946 assert_equal 0, game.board.positions[ 6].contains.length
947 assert_equal 1, game.board.positions[ 7].contains.length
948 assert_equal 0, game.board.positions[ 8].contains.length
949 assert_equal 0, game.board.positions[ 9].contains.length
950 assert_equal 0, game.board.positions[10].contains.length
951 assert_equal 0, game.board.positions[11].contains.length
952 assert_equal 0, game.board.positions[12].contains.length
953 assert_equal 0, game.board.positions[13].contains.length
954 assert_equal 0, game.board.positions[14].contains.length
955 assert_equal 0, game.board.positions[15].contains.length
956 assert_equal 0, game.board.positions[16].contains.length
957 assert_equal 0, game.board.positions[17].contains.length
958 assert_equal 0, game.board.positions[18].contains.length
959 assert_equal 0, game.board.positions[19].contains.length
960 assert_equal 0, game.board.positions[20].contains.length
961 assert_equal 0, game.board.positions[21].contains.length
962 assert_equal 0, game.board.positions[22].contains.length
963 assert_equal 0, game.board.positions[23].contains.length
964 assert_equal 0, game.board.positions[24].contains.length
965 assert_equal 0, game.board.positions[25].contains.length
966 assert_equal 0, game.board.positions[26].contains.length
967 assert_equal 0, game.board.positions[27].contains.length
968 assert_equal 0, game.board.positions[28].contains.length
969 assert_equal 0, game.board.positions[29].contains.length
970 assert_equal 0, game.board.positions[30].contains.length
971 assert_equal 0, game.board.positions[31].contains.length
972 assert_equal 0, game.board.positions[32].contains.length
973 assert_equal 0, game.board.positions[33].contains.length
974 assert_equal 0, game.board.positions[34].contains.length
975 assert_equal 0, game.board.positions[35].contains.length
976 assert_equal 0, game.board.positions[36].contains.length
977 assert_equal 0, game.board.positions[37].contains.length
978
979 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
980 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
981 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
982 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
983 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
984 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
985 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
986 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
987 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
988 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
989 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
990 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
991 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
992 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
993 :gun, :skull, :keys, :bottle],
994 game.deck
995 assert_equal 1, game.current_player
996 assert_equal 2, game.moves_by_current_player
997
998 # Re-apply player 1's third move
999 game.apply_move!('1 7 4'.to_move(game))
1000 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1001
1002 game.next_player!
1003 assert_equal 2, game.current_player
1004 game.apply_move!('2 0 7'.to_move(game))
1005 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
1006 game.apply_move!('2 0 10'.to_move(game))
1007 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
1008
1009 assert_equal 8, game.history.length
1010
1011 assert_equal 24, game.board.positions[ 0].contains.length
1012 assert_equal 0, game.board.positions[ 1].contains.length
1013 assert_equal 1, game.board.positions[ 2].contains.length
1014 assert_equal 0, game.board.positions[ 3].contains.length
1015 assert_equal 3, game.board.positions[ 4].contains.length
1016 assert_equal 0, game.board.positions[ 5].contains.length
1017 assert_equal 0, game.board.positions[ 6].contains.length
1018 assert_equal 1, game.board.positions[ 7].contains.length
1019 assert_equal 0, game.board.positions[ 8].contains.length
1020 assert_equal 0, game.board.positions[ 9].contains.length
1021 assert_equal 1, game.board.positions[10].contains.length
1022 assert_equal 0, game.board.positions[11].contains.length
1023 assert_equal 0, game.board.positions[12].contains.length
1024 assert_equal 0, game.board.positions[13].contains.length
1025 assert_equal 0, game.board.positions[14].contains.length
1026 assert_equal 0, game.board.positions[15].contains.length
1027 assert_equal 0, game.board.positions[16].contains.length
1028 assert_equal 0, game.board.positions[17].contains.length
1029 assert_equal 0, game.board.positions[18].contains.length
1030 assert_equal 0, game.board.positions[19].contains.length
1031 assert_equal 0, game.board.positions[20].contains.length
1032 assert_equal 0, game.board.positions[21].contains.length
1033 assert_equal 0, game.board.positions[22].contains.length
1034 assert_equal 0, game.board.positions[23].contains.length
1035 assert_equal 0, game.board.positions[24].contains.length
1036 assert_equal 0, game.board.positions[25].contains.length
1037 assert_equal 0, game.board.positions[26].contains.length
1038 assert_equal 0, game.board.positions[27].contains.length
1039 assert_equal 0, game.board.positions[28].contains.length
1040 assert_equal 0, game.board.positions[29].contains.length
1041 assert_equal 0, game.board.positions[30].contains.length
1042 assert_equal 0, game.board.positions[31].contains.length
1043 assert_equal 0, game.board.positions[32].contains.length
1044 assert_equal 0, game.board.positions[33].contains.length
1045 assert_equal 0, game.board.positions[34].contains.length
1046 assert_equal 0, game.board.positions[35].contains.length
1047 assert_equal 0, game.board.positions[36].contains.length
1048 assert_equal 0, game.board.positions[37].contains.length
1049
1050 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1051 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1052 assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
1053 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1054 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1055 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1056 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1057 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1058 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1059 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1060 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1061 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1062 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1063 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1064 :gun, :skull],
1065 game.deck
1066 assert_equal 2, game.current_player
1067 assert_equal 2, game.moves_by_current_player
1068
1069 game.undo_move! # player 2's second move
1070
1071 assert_equal 7, game.history.length
1072
1073 assert_equal 25, game.board.positions[ 0].contains.length
1074 assert_equal 0, game.board.positions[ 1].contains.length
1075 assert_equal 1, game.board.positions[ 2].contains.length
1076 assert_equal 0, game.board.positions[ 3].contains.length
1077 assert_equal 3, game.board.positions[ 4].contains.length
1078 assert_equal 0, game.board.positions[ 5].contains.length
1079 assert_equal 0, game.board.positions[ 6].contains.length
1080 assert_equal 1, game.board.positions[ 7].contains.length
1081 assert_equal 0, game.board.positions[ 8].contains.length
1082 assert_equal 0, game.board.positions[ 9].contains.length
1083 assert_equal 0, game.board.positions[10].contains.length
1084 assert_equal 0, game.board.positions[11].contains.length
1085 assert_equal 0, game.board.positions[12].contains.length
1086 assert_equal 0, game.board.positions[13].contains.length
1087 assert_equal 0, game.board.positions[14].contains.length
1088 assert_equal 0, game.board.positions[15].contains.length
1089 assert_equal 0, game.board.positions[16].contains.length
1090 assert_equal 0, game.board.positions[17].contains.length
1091 assert_equal 0, game.board.positions[18].contains.length
1092 assert_equal 0, game.board.positions[19].contains.length
1093 assert_equal 0, game.board.positions[20].contains.length
1094 assert_equal 0, game.board.positions[21].contains.length
1095 assert_equal 0, game.board.positions[22].contains.length
1096 assert_equal 0, game.board.positions[23].contains.length
1097 assert_equal 0, game.board.positions[24].contains.length
1098 assert_equal 0, game.board.positions[25].contains.length
1099 assert_equal 0, game.board.positions[26].contains.length
1100 assert_equal 0, game.board.positions[27].contains.length
1101 assert_equal 0, game.board.positions[28].contains.length
1102 assert_equal 0, game.board.positions[29].contains.length
1103 assert_equal 0, game.board.positions[30].contains.length
1104 assert_equal 0, game.board.positions[31].contains.length
1105 assert_equal 0, game.board.positions[32].contains.length
1106 assert_equal 0, game.board.positions[33].contains.length
1107 assert_equal 0, game.board.positions[34].contains.length
1108 assert_equal 0, game.board.positions[35].contains.length
1109 assert_equal 0, game.board.positions[36].contains.length
1110 assert_equal 0, game.board.positions[37].contains.length
1111
1112 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1113 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1114 assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
1115 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1116 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1117 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1118 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1119 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1120 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1121 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1122 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1123 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1124 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1125 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1126 :gun, :skull],
1127 game.deck
1128 assert_equal 2, game.current_player
1129 assert_equal 1, game.moves_by_current_player
1130
1131
1132 game.undo_move! # Player 2's first move
1133
1134 assert_equal 6, game.history.length
1135
1136 assert_equal 26, game.board.positions[ 0].contains.length
1137 assert_equal 0, game.board.positions[ 1].contains.length
1138 assert_equal 1, game.board.positions[ 2].contains.length
1139 assert_equal 0, game.board.positions[ 3].contains.length
1140 assert_equal 3, game.board.positions[ 4].contains.length
1141 assert_equal 0, game.board.positions[ 5].contains.length
1142 assert_equal 0, game.board.positions[ 6].contains.length
1143 assert_equal 0, game.board.positions[ 7].contains.length
1144 assert_equal 0, game.board.positions[ 8].contains.length
1145 assert_equal 0, game.board.positions[ 9].contains.length
1146 assert_equal 0, game.board.positions[10].contains.length
1147 assert_equal 0, game.board.positions[11].contains.length
1148 assert_equal 0, game.board.positions[12].contains.length
1149 assert_equal 0, game.board.positions[13].contains.length
1150 assert_equal 0, game.board.positions[14].contains.length
1151 assert_equal 0, game.board.positions[15].contains.length
1152 assert_equal 0, game.board.positions[16].contains.length
1153 assert_equal 0, game.board.positions[17].contains.length
1154 assert_equal 0, game.board.positions[18].contains.length
1155 assert_equal 0, game.board.positions[19].contains.length
1156 assert_equal 0, game.board.positions[20].contains.length
1157 assert_equal 0, game.board.positions[21].contains.length
1158 assert_equal 0, game.board.positions[22].contains.length
1159 assert_equal 0, game.board.positions[23].contains.length
1160 assert_equal 0, game.board.positions[24].contains.length
1161 assert_equal 0, game.board.positions[25].contains.length
1162 assert_equal 0, game.board.positions[26].contains.length
1163 assert_equal 0, game.board.positions[27].contains.length
1164 assert_equal 0, game.board.positions[28].contains.length
1165 assert_equal 0, game.board.positions[29].contains.length
1166 assert_equal 0, game.board.positions[30].contains.length
1167 assert_equal 0, game.board.positions[31].contains.length
1168 assert_equal 0, game.board.positions[32].contains.length
1169 assert_equal 0, game.board.positions[33].contains.length
1170 assert_equal 0, game.board.positions[34].contains.length
1171 assert_equal 0, game.board.positions[35].contains.length
1172 assert_equal 0, game.board.positions[36].contains.length
1173 assert_equal 0, game.board.positions[37].contains.length
1174
1175 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1176 assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1177 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1178 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1179 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1180 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1181 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1182 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1183 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1184 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1185 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1186 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1187 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1188 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1189 :gun, :skull],
1190 game.deck
1191 assert_equal 2, game.current_player
1192 assert_equal 0, game.moves_by_current_player
1193
1194
1195 game.undo_move! # Player 1's third move
1196
1197 assert_equal 5, game.history.length
1198
1199 assert_equal 26, game.board.positions[ 0].contains.length
1200 assert_equal 0, game.board.positions[ 1].contains.length
1201 assert_equal 1, game.board.positions[ 2].contains.length
1202 assert_equal 0, game.board.positions[ 3].contains.length
1203 assert_equal 2, game.board.positions[ 4].contains.length
1204 assert_equal 0, game.board.positions[ 5].contains.length
1205 assert_equal 0, game.board.positions[ 6].contains.length
1206 assert_equal 1, game.board.positions[ 7].contains.length
1207 assert_equal 0, game.board.positions[ 8].contains.length
1208 assert_equal 0, game.board.positions[ 9].contains.length
1209 assert_equal 0, game.board.positions[10].contains.length
1210 assert_equal 0, game.board.positions[11].contains.length
1211 assert_equal 0, game.board.positions[12].contains.length
1212 assert_equal 0, game.board.positions[13].contains.length
1213 assert_equal 0, game.board.positions[14].contains.length
1214 assert_equal 0, game.board.positions[15].contains.length
1215 assert_equal 0, game.board.positions[16].contains.length
1216 assert_equal 0, game.board.positions[17].contains.length
1217 assert_equal 0, game.board.positions[18].contains.length
1218 assert_equal 0, game.board.positions[19].contains.length
1219 assert_equal 0, game.board.positions[20].contains.length
1220 assert_equal 0, game.board.positions[21].contains.length
1221 assert_equal 0, game.board.positions[22].contains.length
1222 assert_equal 0, game.board.positions[23].contains.length
1223 assert_equal 0, game.board.positions[24].contains.length
1224 assert_equal 0, game.board.positions[25].contains.length
1225 assert_equal 0, game.board.positions[26].contains.length
1226 assert_equal 0, game.board.positions[27].contains.length
1227 assert_equal 0, game.board.positions[28].contains.length
1228 assert_equal 0, game.board.positions[29].contains.length
1229 assert_equal 0, game.board.positions[30].contains.length
1230 assert_equal 0, game.board.positions[31].contains.length
1231 assert_equal 0, game.board.positions[32].contains.length
1232 assert_equal 0, game.board.positions[33].contains.length
1233 assert_equal 0, game.board.positions[34].contains.length
1234 assert_equal 0, game.board.positions[35].contains.length
1235 assert_equal 0, game.board.positions[36].contains.length
1236 assert_equal 0, game.board.positions[37].contains.length
1237
1238 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1239 assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
1240 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1241 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1242 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1243 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1244 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1245 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1246 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1247 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1248 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1249 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1250 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1251 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1252 :gun, :skull, :keys, :bottle],
1253 game.deck
1254 assert_equal 1, game.current_player
1255 assert_equal 2, game.moves_by_current_player
1256
1257 end
1258
1259 def test_apply_moves
1260 game = Game.new(5,6,6)
1261 game.set_testing_game!
1262 game.pieces.each do |player|
1263 player.each do |piece|
1264 assert_equal game.board.positions[0], piece.position
1265 end
1266 end
1267 assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
1268 :keys, :dagger, :skull, :hat, :gun, :bottle,
1269 :dagger, :bottle, :keys, :gun, :hat, :skull,
1270 :dagger, :skull, :bottle, :gun, :keys, :hat,
1271 :hat, :dagger, :keys, :bottle, :gun, :skull,
1272 :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
1273 game.board.positions.collect {|p| p.symbol}
1274 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1275 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1276 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1277 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1278 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1279 assert_equal 5, game.players_cards.length
1280 assert_equal 5, game.players.length
1281 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1282 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1283 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1284 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1285 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1286 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1287 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1288 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1289 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1290 :gun, :skull, :keys, :bottle, :skull],
1291 game.deck
1292
1293 assert_equal 0, game.history.length
1294
1295 game.apply_move!('0 0 5'.to_move(game))
1296 assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
1297 assert_equal 1, game.history.length
1298 game.apply_move!('0 0 4'.to_move(game))
1299 assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
1300 assert_equal 2, game.history.length
1301 game.apply_move!('0 5 4'.to_move(game))
1302 assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1303 assert_equal 3, game.history.length
1304
1305 game.next_player!
1306 assert_equal 1, game.current_player
1307 assert_equal 3, game.history.length
1308 game.apply_move!('1 0 2'.to_move(game))
1309 end
1310
1311 def test_read_game_lines
1312 gamelines1 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1313 "keys", "dagger", "skull", "hat", "gun", "bottle",
1314 "dagger", "bottle", "keys", "gun", "hat", "skull",
1315 "dagger", "skull", "bottle", "gun", "keys", "hat",
1316 "hat", "dagger", "keys", "bottle", "gun", "skull",
1317 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1318 "1 0 5 skull", "1 0 4 hat",
1319 "1",
1320 "dagger"]
1321 assert_nothing_raised {Game.read_game(gamelines1)}
1322 game, moves = Game.read_game(gamelines1)
1323 assert_equal 2, game.history.length
1324 assert_equal 0, game.current_player
1325 assert_equal 2, game.moves_by_current_player
1326 assert_equal 1, game.players_cards[0].length
1327 assert_equal 3, game.players_cards[1].length
1328 assert_equal 3, game.players_cards[2].length
1329 assert_equal 3, game.players_cards[3].length
1330 assert_equal 3, game.players_cards[4].length
1331 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 15, game.deck.length
1332
1333 game.apply_move!('0 5 4'.to_move(game))
1334 assert_equal 3, game.history.length
1335 assert_equal 0, game.current_player
1336 assert_equal 3, game.moves_by_current_player
1337 assert_equal 2, game.players_cards[0].length
1338 assert_equal 3, game.players_cards[1].length
1339 assert_equal 3, game.players_cards[2].length
1340 assert_equal 3, game.players_cards[3].length
1341 assert_equal 3, game.players_cards[4].length
1342 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1343
1344 gamelines2 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1345 "keys", "dagger", "skull", "hat", "gun", "bottle",
1346 "dagger", "bottle", "keys", "gun", "hat", "skull",
1347 "dagger", "skull", "bottle", "gun", "keys", "hat",
1348 "hat", "dagger", "keys", "bottle", "gun", "skull",
1349 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1350 "1 0 5", "1 0 4", "1 5 4",
1351 "2",
1352 "dagger", "hat", "keys"]
1353 assert_nothing_raised {Game.read_game(gamelines2)}
1354 game, moves = Game.read_game(gamelines2)
1355 assert_equal 3, game.history.length
1356 assert_equal 1, game.current_player
1357 assert_equal 0, game.moves_by_current_player
1358 assert_equal 2, game.players_cards[0].length
1359 assert_equal 3, game.players_cards[1].length
1360 assert_equal 3, game.players_cards[2].length
1361 assert_equal 3, game.players_cards[3].length
1362 assert_equal 3, game.players_cards[4].length
1363 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1364
1365 game.apply_move!('1 0 2'.to_move(game))
1366 assert_equal 4, game.history.length
1367 assert_equal 1, game.current_player
1368 assert_equal 1, game.moves_by_current_player
1369 assert_equal 2, game.players_cards[0].length
1370 assert_equal 2, game.players_cards[1].length
1371 assert_equal 3, game.players_cards[2].length
1372 assert_equal 3, game.players_cards[3].length
1373 assert_equal 3, game.players_cards[4].length
1374 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1375
1376 gamelines3 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1377 "keys", "dagger", "skull", "hat", "gun", "bottle",
1378 "dagger", "bottle", "keys", "gun", "hat", "skull",
1379 "dagger", "skull", "bottle", "gun", "keys", "hat",
1380 "hat", "dagger", "keys", "bottle", "gun", "skull",
1381 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1382 "1 0 5", "1 0 4", "1 5 4", "2 0 2",
1383 "2",
1384 "dagger", "keys"]
1385 assert_nothing_raised {Game.read_game(gamelines3)}
1386 game, moves = Game.read_game(gamelines3)
1387 assert_equal 4, game.history.length
1388 assert_equal 1, game.current_player
1389 assert_equal 1, game.moves_by_current_player
1390 assert_equal 2, game.players_cards[0].length
1391 assert_equal 2, game.players_cards[1].length
1392 assert_equal 3, game.players_cards[2].length
1393 assert_equal 3, game.players_cards[3].length
1394 assert_equal 3, game.players_cards[4].length
1395 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1396
1397 game.apply_move!('1 0 7'.to_move(game))
1398 assert_equal 5, game.history.length
1399 assert_equal 1, game.current_player
1400 assert_equal 2, game.moves_by_current_player
1401 assert_equal 2, game.players_cards[0].length
1402 assert_equal 1, game.players_cards[1].length
1403 assert_equal 3, game.players_cards[2].length
1404 assert_equal 3, game.players_cards[3].length
1405 assert_equal 3, game.players_cards[4].length
1406 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1407
1408 gamelines4 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1409 "keys", "dagger", "skull", "hat", "gun", "bottle",
1410 "dagger", "bottle", "keys", "gun", "hat", "skull",
1411 "dagger", "skull", "bottle", "gun", "keys", "hat",
1412 "hat", "dagger", "keys", "bottle", "gun", "skull",
1413 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1414 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7",
1415 "2",
1416 "dagger"]
1417 assert_nothing_raised {Game.read_game(gamelines4)}
1418 game, moves = Game.read_game(gamelines4)
1419 assert_equal 5, game.history.length
1420 assert_equal 1, game.current_player
1421 assert_equal 2, game.moves_by_current_player
1422 assert_equal 2, game.players_cards[0].length
1423 assert_equal 1, game.players_cards[1].length
1424 assert_equal 3, game.players_cards[2].length
1425 assert_equal 3, game.players_cards[3].length
1426 assert_equal 3, game.players_cards[4].length
1427 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
1428
1429 game.apply_move!('1 7 4'.to_move(game))
1430 assert_equal 6, game.history.length
1431 assert_equal 1, game.current_player
1432 assert_equal 3, game.moves_by_current_player
1433 assert_equal 2, game.players_cards[0].length
1434 assert_equal 3, game.players_cards[1].length
1435 assert_equal 3, game.players_cards[2].length
1436 assert_equal 3, game.players_cards[3].length
1437 assert_equal 3, game.players_cards[4].length
1438 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1439
1440 gamelines5 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1441 "keys", "dagger", "skull", "hat", "gun", "bottle",
1442 "dagger", "bottle", "keys", "gun", "hat", "skull",
1443 "dagger", "skull", "bottle", "gun", "keys", "hat",
1444 "hat", "dagger", "keys", "bottle", "gun", "skull",
1445 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1446 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
1447 "2",
1448 "bottle", "hat", "keys"]
1449 assert_nothing_raised {Game.read_game(gamelines5)}
1450 game, moves = Game.read_game(gamelines5)
1451 assert_equal 6, game.history.length
1452 assert_equal 1, game.current_player
1453 assert_equal 3, game.moves_by_current_player
1454 assert_equal 2, game.players_cards[0].length
1455 assert_equal 3, game.players_cards[1].length
1456 assert_equal 3, game.players_cards[2].length
1457 assert_equal 3, game.players_cards[3].length
1458 assert_equal 3, game.players_cards[4].length
1459 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1460
1461 game.players_cards[2] << :keys
1462 game.players_cards[2] << :hat
1463 game.apply_move!('3 0 7'.to_move(game, true), 2)
1464 assert_equal 7, game.history.length
1465 assert_equal 2, game.current_player
1466 assert_equal 1, game.moves_by_current_player
1467 game.apply_move!('3 0 10'.to_move(game, true))
1468 assert_equal 8, game.history.length
1469 assert_equal 2, game.current_player
1470 assert_equal 2, game.moves_by_current_player
1471
1472 gamelines6 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
1473 "keys", "dagger", "skull", "hat", "gun", "bottle",
1474 "dagger", "bottle", "keys", "gun", "hat", "skull",
1475 "dagger", "skull", "bottle", "gun", "keys", "hat",
1476 "hat", "dagger", "keys", "bottle", "gun", "skull",
1477 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1478 "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
1479 "3",
1480 "bottle", "hat", "keys"]
1481 assert_nothing_raised {Game.read_game(gamelines6)}
1482 game, moves = Game.read_game(gamelines6)
1483 assert_equal 6, game.history.length
1484 assert_equal 2, game.current_player
1485 assert_equal 0, game.moves_by_current_player
1486 assert_equal 2, game.players_cards[0].length
1487 assert_equal 3, game.players_cards[1].length
1488 assert_equal 3, game.players_cards[2].length
1489 assert_equal 3, game.players_cards[3].length
1490 assert_equal 3, game.players_cards[4].length
1491 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1492
1493 game.apply_move!('2 0 7'.to_move(game))
1494 assert_equal 7, game.history.length
1495 assert_equal 2, game.current_player
1496 assert_equal 1, game.moves_by_current_player
1497 assert_equal 2, game.players_cards[0].length
1498 assert_equal 3, game.players_cards[1].length
1499 assert_equal 2, game.players_cards[2].length
1500 assert_equal 3, game.players_cards[3].length
1501 assert_equal 3, game.players_cards[4].length
1502 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1503
1504 game.apply_move!('2 0 10'.to_move(game))
1505 assert_equal 8, game.history.length
1506 assert_equal 2, game.current_player
1507 assert_equal 2, game.moves_by_current_player
1508 assert_equal 2, game.players_cards[0].length
1509 assert_equal 3, game.players_cards[1].length
1510 assert_equal 1, game.players_cards[2].length
1511 assert_equal 3, game.players_cards[3].length
1512 assert_equal 3, game.players_cards[4].length
1513 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
1514
1515 # Need to do a test with a very long sequence of moves,
1516 # to test that the card dealing works properly when the deck is exhausted
1517
1518 end
1519
1520 def test_dealing
1521 game = Game.new(5,6,6)
1522 game.set_testing_game!
1523 0.upto(4) do |i|
1524 assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
1525 end
1526 assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 5 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
1527 assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
1528 assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1529 assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
1530 assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
1531 assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
1532 assert_equal 5, game.players_cards.length
1533 assert_equal 5, game.players.length
1534 assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
1535 :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
1536 :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
1537 :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
1538 :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
1539 :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
1540 :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
1541 :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
1542 :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
1543 :gun, :skull, :keys, :bottle, :skull],
1544 game.deck
1545 game.deal_cards!(86, 0)
1546 assert_equal 89, game.players_cards[0].length
1547 assert_equal 1, game.deck.length
1548 assert_equal [:hat], game.deck
1549
1550 game.players_cards[0] = [:hat, :hat, :hat, :hat, :hat]
1551 game.players_cards[1] = [:keys, :keys, :keys]
1552 game.players_cards[2] = [:bottle, :dagger, :skull]
1553 game.players_cards[3] = []
1554 game.players_cards[4] = []
1555 game.deal_cards!(1, 3)
1556
1557 assert_equal [:hat, :hat, :hat, :hat, :hat], game.players_cards[0].sort_by {|c| c.to_s}
1558 assert_equal [:keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
1559 assert_equal [:bottle, :dagger, :skull], game.players_cards[2].sort_by {|c| c.to_s}
1560 assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
1561 assert_equal [], game.players_cards[4].sort_by {|c| c.to_s}
1562 assert_equal [], game.deck
1563
1564 game.deal_cards!(1, 4)
1565 assert_equal [:keys], game.players_cards[4].sort_by {|c| c.to_s}
1566 assert_equal $CARDS_PER_SYMBOL - 6, game.deck.select {|c| c == :hat}.length
1567 assert_equal $CARDS_PER_SYMBOL - 4, game.deck.select {|c| c == :keys}.length
1568 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :bottle}.length
1569 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :dagger}.length
1570 assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :skull}.length
1571 assert_equal $CARDS_PER_SYMBOL, game.deck.select {|c| c == :gun}.length
1572 assert_equal $CARDS_PER_SYMBOL * 6 - 13, game.deck.length
1573
1574 end
1575
1576 def test_long_deal
1577 gamelines0 = ["3", "cell",
1578 "gun", "keys", "dagger", "hat", "skull", "bottle",
1579 "keys", "dagger", "skull", "hat", "gun", "bottle",
1580 "dagger", "bottle", "keys", "gun", "hat", "skull",
1581 "dagger", "skull", "bottle", "gun", "keys", "hat",
1582 "hat", "dagger", "keys", "bottle", "gun", "skull",
1583 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1584 "1",
1585 "hat", "skull", "bottle"]
1586 assert_nothing_raised {Game.read_game(gamelines0)}
1587 game, moves = Game.read_game(gamelines0)
1588 assert_equal 0, game.history.length
1589 assert_equal 0, game.current_player
1590 assert_equal 0, game.moves_by_current_player
1591 assert_equal 3, game.players_cards[0].length
1592 assert_equal 3, game.players_cards[1].length
1593 assert_equal 3, game.players_cards[2].length
1594 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
1595 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1596 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length, unplayed_cards.length
1597 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
1598 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
1599 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
1600 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :gun}).length
1601 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
1602 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :keys}).length
1603 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
1604
1605 gamelines1 = ["3", "cell",
1606 "gun", "keys", "dagger", "hat", "skull", "bottle",
1607 "keys", "dagger", "skull", "hat", "gun", "bottle",
1608 "dagger", "bottle", "keys", "gun", "hat", "skull",
1609 "dagger", "skull", "bottle", "gun", "keys", "hat",
1610 "hat", "dagger", "keys", "bottle", "gun", "skull",
1611 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1612 "1 0 1 gun", "1 0 2 keys", "1 2 1",
1613 "2",
1614 "hat", "skull", "bottle"]
1615 assert_nothing_raised {Game.read_game(gamelines1)}
1616 game, moves = Game.read_game(gamelines1)
1617 assert_equal 3, game.history.length
1618 assert_equal 1, game.current_player
1619 assert_equal 0, game.moves_by_current_player
1620 assert_equal 2, game.players_cards[0].length
1621 assert_equal 3, game.players_cards[1].length
1622 assert_equal 3, game.players_cards[2].length
1623 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
1624 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1625 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 2, unplayed_cards.length
1626 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
1627 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
1628 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
1629 assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :gun}).length
1630 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
1631 assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :keys}).length
1632 assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
1633
1634 gamelines2 = ["3", "cell",
1635 "gun", "keys", "dagger", "hat", "skull", "bottle",
1636 "keys", "dagger", "skull", "hat", "gun", "bottle",
1637 "dagger", "bottle", "keys", "gun", "hat", "skull",
1638 "dagger", "skull", "bottle", "gun", "keys", "hat",
1639 "hat", "dagger", "keys", "bottle", "gun", "skull",
1640 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1641 "1 0 1", "1 0 2", "1 2 1",
1642 "2 0 2", "2 0 3", "2 3 2",
1643 "3 0 3", "3 0 4", "3 4 3",
1644 "1 0 4", "1 0 5", "1 5 4",
1645 "2 0 5", "2 0 6", "2 6 5",
1646 "3 0 6", "3 0 11", "3 11 6",
1647 "1",
1648 "hat"]
1649 assert_nothing_raised {Game.read_game(gamelines2)}
1650 game, moves = Game.read_game(gamelines2)
1651 assert_equal 18, game.history.length
1652 assert_equal 0, game.current_player
1653 assert_equal 0, game.moves_by_current_player
1654 assert_equal 1, game.players_cards[0].length
1655 assert_equal 1, game.players_cards[1].length
1656 assert_equal 1, game.players_cards[2].length
1657 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
1658 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1659 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 12, unplayed_cards.length
1660 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
1661 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :bottle}).length
1662 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :dagger}).length
1663 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :gun}).length
1664 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :hat}).length
1665 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :keys}).length
1666 assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :skull}).length
1667
1668 gamelines2 = ["3", "cell",
1669 "gun", "keys", "dagger", "hat", "skull", "bottle",
1670 "keys", "dagger", "skull", "hat", "gun", "bottle",
1671 "dagger", "bottle", "keys", "gun", "hat", "skull",
1672 "dagger", "skull", "bottle", "gun", "keys", "hat",
1673 "hat", "dagger", "keys", "bottle", "gun", "skull",
1674 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1675 "1 0 1", "1 0 2", "1 2 1",
1676 "2 0 2", "2 0 3", "2 3 2",
1677 "3 0 3", "3 0 4", "3 4 3",
1678 "1 0 4", "1 0 5", "1 5 4",
1679 "2 0 5", "2 0 6", "2 6 5",
1680 "3 0 6", "3 0 11", "3 11 6",
1681 "1 0 7", "1 7 6",
1682 "2 0 8", "2 8 5",
1683 "3 0 9", "3 9 4",
1684 "1 0 10", "1 10 3",
1685 "2 0 11", "2 11 2",
1686 "3 0 12", "3 12 1",
1687 "1",
1688 "hat", "skull", "bottle"]
1689 assert_nothing_raised {Game.read_game(gamelines2)}
1690 game, moves = Game.read_game(gamelines2)
1691 assert_equal 30, game.history.length
1692 assert_equal 0, game.current_player
1693 assert_equal 0, game.moves_by_current_player
1694 assert_equal 3, game.players_cards[0].length
1695 assert_equal 3, game.players_cards[1].length
1696 assert_equal 3, game.players_cards[2].length
1697 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
1698 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1699 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, unplayed_cards.length
1700 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
1701 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :bottle}).length
1702 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :dagger}).length
1703 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :gun}).length
1704 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :hat}).length
1705 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :keys}).length
1706 assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :skull}).length
1707
1708 gamelines3 = ["3", "cell",
1709 "gun", "keys", "dagger", "hat", "skull", "bottle",
1710 "keys", "dagger", "skull", "hat", "gun", "bottle",
1711 "dagger", "bottle", "keys", "gun", "hat", "skull",
1712 "dagger", "skull", "bottle", "gun", "keys", "hat",
1713 "hat", "dagger", "keys", "bottle", "gun", "skull",
1714 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1715 "1 0 1", "1 0 2", "1 2 1",
1716 "2 0 2", "2 0 3", "2 3 2",
1717 "3 0 3", "3 0 4", "3 4 3",
1718 "1 0 4", "1 0 5", "1 5 4",
1719 "2 0 5", "2 0 6", "2 6 5",
1720 "3 0 6", "3 0 11", "3 11 6",
1721 "1 0 7", "1 7 6",
1722 "2 0 8", "2 8 5",
1723 "3 0 9", "3 9 4",
1724 "1 0 10", "1 10 3",
1725 "2 0 11", "2 11 2",
1726 "3 0 12", "3 12 1",
1727 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1728 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1729 "1",
1730 "hat", "skull", "bottle", "gun", "dagger"]
1731 assert_nothing_raised {Game.read_game(gamelines3)}
1732 game, moves = Game.read_game(gamelines3)
1733 assert_equal 42, game.history.length
1734 assert_equal 0, game.current_player
1735 assert_equal 0, game.moves_by_current_player
1736 assert_equal 5, game.players_cards[0].length
1737 assert_equal 5, game.players_cards[1].length
1738 assert_equal 5, game.players_cards[2].length
1739 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
1740 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1741 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 24, unplayed_cards.length
1742 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
1743 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :bottle}).length
1744 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :dagger}).length
1745 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :gun}).length
1746 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :hat}).length
1747 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :keys}).length
1748 assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :skull}).length
1749
1750 gamelines4 = ["3", "cell",
1751 "gun", "keys", "dagger", "hat", "skull", "bottle",
1752 "keys", "dagger", "skull", "hat", "gun", "bottle",
1753 "dagger", "bottle", "keys", "gun", "hat", "skull",
1754 "dagger", "skull", "bottle", "gun", "keys", "hat",
1755 "hat", "dagger", "keys", "bottle", "gun", "skull",
1756 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1757 "1 0 1", "1 0 2", "1 2 1",
1758 "2 0 2", "2 0 3", "2 3 2",
1759 "3 0 3", "3 0 4", "3 4 3",
1760 "1 0 4", "1 0 5", "1 5 4",
1761 "2 0 5", "2 0 6", "2 6 5",
1762 "3 0 6", "3 0 11", "3 11 6",
1763 "1 0 7", "1 7 6",
1764 "2 0 8", "2 8 5",
1765 "3 0 9", "3 9 4",
1766 "1 0 10", "1 10 3",
1767 "2 0 11", "2 11 2",
1768 "3 0 12", "3 12 1",
1769 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1770 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1771 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1772 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1773 "1",
1774 "hat", "skull", "bottle", "gun", "dagger", "keys", "hat"]
1775 assert_nothing_raised {Game.read_game(gamelines4)}
1776 game, moves = Game.read_game(gamelines4)
1777 assert_equal 54, game.history.length
1778 assert_equal 0, game.current_player
1779 assert_equal 0, game.moves_by_current_player
1780 assert_equal 7, game.players_cards[0].length
1781 assert_equal 7, game.players_cards[1].length
1782 assert_equal 7, game.players_cards[2].length
1783 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
1784 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1785 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 30, unplayed_cards.length
1786 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
1787 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :bottle}).length
1788 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :dagger}).length
1789 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :gun}).length
1790 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :hat}).length
1791 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :keys}).length
1792 assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :skull}).length
1793
1794
1795 gamelines5 = ["3", "cell",
1796 "gun", "keys", "dagger", "hat", "skull", "bottle",
1797 "keys", "dagger", "skull", "hat", "gun", "bottle",
1798 "dagger", "bottle", "keys", "gun", "hat", "skull",
1799 "dagger", "skull", "bottle", "gun", "keys", "hat",
1800 "hat", "dagger", "keys", "bottle", "gun", "skull",
1801 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1802 "1 0 1", "1 0 2", "1 2 1",
1803 "2 0 2", "2 0 3", "2 3 2",
1804 "3 0 3", "3 0 4", "3 4 3",
1805 "1 0 4", "1 0 5", "1 5 4",
1806 "2 0 5", "2 0 6", "2 6 5",
1807 "3 0 6", "3 0 11", "3 11 6",
1808 "1 0 7", "1 7 6",
1809 "2 0 8", "2 8 5",
1810 "3 0 9", "3 9 4",
1811 "1 0 10", "1 10 3",
1812 "2 0 11", "2 11 2",
1813 "3 0 12", "3 12 1",
1814 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1815 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1816 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1817 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1818 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1819 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1820 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1821 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1822 "1",
1823 "hat", "skull", "bottle", "gun", "dagger", "keys", "hat", "skull", "bottle", "gun", "dagger"]
1824 assert_nothing_raised {Game.read_game(gamelines5)}
1825 game, moves = Game.read_game(gamelines5)
1826 assert_equal 78, game.history.length
1827 assert_equal 0, game.current_player
1828 assert_equal 0, game.moves_by_current_player
1829 assert_equal 11, game.players_cards[0].length
1830 assert_equal 11, game.players_cards[1].length
1831 assert_equal 11, game.players_cards[2].length
1832 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
1833 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1834 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 42, unplayed_cards.length
1835 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
1836 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :bottle}).length
1837 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :dagger}).length
1838 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :gun}).length
1839 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :hat}).length
1840 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :keys}).length
1841 assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :skull}).length
1842
1843 gamelines6 = ["3", "cell",
1844 "gun", "keys", "dagger", "hat", "skull", "bottle",
1845 "keys", "dagger", "skull", "hat", "gun", "bottle",
1846 "dagger", "bottle", "keys", "gun", "hat", "skull",
1847 "dagger", "skull", "bottle", "gun", "keys", "hat",
1848 "hat", "dagger", "keys", "bottle", "gun", "skull",
1849 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1850 "1 0 1", "1 0 2", "1 2 1",
1851 "2 0 2", "2 0 3", "2 3 2",
1852 "3 0 3", "3 0 4", "3 4 3",
1853 "1 0 4", "1 0 5", "1 5 4",
1854 "2 0 5", "2 0 6", "2 6 5",
1855 "3 0 6", "3 0 11", "3 11 6",
1856 "1 0 7", "1 7 6",
1857 "2 0 8", "2 8 5",
1858 "3 0 9", "3 9 4",
1859 "1 0 10", "1 10 3",
1860 "2 0 11", "2 11 2",
1861 "3 0 12", "3 12 1",
1862 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1863 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1864 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1865 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1866 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1867 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1868 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1869 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1870 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1871 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1872 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1873 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1874 "1",
1875 "hat", "skull", "bottle", "gun", "dagger", "keys",
1876 "hat", "skull", "bottle", "gun", "dagger", "keys",
1877 "hat", "skull", "bottle"]
1878 assert_nothing_raised {Game.read_game(gamelines6)}
1879 game, moves = Game.read_game(gamelines6)
1880 assert_equal 102, game.history.length
1881 assert_equal 0, game.current_player
1882 assert_equal 0, game.moves_by_current_player
1883 assert_equal 15, game.players_cards[0].length
1884 assert_equal 15, game.players_cards[1].length
1885 assert_equal 15, game.players_cards[2].length
1886 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
1887 assert_equal 3, game.deck.length
1888 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1889 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 54, unplayed_cards.length
1890 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
1891 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
1892 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
1893 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
1894 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
1895 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :keys}).length
1896 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
1897
1898 gamelines7 = ["3", "cell",
1899 "gun", "keys", "dagger", "hat", "skull", "bottle",
1900 "keys", "dagger", "skull", "hat", "gun", "bottle",
1901 "dagger", "bottle", "keys", "gun", "hat", "skull",
1902 "dagger", "skull", "bottle", "gun", "keys", "hat",
1903 "hat", "dagger", "keys", "bottle", "gun", "skull",
1904 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1905 "1 0 1", "1 0 2", "1 2 1",
1906 "2 0 2", "2 0 3", "2 3 2",
1907 "3 0 3", "3 0 4", "3 4 3",
1908 "1 0 4", "1 0 5", "1 5 4",
1909 "2 0 5", "2 0 6", "2 6 5",
1910 "3 0 6", "3 0 11", "3 11 6",
1911 "1 0 7", "1 7 6",
1912 "2 0 8", "2 8 5",
1913 "3 0 9", "3 9 4",
1914 "1 0 10", "1 10 3",
1915 "2 0 11", "2 11 2",
1916 "3 0 12", "3 12 1",
1917 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1918 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1919 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1920 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1921 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1922 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1923 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1924 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1925 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1926 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1927 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1928 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1929 "1 1 7", "1 7 1",
1930 "1",
1931 "hat", "skull", "bottle", "gun", "dagger", "keys",
1932 "hat", "skull", "bottle", "gun", "dagger", "keys",
1933 "hat", "skull", "bottle", "gun"]
1934 assert_nothing_raised {Game.read_game(gamelines7)}
1935 game, moves = Game.read_game(gamelines7)
1936 assert_equal 104, game.history.length
1937 assert_equal 0, game.current_player
1938 assert_equal 2, game.moves_by_current_player
1939 assert_equal 16, game.players_cards[0].length
1940 assert_equal 15, game.players_cards[1].length
1941 assert_equal 15, game.players_cards[2].length
1942 assert_equal 1, game.deck.length
1943 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1944 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 55, unplayed_cards.length
1945 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
1946 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
1947 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
1948 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
1949 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
1950 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
1951
1952 gamelines8 = ["3", "cell",
1953 "gun", "keys", "dagger", "hat", "skull", "bottle",
1954 "keys", "dagger", "skull", "hat", "gun", "bottle",
1955 "dagger", "bottle", "keys", "gun", "hat", "skull",
1956 "dagger", "skull", "bottle", "gun", "keys", "hat",
1957 "hat", "dagger", "keys", "bottle", "gun", "skull",
1958 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
1959 "1 0 1", "1 0 2", "1 2 1",
1960 "2 0 2", "2 0 3", "2 3 2",
1961 "3 0 3", "3 0 4", "3 4 3",
1962 "1 0 4", "1 0 5", "1 5 4",
1963 "2 0 5", "2 0 6", "2 6 5",
1964 "3 0 6", "3 0 11", "3 11 6",
1965 "1 0 7", "1 7 6",
1966 "2 0 8", "2 8 5",
1967 "3 0 9", "3 9 4",
1968 "1 0 10", "1 10 3",
1969 "2 0 11", "2 11 2",
1970 "3 0 12", "3 12 1",
1971 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1972 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1973 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1974 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1975 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1976 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1977 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1978 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1979 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1980 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1981 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
1982 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
1983 "1 1 7", "1 7 1", "1 1 10",
1984 "1",
1985 "hat", "skull", "bottle", "gun", "dagger", "keys",
1986 "hat", "skull", "bottle", "gun", "dagger", "keys",
1987 "skull", "bottle", "dagger"]
1988 assert_nothing_raised {Game.read_game(gamelines8)}
1989 game, moves = Game.read_game(gamelines8)
1990 assert_equal 105, game.history.length
1991 assert_equal 0, game.current_player
1992 assert_equal 3, game.moves_by_current_player
1993 assert_equal 15, game.players_cards[0].length
1994 assert_equal 15, game.players_cards[1].length
1995 assert_equal 15, game.players_cards[2].length
1996 assert_equal 1, game.deck.length
1997 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
1998 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 56, unplayed_cards.length
1999 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
2000 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
2001 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
2002 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :hat}).length
2003 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
2004 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
2005
2006
2007 gamelines9 = ["3", "cell",
2008 "gun", "keys", "dagger", "hat", "skull", "bottle",
2009 "keys", "dagger", "skull", "hat", "gun", "bottle",
2010 "dagger", "bottle", "keys", "gun", "hat", "skull",
2011 "dagger", "skull", "bottle", "gun", "keys", "hat",
2012 "hat", "dagger", "keys", "bottle", "gun", "skull",
2013 "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
2014 "1 0 1", "1 0 2", "1 2 1",
2015 "2 0 2", "2 0 3", "2 3 2",
2016 "3 0 3", "3 0 4", "3 4 3",
2017 "1 0 4", "1 0 5", "1 5 4",
2018 "2 0 5", "2 0 6", "2 6 5",
2019 "3 0 6", "3 0 11", "3 11 6",
2020 "1 0 7", "1 7 6",
2021 "2 0 8", "2 8 5",
2022 "3 0 9", "3 9 4",
2023 "1 0 10", "1 10 3",
2024 "2 0 11", "2 11 2",
2025 "3 0 12", "3 12 1",
2026 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2027 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2028 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2029 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2030 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2031 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2032 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2033 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2034 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2035 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2036 "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
2037 "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
2038 "1 1 7", "1 7 1", "1 1 10",
2039 "2 2 12", "2 12 10",
2040 "2",
2041 "hat", "skull", "bottle", "gun", "dagger", "keys",
2042 "hat", "skull", "bottle", "gun", "dagger", "keys",
2043 "hat", "skull", "bottle"]
2044 assert_nothing_raised {Game.read_game(gamelines9)}
2045 game, moves = Game.read_game(gamelines9)
2046 assert_equal 107, game.history.length
2047 assert_equal 1, game.current_player
2048 assert_equal 2, game.moves_by_current_player
2049 assert_equal 15, game.players_cards[0].length
2050 assert_equal 15, game.players_cards[1].length
2051 assert_equal 15, game.players_cards[2].length
2052 assert_equal 0, game.deck.length
2053 unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
2054 assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 56, unplayed_cards.length
2055 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
2056 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
2057 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
2058 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
2059 assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
2060 assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
2061
2062
2063 end
2064
2065 end