feat: add encounter roster visibility and kill actions
- persist independent Hide Disabled and Hide Dead encounter controls - keep dead PCs exempt from Hide Dead while allowing Hide Disabled to hide any inactive participant - add confirmed Kill action that sets zero HP, dead, and inactive without deleting - add undoable Heal Full action above Revive - fix random initiative reroll test flake
This commit is contained in:
1 parent
0e7bc7c099
commit
15347bfdc8
5 files changed
+300
-27
No files matched your search
@@ -1,9 +1,9 @@
|
||||
// Generic (non-5e) ruleset: no death saves, negative HP allowed, down status.
|
||||
const shared = require('@ttrpg/shared');
|
||||
const { mockCtx } = require('./_helpers');
|
||||
const { mockCtx, undoLast } = require('./_helpers');
|
||||
const {
|
||||
buildCharacterParticipant, buildMonsterParticipant,
|
||||
startEncounter, applyHpChange, deathSave, markDead, reviveParticipant,
|
||||
startEncounter, applyHpChange, deathSave, markDead, reviveParticipant, healFullParticipant,
|
||||
} = shared;
|
||||
|
||||
function char(id, hp = 100) {
|
||||
@@ -121,25 +121,48 @@ describe('generic ruleset', () => {
|
||||
expect(p.isActive).toBe(true);
|
||||
});
|
||||
|
||||
test('markDead sets status dead (character, stays active)', async () => {
|
||||
test('markDead kills and disables character', async () => {
|
||||
const { ctx } = mockCtx();
|
||||
let e = enc([char('a', 10)]);
|
||||
let e = enc([{ ...char('a', 10), tempHp: 4, deathSaveSuccesses: 2, deathSaveFailures: 1 }]);
|
||||
e = await startEncounter(e, ctx);
|
||||
e = await applyHpChange(e, 'a', 'damage', 10, ctx); // down
|
||||
const newEnc = await markDead(e, 'a', ctx);
|
||||
const p = newEnc.participants.find(x => x.id === 'a');
|
||||
expect(p.status).toBe('dead');
|
||||
expect(p.isActive).toBe(true);
|
||||
expect(p).toMatchObject({
|
||||
currentHp: 0, tempHp: 0, status: 'dead', isActive: false,
|
||||
deathSaveSuccesses: 0, deathSaveFailures: 0, stableRegainHours: null,
|
||||
});
|
||||
|
||||
const undone = await undoLast(ctx, newEnc);
|
||||
expect(undone.participants.find(x => x.id === 'a')).toMatchObject({
|
||||
currentHp: 10, tempHp: 4, status: 'conscious', isActive: true,
|
||||
deathSaveSuccesses: 2, deathSaveFailures: 1,
|
||||
});
|
||||
});
|
||||
|
||||
test('markDead on monster = dead + inactive', async () => {
|
||||
test('healFullParticipant restores dead participant to full, active, conscious; undo restores death', async () => {
|
||||
const { ctx } = mockCtx();
|
||||
let e = enc([{ ...char('a', 20), currentHp: 0, status: 'dead', isActive: false, deathSaveSuccesses: 2, deathSaveFailures: 1, conditions: ['unconscious'], stableRegainHours: 3 }]);
|
||||
const healed = await healFullParticipant(e, 'a', ctx);
|
||||
expect(healed.participants[0]).toMatchObject({
|
||||
currentHp: 20, status: 'conscious', isActive: true,
|
||||
deathSaveSuccesses: 0, deathSaveFailures: 0, stableRegainHours: null,
|
||||
});
|
||||
expect(healed.participants[0].conditions).not.toContain('unconscious');
|
||||
|
||||
const undone = await undoLast(ctx, healed);
|
||||
expect(undone.participants[0]).toMatchObject({ currentHp: 0, status: 'dead', isActive: false, stableRegainHours: 3 });
|
||||
expect(undone.participants[0].conditions).toContain('unconscious');
|
||||
});
|
||||
|
||||
test('markDead on monster = 0 HP + dead + inactive', async () => {
|
||||
const { ctx } = mockCtx();
|
||||
let e = enc([mon('m', 10)]);
|
||||
e = await startEncounter(e, ctx);
|
||||
e = await applyHpChange(e, 'm', 'damage', 5, ctx); // down (5hp)
|
||||
e = await applyHpChange(e, 'm', 'damage', 5, ctx); // 5 HP remain
|
||||
const newEnc = await markDead(e, e.participants[0].id, ctx);
|
||||
const p = newEnc.participants[0];
|
||||
expect(p.status).toBe('dead');
|
||||
expect(p.currentHp).toBe(0);
|
||||
expect(p.isActive).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user