Beispiel #1
0
    def test_can_place_building_returns_false_if_building_exists(self):
        player = Player()
        vertex = Vertex(id=0)
        edge = Edge(id=0)

        edge.vertices = [vertex]
        edge.road = Road(player)
        vertex.edges = [edge]
        vertex.assign_building(building=Settlement(player=player))

        assert not vertex.can_place_building(player=player)
Beispiel #2
0
    def test_can_place_building_returns_true(self):
        player = Player()
        vertex = Vertex(id=0)
        edge = Edge(id=0)
        neighbour_vertex = Vertex(id=1)

        edge.road = Road(player)
        vertex.edges = [edge]
        neighbour_vertex.edges = [edge]
        edge.vertices = [vertex, neighbour_vertex]

        assert vertex.can_place_building(player=player)
Beispiel #3
0
    def test_can_place_building_Returns_false_if_building_is_nearby(self):
        player = Player()
        vertex = Vertex(id=0)
        neighbour_vertex = Vertex(id=1)
        edge = Edge(id=0)

        vertex.edges = [edge]
        neighbour_vertex.edges = [edge]
        neighbour_vertex.building = Settlement(player=player)
        edge.vertices = [vertex, neighbour_vertex]
        edge.road = Road(player=player)

        assert not vertex.can_place_building(player=player)
Beispiel #4
0
    def test_can_place_building_returns_false_if_no_roads_exist(self):
        player = Player()
        different_player = Player()
        vertex = Vertex(id=0)
        edge_no_road = Edge(id=0)
        edge_road_different_player = Edge(id=1)

        vertex.edges = [edge_no_road, edge_road_different_player]
        edge_no_road.vertices = [vertex]
        edge_road_different_player.vertices = [vertex]
        edge_road_different_player.road = Road(player=different_player)

        assert not vertex.can_place_building(player=player)
Beispiel #5
0
    def test_can_place_road_returns_true_if_adjacent_road_for_player(self):
        player = Player()

        edge = Edge(id=0)
        edge_with_road = Edge(id=1)
        edge_with_road.road = Road(player=player)

        vertex = Vertex(id=0)

        # Connect vertex to edges
        edge.vertices = [vertex]
        edge_with_road.vertices = [vertex]
        vertex.edges = [edge, edge_with_road]

        assert edge.can_place_road(player=player)
Beispiel #6
0
    def test_can_place_road_returns_false_if_no_adjacent_roads_for_player(
        self, ):
        player1 = Player()
        player2 = Player()

        edge = Edge(id=0)
        edge_no_road = Edge(id=1)
        edge_with_road_player2 = Edge(id=2)
        edge_with_road_player2.road = Road(player=player2)

        v1 = Vertex(id=0)
        v2 = Vertex(id=1)

        # Connect vertex to edges
        edge.vertices = [v1, v2]
        edge_no_road.vertices = [v1]
        edge_with_road_player2.vertices = [v2]
        v1.edges = [edge, edge_no_road]
        v2.edges = [edge, edge_with_road_player2]

        assert not edge.can_place_road(player=player1)
Beispiel #7
0
 def test_can_place_road_returns_false_if_road_already_exists(self):
     edge = Edge(id=0)
     player = Player()
     edge.road = Road(player=player)
     assert not edge.can_place_road(player=player)