46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/**
|
|
* 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 "../util/array.h"
|
|
|
|
/**
|
|
* Returns the suit of a given card.
|
|
* @param card to get the suit for.
|
|
* @returns The suit.
|
|
*/
|
|
#define cardGetSuit(card) (card / CARD_COUNT_PER_SUIT)
|
|
|
|
/**
|
|
* Returns the number of a given card.
|
|
* @param card The card to get the number for.
|
|
* @returns The card number.
|
|
*/
|
|
#define cardGetNumber(card) (card % CARD_COUNT_PER_SUIT)
|
|
|
|
/**
|
|
* Deals a card from an array source to an array destination. Pointers to array
|
|
* lengths will be updated.
|
|
*
|
|
* @param source Array source.
|
|
* @param sourceSize Pointer to where the count of cards is being stored.
|
|
* @param dest Array destination.
|
|
* @param destSize Pointer to the size of the destination array.
|
|
*/
|
|
void cardDeal(card_t *source, uint8_t *sourceSize, card_t *dest,
|
|
uint8_t *destSize
|
|
);
|
|
|
|
/**
|
|
* Sort a hand of cards.
|
|
*
|
|
* @param cards Hand of cards to sort.
|
|
* @param length Length of the array of cards.
|
|
*/
|
|
void cardHandSort(card_t *cards, uint8_t length);
|
|
|
|
int32_t _cardSorter(void *left, void *right); |