V1.6.0: targets and an attack bar in encounters
- One combatant at a time can be marked as the target with the Target button on its card. The DM can mark anyone at any time; a player can while their own character is on turn in a battle. - The target's card is outlined for everyone and names who is going for it. - While a target is marked the DM gets an attack bar above the list: who is attacking whom, the target's AC and HP, the attacker's weapons, spells or monster attack, and a box to apply damage or healing straight away. - The target is cleared when the turn or round moves on, when the encounter begins, ends or is reopened, or when the target is removed. - All packages at version 1.6.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1912,6 +1912,48 @@ describe('initiative', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('targets', () => {
|
||||
itIfDb('are picked by the DM or the player on turn, shown to all, and go when the turn does', async () => {
|
||||
const { dmAuth, playerAuth, campaign } = await setupCampaign('target');
|
||||
const c = `/campaigns/${campaign.id}`;
|
||||
const heroId = await buildCharacter(campaign.id, playerAuth, 'Archer');
|
||||
const goblin = (await request(app).post(`${c}/monsters/from-library`).set(dmAuth).send({ key: 'goblin' })).body.monster;
|
||||
const e = `/encounters/${(await request(app).post(`${c}/encounters`).set(dmAuth).send({ name: 'Ambush' })).body.encounter.id}`;
|
||||
const add = async (body) => (await request(app).post(`${e}/participants`).set(dmAuth).send(body)).body.participant;
|
||||
const hero = await add({ characterId: heroId, initiativeRoll: 20 });
|
||||
const first = await add({ monsterId: goblin.id, initiativeRoll: 10 });
|
||||
const second = await add({ monsterId: goblin.id, initiativeRoll: 1 });
|
||||
const target = (auth, participantId) => request(app).put(`${e}/target`).set(auth).send({ participantId });
|
||||
const seen = async (auth) => (await request(app).get(e).set(auth)).body.encounter.targetParticipantId;
|
||||
|
||||
// Before the battle only the DM can mark anyone.
|
||||
expect((await target(playerAuth, first.id)).status).toBe(403);
|
||||
expect((await target(dmAuth, first.id)).body.encounter.targetParticipantId).toBe(first.id);
|
||||
expect(await seen(playerAuth)).toBe(first.id);
|
||||
expect((await target(dmAuth, 'nobody')).status).toBe(400);
|
||||
|
||||
// Beginning the battle clears it and puts the hero on turn: now the player can.
|
||||
await request(app).patch(e).set(dmAuth).send({ status: 'ACTIVE' });
|
||||
expect(await seen(dmAuth)).toBeNull();
|
||||
expect((await target(playerAuth, second.id)).status).toBe(200);
|
||||
expect(await seen(dmAuth)).toBe(second.id);
|
||||
|
||||
// Removing the target clears it.
|
||||
await request(app).delete(`${e}/participants/${second.id}`).set(dmAuth);
|
||||
expect(await seen(dmAuth)).toBeNull();
|
||||
|
||||
// The turn passing clears it, and the player is no longer on turn.
|
||||
await target(playerAuth, first.id);
|
||||
await request(app).post(`${e}/next-turn`).set(dmAuth);
|
||||
expect(await seen(dmAuth)).toBeNull();
|
||||
expect((await target(playerAuth, first.id)).status).toBe(403);
|
||||
|
||||
// The goblin's turn: the DM marks the hero, and can clear it again.
|
||||
expect((await target(dmAuth, hero.id)).body.encounter.targetParticipantId).toBe(hero.id);
|
||||
expect((await target(dmAuth, null)).body.encounter.targetParticipantId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('number limits', () => {
|
||||
itIfDb('are enforced by the server, whatever a form sends', async () => {
|
||||
const { dmAuth, playerAuth, campaign } = await setupCampaign('limits');
|
||||
|
||||
Reference in New Issue
Block a user