def test_card_discarded_invalid_trick_id(self, send_turn_notification, finish, send_players_discard): old_hand = [Card(2, Card.CLUBS)] time_turn_started = timezone.make_aware( datetime.datetime(2017, 10, 1, 0, 0, 0, 0)) time_turn_ended = timezone.make_aware( datetime.datetime(2017, 10, 1, 0, 0, 4, 0)) tt = self.tt tt.id = 9 tt.active = True tt.discards = [] tt.save() player = self.player player.id = 2 player.position = 0 player.hand = old_hand player.bank_ms = 10000 player.time_turn_started = time_turn_started player.save() discard = Card(2, Card.CLUBS) trick_turn_rules.card_discarded(discard, 2, 1, time_turn_ended) tt.refresh_from_db() player.refresh_from_db() self.assertListEqual([], tt.discards) self.assertEqual(0, tt.expected_seat) self.assertListEqual(old_hand, player.hand) self.assertEqual(10000, player.bank_ms)
def trick_cards_selected(game, cards_str, player, turn_id): '''Called when a player selects which card to play for the trick turn 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) # The assumption is that the player can only select one card on their turn # for the trick. card = cards[0] trick_turn.card_discarded(game, player, card, turn_id)