1
0
Fork 0

Fix combat tests for new events

This commit is contained in:
Pabloader 2026-05-08 15:55:32 +00:00
parent 5c46a531fa
commit e1ba738ea0
1 changed files with 6 additions and 6 deletions

View File

@ -260,7 +260,7 @@ describe('CombatSystem — events', () => {
const target = w.createEntity('target'); const target = w.createEntity('target');
target.add(new Health({ value: 100, min: 0 })); target.add(new Health({ value: 100, min: 0 }));
const hits: unknown[] = []; const hits: unknown[] = [];
target.on('hit', ({ data }) => hits.push(data)); target.on('Combat.hit', ({ data }) => hits.push(data));
target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' })); target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' }));
w.update(1); w.update(1);
expect(hits.length).toBe(1); expect(hits.length).toBe(1);
@ -270,7 +270,7 @@ describe('CombatSystem — events', () => {
expect((hits[0] as any).sourceId).toBe('sword'); expect((hits[0] as any).sourceId).toBe('sword');
}); });
it("emits 'kill' when target health reaches zero", () => { it("emits 'killed' when target health reaches zero", () => {
const w = world(); const w = world();
const sword = w.createEntity('sword'); const sword = w.createEntity('sword');
sword.add(new Damage({ value: 999, damageType: 'physical' })); sword.add(new Damage({ value: 999, damageType: 'physical' }));
@ -278,13 +278,13 @@ describe('CombatSystem — events', () => {
const target = w.createEntity('target'); const target = w.createEntity('target');
target.add(new Health({ value: 50, min: 0 })); target.add(new Health({ value: 50, min: 0 }));
const kills: unknown[] = []; const kills: unknown[] = [];
target.on('kill', ({ data }) => kills.push(data)); target.on('Combat.killed', ({ data }) => kills.push(data));
target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' })); target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' }));
w.update(1); w.update(1);
expect(kills.length).toBe(1); expect(kills.length).toBe(1);
}); });
it("does not emit 'kill' when target survives", () => { it("does not emit 'killed' when target survives", () => {
const w = world(); const w = world();
const sword = w.createEntity('sword'); const sword = w.createEntity('sword');
sword.add(new Damage({ value: 5, damageType: 'physical' })); sword.add(new Damage({ value: 5, damageType: 'physical' }));
@ -292,7 +292,7 @@ describe('CombatSystem — events', () => {
const target = w.createEntity('target'); const target = w.createEntity('target');
target.add(new Health({ value: 100, min: 0 })); target.add(new Health({ value: 100, min: 0 }));
const kills: unknown[] = []; const kills: unknown[] = [];
target.on('kill', ({ data }) => kills.push(data)); target.on('Combat.killed', ({ data }) => kills.push(data));
target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' })); target.add(new Attacked({ attackerId: 'attacker', sourceId: 'sword' }));
w.update(1); w.update(1);
expect(kills.length).toBe(0); expect(kills.length).toBe(0);
@ -306,7 +306,7 @@ describe('CombatSystem — events', () => {
const target = w.createEntity('target'); const target = w.createEntity('target');
target.add(new Health({ value: 100, min: 0 })); target.add(new Health({ value: 100, min: 0 }));
const hits: unknown[] = []; const hits: unknown[] = [];
target.on('hit', ({ data }) => hits.push(data)); target.on('Combat.hit', ({ data }) => hits.push(data));
target.add(new Attacked({ attackerId: 'a', sourceId: 'sword' })); target.add(new Attacked({ attackerId: 'a', sourceId: 'sword' }));
target.add(new Attacked({ attackerId: 'a', sourceId: 'sword' })); target.add(new Attacked({ attackerId: 'a', sourceId: 'sword' }));
w.update(1); w.update(1);