49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "holdem.h"
|
|
|
|
void holdemDeal(holdemmatch_t *match, holdemplayer_t *player) {
|
|
cardDeal(match->deck, player->cards, match->deckSize, player->cardCount);
|
|
match->deckSize--;
|
|
player->cardCount++;
|
|
}
|
|
|
|
void holdemDealAll(holdemmatch_t *match, uint8_t count) {
|
|
uint8_t i, j;
|
|
for(i = 0; i < count; i++) {
|
|
for(j = 0; j < HOLDEM_PLAYER_COUNT; j++) {
|
|
holdemDeal(match, match->players + j);
|
|
}
|
|
}
|
|
}
|
|
|
|
void holdemFlop(holdemmatch_t *match) {
|
|
if(match->cardsFacing >= HOLDEM_DEALER_HAND) return;
|
|
uint8_t i, count;
|
|
|
|
|
|
// Burn the card off the top
|
|
match->deckSize -= 1;
|
|
|
|
// Change count depending on facing
|
|
count = match->cardsFacing == 0 ? 0x03 : 0x01;
|
|
|
|
// Deal
|
|
for(i = 0; i < count; i++) {
|
|
cardDeal(match->deck, match->cards, match->deckSize, match->cardsFacing);
|
|
match->deckSize -= 1;
|
|
match->cardsFacing += 1;
|
|
}
|
|
}
|
|
|
|
uint32_t holdemBet(holdemmatch_t *match, holdemplayer_t *player, uint32_t amount) {
|
|
uint32_t realAmount = mathMin(player->chips, amount);
|
|
match->pot += realAmount;
|
|
player->chips -= realAmount;
|
|
return realAmount;
|
|
} |