+# == Synopsis
+#
+# Unit tests for the libcartagena library
+#
+# == Author
+# Neil Smith
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# == Change history
+# Version 1.0:: 5 Dec 2008
+# => * Initial build
+
+
+$:.unshift File.join(File.dirname(__FILE__),'..','lib', 'libcartagena')
+
+require 'test/unit'
+require File.join(File.dirname(__FILE__), '..', 'lib', 'libcartagena')
+
+class TileTest < Test::Unit::TestCase
+ def test_tile_init
+ front = [:hat, :keys, :gun, :bottle, :skull, :dagger]
+ back = [:gun, :hat, :dagger, :skull, :bottle, :keys]
+ assert_nothing_raised { Tile.new(front, back) }
+ tile = Tile.new(front, back)
+
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal front, tile.exposed.map {|p| p.symbol}
+
+ tile.flip!
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal back, tile.exposed.map {|p| p.symbol}
+
+ tile.flip!
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal front, tile.exposed.map {|p| p.symbol}
+
+ tile.flip!
+ tile.reverse!
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal back.reverse, tile.exposed.map {|p| p.symbol}
+
+ tile.flip!
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal front, tile.exposed.map {|p| p.symbol}
+
+ tile.reverse!
+ assert_equal 6, tile.front.length
+ assert_equal 6, tile.back.length
+ assert_equal 6, tile.exposed.length
+ assert_equal front, tile.front.map {|p| p.symbol}
+ assert_equal back, tile.back.map {|p| p.symbol}
+ assert_equal front.reverse, tile.exposed.map {|p| p.symbol}
+
+ end
+end
+
+class BoardTest < Test::Unit::TestCase
+ def test_board_init
+ assert_nothing_raised { Board.new(6) }
+ board = Board.new(1)
+ assert_equal 1, board.tiles.length
+ assert_equal 8, board.positions.length
+
+ board = Board.new(6)
+ assert_equal 6, board.tiles.length
+ assert_equal 38, board.positions.length
+
+ 0.upto(5) do |i|
+ start = i * 6 + 1
+ slice = board.positions[start..(start+5)]
+ $SYMBOLS.each do |tile|
+ assert_equal 1, (slice.find_all {|p| p.symbol == tile}).length
+ end
+ end
+ end
+end
+
+
+class GameTest < Test::Unit::TestCase
+ def test_game_init
+ assert_nothing_raised { Game.new }
+
+ game = Game.new(6)
+ assert_equal 6, game.players.length
+ 0.upto(5) do |i|
+ assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
+ end
+ assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 6 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
+ end
+
+ def test_game_setting
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+ game.pieces.each do |player|
+ player.each do |piece|
+ assert_equal game.board.positions[0], piece.position
+ end
+ end
+ assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
+ :keys, :dagger, :skull, :hat, :gun, :bottle,
+ :dagger, :bottle, :keys, :gun, :hat, :skull,
+ :dagger, :skull, :bottle, :gun, :keys, :hat,
+ :hat, :dagger, :keys, :bottle, :gun, :skull,
+ :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
+ game.board.positions.collect {|p| p.symbol}
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+# assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 18, game.possible_moves.length
+ game.apply_move!(game.possible_moves[0])
+ assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 87, game.deck.length
+
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 12, game.possible_moves.length
+ game.apply_move!(game.possible_moves[3])
+ assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
+ assert_equal 87, game.deck.length
+
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 7, game.possible_moves.length
+ game.apply_move!(game.possible_moves[2])
+ assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
+ assert_equal 86, game.deck.length
+
+ game.reset_current_player 0 # Needed to prevent errors below
+
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 12, game.possible_moves.length
+ game.apply_move!(game.possible_moves[-1])
+ assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
+ assert_equal 5, game.board.positions.index(game.pieces[0][5].position)
+ assert_equal 86, game.deck.length
+
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 7, game.possible_moves.length
+ game.apply_move!(game.possible_moves[-1])
+ assert_equal [:bottle, :hat, :keys], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 1, game.board.positions.index(game.pieces[0][1].position)
+ assert_equal 1, game.board.positions.index(game.pieces[0][5].position)
+ assert_equal 84, game.deck.length
+ end
+
+ def test_game_termination
+ game = Game.new(6)
+ game.set_testing_game!
+ assert_equal 0, game.moves_by_current_player
+
+ game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[0], game.board.positions[36]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[0].contains.include?(game.pieces[0][1])
+ assert game.board.positions[0].contains.include?(game.pieces[0][2])
+ assert game.board.positions[0].contains.include?(game.pieces[0][3])
+ assert game.board.positions[0].contains.include?(game.pieces[0][4])
+ assert game.board.positions[0].contains.include?(game.pieces[0][5])
+ assert_equal 18, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[0], game.board.positions[35]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[0].contains.include?(game.pieces[0][2])
+ assert game.board.positions[0].contains.include?(game.pieces[0][3])
+ assert game.board.positions[0].contains.include?(game.pieces[0][4])
+ assert game.board.positions[0].contains.include?(game.pieces[0][5])
+ assert_equal 19, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[0], game.board.positions[34]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[0].contains.include?(game.pieces[0][3])
+ assert game.board.positions[0].contains.include?(game.pieces[0][4])
+ assert game.board.positions[0].contains.include?(game.pieces[0][5])
+ assert_equal 20, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[0], game.board.positions[33]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[33].contains.include?(game.pieces[0][3])
+ assert game.board.positions[0].contains.include?(game.pieces[0][4])
+ assert game.board.positions[0].contains.include?(game.pieces[0][5])
+ assert_equal 21, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[0], game.board.positions[32]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[33].contains.include?(game.pieces[0][3])
+ assert game.board.positions[32].contains.include?(game.pieces[0][4])
+ assert game.board.positions[0].contains.include?(game.pieces[0][5])
+ assert_equal 22, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[0], game.board.positions[31]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[33].contains.include?(game.pieces[0][3])
+ assert game.board.positions[32].contains.include?(game.pieces[0][4])
+ assert game.board.positions[31].contains.include?(game.pieces[0][5])
+ assert_equal 23, game.possible_moves.length
+
+ # Now start moving pices onto the boat
+ game.apply_move!(Move.new(game.pieces[0][5], game.board.positions[31], game.board.positions[37]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[33].contains.include?(game.pieces[0][3])
+ assert game.board.positions[32].contains.include?(game.pieces[0][4])
+ assert game.board.positions[37].contains.include?(game.pieces[0][5])
+ assert_equal 20, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][4], game.board.positions[32], game.board.positions[37]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[33].contains.include?(game.pieces[0][3])
+ assert game.board.positions[37].contains.include?(game.pieces[0][4])
+ assert game.board.positions[37].contains.include?(game.pieces[0][5])
+ assert_equal 17, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][3], game.board.positions[33], game.board.positions[37]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[34].contains.include?(game.pieces[0][2])
+ assert game.board.positions[37].contains.include?(game.pieces[0][3])
+ assert game.board.positions[37].contains.include?(game.pieces[0][4])
+ assert game.board.positions[37].contains.include?(game.pieces[0][5])
+ assert_equal 14, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][2], game.board.positions[34], game.board.positions[37]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[35].contains.include?(game.pieces[0][1])
+ assert game.board.positions[37].contains.include?(game.pieces[0][2])
+ assert game.board.positions[37].contains.include?(game.pieces[0][3])
+ assert game.board.positions[37].contains.include?(game.pieces[0][4])
+ assert game.board.positions[37].contains.include?(game.pieces[0][5])
+ assert_equal 11, game.possible_moves.length
+
+ game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[35], game.board.positions[37]), 0, false)
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert game.board.positions[36].contains.include?(game.pieces[0][0])
+ assert game.board.positions[37].contains.include?(game.pieces[0][1])
+ assert game.board.positions[37].contains.include?(game.pieces[0][2])
+ assert game.board.positions[37].contains.include?(game.pieces[0][3])
+ assert game.board.positions[37].contains.include?(game.pieces[0][4])
+ assert game.board.positions[37].contains.include?(game.pieces[0][5])
+ assert_equal 8, game.possible_moves.length
+
+ assert_raise(GameWonNotice) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[36], game.board.positions[37]), 0, false)}
+
+ end
+
+ def test_retreats
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+
+ game.pieces.each do |player|
+ player.each do |piece|
+ assert_equal game.board.positions[0], piece.position
+ end
+ end
+ assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
+ :keys, :dagger, :skull, :hat, :gun, :bottle,
+ :dagger, :bottle, :keys, :gun, :hat, :skull,
+ :dagger, :skull, :bottle, :gun, :keys, :hat,
+ :hat, :dagger, :keys, :bottle, :gun, :skull,
+ :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
+ game.board.positions.collect {|p| p.symbol}
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+# assert_equal [:bottle, :keys, :skull], game.players_cards[5].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 18, game.possible_moves.length
+ game.apply_move!(game.possible_moves[0])
+ assert_equal [:hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 87, game.deck.length
+
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 12, game.possible_moves.length
+ game.apply_move!(game.possible_moves[3])
+ assert_equal [:hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.board.positions.index(game.pieces[0][0].position)
+ assert_equal 5, game.board.positions.index(game.pieces[0][1].position)
+ assert_equal 87, game.deck.length
+
+ # Test can't retreat into the cell
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 7, game.possible_moves.length
+ assert_raise(InvalidMoveError) do
+ game.apply_move!(Move.new(game.pieces[0][1], game.board.positions[5], game.board.positions[0]))
+ end
+ end
+
+ # Test invalid move error trapping
+ def test_invalid_move_error_trapping
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+
+ game.pieces.each do |player|
+ player.each do |piece|
+ assert_equal game.board.positions[0], piece.position
+ end
+ end
+ assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
+ :keys, :dagger, :skull, :hat, :gun, :bottle,
+ :dagger, :bottle, :keys, :gun, :hat, :skull,
+ :dagger, :skull, :bottle, :gun, :keys, :hat,
+ :hat, :dagger, :keys, :bottle, :gun, :skull,
+ :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
+ game.board.positions.collect {|p| p.symbol}
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+ assert_equal 0, game.moves_by_current_player
+
+ # Test if can move to a space without the right card
+ assert_raise(InvalidMoveError) {game.apply_move!(Move.new(game.pieces[0][0], game.board.positions[2], game.board.positions[0]))}
+
+
+ # Apply a series of moves to get an interesting game state
+ game.apply_move!('0 0 5'.to_move(game))
+ assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 0 4'.to_move(game))
+ assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 5 4'.to_move(game))
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 0 2'.to_move(game))
+ assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 0 7'.to_move(game))
+ assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 7 4'.to_move(game))
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 0 7'.to_move(game))
+ assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 0 10'.to_move(game))
+ assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 0 6'.to_move(game))
+ assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 0 12'.to_move(game))
+ assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 12 10'.to_move(game))
+ assert_equal [:skull, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 0 5'.to_move(game))
+ assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 0 12'.to_move(game))
+ assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 12 10'.to_move(game))
+ assert_equal [:dagger, :gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 0 3'.to_move(game))
+ assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:gun, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 0 9'.to_move(game))
+ assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 0 1'.to_move(game))
+ assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 9 7'.to_move(game))
+ assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 0 12'.to_move(game))
+ assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 0 14'.to_move(game))
+ assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 12 7'.to_move(game))
+ assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 6 5'.to_move(game))
+ assert_equal [:gun], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 0 11'.to_move(game))
+ assert_equal [], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 11 5'.to_move(game))
+ assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 0 9'.to_move(game))
+ assert_equal [:skull], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 0 18'.to_move(game))
+ assert_equal [], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 18 14'.to_move(game))
+ assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 0 11'.to_move(game))
+ assert_equal [:gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 0 16'.to_move(game))
+ assert_equal [:gun], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 16 14'.to_move(game))
+ assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+
+ assert_equal [:keys], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:hat, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:gun, :keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 0 15'.to_move(game))
+ assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 15 11'.to_move(game))
+ assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 11 9'.to_move(game))
+ assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 0 15'.to_move(game))
+ assert_equal [:hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 0 17'.to_move(game))
+ assert_equal [:keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 17 15'.to_move(game))
+ assert_equal [:keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 0 23'.to_move(game))
+ assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 23 15'.to_move(game))
+ assert_equal [:bottle, :dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 0 17'.to_move(game))
+ assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 10 9'.to_move(game))
+ assert_equal [:bottle, :dagger, :hat], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 0 24'.to_move(game))
+ assert_equal [:bottle, :dagger], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 0 8'.to_move(game))
+ assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 0 16'.to_move(game))
+ assert_equal [:keys, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 16 11'.to_move(game))
+ assert_equal [:keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 11 10'.to_move(game))
+ assert_equal [:dagger, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+
+ assert_equal 2, game.board.positions[ 0].contains.length
+ assert_equal 1, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 1, game.board.positions[ 3].contains.length
+ assert_equal 3, game.board.positions[ 4].contains.length
+ assert_equal 3, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 3, game.board.positions[ 7].contains.length
+ assert_equal 1, game.board.positions[ 8].contains.length
+ assert_equal 3, game.board.positions[ 9].contains.length
+ assert_equal 3, game.board.positions[10].contains.length
+ assert_equal 1, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 3, game.board.positions[14].contains.length
+ assert_equal 3, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 1, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 1, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_raise(InvalidMoveError) {game.apply_move!('0 7 6'.to_move(game))} # can't retreat into an empty space
+ assert_raise(InvalidMoveError) {game.apply_move!('0 7 5'.to_move(game))} # can't retreat into a space with three men
+ assert_raise(InvalidMoveError) {game.apply_move!('0 1 0'.to_move(game))} # can't retreat into the boat
+ assert_raise(InvalidMoveError) {game.apply_move!('0 1 12'.to_move(game))} # can't skip a vacant space of this type
+ assert_raise(InvalidMoveError) {game.apply_move!('0 1 5'.to_move(game))} # can't advance to a space with three pirates
+ assert_raise(InvalidMoveError) {game.apply_move!('0 2 6'.to_move(game))} # can't move another's piece
+ assert_raise(InvalidMoveError) {game.apply_move!('0 9 9'.to_move(game))} # can't advance the same square
+ assert_raise(InvalidMoveError) {game.apply_move!('0 9 20'.to_move(game))} # can't skip a vacant space of this type
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 0 18'.to_move(game))
+ assert_equal [:bottle], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 7 12'.to_move(game))
+ assert_equal [], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 12 11'.to_move(game))
+ assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 14 11'.to_move(game))
+ assert_equal [:dagger, :keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 2 23'.to_move(game))
+ assert_equal [:dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 15 14'.to_move(game))
+ assert_equal [:bottle, :bottle, :dagger, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 17 15'.to_move(game))
+ assert_equal [:bottle, :dagger, :dagger, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 5 27'.to_move(game))
+ assert_equal [:bottle, :dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 5 13'.to_move(game))
+ assert_equal [:bottle, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 8 7'.to_move(game))
+ assert_equal [:bottle, :bottle, :hat], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 5 17'.to_move(game))
+ assert_equal [:bottle, :bottle], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 7 12'.to_move(game))
+ assert_equal [:bottle], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 0 8'.to_move(game))
+ assert_equal [:dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 8 7'.to_move(game))
+ assert_equal [:bottle, :dagger, :keys, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 3 31'.to_move(game))
+ assert_equal [:bottle, :dagger, :keys, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 18 17'.to_move(game))
+ assert_equal [:dagger, :gun], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 1 16'.to_move(game))
+ assert_equal [:dagger], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 17 16'.to_move(game))
+ assert_equal [:dagger, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 4 37 keys'.to_move(game))
+ assert_equal [:bottle, :bottle, :dagger, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 7 4'.to_move(game))
+ assert_equal [:bottle, :bottle, :bottle, :dagger, :hat, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 4 37 keys'.to_move(game))
+ assert_equal [:bottle, :bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 7 21'.to_move(game))
+ assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 13 12'.to_move(game))
+ assert_equal [:dagger, :dagger], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 10 13'.to_move(game))
+ assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 17 16'.to_move(game))
+ assert_equal [:bottle, :hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 9 28'.to_move(game))
+ assert_equal [:hat, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 9 18'.to_move(game))
+ assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 7 37 keys'.to_move(game))
+ assert_equal [:bottle, :dagger, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 11 10'.to_move(game))
+ assert_equal [:bottle, :dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 10 32'.to_move(game))
+ assert_equal [:dagger, :dagger, :gun, :skull, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 11 10'.to_move(game))
+ assert_equal [:bottle, :dagger, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 4 8'.to_move(game))
+ assert_equal [:bottle, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 4 17'.to_move(game))
+ assert_equal [:bottle, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ game.apply_move!('1 11 37 bottle'.to_move(game))
+ assert_equal [:bottle, :bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 14 37 bottle'.to_move(game))
+ assert_equal [:bottle, :dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
+ game.apply_move!('1 15 37 bottle'.to_move(game))
+ assert_equal [:dagger, :hat], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 13 12'.to_move(game))
+ assert_equal [:dagger, :gun, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 12 22 gun'.to_move(game))
+ assert_equal [:dagger, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 12 25 hat'.to_move(game))
+ assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 3, game.current_player
+ game.apply_move!('3 16 15'.to_move(game))
+ assert_equal [:dagger, :gun, :hat], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 12 35 hat'.to_move(game))
+ assert_equal [:dagger, :gun], game.players_cards[3].sort_by {|c| c.to_s}
+ game.apply_move!('3 14 29 gun'.to_move(game))
+ assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 4, game.current_player
+ game.apply_move!('4 10 20 skull'.to_move(game))
+ assert_equal [:dagger, :dagger, :gun, :skull], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 10 30 skull'.to_move(game))
+ assert_equal [:dagger, :dagger, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ game.apply_move!('4 14 36 gun'.to_move(game))
+ assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
+
+
+ game.next_player!
+ assert_equal 0, game.current_player
+
+ game.apply_move!('0 17 16'.to_move(game))
+ assert_equal [:bottle, :gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 8 33 skull'.to_move(game))
+ assert_equal [:bottle, :gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
+ game.apply_move!('0 9 17 hat'.to_move(game))
+ assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ assert_raise(GameWonNotice) {game.apply_move!('1 23 37 hat'.to_move(game))}
+ assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
+
+ assert_equal 0, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 0, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 0, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 0, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 1, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 3, game.board.positions[15].contains.length
+ assert_equal 3, game.board.positions[16].contains.length
+ assert_equal 1, game.board.positions[17].contains.length
+ assert_equal 1, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 1, game.board.positions[20].contains.length
+ assert_equal 1, game.board.positions[21].contains.length
+ assert_equal 1, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 1, game.board.positions[24].contains.length
+ assert_equal 1, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 1, game.board.positions[27].contains.length
+ assert_equal 1, game.board.positions[28].contains.length
+ assert_equal 1, game.board.positions[29].contains.length
+ assert_equal 1, game.board.positions[30].contains.length
+ assert_equal 1, game.board.positions[31].contains.length
+ assert_equal 1, game.board.positions[32].contains.length
+ assert_equal 1, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 1, game.board.positions[35].contains.length
+ assert_equal 1, game.board.positions[36].contains.length
+ assert_equal 7, game.board.positions[37].contains.length
+
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun],
+ game.deck
+
+ assert_equal [:bottle, :gun], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:dagger], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:dagger], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:dagger], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:dagger, :dagger], game.players_cards[4].sort_by {|c| c.to_s}
+
+ end
+ #
+ # : move without a card
+ # move to an occupied space
+ # retreat to an emtpy space
+ # retreat to an overfull space
+ # retreat to the cell with one pirate already in it
+
+
+ # Test current player switching
+
+ # Test undo moves
+
+ # Test file reading
+ # (need a full game file to read)
+
+ def test_undo
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+ game.pieces.each do |player|
+ player.each do |piece|
+ assert_equal game.board.positions[0], piece.position
+ end
+ end
+ assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
+ :keys, :dagger, :skull, :hat, :gun, :bottle,
+ :dagger, :bottle, :keys, :gun, :hat, :skull,
+ :dagger, :skull, :bottle, :gun, :keys, :hat,
+ :hat, :dagger, :keys, :bottle, :gun, :skull,
+ :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
+ game.board.positions.collect {|p| p.symbol}
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+
+ assert_equal 0, game.history.length
+
+ game.apply_move!('0 0 5'.to_move(game))
+ assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.history.length
+ game.apply_move!('0 0 4'.to_move(game))
+ assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 2, game.history.length
+ game.apply_move!('0 5 4'.to_move(game))
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 3, game.history.length
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ assert_equal 3, game.history.length
+ game.apply_move!('1 0 2'.to_move(game))
+ assert_equal [:bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal 4, game.history.length
+ game.apply_move!('1 0 7'.to_move(game))
+ assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal 5, game.history.length
+ game.apply_move!('1 7 4'.to_move(game))
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal 6, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 3, game.moves_by_current_player
+
+ assert_equal 26, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 3, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 0, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 0, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull],
+ game.deck
+
+ game.undo_move! # player 1's third move
+
+ assert_equal 5, game.history.length
+
+ assert_equal 26, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 2, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 1, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 0, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle],
+ game.deck
+ assert_equal 1, game.current_player
+ assert_equal 2, game.moves_by_current_player
+
+ # Re-apply player 1's third move
+ game.apply_move!('1 7 4'.to_move(game))
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+
+ game.next_player!
+ assert_equal 2, game.current_player
+ game.apply_move!('2 0 7'.to_move(game))
+ assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ game.apply_move!('2 0 10'.to_move(game))
+ assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
+
+ assert_equal 8, game.history.length
+
+ assert_equal 24, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 3, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 1, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 1, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull],
+ game.deck
+ assert_equal 2, game.current_player
+ assert_equal 2, game.moves_by_current_player
+
+ game.undo_move! # player 2's second move
+
+ assert_equal 7, game.history.length
+
+ assert_equal 25, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 3, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 1, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 0, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull],
+ game.deck
+ assert_equal 2, game.current_player
+ assert_equal 1, game.moves_by_current_player
+
+
+ game.undo_move! # Player 2's first move
+
+ assert_equal 6, game.history.length
+
+ assert_equal 26, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 3, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 0, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 0, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :bottle, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull],
+ game.deck
+ assert_equal 2, game.current_player
+ assert_equal 0, game.moves_by_current_player
+
+
+ game.undo_move! # Player 1's third move
+
+ assert_equal 5, game.history.length
+
+ assert_equal 26, game.board.positions[ 0].contains.length
+ assert_equal 0, game.board.positions[ 1].contains.length
+ assert_equal 1, game.board.positions[ 2].contains.length
+ assert_equal 0, game.board.positions[ 3].contains.length
+ assert_equal 2, game.board.positions[ 4].contains.length
+ assert_equal 0, game.board.positions[ 5].contains.length
+ assert_equal 0, game.board.positions[ 6].contains.length
+ assert_equal 1, game.board.positions[ 7].contains.length
+ assert_equal 0, game.board.positions[ 8].contains.length
+ assert_equal 0, game.board.positions[ 9].contains.length
+ assert_equal 0, game.board.positions[10].contains.length
+ assert_equal 0, game.board.positions[11].contains.length
+ assert_equal 0, game.board.positions[12].contains.length
+ assert_equal 0, game.board.positions[13].contains.length
+ assert_equal 0, game.board.positions[14].contains.length
+ assert_equal 0, game.board.positions[15].contains.length
+ assert_equal 0, game.board.positions[16].contains.length
+ assert_equal 0, game.board.positions[17].contains.length
+ assert_equal 0, game.board.positions[18].contains.length
+ assert_equal 0, game.board.positions[19].contains.length
+ assert_equal 0, game.board.positions[20].contains.length
+ assert_equal 0, game.board.positions[21].contains.length
+ assert_equal 0, game.board.positions[22].contains.length
+ assert_equal 0, game.board.positions[23].contains.length
+ assert_equal 0, game.board.positions[24].contains.length
+ assert_equal 0, game.board.positions[25].contains.length
+ assert_equal 0, game.board.positions[26].contains.length
+ assert_equal 0, game.board.positions[27].contains.length
+ assert_equal 0, game.board.positions[28].contains.length
+ assert_equal 0, game.board.positions[29].contains.length
+ assert_equal 0, game.board.positions[30].contains.length
+ assert_equal 0, game.board.positions[31].contains.length
+ assert_equal 0, game.board.positions[32].contains.length
+ assert_equal 0, game.board.positions[33].contains.length
+ assert_equal 0, game.board.positions[34].contains.length
+ assert_equal 0, game.board.positions[35].contains.length
+ assert_equal 0, game.board.positions[36].contains.length
+ assert_equal 0, game.board.positions[37].contains.length
+
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle],
+ game.deck
+ assert_equal 1, game.current_player
+ assert_equal 2, game.moves_by_current_player
+
+ end
+
+ def test_apply_moves
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+ game.pieces.each do |player|
+ player.each do |piece|
+ assert_equal game.board.positions[0], piece.position
+ end
+ end
+ assert_equal [:cell, :gun, :keys, :dagger, :hat, :skull, :bottle,
+ :keys, :dagger, :skull, :hat, :gun, :bottle,
+ :dagger, :bottle, :keys, :gun, :hat, :skull,
+ :dagger, :skull, :bottle, :gun, :keys, :hat,
+ :hat, :dagger, :keys, :bottle, :gun, :skull,
+ :keys, :bottle, :skull, :dagger, :hat, :gun, :boat],
+ game.board.positions.collect {|p| p.symbol}
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+
+ assert_equal 0, game.history.length
+
+ game.apply_move!('0 0 5'.to_move(game))
+ assert_equal [:gun, :hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 1, game.history.length
+ game.apply_move!('0 0 4'.to_move(game))
+ assert_equal [:gun], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 2, game.history.length
+ game.apply_move!('0 5 4'.to_move(game))
+ assert_equal [:gun, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal 3, game.history.length
+
+ game.next_player!
+ assert_equal 1, game.current_player
+ assert_equal 3, game.history.length
+ game.apply_move!('1 0 2'.to_move(game))
+ end
+
+ def test_read_game_lines
+ gamelines1 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5 skull", "1 0 4 hat",
+ "1",
+ "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines1)}
+ game, moves = Game.read_game(gamelines1)
+ assert_equal 2, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 1, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 15, game.deck.length
+
+ game.apply_move!('0 5 4'.to_move(game))
+ assert_equal 3, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 3, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ gamelines2 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5", "1 0 4", "1 5 4",
+ "2",
+ "dagger", "hat", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines2)}
+ game, moves = Game.read_game(gamelines2)
+ assert_equal 3, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ game.apply_move!('1 0 2'.to_move(game))
+ assert_equal 4, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 2, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ gamelines3 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5", "1 0 4", "1 5 4", "2 0 2",
+ "2",
+ "dagger", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines3)}
+ game, moves = Game.read_game(gamelines3)
+ assert_equal 4, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 2, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ game.apply_move!('1 0 7'.to_move(game))
+ assert_equal 5, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 1, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ gamelines4 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7",
+ "2",
+ "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines4)}
+ game, moves = Game.read_game(gamelines4)
+ assert_equal 5, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 1, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 16, game.deck.length
+
+ game.apply_move!('1 7 4'.to_move(game))
+ assert_equal 6, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 3, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
+
+ gamelines5 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
+ "2",
+ "bottle", "hat", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines5)}
+ game, moves = Game.read_game(gamelines5)
+ assert_equal 6, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 3, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
+
+ game.players_cards[2] << :keys
+ game.players_cards[2] << :hat
+ game.apply_move!('3 0 7'.to_move(game, true), 2)
+ assert_equal 7, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 1, game.moves_by_current_player
+ game.apply_move!('3 0 10'.to_move(game, true))
+ assert_equal 8, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 2, game.moves_by_current_player
+
+ gamelines6 = ["5", "cell", "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 5", "1 0 4", "1 5 4", "2 0 2", "2 0 7", "2 7 4",
+ "3",
+ "bottle", "hat", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines6)}
+ game, moves = Game.read_game(gamelines6)
+ assert_equal 6, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
+
+ game.apply_move!('2 0 7'.to_move(game))
+ assert_equal 7, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 2, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
+
+ game.apply_move!('2 0 10'.to_move(game))
+ assert_equal 8, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 1, game.players_cards[2].length
+ assert_equal 3, game.players_cards[3].length
+ assert_equal 3, game.players_cards[4].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, game.deck.length
+
+ # Need to do a test with a very long sequence of moves,
+ # to test that the card dealing works properly when the deck is exhausted
+
+ end
+
+ def test_dealing
+ game = Game.new(5,6,6)
+ game.set_testing_game!
+ 0.upto(4) do |i|
+ assert_equal $INITIAL_CARDS_PER_PLAYER, game.players_cards[i].length
+ end
+ assert_equal $SYMBOLS.length * $CARDS_PER_SYMBOL - 5 * $INITIAL_CARDS_PER_PLAYER, game.deck.length
+ assert_equal [:gun, :hat, :skull], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :hat, :keys], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :skull, :skull], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :gun, :gun], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal 5, game.players_cards.length
+ assert_equal 5, game.players.length
+ assert_equal [:hat, :dagger, :hat, :hat, :skull, :bottle, :bottle, :bottle, :dagger,
+ :keys, :hat, :dagger, :skull, :skull, :dagger, :gun, :skull, :gun,
+ :gun, :skull, :keys, :keys, :gun, :hat, :dagger, :keys, :dagger,
+ :hat, :gun, :skull, :keys, :gun, :skull, :gun, :hat, :gun, :dagger,
+ :gun, :gun, :hat, :hat, :bottle, :gun, :dagger, :hat, :skull, :dagger,
+ :bottle, :hat, :skull, :gun, :bottle, :keys, :hat, :bottle, :keys,
+ :dagger, :bottle, :bottle, :dagger, :keys, :dagger, :dagger, :dagger,
+ :skull, :hat, :dagger, :dagger, :hat, :keys, :skull, :bottle, :skull,
+ :keys, :bottle, :keys, :bottle, :gun, :keys, :hat, :keys, :dagger,
+ :gun, :skull, :keys, :bottle, :skull],
+ game.deck
+ game.deal_cards!(86, 0)
+ assert_equal 89, game.players_cards[0].length
+ assert_equal 1, game.deck.length
+ assert_equal [:hat], game.deck
+
+ game.players_cards[0] = [:hat, :hat, :hat, :hat, :hat]
+ game.players_cards[1] = [:keys, :keys, :keys]
+ game.players_cards[2] = [:bottle, :dagger, :skull]
+ game.players_cards[3] = []
+ game.players_cards[4] = []
+ game.deal_cards!(1, 3)
+
+ assert_equal [:hat, :hat, :hat, :hat, :hat], game.players_cards[0].sort_by {|c| c.to_s}
+ assert_equal [:keys, :keys, :keys], game.players_cards[1].sort_by {|c| c.to_s}
+ assert_equal [:bottle, :dagger, :skull], game.players_cards[2].sort_by {|c| c.to_s}
+ assert_equal [:hat], game.players_cards[3].sort_by {|c| c.to_s}
+ assert_equal [], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal [], game.deck
+
+ game.deal_cards!(1, 4)
+ assert_equal [:keys], game.players_cards[4].sort_by {|c| c.to_s}
+ assert_equal $CARDS_PER_SYMBOL - 6, game.deck.select {|c| c == :hat}.length
+ assert_equal $CARDS_PER_SYMBOL - 4, game.deck.select {|c| c == :keys}.length
+ assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :bottle}.length
+ assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :dagger}.length
+ assert_equal $CARDS_PER_SYMBOL - 1, game.deck.select {|c| c == :skull}.length
+ assert_equal $CARDS_PER_SYMBOL, game.deck.select {|c| c == :gun}.length
+ assert_equal $CARDS_PER_SYMBOL * 6 - 13, game.deck.length
+
+ end
+
+ def test_long_deal
+ gamelines0 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1",
+ "hat", "skull", "bottle"]
+ assert_nothing_raised {Game.read_game(gamelines0)}
+ game, moves = Game.read_game(gamelines0)
+ assert_equal 0, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 3, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 9, game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines1 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1 gun", "1 0 2 keys", "1 2 1",
+ "2",
+ "hat", "skull", "bottle"]
+ assert_nothing_raised {Game.read_game(gamelines1)}
+ game, moves = Game.read_game(gamelines1)
+ assert_equal 3, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 2, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 2, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 10, game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 1, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines2 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1",
+ "hat"]
+ assert_nothing_raised {Game.read_game(gamelines2)}
+ game, moves = Game.read_game(gamelines2)
+ assert_equal 18, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 1, game.players_cards[0].length
+ assert_equal 1, game.players_cards[1].length
+ assert_equal 1, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 12, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 6), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 2, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines2 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1",
+ "hat", "skull", "bottle"]
+ assert_nothing_raised {Game.read_game(gamelines2)}
+ game, moves = Game.read_game(gamelines2)
+ assert_equal 30, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 3, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 18, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 18), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 3, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines3 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines3)}
+ game, moves = Game.read_game(gamelines3)
+ assert_equal 42, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 5, game.players_cards[0].length
+ assert_equal 5, game.players_cards[1].length
+ assert_equal 5, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 24, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 30), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 4, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines4 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys", "hat"]
+ assert_nothing_raised {Game.read_game(gamelines4)}
+ game, moves = Game.read_game(gamelines4)
+ assert_equal 54, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 7, game.players_cards[0].length
+ assert_equal 7, game.players_cards[1].length
+ assert_equal 7, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 30, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 42), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 5, (unplayed_cards.select {|c| c == :skull}).length
+
+
+ gamelines5 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys", "hat", "skull", "bottle", "gun", "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines5)}
+ game, moves = Game.read_game(gamelines5)
+ assert_equal 78, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 11, game.players_cards[0].length
+ assert_equal 11, game.players_cards[1].length
+ assert_equal 11, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 42, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 66), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 7, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines6 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle"]
+ assert_nothing_raised {Game.read_game(gamelines6)}
+ game, moves = Game.read_game(gamelines6)
+ assert_equal 102, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 15, game.players_cards[0].length
+ assert_equal 15, game.players_cards[1].length
+ assert_equal 15, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
+ assert_equal 3, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 54, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - (9 + 90), game.deck.length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines7 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun"]
+ assert_nothing_raised {Game.read_game(gamelines7)}
+ game, moves = Game.read_game(gamelines7)
+ assert_equal 104, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 16, game.players_cards[0].length
+ assert_equal 15, game.players_cards[1].length
+ assert_equal 15, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 55, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines8 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "skull", "bottle", "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines8)}
+ game, moves = Game.read_game(gamelines8)
+ assert_equal 105, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 3, game.moves_by_current_player
+ assert_equal 15, game.players_cards[0].length
+ assert_equal 15, game.players_cards[1].length
+ assert_equal 15, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 56, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 9, (unplayed_cards.select {|c| c == :skull}).length
+
+
+ gamelines9 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 12", "2 12 10",
+ "2",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle"]
+ assert_nothing_raised {Game.read_game(gamelines9)}
+ game, moves = Game.read_game(gamelines9)
+ assert_equal 107, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 2, game.moves_by_current_player
+ assert_equal 15, game.players_cards[0].length
+ assert_equal 15, game.players_cards[1].length
+ assert_equal 15, game.players_cards[2].length
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 45, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 0, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 0, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines10 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "hat", "hat", "hat", "hat", "hat",
+ "hat", "hat", "hat"]
+ assert_raise(InvalidMoveError) {Game.read_game(gamelines10)} # Not enough skull cards to go round
+
+ gamelines11 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "skull", "bottle", "dagger"]
+ assert_nothing_raised {Game.read_game(gamelines11)}
+ game, moves = Game.read_game(gamelines11)
+ assert_equal 111, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 15, game.players_cards[0].length
+ assert_equal 12, game.players_cards[1].length
+ assert_equal 12, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 62, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines12 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2",
+ "hat", "skull", "bottle", "gun", "dagger", "keys",
+ "hat", "skull", "bottle", "gun", "dagger", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines12)}
+ game, moves = Game.read_game(gamelines12)
+ assert_equal 114, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 12, game.players_cards[0].length
+ assert_equal 12, game.players_cards[1].length
+ assert_equal 12, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 65, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 14, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines13 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3",
+ "skull", "skull", "bottle", "gun", "dagger", "keys",
+ "bottle", "skull", "bottle", "gun", "dagger", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines13)}
+ game, moves = Game.read_game(gamelines13)
+ assert_equal 117, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 12, game.players_cards[0].length
+ assert_equal 9, game.players_cards[1].length
+ assert_equal 12, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 68, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines14 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 37",
+ "3",
+ "skull", "skull", "bottle", "gun", "dagger", "keys",
+ "bottle", "skull", "bottle", "gun", "dagger"]
+ assert_raise(InvalidMoveError) {Game.read_game(gamelines14)}
+
+ gamelines15 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1",
+ "skull", "skull", "bottle", "gun", "dagger", "keys",
+ "bottle", "skull", "bottle", "gun", "dagger", "keys"]
+ assert_nothing_raised {Game.read_game(gamelines15)}
+ game, moves = Game.read_game(gamelines15)
+ assert_equal 120, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 12, game.players_cards[0].length
+ assert_equal 9, game.players_cards[1].length
+ assert_equal 9, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 71, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 13, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines16 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2",
+ "skull", "skull", "keys", "gun", "dagger", "keys",
+ "skull", "skull", "skull"]
+ assert_nothing_raised {Game.read_game(gamelines16)}
+ game, moves = Game.read_game(gamelines16)
+ assert_equal 123, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 9, game.players_cards[0].length
+ assert_equal 9, game.players_cards[1].length
+ assert_equal 9, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 74, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 16, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines17 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3",
+ "skull", "skull", "keys", "gun", "dagger", "keys",
+ "skull", "skull", "skull"]
+ assert_nothing_raised {Game.read_game(gamelines17)}
+ game, moves = Game.read_game(gamelines17)
+ assert_equal 126, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 9, game.players_cards[0].length
+ assert_equal 6, game.players_cards[1].length
+ assert_equal 9, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 77, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 13, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines18 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1",
+ "skull", "skull", "keys", "gun", "dagger", "keys",
+ "skull", "skull", "skull"]
+ assert_nothing_raised {Game.read_game(gamelines18)}
+ game, moves = Game.read_game(gamelines18)
+ assert_equal 129, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 9, game.players_cards[0].length
+ assert_equal 6, game.players_cards[1].length
+ assert_equal 6, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 80, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 15, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines19 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2",
+ "skull", "skull", "gun", "gun", "dagger", "gun"]
+ assert_nothing_raised {Game.read_game(gamelines19)}
+ game, moves = Game.read_game(gamelines19)
+ assert_equal 132, game.history.length
+ assert_equal 1, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 6, game.players_cards[0].length
+ assert_equal 6, game.players_cards[1].length
+ assert_equal 6, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 83, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines20 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
+ "3",
+ "skull", "skull", "gun", "gun", "dagger", "gun"]
+ assert_nothing_raised {Game.read_game(gamelines20)}
+ game, moves = Game.read_game(gamelines20)
+ assert_equal 135, game.history.length
+ assert_equal 2, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 6, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 6, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 86, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 14, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines21 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
+ "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
+ "1",
+ "gun", "gun", "gun", "gun", "gun", "gun"]
+ assert_nothing_raised {Game.read_game(gamelines21)}
+ game, moves = Game.read_game(gamelines21)
+ assert_equal 138, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 0, game.moves_by_current_player
+ assert_equal 6, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 89, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 11, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :skull}).length
+
+ gamelines22 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
+ "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
+ "1 35 37 gun",
+ "1",
+ "gun", "gun", "gun", "gun", "gun"]
+ assert_nothing_raised {Game.read_game(gamelines22)}
+ game, moves = Game.read_game(gamelines22)
+ assert_equal 139, game.history.length
+ assert_equal 0, game.current_player
+ assert_equal 1, game.moves_by_current_player
+ assert_equal 5, game.players_cards[0].length
+ assert_equal 3, game.players_cards[1].length
+ assert_equal 3, game.players_cards[2].length
+ assert_equal 1, game.deck.length
+ unplayed_cards = game.players_cards.inject(game.deck.dup) {|acc, cs| acc.concat cs}
+ assert_equal $CARDS_PER_SYMBOL * $SYMBOLS.length - 90, unplayed_cards.length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :bottle}).length
+ assert_equal $CARDS_PER_SYMBOL - 10, (unplayed_cards.select {|c| c == :dagger}).length
+ assert_equal $CARDS_PER_SYMBOL - 12, (unplayed_cards.select {|c| c == :gun}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :hat}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :keys}).length
+ assert_equal $CARDS_PER_SYMBOL - 17, (unplayed_cards.select {|c| c == :skull}).length
+
+ assert_raise(GameWonNotice) {game.apply_move!("1 36 37 gun".to_move(game, true))}
+ assert_raise(InvalidMoveError) {game.apply_move!("1 36 37".to_move(game, true))}
+
+ gamelines23 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
+ "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
+ "1 35 37 gun", "1 36 37 gun",
+ "1",
+ "gun", "gun", "gun", "gun"]
+ assert_raise(GameWonNotice) {Game.read_game(gamelines23)}
+
+ gamelines24 = ["3", "cell",
+ "gun", "keys", "dagger", "hat", "skull", "bottle",
+ "keys", "dagger", "skull", "hat", "gun", "bottle",
+ "dagger", "bottle", "keys", "gun", "hat", "skull",
+ "dagger", "skull", "bottle", "gun", "keys", "hat",
+ "hat", "dagger", "keys", "bottle", "gun", "skull",
+ "keys", "bottle", "skull", "dagger", "hat", "gun", "boat",
+ "1 0 1", "1 0 2", "1 2 1",
+ "2 0 2", "2 0 3", "2 3 2",
+ "3 0 3", "3 0 4", "3 4 3",
+ "1 0 4", "1 0 5", "1 5 4",
+ "2 0 5", "2 0 6", "2 6 5",
+ "3 0 6", "3 0 11", "3 11 6",
+ "1 0 7", "1 7 6",
+ "2 0 8", "2 8 5",
+ "3 0 9", "3 9 4",
+ "1 0 10", "1 10 3",
+ "2 0 11", "2 11 2",
+ "3 0 12", "3 12 1",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "2 2 8", "2 8 2", "3 3 9", "3 9 3",
+ "1 1 10", "1 10 1", "2 2 11", "2 11 2", "3 3 12", "3 12 3",
+ "1 1 7", "1 7 1", "1 1 10",
+ "2 2 13 dagger", "2 2 14 bottle", "2 2 15 keys",
+ "3 1 16 gun", "3 3 17 hat", "3 3 18 skull",
+ "1 1 24 hat", "1 3 25 hat", "1 4 35 hat",
+ "2 5 37 hat", "2 5 37 hat", "2 5 37 hat",
+ "3 4 12 bottle", "3 6 21 bottle", "3 6 28 bottle",
+ "1 4 32 bottle", "1 6 37 bottle", "1 10 37 bottle",
+ "2 13 37 bottle", "2 14 23 keys", "2 15 27 keys",
+ "3 12 20 skull", "3 16 31 keys", "3 17 37 keys",
+ "1 24 37 keys", "1 25 37 keys", "1 32 36 gun",
+ "2 23 30 skull", "2 27 33 skull", "2 30 37 skull",
+ "3 18 30 skull", "3 20 37 skull", "3 21 37 skull",
+ "1 35 37 gun", "1 36 37 gun",
+ "2 33 34 dagger",
+ "2",
+ "dagger", "dagger"]
+ assert_raise(GameWonNotice) {Game.read_game(gamelines24)}
+ end
+
+end
\ No newline at end of file