/**
 * Pure function module — no NestJS, no Prisma, no I/O.
 * PF2e Boost Cap rule: +2 if score < 18, +1 if score >= 18 (Pitfall #8).
 * See: .planning/phases/01-level-up-pf2e-regelkonform/01-RESEARCH.md §Pattern 3
 */

export type AbilityScore = number;

export type AbilityAbbreviation = 'STR' | 'DEX' | 'CON' | 'INT' | 'WIS' | 'CHA';

/**
 * Applies a single PF2e attribute boost to a score.
 * - Score below 18 → +2
 * - Score at or above 18 → +1 (cap rule, prevents Pitfall #8)
 */
export function applyAttributeBoost(currentScore: AbilityScore): AbilityScore {
  return currentScore >= 18 ? currentScore + 1 : currentScore + 2;
}

/**
 * Validates a level-up boost set: must be exactly 4 distinct abilities.
 * PF2e: at boost levels (5/10/15/20), the player picks 4 different attributes.
 */
export function isValidBoostSet(targets: readonly string[]): boolean {
  return targets.length === 4 && new Set(targets).size === 4;
}
