def test_placed_piece_spec(self): player = Player(1) player.name = 'abraham' piece = Piece(3, 1, [0, 3, 7]) placed_piece = PlacedPiece(piece, 1, 3, Orientation.South, player) serialized = PlacedPieceSerializer.serialize(placed_piece) spec_file = '../protocol/examples/placed-stone.json' self.assertSerializationEqual(spec_file, serialized)
def setUp(self): self.piece1 = Piece(2, 2, [2, 3, 7]) self.piece2 = Piece(1, 3, [1, 2]) self.piece3 = Piece(1, 3, [0, 7]) self.piece4 = Piece(1, 3, [1]) self.player1 = Player(1) self.player2 = Player(2) self.board1 = Board(8) self.board1.place_simple_initial(self.piece1, self.player1) self.board2 = Board(8) self.board2.place_simple_initial(self.piece1, self.player2) self.board2.place(self.piece3, 5, 4, Orientation.East, None)
def setUp(self): self.pieces = [ Piece(2, 2, [0, 1, 2, 3, 4, 5, 6, 7]), Piece(1, 3, [0, 4, 7]), Piece(1, 3, [0, 4]), Piece(3, 2, [3, 6, 8, 9]), Piece(1, 3, [0, 4]), Piece(1, 3, [0, 4]), Piece(3, 1, [1, 3, 7]) ] self.player1 = Player(1) self.player2 = Player(2) self.players = [self.player1, self.player2] self.objectives = { self.player1: [Board.Side.East, Board.Side.West], self.player2: [Board.Side.North, Board.Side.South] }
def test_game_spec(self): player1 = Player('Player A') player1.name = player1.id player2 = Player('Player B') player2.name = player2.id objectives = { player1: [Board.Side.North, Board.Side.South], player2: [Board.Side.East, Board.Side.West] } pieces, positions = self.game_spec_pieces() board = Board(10) game = Game(board, [player1, player2], objectives, pieces) for piece, pos in zip(pieces, positions): game.make_turn(game.current_player, piece, *pos) serialized = GameSerializer.serialize(game) spec_file = '../protocol/examples/populated-field.json' self.assertSerializationEqual(spec_file, serialized)
def setUp(self): self.piece1 = Piece(2, 2, [0, 1, 2, 3, 4, 5, 6, 7]) self.piece2 = Piece(1, 3, [0, 1, 2, 3, 4, 5, 6, 7]) self.board = Board(8) self.player = Player(1) self.board.place_simple_initial(self.piece1, self.player)
def setUp(self): self.piece1 = Piece(2, 2, [2, 5]) self.piece2 = Piece(1, 3, [0, 1, 4]) self.player = Player(1)