#ifndef GAME_H
#define GAME_H
#include "card.h"
#include "player.h"
/**
* @brief ゲーム構造体
*
* デッキ、ディーラー、プレイヤー、ゲームの進行状況など
* ゲームに関連する全ての情報を保持する中心的な構造体。
*/
typedef struct
{
Card deck[52]; /**< トランプのデッキ */
int deckIndex; /**< 現在のデッキの位置 */
Player dealer; /**< ディーラーの情報 */
Player *players; /**< プレイヤー(人間とボット)の配列 */
int playerCount; /**< 全プレイヤー数 */
} Game;
/**
* @brief プレイヤーの初期化
*
* 人間プレイヤーとボットプレイヤーを初期チップ数で設定する。
*
* @param game ゲーム状態
* @param initChips 初期チップ数
* @param playerCount 人間プレイヤー数
* @param botCount ボットプレイヤー数
*/
void initPlayers(Game *game, const int initChips, const int playerCount, const int botCount);
/**
* @brief 新しいゲームラウンドの初期化
*
* デッキをリセットしてシャッフルし、全ての手札とベットをクリアする。
*
* @param game ゲーム状態
*/
void initGame(Game *game);
/**
* @brief カードを引く
*
* デッキから次のカードを取り出し、デッキの位置を進める。
*
* @param game ゲーム状態
* @return Card 引いたカード
*/
Card drawCard(Game *game);
/**
* @brief タイトル画面の表示
*
* "BlackJack"のタイトルを表示する。
*/
void displayTitle();
/**
* @brief ゲーム画面の表示
*
* ディーラーのカード、プレイヤーのカード、賭け金など
* 現在のゲーム状態を表示する。
*
* @param game ゲーム状態
* @param init 真の場合、ディーラーのホールカードを隠す
*/
void displayBoard(const Game *game, const int init);
/**
* @brief ゲーム結果の表示
*
* 勝敗を含むゲームの最終状態を表示する。
*
* @param game ゲーム状態
*/
void displayStatus(const Game *game);
/**
* @brief プレイヤーの行動を表示
*
* プレイヤーの現在の行動(ヒット/スタンド等)を表示する。
*
* @param game ゲーム状態
* @param playerIndex 現在のプレイヤーの番号
* @param action 行動(H:ヒット/S:スタンド/D:ダブル/R:サレンダー/P:スプリット)
* @param split スプリットハンドの行動かどうか
*/
void displayAction(const Game *game, const int playerIndex, char action, int split);
/**
* @brief ベット結果の処理
*
* プレイヤーのメインハンドの勝敗を計算し、チップを精算する。
*
* @param game ゲーム状態
* @param player 対象プレイヤー
* @param bjRate ブラックジャック時の配当倍率(通常1.5)
*/
void processBet(Game *game, Player *player, const double bjRate);
/**
* @brief スプリットハンドのベット結果処理
*
* プレイヤーのスプリットハンドの勝敗を計算し、チップを精算する。
*
* @param game ゲーム状態
* @param player 対象プレイヤー
* @param bjRate ブラックジャック時の配当倍率(通常1.5)
*/
void processSplitBet(Game *game, Player *player, const double bjRate);
/**
* @brief プレイヤーの行動を処理
*
* プレイヤーの行動(ヒット/スタンド/ダブル/スプリット/サレンダー)を実行する。
*
* @param game ゲーム状態
* @param playerIndex プレイヤーの番号
* @param split スプリットハンドの行動かどうか
* @param action 実行する行動(H/S/D/R/P)
* @return int ターン終了なら1、続行可能なら0
*/
int processAction(Game *game, const int playerIndex, const int split, const char action);
#endif