feat(01-01): implement applyAttributeBoost and isValidBoostSet pure functions

- applyAttributeBoost: PF2e boost-cap-at-18 rule (Pitfall #8 mitigation)
  - Returns score + 2 when current < 18
  - Returns score + 1 when current >= 18
- isValidBoostSet: validates exactly 4 distinct abilities for boost levels
- Pure-function module (no NestJS, no Prisma, no I/O imports)
- TypeScript strict, named exports only
- 9/9 tests pass — proves Jest infrastructure works on src/modules/**/*.spec.ts
This commit is contained in:
2026-04-27 14:30:02 +02:00
parent 1e17225fa2
commit 65fcebdbdb

View File

@@ -0,0 +1,26 @@
/**
* 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;
}