Пример #1
0
    def test_received_passed_cards_first_pass_valid(self, has_everyone_passed):
        pr = self.pr
        pr.id = 1
        pr.active = True
        pr.seats_received = []
        pr.passed_cards = []
        pr.save()

        pass_cards = (
            [Card(2, Card.CLUBS), Card(3, Card.CLUBS), Card(4, Card.CLUBS)])

        player = self.player
        player.id = 2
        player.position = 0
        player.hand = pass_cards
        player.save()

        has_everyone_passed.return_value = False

        pass_round.received_passed_cards(pass_cards, 2, 1)

        pr.refresh_from_db()

        self.assertListEqual(pass_cards, pr.passed_cards)
        self.assertListEqual([0], pr.seats_received)
Пример #2
0
    def test_received_passed_cards_middle_pass_valid(self, has_everyone_passed):
        pr = self.pr
        pr.id = 1
        pr.active = True
        pr.seats_received = [0, 2]
        pr.passed_cards = [Card(2, Card.CLUBS), Card(3, Card.CLUBS),
                           Card(4, Card.CLUBS), Card(8, Card.CLUBS),
                           Card(9, Card.CLUBS), Card(10, Card.CLUBS)]
        pr.save()

        pass_cards = (
            [Card(5, Card.CLUBS), Card(6, Card.CLUBS), Card(7, Card.CLUBS)])

        player = self.player
        player.id = 2
        player.position = 1
        player.hand = pass_cards
        player.save()

        has_everyone_passed.return_value = False


        pass_round.received_passed_cards(pass_cards, 2, 1)

        pr.refresh_from_db()

        expected_cards = [Card(2, Card.CLUBS), Card(3, Card.CLUBS),
                          Card(4, Card.CLUBS), Card(5, Card.CLUBS),
                          Card(6, Card.CLUBS), Card(7, Card.CLUBS),
                          Card(8, Card.CLUBS), Card(9, Card.CLUBS),
                          Card(10, Card.CLUBS)]
        self.assertListEqual(expected_cards, pr.passed_cards)
        self.assertListEqual([0, 1, 2], pr.seats_received)
Пример #3
0
    def test_received_passed_cards_pass_round_card_not_in_hand_invalid(self):
        pr = self.pr
        pr.id = 1
        pr.active = True
        pr.seats_received = []
        pr.passed_cards = []
        pr.save()

        pass_cards = (
            [Card(5, Card.CLUBS), Card(6, Card.CLUBS), Card(7, Card.CLUBS)])

        player = self.player
        player.id = 2
        player.position = 1
        player.save()

        pass_cards = (
            [Card(4, Card.CLUBS), Card(6, Card.CLUBS), Card(7, Card.CLUBS)])

        pass_round.received_passed_cards(pass_cards, 2, 1)

        pr.refresh_from_db()

        expected_cards = []
        self.assertListEqual(expected_cards, pr.passed_cards)
        self.assertListEqual([], pr.seats_received)
Пример #4
0
def pass_cards_selected(game, cards_str, player, turn_id):
    '''Called when a player selects which cards to pass
    
    Arguments:
        game: the game database entry
        cards_str: a string shorthand representing which cards the player chose
            to pass
        player: the database entry for the player who is passing their cards
        turn_id: the id of the current turn
    '''
    cards = Card.list_from_str_list(cards_str)
    pass_round.received_passed_cards(game, player, cards, turn_id)