diff --git a/server/src/modules/leveling/lib/skill-increase-cap.ts b/server/src/modules/leveling/lib/skill-increase-cap.ts new file mode 100644 index 0000000..b8c0fa3 --- /dev/null +++ b/server/src/modules/leveling/lib/skill-increase-cap.ts @@ -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 = { + 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; +}