feat(01-02): implement skill-increase-cap (LVL-06)
Task 2 GREEN phase. PF2e skill-increase cap rule: - UNTRAINED → TRAINED at any level - TRAINED → EXPERT requires L3+ - EXPERT → MASTER requires L7+ - MASTER → LEGENDARY requires L15+ Pure function, no NestJS, no Prisma. 9 tests passing.
This commit is contained in:
31
server/src/modules/leveling/lib/skill-increase-cap.ts
Normal file
31
server/src/modules/leveling/lib/skill-increase-cap.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { Proficiency } from './types';
|
||||
|
||||
/** Levels at which a skill-increase step occurs (PF2e CRB). */
|
||||
export const SKILL_INCREASE_LEVELS: readonly number[] = [3, 5, 7, 9, 11, 13, 15, 17, 19];
|
||||
|
||||
/**
|
||||
* Minimum character level required to advance a skill from `currentRank`.
|
||||
* UNTRAINED → TRAINED is unrestricted (any level >= 1 with a skill-increase step).
|
||||
* LEGENDARY is `null` because it is the maximum rank — no further increases possible.
|
||||
*/
|
||||
const SKILL_RANK_LEVEL_REQUIREMENTS: Record<Proficiency, number | null> = {
|
||||
UNTRAINED: 1, // → TRAINED
|
||||
TRAINED: 3, // → EXPERT (PF2e CRB)
|
||||
EXPERT: 7, // → MASTER
|
||||
MASTER: 15, // → LEGENDARY
|
||||
LEGENDARY: null, // already maxed
|
||||
};
|
||||
|
||||
/**
|
||||
* PF2e skill-increase cap rule (LVL-06).
|
||||
* Returns true if a character at `characterLevel` may advance a skill that is
|
||||
* currently at `currentRank` to the next rank.
|
||||
*/
|
||||
export function canIncreaseSkill(
|
||||
currentRank: Proficiency,
|
||||
characterLevel: number,
|
||||
): boolean {
|
||||
const required = SKILL_RANK_LEVEL_REQUIREMENTS[currentRank];
|
||||
if (required === null) return false;
|
||||
return characterLevel >= required;
|
||||
}
|
||||
Reference in New Issue
Block a user