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

#pragma once
#include "../../libs.h"
#include "../../vn/conversation/vnconversation.h"
#include "../../vn/conversation/talk.h"
#include "actions/look.h"

/** Maximum number of messages that the discussion buffer can hold */
#define POKER_DISCUSSION_MESSAGE_COUNT_MAX 32

/** Why the discussion is happening */
#define POKER_DISCUSSION_REASON_TEST 0x00
#define POKER_DISCUSSION_REASON_MATCH_START 0x01
#define POKER_DISCUSSION_REASON_ROUND_START 0x02
#define POKER_DISCUSSION_REASON_BLINDS_TAKEN 0x03
#define POKER_DISCUSSION_REASON_PLAYER_FOLDING 0x04
#define POKER_DISCUSSION_REASON_PLAYER_CHECKING 0x05
#define POKER_DISCUSSION_REASON_PLAYER_CALLING 0x06
#define POKER_DISCUSSION_REASON_PLAYER_RAISING 0x07
#define POKER_DISCUSSION_REASON_PLAYER_ALL_IN 0x08
#define POKER_DISCUSSION_REASON_FLOP 0x09
#define POKER_DISCUSSION_REASON_DEAL 0x0A
#define POKER_DISCUSSION_REASON_BETTING_DONE 0x0B

typedef struct {
  pokergame_t *poker;
  uint8_t reason;
  uint8_t playerCause;
  uint8_t playerTarget;
} pokerdiscussiondata_t;

typedef struct {
  char *messages[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
  uint8_t players[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
  uint8_t emotions[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
  uint8_t count;
} pokerdiscussion_t;

/**
 * Retreives the discussion based on some discussion data.
 * @param disc The discussion data to buffer into.
 * @param data The discussion data.
 */
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);

/**
 * Fetch the discussion type from a turn type.
 * 
 * @param winningType Winning type 
 * @return Relevant discussion type.
 */
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType);

/**
 * Queue a discussion data result onto the conversation stack.
 * 
 * @param data The discussion data.
 */
void pokerDiscussionQueue(pokerdiscussiondata_t *data);