import type { WordBank, TargetWord } from '@wordle/shared';

/**
 * Check whether a guess is in the word bank's guessable list.
 */
export function isValidGuess(wordBank: WordBank, guess: string): boolean {
  if (guess.length !== 5) return false;
  return wordBank.guessable.includes(guess.toLowerCase());
}

/**
 * Look up a target word by ID. Returns undefined if not found.
 */
export function getTargetWord(
  wordBank: WordBank,
  wordId: number
): TargetWord | undefined {
  return wordBank.targets.find((t) => t.id === wordId);
}
