From ac3f0c05e6d804f6b8d03496c05407fb92c5eb1a Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 23 Jan 2022 11:03:21 -0800 Subject: [PATCH] Fixed shuffle and deal bugs --- src/poker/poker.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/poker/poker.c b/src/poker/poker.c index 43995c1..6be34c0 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -72,9 +72,10 @@ void pokerNewRound() { POKER_DECK_SIZE = CARD_DECK_SIZE; // Shuffle Deck - for(i = CARD_DECK_SIZE-1; i > 0; i--) { + for(i = POKER_DECK_SIZE-1; i > 0; i--) { + k = rand(); + j = k % (i+1); k = POKER_DECK[i]; - j = rand() % (i+1); POKER_DECK[i] = POKER_DECK[j]; POKER_DECK[j] = k; } @@ -108,7 +109,7 @@ void pokerNewRound() { // Deal two cards to the player. for(j = 0; j < POKER_PLAYER_HAND_SIZE_MAX; j++) { - POKER_PLAYERS[i].hand[j] = POKER_DECK[POKER_DECK_SIZE--]; + POKER_PLAYERS[i].hand[j] = POKER_DECK[--POKER_DECK_SIZE]; } }