From f1897501de4e0312d1e1ff93d4bb611acac60247 Mon Sep 17 00:00:00 2001 From: Alexander Zielonka Date: Mon, 27 Apr 2026 14:06:09 +0200 Subject: [PATCH] feat(01-02): implement skill-increase-cap (LVL-06) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../leveling/lib/skill-increase-cap.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 server/src/modules/leveling/lib/skill-increase-cap.ts 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; +}