Exemplo n.º 1
0
 def test_remove_has_at_least_x_of_resource_type(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     player_hand.hand[Clay] = 2
     removed_count = player_hand.remove(resource_type=Clay, count=1)
     assert removed_count == 1
     assert player_hand.hand[Clay] == 1
Exemplo n.º 2
0
 def test_remove_has_less_than_x_of_resource_type(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     player_hand.hand[Clay] = 2
     removed_count = player_hand.remove(resource_type=Clay, count=3)
     assert removed_count == 2
     assert player_hand.hand[Clay] == 0
Exemplo n.º 3
0
 def test_add_raises_if_count_less_than_1(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     with pytest.raises(
         RuntimeError, match="Cannot add 0 or less cards to the hand."
     ):
         player_hand.add(resource_type=Clay, count=0)
Exemplo n.º 4
0
 def test_remove_raises_if_count_less_than_1(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     with pytest.raises(
         RuntimeError, match="Cannot remove 0 or less cards from the hand."
     ):
         player_hand.remove(resource_type=Clay, count=0)
Exemplo n.º 5
0
    def __init__(self, players=[]):
        # There should be 19 of each resource type.
        self.resource_card_deck = ResourceCardDeck()

        # Shuffle the development card deck.
        self.development_card_deck = DevelopmentCardDeck()

        # Create the board.
        self.board = Board()

        self.players = players.copy()
        random.shuffle(self.players)

        self.current_player_turn = self.players[0]

        self.dice_rolled = False

        self.player_pieces = {}
        self.bonus_victory_points = {}
        self.player_hand = {}
        for player in self.players:
            # Each player gets 15 roads, 5 settlements, and 4 cities.
            self.player_pieces[player] = {"roads": 15, "settlements": 5, "cities": 4}

            # Bonus victory points
            self.bonus_victory_points[player] = {
                "victory_point_development_cards": 0,
                "longest_road": False,
                "largest_army": False,
            }

            self.player_hand[player] = PlayerHand(player=player)
Exemplo n.º 6
0
 def test_init_hand(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     assert player_hand.hand[Clay] == 0
     assert player_hand.hand[Rock] == 0
     assert player_hand.hand[Sheep] == 0
     assert player_hand.hand[Wheat] == 0
     assert player_hand.hand[Wood] == 0
Exemplo n.º 7
0
    def test_can_buy_settlement(self):
        player = Player()
        player_hand = PlayerHand(player=player)

        assert not player_hand.can_buy_settlement()

        player_hand.hand[Wood] = 1
        player_hand.hand[Clay] = 1
        player_hand.hand[Wheat] = 1
        player_hand.hand[Sheep] = 1

        assert player_hand.can_buy_settlement()
Exemplo n.º 8
0
    def test_can_buy_development_card(self):
        player = Player()
        player_hand = PlayerHand(player=player)

        assert not player_hand.can_buy_development_card()

        player_hand.hand[Rock] = 1
        player_hand.hand[Sheep] = 1
        player_hand.hand[Wheat] = 1

        assert player_hand.can_buy_development_card()
Exemplo n.º 9
0
    def test_can_buy_road(self):
        player = Player()
        player_hand = PlayerHand(player=player)

        assert not player_hand.can_buy_road()

        player_hand.hand[Clay] = 1
        player_hand.hand[Wood] = 1

        assert player_hand.can_buy_road()
Exemplo n.º 10
0
    def test_can_buy_city(self):
        player = Player()
        player_hand = PlayerHand(player=player)

        assert not player_hand.can_buy_city()

        player_hand.hand[Rock] = 3
        player_hand.hand[Wheat] = 2

        assert player_hand.can_buy_city()
Exemplo n.º 11
0
 def test_add_resources_to_hand(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     player_hand.add(resource_type=Clay, count=10)
     assert player_hand.hand[Clay] == 10
Exemplo n.º 12
0
 def test_has_less_than_x_of_resource_type(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     player_hand.hand[Clay] = 2
     assert not player_hand.has(resource_type=Clay, count=3)
Exemplo n.º 13
0
 def test_has_at_least_x_of_resource_type(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     player_hand.hand[Clay] = 2
     assert player_hand.has(resource_type=Clay, count=2)
Exemplo n.º 14
0
 def test_init_player(self):
     player = Player()
     player_hand = PlayerHand(player=player)
     assert player_hand.player == player