30 lines
758 B
C
30 lines
758 B
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "deal.h"
|
|
|
|
void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
|
|
poker_t *poker;
|
|
poker = (poker_t *)action->data;
|
|
|
|
|
|
// Shuffle the deck
|
|
poker->state = POKER_STATE_DEALING;
|
|
cardShuffle(poker->dealer.deck, CARD_DECK_SIZE);
|
|
|
|
// Deal 2 card to each player
|
|
pokerDealerDealAll(&poker->dealer, poker->players, POKER_DEAL_CARD_EACH);
|
|
queueNext(queue);
|
|
}
|
|
|
|
queueaction_t * pokerActionDealAdd(queue_t *queue, poker_t *poker) {
|
|
queueaction_t *action;
|
|
action = queueAdd(queue);
|
|
action->data = (void *)poker;
|
|
action->onStart = &_pokerActionDealOnStart;
|
|
return action;
|
|
} |