V1.0.1: Aldenfell campaign seed, content library, party overview
- Seed now resets the database and seeds the Aldenfell campaign from the campaign book: admin DM user, default weapons, locations, bestiary, pre-built encounters, and DM/shared notes - Default weapon/spell/monster library, character profile fields, locations and dice mode (new migration) - Party overview page, pagination, info tips, build preview calc - Remove stale demo-login hint; notes preserve line breaks Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import type { Ability } from '../api/types';
|
||||
|
||||
// Mirrors the pure formulas in backend/src/game/calculations.js — used only
|
||||
// to render a live "what does this change" preview while building a
|
||||
// character. Display-only: the server recomputes authoritatively at
|
||||
// finalize, so this duplication is never gameplay-deciding. Keep in sync by
|
||||
// hand if the backend formulas change.
|
||||
|
||||
export function abilityModifier(score: number): number {
|
||||
return Math.floor((score - 10) / 2);
|
||||
}
|
||||
|
||||
export function proficiencyBonus(level: number): number {
|
||||
return 2 + Math.floor((level - 1) / 4);
|
||||
}
|
||||
|
||||
export function armorClass(dexMod: number, armorBonus = 0): number {
|
||||
return 10 + dexMod + armorBonus;
|
||||
}
|
||||
|
||||
// Level 1 always uses the maximum possible Hit Die roll; every level after
|
||||
// uses the fixed "average" value (floor(hitDieSize / 2) + 1).
|
||||
export function hpMax(level: number, hitDieSize: number, conMod: number): number {
|
||||
const base = hitDieSize + conMod;
|
||||
if (level <= 1) return base;
|
||||
const perLevelAverage = Math.floor(hitDieSize / 2) + 1;
|
||||
return base + (level - 1) * (perLevelAverage + conMod);
|
||||
}
|
||||
|
||||
export function saveBonus(abilityMod: number, proficient: boolean, profBonus: number): number {
|
||||
return abilityMod + (proficient ? profBonus : 0);
|
||||
}
|
||||
|
||||
export function skillBonus(abilityMod: number, proficient: boolean, profBonus: number, expertise = false): number {
|
||||
if (!proficient) return abilityMod;
|
||||
return abilityMod + profBonus * (expertise ? 2 : 1);
|
||||
}
|
||||
|
||||
export function passivePerception(perceptionSkillBonus: number): number {
|
||||
return 10 + perceptionSkillBonus;
|
||||
}
|
||||
|
||||
export function spellSaveDC(profBonus: number, spellAbilityMod: number): number {
|
||||
return 8 + profBonus + spellAbilityMod;
|
||||
}
|
||||
|
||||
export function spellAttackBonus(profBonus: number, spellAbilityMod: number): number {
|
||||
return profBonus + spellAbilityMod;
|
||||
}
|
||||
|
||||
export function fmtMod(n: number): string {
|
||||
return n >= 0 ? `+${n}` : `${n}`;
|
||||
}
|
||||
|
||||
export interface PreviewAbilities {
|
||||
STR: number;
|
||||
DEX: number;
|
||||
CON: number;
|
||||
INT: number;
|
||||
WIS: number;
|
||||
CHA: number;
|
||||
}
|
||||
|
||||
export const ABILITY_ORDER: Ability[] = ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA'];
|
||||
Reference in New Issue
Block a user