Implementation of functions relative to manipulating and analyzing the contents of the Hand. More...
#include "hand.h"#include "audio_utils.h"#include "card.h"#include "game.h"#include "game/round.h"#include "game_variables.h"#include "graphic_utils.h"#include "soundbank.h"#include "util.h"#include <tonc.h>Go to the source code of this file.
Data Structures | |
| struct | HandValues |
| struct | Hand |
Typedefs | |
| typedef struct Hand | Hand |
Functions | |
| static ContainedHandTypes | compute_contained_hand_types (void) |
| static enum HandType | compute_hand_type (struct ContainedHandTypes contained_types) |
| const char * | get_hand_type_name (enum HandType hand_type) |
| enum HandState | get_hand_state (void) |
| Get the hand state. | |
| void | set_hand_state (enum HandState new_hand_state) |
| Set the hand state. Primarily used by the GAME_PLAYING game state. | |
| CardObject ** | get_hand_array (void) |
| Get the hand array of Cards currently held in hand. | |
| int | get_hand_top (void) |
| Get the position in hand array of the last card obtained. | |
| void | set_hand_top (int new_hand_top) |
| Set the position in hand array of the last card obtained. | |
| int | hand_nb_held_cards (void) |
| Get the current number of Cards in hand. | |
| int | hand_get_nb_selected_cards (void) |
| Get the current number of selected Cards. | |
| void | hand_set_nb_selected_cards (int new_selections) |
| Set the current number of selected Cards. | |
| enum HandType | get_hand_type (void) |
| Get the current hand type. | |
| ContainedHandTypes * | get_contained_hands (void) |
| Get the contained hands within the selected hand. | |
| static void | print_hand_type (const char *hand_type_str) |
| void | compute_hand_value_info (void) |
| Determine the HandType and ContainedHandTypes of the currently selected Cards, then print the Hand's name, chips, and mult on screen. | |
| void | swap_cards_in_hand (int idx_a, int idx_b) |
| Swaps the order of two cards in hand. | |
| static void | sort_hand_by_suit (void) |
| static void | sort_hand_by_rank (void) |
| static bool | shift_null_card_to_end (int null_card_idx) |
| void | reorder_card_sprites_layers (void) |
| Destroy the sprites of the Cards held in hand and recreate then in the same order as the Cards in the hand array. This allows Cards to render properly when help in hand during the round or a Tarot/Spectral booster pack. | |
| void | sort_cards (void) |
| Sort the hand array according to the selected method to do that. | |
| void | hand_change_sort (bool to_sort_by_suit) |
| Switch to the given sort method. Can sort playing cards in two ways: by rank and suit. The order of suits is as follows: | |
| void | hand_select_card (int index) |
| Set the card at a given index in Hand as selected. | |
| void | hand_deselect_all_cards (void) |
| Deselect all cards in hand. | |
| static void | get_hand_distribution (u8 ranks_out[NUM_RANKS], u8 suits_out[NUM_SUITS]) |
| Outputs the distribution of ranks and suits in the hand. | |
| static u8 | hand_contains_n_of_a_kind (u8 *ranks) |
| static bool | hand_contains_two_pair (u8 *ranks) |
| static bool | hand_contains_full_house (u8 *ranks) |
| static bool | hand_contains_straight (u8 *ranks) |
| static bool | hand_contains_flush (u8 *suits) |
| int | find_flush_in_played_cards (CardObject **played, int top, int min_len, bool *out_selection) |
| Finds the best flush (set of cards with the same suit) in the given array of played cards. | |
| int | find_straight_in_played_cards (CardObject **played, int top, int min_len, bool *out_selection) |
| Finds the best straight in the given array of played cards. | |
| void | select_paired_cards_in_hand (CardObject **played, int played_top, bool *selection) |
| This is used for the special case in "Four Fingers" where you can add a pair into a straight (e.g. AA234 should score all 5 cards) | |
Variables | |
| static const HandValues | HAND_BASE_VALUES [] |
| static const Rect | HAND_TYPE_RECT = {8, 64, 64, 72} |
| static Hand | s_hand |
Implementation of functions relative to manipulating and analyzing the contents of the Hand.
Definition in file hand.c.
|
static |
|
static |
| void compute_hand_value_info | ( | void | ) |
Determine the HandType and ContainedHandTypes of the currently selected Cards, then print the Hand's name, chips, and mult on screen.
| int find_flush_in_played_cards | ( | CardObject ** | played, |
| int | top, | ||
| int | min_len, | ||
| bool * | out_selection | ||
| ) |
Finds the best flush (set of cards with the same suit) in the given array of played cards.
Normally a Flush is made of 5 cards of the same suit, but this function takes into account the Four Fingers joker which allows for Flushes made of 4 cards only.
The cards belonging to that flush will be marked as selected in the out_selection array.
| played | Array of pointers to CardObject representing played cards. |
| top | Index of the top of the played stack. |
| min_len | Minimum number of cards required for a flush. |
| out_selection | Output array of bools; set to true for cards in the best flush, false otherwise. |
| int find_straight_in_played_cards | ( | CardObject ** | played, |
| int | top, | ||
| int | min_len, | ||
| bool * | out_selection | ||
| ) |
Finds the best straight in the given array of played cards.
Normally, a Straight is a set of 5 cards with sequential ranks, but this function takes into account the Four Fingers and Shortcut jokers, which respectively allow for Straights made of 4 cards and with gaps of 1 rank between two cards.
The cards belonging to that straight will be marked as selected in the out_selection array.
| played | Array of pointers to CardObject representing played cards. |
| top | Index of the top of the played stack. |
| min_len | Minimum number of cards required for a straight. |
| out_selection | Output array of bools; set to true for cards in the best straight, false otherwise. |
| ContainedHandTypes * get_contained_hands | ( | void | ) |
Get the contained hands within the selected hand.
| CardObject ** get_hand_array | ( | void | ) |
|
static |
Outputs the distribution of ranks and suits in the hand.
| ranks_out | output - updated such as ranks_out[rank] is the number of cards of rank in the hand. Must be of size NUM_RANKS. |
| suits_out | output - updated such as suits_out[suit] is the number of cards if suit in the hand Must be of size NUM_SUITS |
| enum HandState get_hand_state | ( | void | ) |
| int get_hand_top | ( | void | ) |
| enum HandType get_hand_type | ( | void | ) |
| void hand_change_sort | ( | bool | to_sort_by_suit | ) |
| void hand_deselect_all_cards | ( | void | ) |
| int hand_get_nb_selected_cards | ( | void | ) |
| int hand_nb_held_cards | ( | void | ) |
| void hand_select_card | ( | int | index | ) |
| void hand_set_nb_selected_cards | ( | int | new_selections | ) |
Set the current number of selected Cards.
| new_selections |
|
static |
| void reorder_card_sprites_layers | ( | void | ) |
| void select_paired_cards_in_hand | ( | CardObject ** | played, |
| int | top, | ||
| bool * | selection | ||
| ) |
This is used for the special case in "Four Fingers" where you can add a pair into a straight (e.g. AA234 should score all 5 cards)
| played | Array of pointers to CardObject representing played cards. |
| top | Index of the top of the played stack. |
| selection | In/Out array of bools; cards from a straight are already set to true, so we add to those the leftover ones that form a pair with an already selected card. |
| void set_hand_state | ( | enum | HandState | ) |
| void set_hand_top | ( | int | new_hand_top | ) |
Set the position in hand array of the last card obtained.
| new_hand_top |
|
inlinestatic |
| void sort_cards | ( | void | ) |
Sort the hand array according to the selected method to do that.
| void swap_cards_in_hand | ( | int | idx_a, |
| int | idx_b | ||
| ) |
|
static |