feat(api): report monster guard and enrage state in the combat DTO
This commit is contained in:
@@ -343,6 +343,8 @@ describe('CombatService', () => {
|
|||||||
currentHp: 45,
|
currentHp: 45,
|
||||||
artworkPath: '/images/monsters/ash-rat.png',
|
artworkPath: '/images/monsters/ash-rat.png',
|
||||||
pendingIntent: null,
|
pendingIntent: null,
|
||||||
|
guardRemainingRounds: null,
|
||||||
|
enraged: false,
|
||||||
});
|
});
|
||||||
expect(combat.events).toEqual([]);
|
expect(combat.events).toEqual([]);
|
||||||
expect(dataSource.state.combats).toHaveLength(1);
|
expect(dataSource.state.combats).toHaveLength(1);
|
||||||
@@ -818,6 +820,34 @@ describe('CombatService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('getCombat', () => {
|
describe('getCombat', () => {
|
||||||
|
it('reports an active guard and an enraged monster to the client', async () => {
|
||||||
|
const state = createState();
|
||||||
|
const { service, dataSource } = createService({ state });
|
||||||
|
const started = await service.startCombat(CHARACTER_ID, ENCOUNTER_ID);
|
||||||
|
|
||||||
|
dataSource.state.combats[0].monsterState = {
|
||||||
|
...dataSource.state.combats[0].monsterState,
|
||||||
|
activeGuard: { remainingRounds: 2, armorBonus: 10 },
|
||||||
|
enraged: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const dto = await service.getCombat(CHARACTER_ID, started.id);
|
||||||
|
|
||||||
|
expect(dto.monster.guardRemainingRounds).toBe(2);
|
||||||
|
expect(dto.monster.enraged).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports no guard when the monster is not covering', async () => {
|
||||||
|
const state = createState();
|
||||||
|
const { service, dataSource } = createService({ state });
|
||||||
|
const started = await service.startCombat(CHARACTER_ID, ENCOUNTER_ID);
|
||||||
|
|
||||||
|
const dto = await service.getCombat(CHARACTER_ID, started.id);
|
||||||
|
|
||||||
|
expect(dto.monster.guardRemainingRounds).toBeNull();
|
||||||
|
expect(dto.monster.enraged).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('returns the persisted state and ordered events after a refresh', async () => {
|
it('returns the persisted state and ordered events after a refresh', async () => {
|
||||||
const context = createService();
|
const context = createService();
|
||||||
const started = await context.service.startCombat(
|
const started = await context.service.startCombat(
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ export interface CombatMonsterDto {
|
|||||||
currentHp: number;
|
currentHp: number;
|
||||||
artworkPath: string;
|
artworkPath: string;
|
||||||
pendingIntent: CombatIntent | null;
|
pendingIntent: CombatIntent | null;
|
||||||
|
/** Rounds the monster's raised guard still covers, or null when open. */
|
||||||
|
guardRemainingRounds: number | null;
|
||||||
|
enraged: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CombatEventDto {
|
export interface CombatEventDto {
|
||||||
@@ -459,6 +462,9 @@ export class CombatService {
|
|||||||
currentHp: combat.monsterCurrentHp,
|
currentHp: combat.monsterCurrentHp,
|
||||||
artworkPath: monster.artworkPath,
|
artworkPath: monster.artworkPath,
|
||||||
pendingIntent: combat.monsterState.pendingAction ?? null,
|
pendingIntent: combat.monsterState.pendingAction ?? null,
|
||||||
|
guardRemainingRounds:
|
||||||
|
combat.monsterState.activeGuard?.remainingRounds ?? null,
|
||||||
|
enraged: combat.monsterState.enraged ?? false,
|
||||||
},
|
},
|
||||||
events: events.map((event) => ({
|
events: events.map((event) => ({
|
||||||
round: event.round,
|
round: event.round,
|
||||||
|
|||||||
Reference in New Issue
Block a user