#ifndef _HF_GAME_
#define _HF_GAME_

#include <stdbool.h>

typedef struct Game Game;

#include "card.h"
#include "field_multiplier.h"
#include "teyaku.h"
#include "dekiyaku.h"
#include "points.h"
#include "player.h"
#include "dialog.h"

typedef enum GameState {
  GAME_STATE_INITIALIZING,
  GAME_STATE_DEALING,
  GAME_STATE_CALCULATING_FIELD_MULTIPLIER,
  GAME_STATE_CALCULATING_TEYAKU,
  GAME_STATE_START_OF_TURN,
  GAME_STATE_CHECKING_FOR_CANCEL,
  GAME_STATE_CHOOSING_FROM_HAND,
  GAME_STATE_CHOOSING_TARGET,
  GAME_STATE_PLAYING_FROM_DECK,
  GAME_STATE_CHECKING_FOR_NEW_DEKIYAKU,
  GAME_STATE_SELECTING_DEKIYAKU_ACTION,
  GAME_STATE_CALCULATING_SCORES,
  GAME_STATE_CALCULATING_DEKIYAKU_SCORE,
} GameState;

struct Game {
  GameState state;
  bool should_close;
  Card cards[48];
  Texture2D cards_texture;
  Hand deck, field;
  FieldMultiplier *field_multiplier;
  Card *current_play_from_hand, *current_play_target;
  int kan_value;
  Player player, right, left;
  int temp_points;
  int turn_number;
  Dialog *dialog;
};

void initialize_game(Game *g);
void run_until_closing(Game *g);
void transfer_points(Game *g, int *to, int *from, int amount);
void transfer_kan(Game *g, int *to, int *from, int amount);

#endif
