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

#include "flop.h"

pokeraction_t actionFlop() {
  return (pokeraction_t){
    .init = &actionFlopInit,
    .update = &actionFlopUpdate,
    .dispose = &actionFlopDispose
  };
}

void actionFlopInit(int32_t index, void *data) {
  uint8_t i, count;
  logText("Flop");
  
  // Look at the dealer

  // Do the flop
  // if(match->cardsFacing >= HOLDEM_DEALER_HAND) return;

  // Burn the card off the top
  GAME_STATE.deckSize -= 1;

  // Change count depending on facing
  count = GAME_STATE.cardsFacing == 0 ? 0x03 : 0x01;

  // Deal
  for(i = 0; i < count; i++) {
    cardDeal(GAME_STATE.deck, GAME_STATE.cards, GAME_STATE.deckSize, GAME_STATE.cardsFacing);
    GAME_STATE.deckSize -= 1;
    GAME_STATE.cardsFacing += 1;
  }

  // Next action
  pokerActionRemove(index);
}

void actionFlopUpdate(int32_t index, void *data) {

}

void actionFlopDispose(int32_t index, void *data) {
  pokerActionAdd(actionAi());
}