04fa90e580
The bare name/class/level form left new characters as shells (1 HP, all-10
abilities, no proficiencies). Now creation and level-up are guided and auto-populate.
- Hand-authored progression tables (no SRD class/slot data exists on disk):
src/lib/rules/{dnd5e,pf2e}/progression.ts — core classes' hit die/HP, key
abilities, save & perception proficiencies, trained-skill counts, caster type;
5e full/half/pact spell-slot tables, pf2e slot approximation; ASI/boost/skill
schedules.
- src/lib/rules/progression.ts: getClassDefs/getClassDef, classSkillChoices/Count,
buildCharacter() (HP from hit die + CON over levels, trained saves/skills, spell
slots + ability), planLevelUp() (HP gain, new slots, ASI/boost/skill choices),
applyIncreases/bumpRank. Pure + 12 unit tests.
- Multi-step CreationWizard (Basics → Abilities → Skills → Review) replaces the
old form; pulls PF2e ancestry HP/speed from the bestiary; review previews HP/AC/
saves/skills/slots; lands on a ready-to-play sheet.
- LevelUpModal reworked into a guided wizard: auto HP + spell slots, presents the
level's actual choices (5e ASI/feat, pf2e ability boosts + skill increase) and
applies them; keeps the strategic build-route advisor.
e2e helper drives the wizard; updated 7 specs to the new flow; new character-wizard
spec asserts a complete level-3 Wizard (HP 17, slots 4xL1 2xL2).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
52 lines
2.3 KiB
TypeScript
52 lines
2.3 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
import { createCharacter } from './helpers';
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await page.goto('/');
|
|
await page.evaluate(async () => {
|
|
indexedDB.deleteDatabase('ttrpg-manager');
|
|
localStorage.clear();
|
|
});
|
|
await page.reload();
|
|
});
|
|
|
|
test('character depth: inventory, spellcasting, attacks, resources + rest', async ({ page }) => {
|
|
// Campaign + character
|
|
await page.getByRole('button', { name: '+ New campaign' }).first().click();
|
|
await page.locator('input[data-autofocus]').fill('Phandelver');
|
|
await page.getByRole('button', { name: 'Create' }).click();
|
|
await page.getByRole('link', { name: 'Characters' }).click();
|
|
await createCharacter(page, 'Gandalf');
|
|
|
|
// Set INT high so spell DC is computable
|
|
await page.getByLabel('INT score').fill('18');
|
|
|
|
// Inventory — add an item via Enter
|
|
await page.getByPlaceholder('Longsword', { exact: true }).fill('Staff of Power');
|
|
await page.getByPlaceholder('Longsword', { exact: true }).press('Enter');
|
|
await expect(page.locator('input[aria-label="Item name"]')).toHaveValue('Staff of Power');
|
|
|
|
// Spellcasting — choose ability, expect a derived DC to appear
|
|
await page.getByLabel('Casting ability').selectOption('int');
|
|
await expect(page.getByText('Spell DC')).toBeVisible();
|
|
|
|
// Attacks — add one, expect a computed to-hit
|
|
await page.getByPlaceholder('Longsword, Shortbow…').fill('Quarterstaff');
|
|
await page.getByPlaceholder('Longsword, Shortbow…').press('Enter');
|
|
await expect(page.getByText('to hit')).toBeVisible();
|
|
|
|
// Resources — add one, spend it, long rest restores it
|
|
await page.getByPlaceholder('Ki Points, Rage, Focus…').fill('Sorcery Points');
|
|
await page.getByPlaceholder('Ki Points, Rage, Focus…').press('Enter');
|
|
// Only one resource exists, so the controls are unambiguous.
|
|
await page.getByRole('button', { name: 'Spend' }).click();
|
|
await expect(page.getByText('0/1')).toBeVisible();
|
|
await page.getByRole('button', { name: 'Long Rest' }).click();
|
|
await expect(page.getByText('1/1')).toBeVisible();
|
|
|
|
// Reload — persistence survived (autosave). Wait for the debounce + beforeunload flush.
|
|
await page.waitForTimeout(500);
|
|
await page.reload();
|
|
await expect(page.locator('input[aria-label="Item name"]')).toHaveValue('Staff of Power');
|
|
});
|