V1.22.0: campaign settings for dice, scores, multiclassing, auto-rolls, XP and crits
- Settings grouped into Characters, Dice & rolls, Combat and Progression - Dice: digital, physical or both; a campaign's own choice applies to every character - Ability scores by 4d6, the standard array or point buy (27 points, 8 to 15) - Track XP can be turned off for milestone levelling: XP is hidden and not awarded - New settings saved ahead of their features: multiclassing, auto-rolled monster and NPC attacks, roll visibility, hidden monster rolls, HP on level up, crit rule - docs/CAMPAIGN_SETTINGS.md lists every setting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ import { CLASS_SPELLCASTING_ABILITY, CLASS_HIT_DIE, CLASS_SAVE_PROFICIENCIES } f
|
||||
import { ABILITY_GUIDE, CLASS_GUIDE, SKILL_GUIDE, SPECIES_GUIDE, SPECIES_SPEED, STEP_GUIDE, STEP_NAMES, hitDieToughness } from '../lib/guide';
|
||||
import { speciesIcon } from '../lib/speciesIcons';
|
||||
import { armorClass, hpMax, passivePerception, proficiencyBonus, saveBonus, spellAttackBonus, spellSaveDC } from '../lib/previewCalc';
|
||||
import type { Ability, BuildOptions, CharacterClass, DiceMode, NamedAbility, PickGroup, Picks, Species } from '../api/types';
|
||||
import type { Ability, BuildOptions, CharacterClass, DiceMode, NamedAbility, PickGroup, Picks, ScoreMethod, Species } from '../api/types';
|
||||
|
||||
interface SpeciesChoices {
|
||||
type: 'choice' | 'wildcard';
|
||||
@@ -21,9 +21,10 @@ interface ClassChoices {
|
||||
type: 'choice' | 'wildcard' | 'reroll';
|
||||
options: string[];
|
||||
}
|
||||
// A rolled score; the standard array and point buy come as scores alone, no dice.
|
||||
interface AbilityRoll {
|
||||
dice: number[];
|
||||
dropped: number;
|
||||
dropped: number | null;
|
||||
total: number;
|
||||
}
|
||||
interface BuildState {
|
||||
@@ -38,6 +39,7 @@ interface BuildState {
|
||||
motivationText?: string | null;
|
||||
abilityRolls?: AbilityRoll[];
|
||||
abilityAssignments?: Record<Ability, number>;
|
||||
pointBuy?: Record<Ability, number>;
|
||||
skillProficiencies?: { skill: string; proficient: boolean; expertise: boolean }[];
|
||||
motivationChoice?: number;
|
||||
talents?: string[];
|
||||
@@ -47,6 +49,10 @@ interface BuildState {
|
||||
}
|
||||
|
||||
const ABILITIES: Ability[] = ['STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA'];
|
||||
// Point buy, as the server checks it (game/buildFlow.js): every score starts
|
||||
// at 8, and raising it to 15 at most spends from a budget of 27.
|
||||
const POINT_BUY_BUDGET = 27;
|
||||
const POINT_BUY_COSTS: Record<number, number> = { 8: 0, 9: 1, 10: 2, 11: 3, 12: 4, 13: 5, 14: 7, 15: 9 };
|
||||
const HALF_ELF_ELIGIBLE: Ability[] = ['STR', 'DEX', 'CON', 'INT', 'WIS'];
|
||||
const ALL_SKILLS = Object.keys(SKILL_LABELS);
|
||||
// The six steps, in order, matching STEP_NAMES.
|
||||
@@ -179,7 +185,8 @@ export function CharacterBuilderPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const needsDiceModeChoice = stage === 'ROLLING_SPECIES' && !bs.speciesRoll && !diceModeConfirmed;
|
||||
// Only asked when the campaign leaves the dice to each character.
|
||||
const needsDiceModeChoice = character.diceModeChoosable && stage === 'ROLLING_SPECIES' && !bs.speciesRoll && !diceModeConfirmed;
|
||||
|
||||
// On its own step, the current pick is whatever was clicked, falling back to
|
||||
// what was chosen before (when the player has come back to change it).
|
||||
@@ -452,6 +459,8 @@ export function CharacterBuilderPage() {
|
||||
<AssignScoresStep
|
||||
bs={bs}
|
||||
diceMode={diceMode}
|
||||
method={campaignData?.campaign.abilityScoreMethod ?? 'ROLL_4D6'}
|
||||
onPointBuy={(pointBuy) => safeChoose({ pointBuy })}
|
||||
assignments={assignments}
|
||||
setAssignments={setAssignments}
|
||||
onRoll={safeRoll}
|
||||
@@ -948,6 +957,8 @@ function BuildProgress({ stage }: { stage: string }) {
|
||||
function AssignScoresStep({
|
||||
bs,
|
||||
diceMode,
|
||||
method,
|
||||
onPointBuy,
|
||||
assignments,
|
||||
setAssignments,
|
||||
onRoll,
|
||||
@@ -957,6 +968,8 @@ function AssignScoresStep({
|
||||
}: {
|
||||
bs: BuildState;
|
||||
diceMode: DiceMode;
|
||||
method: ScoreMethod;
|
||||
onPointBuy: (scores: Record<Ability, number>) => void;
|
||||
assignments: Partial<Record<Ability, number>>;
|
||||
setAssignments: (a: Partial<Record<Ability, number>>) => void;
|
||||
onRoll: (body?: { abilitySets?: number[][] }) => void;
|
||||
@@ -964,6 +977,21 @@ function AssignScoresStep({
|
||||
rolling: boolean;
|
||||
submitting: boolean;
|
||||
}) {
|
||||
if (method === 'POINT_BUY') {
|
||||
return <PointBuyStep bs={bs} onSubmit={onPointBuy} submitting={submitting} />;
|
||||
}
|
||||
if (!bs.abilityRolls && method === 'STANDARD_ARRAY') {
|
||||
return (
|
||||
<div className="card mt-md text-center">
|
||||
<div className="card-title">Step 4 — Ability Scores</div>
|
||||
<p className="step-intro">{STEP_GUIDE.SCORES}</p>
|
||||
<p>This campaign uses the standard array: the six scores 15, 14, 13, 12, 10 and 8, for you to place.</p>
|
||||
<button className="btn btn-primary" onClick={() => onRoll()} disabled={rolling}>
|
||||
Use the standard array
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (!bs.abilityRolls) {
|
||||
if (diceMode === 'PHYSICAL') {
|
||||
return <PhysicalAbilityRollForm onRoll={onRoll} rolling={rolling} />;
|
||||
@@ -1017,7 +1045,7 @@ function AssignScoresStep({
|
||||
<div className="flex-row flex-wrap gap-sm mt-sm">
|
||||
{bs.abilityRolls.map((r, i) => (
|
||||
<span key={i} className="badge" style={usedIndexes.has(i) ? { opacity: 0.4 } : { borderColor: 'var(--accent)' }}>
|
||||
{r.dice.join('+')} (drop {r.dropped}) = {r.total}
|
||||
{r.dice.length > 0 ? `${r.dice.join('+')} (drop ${r.dropped}) = ${r.total}` : r.total}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
@@ -1076,6 +1104,74 @@ function AssignScoresStep({
|
||||
);
|
||||
}
|
||||
|
||||
// Point buy: each ability starts at 8 and is raised with points from the
|
||||
// budget. The scores go straight to their abilities; nothing is rolled.
|
||||
function PointBuyStep({ bs, onSubmit, submitting }: { bs: BuildState; onSubmit: (scores: Record<Ability, number>) => void; submitting: boolean }) {
|
||||
const [scores, setScores] = useState<Record<Ability, number>>(() => {
|
||||
const bought = bs.pointBuy;
|
||||
return Object.fromEntries(ABILITIES.map((a) => [a, bought?.[a] ?? 8])) as Record<Ability, number>;
|
||||
});
|
||||
const spent = ABILITIES.reduce((sum, a) => sum + POINT_BUY_COSTS[scores[a]], 0);
|
||||
const left = POINT_BUY_BUDGET - spent;
|
||||
const species = bs.species ?? null;
|
||||
const keyAbilities = bs.characterClass ? CLASS_GUIDE[bs.characterClass].keyAbilities : [];
|
||||
const canRaise = (a: Ability) => scores[a] < 15 && POINT_BUY_COSTS[scores[a] + 1] - POINT_BUY_COSTS[scores[a]] <= left;
|
||||
|
||||
return (
|
||||
<div className="card mt-md">
|
||||
<div className="card-title">
|
||||
<span>Step 4 — Buy Ability Scores</span>
|
||||
<span className={`badge${left < 0 ? ' badge-hostile' : ''}`}>
|
||||
{left} of {POINT_BUY_BUDGET} points left
|
||||
</span>
|
||||
</div>
|
||||
<p className="step-intro">
|
||||
Every score starts at 8. Raising one costs a point a step up to 13, and two a step for 14 and 15. Spend up to {POINT_BUY_BUDGET}.
|
||||
</p>
|
||||
<div className="grid grid-cols-3 mt-md">
|
||||
{ABILITIES.map((ability) => {
|
||||
const bonus = speciesBonusFor(species, ability, bs.halfElfBonusAbilities || []);
|
||||
const final = scores[ability] + bonus;
|
||||
return (
|
||||
<div className={`stat-block${keyAbilities.includes(ability) ? ' is-key' : ''}`} key={ability}>
|
||||
<span className="stat-label">{ABILITY_LABELS[ability]}</span>
|
||||
<span className="stat-sub">{ABILITY_GUIDE[ability].short}</span>
|
||||
{keyAbilities.includes(ability) && <span className="key-marker">★ Key for your class</span>}
|
||||
<div className="flex-row gap-sm" style={{ justifyContent: 'center' }}>
|
||||
<button
|
||||
className="btn btn-sm"
|
||||
aria-label={`Lower ${ABILITY_LABELS[ability]}`}
|
||||
disabled={scores[ability] <= 8}
|
||||
onClick={() => setScores({ ...scores, [ability]: scores[ability] - 1 })}
|
||||
>
|
||||
−
|
||||
</button>
|
||||
<span className="stat-value">{scores[ability]}</span>
|
||||
<button
|
||||
className="btn btn-sm"
|
||||
aria-label={`Raise ${ABILITY_LABELS[ability]}`}
|
||||
disabled={!canRaise(ability)}
|
||||
onClick={() => setScores({ ...scores, [ability]: scores[ability] + 1 })}
|
||||
>
|
||||
+
|
||||
</button>
|
||||
</div>
|
||||
<span className="stat-sub">
|
||||
{scores[ability]} {bonus ? `+${bonus}` : ''} = {final} ({fmtMod(abilityModifier(final))})
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<StepFooter
|
||||
hint={left > 0 ? `You still have ${left} point${left === 1 ? '' : 's'} to spend (or keep them).` : 'All points spent. Press Next.'}
|
||||
disabled={left < 0 || submitting}
|
||||
onNext={() => onSubmit(scores)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function PhysicalAbilityRollForm({ onRoll, rolling }: { onRoll: (body?: { abilitySets?: number[][] }) => void; rolling: boolean }) {
|
||||
const [sets, setSets] = useState<string[][]>(Array.from({ length: 6 }, () => ['', '', '', '']));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user