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

#include "winner.h"

void _pokerGameActionWinnerOnStart(
  queue_t *queue, queueaction_t *action, uint8_t i
) {
  pokerdiscussiondata_t discussion;
  pokergame_t *game = (pokergame_t *)action->data;

  // Calculate the winners
  // TODO: Calculate Winners
  // pokerWinnerCalculate(
  //   &game->poker.winner,
  //   &game->poker.dealer,
  //   game->poker.players
  // );

  // Action
  // pokerGameWin(&game->poker);

  // Say stuff
  discussion.reason = POKER_DISCUSSION_REASON_BETTING_DONE;
  discussion.poker = game;
  pokerDiscussionQueue(&discussion);
  
  // Begin next round.
  pokerGameActionRoundAdd(game);
  queueNext(queue);
}

queueaction_t * pokerGameActionWinnerAdd(pokergame_t *game) {
  queueaction_t *action = pokerGameActionAdd(game);
  action->onStart = &_pokerGameActionWinnerOnStart;
  return action;
}