Fix combat tests for new events
This commit is contained in:
parent
5c46a531fa
commit
e1ba738ea0
|
|
@ -260,7 +260,7 @@ describe('CombatSystem — events', () => {
|
|||
const target = w.createEntity('target');
|
||||
target.add(new Health({ value: 100, min: 0 }));
|
||||
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' }));
|
||||
w.update(1);
|
||||
expect(hits.length).toBe(1);
|
||||
|
|
@ -270,7 +270,7 @@ describe('CombatSystem — events', () => {
|
|||
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 sword = w.createEntity('sword');
|
||||
sword.add(new Damage({ value: 999, damageType: 'physical' }));
|
||||
|
|
@ -278,13 +278,13 @@ describe('CombatSystem — events', () => {
|
|||
const target = w.createEntity('target');
|
||||
target.add(new Health({ value: 50, min: 0 }));
|
||||
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' }));
|
||||
w.update(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 sword = w.createEntity('sword');
|
||||
sword.add(new Damage({ value: 5, damageType: 'physical' }));
|
||||
|
|
@ -292,7 +292,7 @@ describe('CombatSystem — events', () => {
|
|||
const target = w.createEntity('target');
|
||||
target.add(new Health({ value: 100, min: 0 }));
|
||||
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' }));
|
||||
w.update(1);
|
||||
expect(kills.length).toBe(0);
|
||||
|
|
@ -306,7 +306,7 @@ describe('CombatSystem — events', () => {
|
|||
const target = w.createEntity('target');
|
||||
target.add(new Health({ value: 100, min: 0 }));
|
||||
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' }));
|
||||
w.update(1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue