#ifndef _HF_CARD_
#define _HF_CARD_

#include <stdbool.h>
#include <raylib.h>

#include "move.h"

typedef struct Card Card;
typedef struct Hand Hand;
#define CARD_WIDTH 73
#define CARD_HEIGHT 120
#define CARD_BORDER 5

#define CRANE_INDEX 0
#define CURTAIN_INDEX 8
#define MOON_INDEX 28
#define RAINY_MAN_INDEX 40
#define PHOENIX_INDEX 44

typedef enum CardType {
  CHAFF,
  RIBBON,
  ANIMAL,
  BRIGHT,
} CardType;

typedef enum RibbonType {
  RIBBON_NONE,
  RIBBON_PLAIN,
  RIBBON_BLUE,
  RIBBON_POETRY,
} RibbonType;

typedef enum Month {
  JANUARY,
  FEBRUARY,
  MARCH,
  APRIL,
  MAY,
  JUNE,
  JULY,
  AUGUST,
  SEPTEMBER,
  OCTOBER,
  NOVEMBER,
  DECEMBER
} Month;

struct Card {
  int index;
  CardType type;
  RibbonType ribbon_type;
  Month month;
  Vector2 position;
  bool selected;
  bool visible;
  Move move;
  int order;
};

typedef enum HandDisplayType {
  HAND_DISPLAY_ROW,
  HAND_DISPLAY_FIELD,
  HAND_DISPLAY_DECK,
  HAND_DISPLAY_SCORED,
} HandDisplayType;

struct Hand {
  Card *cards[48];
  int count;
  Vector2 position;
  HandDisplayType display_type;
};

void draw_card(Card *c, Texture2D *cards_texture);
bool point_within_card(Card *c, Vector2 v);
void shuffle_hand(Hand *h);
void deal(Hand *from, Hand *to, int count, bool up);
void remove_from_hand(Hand *h, Card *c);
void add_to_hand(Hand *h, Card *c);
bool card_done_moving(Card *c);
Rectangle next_card_position(Hand *h);

#endif
