Dawn/src/poker/round/deal.c

41 lines
1.0 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "deal.h"
void pokerDealInit(poker_t *poker) {
uint8_t x, y;
card_t temporary;
pokerplayer_t *player;
poker->round = POKER_ROUND_DEAL;
// Hard look at the dealer
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER);
// Shuffle the deck
for(x = 0; x < CARD_DECK_SIZE - 1; x++) {
// Select random element from remaining elements.
y = u8randRange(x, CARD_DECK_SIZE);
temporary = poker->deck[y];// Take out other card
poker->deck[y] = poker->deck[x];// Move my card there
poker->deck[x] = temporary;// Put other card here.
}
// Deal 2 card to each player
for(y = 0; y < POKER_DEAL_CARD_EACH; y++) {
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
player = poker->players + x;
cardDeal(
poker->deck, &poker->deckSize,
player->cards, &player->cardCount
);
}
}
printf("Cards Dealt\n");
pokerBetInit(poker);
}