This repository has been archived on 2024-11-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Dawn-GB/src/poker/winner.h

64 lines
2.1 KiB
C

/**
* Copyright (c) 2022 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#include "card.h"
/** Maximum number of cards a winning state can hold. */
#define POKER_WINNING_FULL_SIZE 0x07
/** How many cards in the winning set */
#define POKER_WINNING_SET_SIZE 0x05
/** Winning Types */
#define POKER_WINNING_TYPE_NULL 0x00
#define POKER_WINNING_TYPE_ROYAL_FLUSH 0x01
#define POKER_WINNING_TYPE_STRAIGHT_FLUSH 0x02
#define POKER_WINNING_TYPE_FOUR_OF_A_KIND 0x03
#define POKER_WINNING_TYPE_FULL_HOUSE 0x04
#define POKER_WINNING_TYPE_FLUSH 0x05
#define POKER_WINNING_TYPE_STRAIGHT 0x06
#define POKER_WINNING_TYPE_THREE_OF_A_KIND 0x07
#define POKER_WINNING_TYPE_TWO_PAIR 0x08
#define POKER_WINNING_TYPE_PAIR 0x09
#define POKER_WINNING_TYPE_HIGH_CARD 0x0A
/** Confidences of winning based on the current hand type */
#define POKER_WINNING_CONFIDENCE_ROYAL_FLUSH 1000
#define POKER_WINNING_CONFIDENCE_STRAIGHT_FLUSH 990
#define POKER_WINNING_CONFIDENCE_FOUR_OF_A_KIND 900
#define POKER_WINNING_CONFIDENCE_FULL_HOUSE 850
#define POKER_WINNING_CONFIDENCE_FLUSH 800
#define POKER_WINNING_CONFIDENCE_STRAIGHT 700
#define POKER_WINNING_CONFIDENCE_THREE_OF_A_KIND 500
#define POKER_WINNING_CONFIDENCE_TWO_PAIR 400
#define POKER_WINNING_CONFIDENCE_PAIR 200
#define POKER_WINNING_CONFIDENCE_HIGH_CARD 100
/** Holds information about a player's winning state */
typedef struct {
/** The full set of both the dealer and player's hand */
uint8_t full[POKER_WINNING_FULL_SIZE];
uint8_t fullSize;
/** Holds the winning set */
uint8_t set[POKER_WINNING_SET_SIZE];
uint8_t setSize;
/** Winning Type */
uint8_t type;
/** If there was a kicker card it will be here, otherwise -1 for no kicker */
uint8_t kicker;
} pokerplayerwinning_t;
extern pokerplayerwinning_t POKER_WINNERS[POKER_PLAYER_COUNT_MAX];
extern uint8_t POKER_WINNER_PLAYERS[POKER_PLAYER_COUNT_MAX];
extern uint8_t POKER_WINNER_PARTICIPANTS[POKER_PLAYER_COUNT_MAX];
extern uint8_t POKER_WINNER_COUNT;
extern uint8_t POKER_WINNER_PARTICIPANT_COUNT;