diff --git a/gameloop.py b/gameloop.py index d453a8d..92ce736 100644 --- a/gameloop.py +++ b/gameloop.py @@ -574,18 +574,18 @@ def game(send, notice, voice, devoice, get_event): # Select call card for the next round round_call_card = deal_call() + # See note above num_blanks in top_of_round() + num_blanks = len(round_call_card.text) - 1 + # Find out how many response cards we need + hand_size = 9 + num_blanks need_responses = 0 for player in players.values(): # Don't deal cards to the czar this round if player is czar: continue - if len(player.hand) < 10: - need_responses += 10 - len(player.hand) - need_responses += player.hand.count(None) + need_responses += max(hand_size - len(player.hand) + player.hand.count(None), 0) - # See note above num_blanks in top_of_round() - num_blanks = len(round_call_card.text) - 1 for bot in bots.values(): need_responses += bot.num_need_cards(num_blanks) @@ -603,10 +603,29 @@ def game(send, notice, voice, devoice, get_event): # We skipped the czar in the counts, so skip here too if player is czar: continue - while len(player.hand) < 10: + # Move the cards outside of the current hand size into + # the hand + overflow = player.hand[hand_size:] + player.hand = player.hand[:hand_size] + for index in range(len(player.hand)): + if len(overflow) == 0: + break + + if player.hand[index] is None: + # .pop(0) instead of .pop() since we + # want to keep the same order + player.hand[index] = overflow.pop(0) + + # Do we still have some overflow cards we couldn't fit + # into the hand? If so, just stick them at the end and + # we'll just have an oversized hand this round + player.hand.extend(overflow) + + # Fill any remaining empty spots with dealt cards + while len(player.hand) < hand_size: player.hand.append(responses.pop()) - for index in range(10): + for index in range(hand_size): if player.hand[index] is None: player.hand[index] = responses.pop()