feat: death-save display, stable-hour recovery, reroll-all initiative
- Player display: death-save pips for dying participants (3 successes / 3 failures), stable shows note without pips - stableRegainHours: 1d4 hours rolled on natural stabilization (3rd save success, manual stabilize, revive-to-stable); cleared on heal, damage-while-stable, inline HP edit, and death; undo/redo round-trips through all paths - Roster writeback: end-of-encounter sync writes stable hours to characters (stable -> hours, conscious -> null); character card badge shows hours; stable state carried into new encounters via buildCharacterParticipant; editor Cur HP > 0 clears - End-combat message corrected: states turn position and round reset while initiative values are kept - Reroll All Initiative: d20 + initMod for every participant in a single write, undoable, pre-combat or paused only; confirmation modal in UI, hidden during active combat - Add All (Roll Init) hoisted to Add Participants header row so it stays visible when the section is collapsed; header title remains the collapse toggle
This commit is contained in:
1 parent
8ecd31d570
commit
8d71f0ba4b
9 files changed
+664
-33
No files matched your search
@@ -0,0 +1,52 @@
|
||||
// Roster stable state: badge on character card, cleared when Current HP raised.
|
||||
|
||||
import { screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { renderApp, createCampaignViaUI, selectCampaignByName, MOCK_DB } from './testHelpers';
|
||||
|
||||
const campPath = id => `artifacts/ttrpg-initiative-tracker-default/public/data/campaigns/${id}`;
|
||||
|
||||
async function setupWithStableChar() {
|
||||
await renderApp();
|
||||
const id = await createCampaignViaUI('StableCamp');
|
||||
await selectCampaignByName('StableCamp');
|
||||
|
||||
// character form
|
||||
fireEvent.change(screen.getByLabelText('Name', { selector: '#characterName' }), { target: { value: 'Fallen Hero' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Add Character' }));
|
||||
await screen.findByText('Fallen Hero');
|
||||
|
||||
// writeback would have set these; seed directly
|
||||
const doc = MOCK_DB.get(campPath(id));
|
||||
doc.players = doc.players.map(p => p.name === 'Fallen Hero'
|
||||
? { ...p, defaultCurrentHp: 0, stableRegainHours: 3 }
|
||||
: p);
|
||||
MOCK_DB.set(campPath(id), doc);
|
||||
await screen.findByText(/Stable — regains 1 HP after 3 hours/);
|
||||
return id;
|
||||
}
|
||||
|
||||
describe('roster stable state', () => {
|
||||
test('character card shows stable badge with hours', async () => {
|
||||
await setupWithStableChar();
|
||||
expect(screen.getByText(/Stable — regains 1 HP after 3 hours/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('raising Current HP in editor clears stable state', async () => {
|
||||
const id = await setupWithStableChar();
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Edit character' }));
|
||||
const curHpInput = await screen.findByTitle('Default Current HP');
|
||||
expect(curHpInput).toHaveValue(0);
|
||||
fireEvent.change(curHpInput, { target: { value: '10' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Save character' }));
|
||||
|
||||
await waitFor(() => {
|
||||
const doc = MOCK_DB.get(campPath(id));
|
||||
const hero = doc.players.find(p => p.name === 'Fallen Hero');
|
||||
expect(hero.defaultCurrentHp).toBe(10);
|
||||
expect(hero.stableRegainHours).toBeNull();
|
||||
});
|
||||
await waitFor(() => expect(screen.queryByText(/Stable — regains/)).not.toBeInTheDocument());
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user