Beispiel #1
0
    def test_can_buy(self):
        """Test out the _can_buy helper method."""
        deck = Deck()
        deck.treasure = 3
        deck.buys = 1

        # Test too little treasure for the card
        assert_equal(deck._can_buy(cards.Gold), False)
        # Test just enough
        assert_equal(deck._can_buy(cards.Silver), True)
        # Test too much
        assert_equal(deck._can_buy(cards.Copper), True)
Beispiel #2
0
class Player(object):

    """
    The player class is responsible for simulating a single player,
    including their current deck and hand and their strategy.
    """

    def __init__(self, deck):
        """Set up a default strategy, initialize the player's deck and hand."""
        self.deck = Deck(deck)

    def can_buy(self, card):
        """Convenience method for self.deck._can_buy(card)."""
        return self.deck._can_buy(card)

    def buy_card(self, card, game):
        """Convenience method for self.deck.buy_card(card, game)."""
        self.deck.buy_card(card, game)

    def new_hand(self):
        """Empties current hand into discard, redraws new hand."""
        self.deck.discard_pile.extend(self.deck.hand)
        self.deck.hand = []
        self.deck.draw(self.deck.HAND_SIZE)
        self.deck._update_deck_vars()

    def num_in_bank(self, card, game):
        """Returns the number of this card left in the bank."""
        return game.num_in_bank(card)

    def play_one_turn(self, game):
        raise NotImplementedError