Exemplo n.º 1
0
    def test_default_game_terrain_edge_cases(self) -> None:
        # First row.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="A", column=1)),
            common.Terrain.PLAIN)  # First.
        # Second.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="A", column=2)),
            common.Terrain.MOUNTAIN)
        # Second to last.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="A", column=12)),
            common.Terrain.WASTELAND)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="A", column=13)),
            common.Terrain.SWAMP)  # Last.

        # Second row.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="B", column=1)),
            common.Terrain.DESERT)  # First.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="B", column=2)),
            common.Terrain.WATER)  # Second.
        # Second to last.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="B", column=11)),
            common.Terrain.WATER)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="B", column=12)),
            common.Terrain.DESERT)  # Last
Exemplo n.º 2
0
 def test_default_game_board_terrain_failure_cases(self) -> None:
     with self.assertRaises(KeyError):
         self.default_board.get_terrain(
             board.Position(row=chr(ord("A") - 1),
                            column=1))  # No such row.
     with self.assertRaises(KeyError):
         self.default_board.get_terrain(board.Position(
             row="J", column=1))  # No such row.
     with self.assertRaises(KeyError):
         self.default_board.get_terrain(board.Position(
             row="A", column=0))  # No such column.
     with self.assertRaises(KeyError):
         self.default_board.get_terrain(board.Position(
             row="I", column=14))  # No such column.
Exemplo n.º 3
0
    def test_only_myself_around_me(self, _: mock.Mock) -> None:
        player1 = mock.Mock(auto_spec=player.Player)
        player1.faction.home_terrain.return_value = common.Terrain.MOUNTAIN

        player2 = mock.Mock(auto_spec=player.Player)
        player2.faction.home_terrain.return_value = common.Terrain.WASTELAND

        game = gameplay.Game(players=[player1, player2],
                             scoring_tiles=[],
                             bonus_cards=[],
                             interface=self.mock_interface)

        # Board will always tell us we have a dwelling on a mountain terrain
        # and a dwelling on a wasteland terrain next to us.
        mock_board = mock.Mock(auto_spec=board.GameBoard)
        mock_board.neighbor_structure_owners.return_value = set([
            (common.Structure.DWELLING, common.Terrain.MOUNTAIN),
            (common.Structure.DWELLING, common.Terrain.MOUNTAIN)
        ])

        game.board = mock_board

        self.assertFalse(
            game.player_has_opponent_neighbors_at_position(
                player1, board.Position(row="A", column=1)))
Exemplo n.º 4
0
    def test_extra_water_tile_for_even_rows(self) -> None:

        # We allow requesting the 13th column for these rows, but it's always
        # water.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="B", column=13)),
            common.Terrain.WATER)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="D", column=13)),
            common.Terrain.WATER)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="F", column=13)),
            common.Terrain.WATER)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="H", column=13)),
            common.Terrain.WATER)
Exemplo n.º 5
0
    def test_default_game_board_neighbors_corners(self) -> None:

        self.assertCountEqual(
            self.default_board.get_neighbor_tiles(
                board.Position(row="A", column=1)), {("A", 2), ("B", 1)})
        # We technically allow a fictional water tile at B13 to be a neighbor.
        self.assertCountEqual(
            self.default_board.get_neighbor_tiles(
                board.Position(row="A", column=13)), {("A", 12), ("B", 12),
                                                      ("B", 13)})
        self.assertCountEqual(
            self.default_board.get_neighbor_tiles(
                board.Position(row="I", column=1)), {("I", 2), ("H", 1)})
        # We technically allow a fictional water tile at G13 to be a neighbor.
        self.assertCountEqual(
            self.default_board.get_neighbor_tiles(
                board.Position(row="I", column=13)), {("I", 12), ("H", 12),
                                                      ("H", 13)})
Exemplo n.º 6
0
    def test_default_game_bard_terrain_random(self) -> None:

        # Random checks.
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="F", column=4)),
            common.Terrain.WATER)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="F", column=5)),
            common.Terrain.DESERT)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="F", column=6)),
            common.Terrain.FOREST)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="D", column=7)),
            common.Terrain.LAKE)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="I", column=7)),
            common.Terrain.DESERT)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="I", column=8)),
            common.Terrain.WASTELAND)
        self.assertEqual(
            self.default_board.get_terrain(board.Position(row="I", column=9)),
            common.Terrain.MOUNTAIN)
Exemplo n.º 7
0
 def test_initialization(self) -> None:
     pos = board.Position(row='row', column=1)
     self.assertEqual('row', pos.row)
     self.assertEqual(1, pos.column)
Exemplo n.º 8
0
 def test_parse_position(self) -> None:
     self.assertEqual(board.ParsePosition("A13"),
                      board.Position(row="A", column=13))
     self.assertEqual(board.ParsePosition("I1"),
                      board.Position(row="I", column=1))