Rework backend #1
@@ -26,6 +26,10 @@
|
||||
- Future NEXT_TURN continues from jumped position.
|
||||
- UI button: "Make This Turn"
|
||||
- Backend action: new endpoint or via generic doc patch.
|
||||
- RED test: `shared/tests/turn.jump.test.js` (3 tests, 2 RED).
|
||||
- jump sets currentTurn, future nextTurn continues
|
||||
- jump to first stays same round
|
||||
- jump invalid throws (green via TypeError)
|
||||
|
||||
## Confirmed bugs (tests written, NOT fixed)
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// JUMP_TURN_TO feature: DM clicks participant → turn jumps → future NEXT_TURN
|
||||
// continues from jumped position. Missing feature, not bug.
|
||||
// Test asserts desired behavior = RED (function doesn't exist).
|
||||
|
||||
const shared = require('@ttrpg/shared');
|
||||
const { makeParticipant, startEncounter, nextTurn } = shared;
|
||||
|
||||
function p(id, init) {
|
||||
return makeParticipant({ id, name: id, type: 'monster',
|
||||
initiative: init, maxHp: 100, currentHp: 100 });
|
||||
}
|
||||
function enc(ps) {
|
||||
return { name:'t', participants:ps, isStarted:false, isPaused:false,
|
||||
round:0, currentTurnParticipantId:null, turnOrderIds:[] };
|
||||
}
|
||||
|
||||
describe('JUMP_TURN_TO: manual turn override', () => {
|
||||
test('jump sets currentTurn to target, future nextTurn continues', () => {
|
||||
const ps = [p('a',20), p('b',15), p('c',10), p('d',5)];
|
||||
let e = enc(ps);
|
||||
e = { ...e, ...startEncounter(e).patch };
|
||||
// current=a
|
||||
e = { ...e, ...shared.jumpTurnTo(e, 'c').patch };
|
||||
expect(e.currentTurnParticipantId).toBe('c');
|
||||
// next turn continues from c → d
|
||||
e = { ...e, ...nextTurn(e).patch };
|
||||
expect(e.currentTurnParticipantId).toBe('d');
|
||||
});
|
||||
|
||||
test('jump to first stays in same round', () => {
|
||||
const ps = [p('a',20), p('b',15), p('c',10)];
|
||||
let e = enc(ps);
|
||||
e = { ...e, ...startEncounter(e).patch };
|
||||
e = { ...e, ...nextTurn(e).patch }; // b
|
||||
e = { ...e, ...shared.jumpTurnTo(e, 'a').patch };
|
||||
expect(e.round).toBe(1);
|
||||
expect(e.currentTurnParticipantId).toBe('a');
|
||||
});
|
||||
|
||||
test('jump to invalid id throws', () => {
|
||||
const ps = [p('a',20), p('b',15)];
|
||||
let e = enc(ps);
|
||||
e = { ...e, ...startEncounter(e).patch };
|
||||
expect(() => shared.jumpTurnTo(e, 'zzz')).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user