import { EXPEDITION_NAMES, cardColor, cardName } from "./cards";
import { currentHandSorted, decodeAction } from "./engine";
import { DRAW_DECK, PLAY, type GameState } from "./types";

/** Human-readable move, e.g. "Play Red 7 · draw from the Ocean discard". */
export function describeAction(state: GameState, action: number): string {
  const { handSlot, placeType, drawSource } = decodeAction(action);
  const card = currentHandSorted(state)[handSlot];
  if (card === undefined) return "—";
  const place = placeType === PLAY
    ? `Play ${cardName(card)} on ${EXPEDITION_NAMES[cardColor(card)]}`
    : `Discard ${cardName(card)}`;
  const draw = drawSource === DRAW_DECK
    ? "draw from the deck"
    : `draw the ${EXPEDITION_NAMES[drawSource - 1]} discard`;
  return `${place} · ${draw}`;
}
