Beispiel #1
0
    def test_pick_up_from_mesa(self):
        """Plays one card from their current hand and picks up
        cards from the mesa, adding up to 15, and places them
        in their pila. If last card is taken from the mesa,
        an escoba is counted.
        
        Modifies the player's currenthand, pila, and the mesa.
        """
        alice = Player('Alice')
        bob = Player('Bob')
        card_alice1 = Card(5, 'oro')
        card_alice2 = Card(7, 'basto')
        card_alice3 = Card(8, 'espada')
        card_bob1 = Card(5, 'espada')
        card_bob2 = Card(7, 'copa')
        card_bob3 = Card(8, 'oro')
        card_mesa1 = Card(4, 'copa')
        card_mesa2 = Card(4, 'basto')
        card_mesa3 = Card(10, 'oro')

        alice.pick_up_hand([card_alice1, card_alice2, card_alice3])
        bob.pick_up_hand([card_bob1, card_bob2, card_bob3])
        mesa = [card_mesa1, card_mesa2, card_mesa3]
        
        # Alice uses her 7 to pick up two 4s from the table
        alice.pick_up_from_mesa(mesa, (7, 'basto'), [(4, 'basto'), (4,'copa')])
        self.assertEqual([card_mesa3], mesa)
        self.assertEqual([card_alice1, card_alice3], alice.current_hand())
        
        # Next, bob uses his 5 to pick up the 10 from the table and get an escoba
        bob.pick_up_from_mesa(mesa, (5, 'espada'), [(10, 'oro')])
        self.assertEqual([], mesa)
        self.assertEqual(1, bob.pila().get_escobas())
        self.assertEqual([card_bob2, card_bob3], bob.current_hand())
Beispiel #2
0
 def test_pick_up_hand(self):
     """Collects a hand of three cards from the deck (ie. at the start of each round)"""
     bob = Player('Bob')
     a = Card(3, 'oro')
     b = Card(4, 'oro')
     c = Card(5, 'oro')
     bob.pick_up_hand([a, b, c])
     self.assertEqual([a, b, c], bob.current_hand())
Beispiel #3
0
 def test_holds_card(self):
     """True if the player has the card in their current hand"""
     alice = Player('Alice')
     a = Card(3, 'oro')
     b = Card(4, 'oro')
     c = Card(5, 'espada')
     alice.pick_up_hand([a, b, c])
     
     self.assertTrue(alice.holds_card((3, 'oro')))
     self.assertTrue(alice.holds_card((5, 'espada')))
     self.assertFalse(alice.holds_card((10, 'oro')))
     self.assertFalse(alice.holds_card((4, 'copa')))
Beispiel #4
0
 def test_place_card_on_mesa(self):
     """Puts down a card on the mesa"""
     alice = Player('Alice')
     card1 = Card(5, 'oro')
     card2 = Card(10, 'basto')
     card3 = Card(8, 'espada')
     alice.pick_up_hand([card1, card2, card3])
     
     mesa = []
     alice.place_card_on_mesa(mesa, (5, 'oro'))
     self.assertEqual(card1, mesa[0])
     self.assertEqual([card2, card3], alice.current_hand())
     
     alice.place_card_on_mesa(mesa, (8, 'espada'))
     self.assertEqual([card1, card3], mesa)
     self.assertEqual([card2], alice.current_hand())