def test_failing_defense_pushes_attack_cards_into_defender_hand(self): game = Game() game.turn = 'player' game.attack_cards = [Card(Suit.CLUBS, Rank.JACK)] game.defender.hand = [] game.defend() assert game.defender.hand[0] == Card(Suit.CLUBS, Rank.JACK)
def test_defense_when_cant_beat_attack(self): hand = [ Card(Suit.CLUBS, Rank.SEVEN), Card(Suit.HEARTS, Rank.SEVEN), Card(Suit.SPADES, Rank.SEVEN), Card(Suit.HEARTS, Rank.JACK), Card(Suit.CLUBS, Rank.JACK), Card(Suit.SPADES, Rank.JACK) ] game = Game() game.trump = Card(Suit.DIAMONDS, Rank.SIX) game.attack_cards = [Card(Suit.CLUBS, Rank.ACE)] p = AIPlayer(hand=hand, game=game) assert p.defend() == None
def test_successful_defense(self): hand = [ Card(Suit.CLUBS, Rank.KING), Card(Suit.HEARTS, Rank.SIX), Card(Suit.SPADES, Rank.ACE), Card(Suit.CLUBS, Rank.ACE), Card(Suit.HEARTS, Rank.ACE), Card(Suit.SPADES, Rank.JACK) ] game = Game() game.trump = Card(Suit.DIAMONDS, Rank.SIX) game.attack_cards = [ Card(Suit.CLUBS, Rank.QUEEN), Card(Suit.HEARTS, Rank.QUEEN) ] p = AIPlayer(hand=hand, game=game) assert p.defend() == [ Card(Suit.CLUBS, Rank.KING), Card(Suit.HEARTS, Rank.ACE) ]