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

#include "start.h"

pokeraction_t actionStart() {
  pokeraction_t action = {
    .init = &actionStartInit,
    .update = &actionStartUpdate,
    .dispose = &actionStartDispose
  };

  return action;
}

void actionStartInit(int32_t index, void *data) {
  uint8_t i;
  pokerplayer_t *player;
  logText("Holdem Starting");

  // Prepare the match
  GAME_STATE.blindBig = 0;
  GAME_STATE.blindSmall = 0;
  GAME_STATE.pot = 0;

  // Reset the players
  for(i = 0; i < POKER_PLAYER_COUNT; i++) {
    player = GAME_STATE.players + i;
    player->state = 0x00;
    player->chips = 0;
  }

  pokerActionRemove(index);
}

void actionStartUpdate(int32_t index, void *data) {
}

void actionStartDispose(int32_t index, void *data) {
  // Begin the first round
  pokerActionAdd(actionRound());
}