import { CARDS_PER_COLOR } from "./types";

export const COLOR_NAMES = ["Red", "Blue", "Green", "Gold", "Violet"] as const;
export const EXPEDITION_NAMES = ["Volcano", "Ocean", "Jungle", "Desert", "Cavern"] as const;
export const COLOR_HEX = ["#b94737", "#3569a7", "#397b4e", "#b37d20", "#704487"] as const;
export const COLOR_GLYPHS = ["▲", "≋", "♧", "◆", "⬟"] as const;

export function cardColor(card: number): number {
  return Math.floor(card / CARDS_PER_COLOR);
}

export function cardSlot(card: number): number {
  return card % CARDS_PER_COLOR;
}

export function isHandshake(card: number): boolean {
  return cardSlot(card) < 3;
}

export function cardRank(card: number): number {
  return isHandshake(card) ? 0 : cardSlot(card) - 1;
}

export function cardValue(card: number): string {
  return isHandshake(card) ? "H" : String(cardRank(card));
}

export function cardName(card: number): string {
  return `${COLOR_NAMES[cardColor(card)]} ${cardValue(card)}`;
}
