/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#include "player.h"

bool pokerPlayerIsAlive(pokerplayer_t *player) {
  return !(player->state & (POKER_PLAYER_STATE_FOLDED|POKER_PLAYER_STATE_OUT));
}

bool pokerPlayerIsHuman(poker_t *poker, pokerplayer_t *player) {
  return (poker->players + POKER_PLAYER_HUMAN_INDEX) == player;
}

void pokerPlayerReset(pokerplayer_t *player) {
  player->cardCount = 0;
  player->currentBet = 0;

  // Invert then bitwise AND to turn off.
  player->state &= ~(
    POKER_PLAYER_STATE_FOLDED | 
    POKER_PLAYER_STATE_SHOWING
  );
}