feat(01-02): add apply-attribute-boost dependency from Plan 01-01
Rule 3 deviation: Plan 01-01 (wave 0) work not yet merged into this
worktree base (096edbf). Plan 01-02 imports applyAttributeBoost and
AbilityAbbreviation from this module — required for types.ts and
recompute-derived-stats.ts to compile. Content matches 01-01 plan exactly,
so orchestrator merge will be clean.
- export type AbilityScore = number
- export type AbilityAbbreviation = 'STR'|'DEX'|'CON'|'INT'|'WIS'|'CHA'
- export function applyAttributeBoost(score) — PF2e boost-cap-at-18 (Pitfall #8)
- export function isValidBoostSet(targets) — exactly 4 distinct
This commit is contained in:
26
server/src/modules/leveling/lib/apply-attribute-boost.ts
Normal file
26
server/src/modules/leveling/lib/apply-attribute-boost.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user