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

#pragma once
#include <dawn/dawn.h>
#include "card.h"
#include "player.h"

/**
 * Returns the full hand for a given player including the best cards on the 
 * bench.
 * 
 * @param poker Poker game instance.
 * @param player Poker player game instance.
 * @param cards Array of at least 7 length to store the array.
 */
void pokerWinnerHandGetFull(poker_t *poker, pokerplayer_t *player,
  card_t *cards
);

/**
 * Calculates and returns the winning state for a given player
 * 
 * @param poker Poker game instance.
 * @param player Player game instance.
 * @param winning Pointer to the poker winning to fill out.
 * @return The winning state for this player. 
 */
void pokerWinnerPlayerGet(
  poker_t *poker, pokerplayer_t *player, pokerplayerwinning_t *winning
);

/**
 * Fills the remaining cards for a given poker player winning hand. Essentially
 * this will just take the highest cards and slot them into the array.
 * @param winning Pointer to the poker winning to fill out.
 */
void _pokerWinnerFillRemaining(pokerplayerwinning_t *winning);

/**
 * Compares two winning sets. The returned card is the kicker if the LEFT side
 * is the winner. If LEFT is not a winner then 0xFF will be returned.
 * 
 * @param left Left winning set.
 * @param right Right winning set.
 * @return The kicker card from left's hand or 0xFF if left is not the winner.
 */
card_t pokerWinnerCompare(
  pokerplayerwinning_t *left, pokerplayerwinning_t *right
);

/**
 * Determines the winning player for the game. Values will be stored back into
 * the poker winning state.
 * 
 * @param poker Poker game instance.
 */
void pokerWinnerCalculate(poker_t *poker);