Dawn/backup/poker/player.c

35 lines
776 B
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "player.h"
bool pokerPlayerIsInRound(pokerplayer_t *player) {
return !(
player->state & (POKER_PLAYER_STATE_FOLDED|POKER_PLAYER_STATE_OUT)
);
}
uint8_t pokerPlayerGetCountInRound(pokerplayer_t *players) {
return (uint8_t)arraySum(
sizeof(pokerplayer_t),
players,
POKER_PLAYER_COUNT,
(arraysumcallback_t *)(&pokerPlayerIsInRound)
);
}
void pokerPlayerReset(pokerplayer_t *player) {
player->cardCount = 0;
player->currentBet = 0;
player->timesRaised = 0;
// Invert then bitwise AND to turn off.
player->state &= ~(
POKER_PLAYER_STATE_FOLDED |
POKER_PLAYER_STATE_SHOWING
);
}