Re-apply to SpeciesFormChangeStatusEffectTrigger constructor

Apply to new instances in test mocks
This commit is contained in:
NightKev 2025-06-12 21:27:09 -07:00
parent be080b505b
commit 5e2fd4ef00
4 changed files with 12 additions and 29 deletions

View File

@ -1,5 +1,5 @@
import i18next from "i18next"; import i18next from "i18next";
import type { Constructor } from "#app/utils/common"; import { coerceArray, type Constructor } from "#app/utils/common";
import type { TimeOfDay } from "#enums/time-of-day"; import type { TimeOfDay } from "#enums/time-of-day";
import type Pokemon from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon";
import type { SpeciesFormChange } from "#app/data/pokemon-forms"; import type { SpeciesFormChange } from "#app/data/pokemon-forms";
@ -125,10 +125,7 @@ export class SpeciesFormChangeStatusEffectTrigger extends SpeciesFormChangeTrigg
constructor(statusEffects: StatusEffect | StatusEffect[], invert = false) { constructor(statusEffects: StatusEffect | StatusEffect[], invert = false) {
super(); super();
if (!Array.isArray(statusEffects)) { this.statusEffects = coerceArray(statusEffects);
statusEffects = [statusEffects];
}
this.statusEffects = statusEffects;
this.invert = invert; this.invert = invert;
// this.description = i18next.t("pokemonEvolutions:Forms.statusEffect"); // this.description = i18next.t("pokemonEvolutions:Forms.statusEffect");
} }

View File

@ -1,3 +1,4 @@
import { coerceArray } from "#app/utils/common";
import type MockTextureManager from "#test/testUtils/mocks/mockTextureManager"; import type MockTextureManager from "#test/testUtils/mocks/mockTextureManager";
import type { MockGameObject } from "../mockGameObject"; import type { MockGameObject } from "../mockGameObject";
@ -216,11 +217,7 @@ export default class MockContainer implements MockGameObject {
} }
add(obj: MockGameObject | MockGameObject[]): this { add(obj: MockGameObject | MockGameObject[]): this {
if (Array.isArray(obj)) { this.list.push(...coerceArray(obj));
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this; return this;
} }
@ -232,18 +229,12 @@ export default class MockContainer implements MockGameObject {
addAt(obj: MockGameObject | MockGameObject[], index = 0): this { addAt(obj: MockGameObject | MockGameObject[], index = 0): this {
// Adds a Game Object to this Container at the given index. // Adds a Game Object to this Container at the given index.
if (!Array.isArray(obj)) { this.list.splice(index, 0, ...coerceArray(obj));
obj = [obj];
}
this.list.splice(index, 0, ...obj);
return this; return this;
} }
remove(obj: MockGameObject | MockGameObject[], destroyChild = false): this { remove(obj: MockGameObject | MockGameObject[], destroyChild = false): this {
if (!Array.isArray(obj)) { for (const item of coerceArray(obj)) {
obj = [obj];
}
for (const item of obj) {
const index = this.list.indexOf(item); const index = this.list.indexOf(item);
if (index !== -1) { if (index !== -1) {
this.list.splice(index, 1); this.list.splice(index, 1);

View File

@ -1,3 +1,4 @@
import { coerceArray } from "#app/utils/common";
import type { MockGameObject } from "../mockGameObject"; import type { MockGameObject } from "../mockGameObject";
export default class MockRectangle implements MockGameObject { export default class MockRectangle implements MockGameObject {
@ -50,11 +51,7 @@ export default class MockRectangle implements MockGameObject {
add(obj: MockGameObject | MockGameObject[]): this { add(obj: MockGameObject | MockGameObject[]): this {
// Adds a child to this Game Object. // Adds a child to this Game Object.
if (Array.isArray(obj)) { this.list.push(...coerceArray(obj));
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this; return this;
} }

View File

@ -1,6 +1,8 @@
import { coerceArray } from "#app/utils/common";
import Phaser from "phaser"; import Phaser from "phaser";
import type { MockGameObject } from "../mockGameObject"; import type { MockGameObject } from "../mockGameObject";
import Frame = Phaser.Textures.Frame;
type Frame = Phaser.Textures.Frame;
export default class MockSprite implements MockGameObject { export default class MockSprite implements MockGameObject {
private phaserSprite; private phaserSprite;
@ -204,11 +206,7 @@ export default class MockSprite implements MockGameObject {
add(obj: MockGameObject | MockGameObject[]): this { add(obj: MockGameObject | MockGameObject[]): this {
// Adds a child to this Game Object. // Adds a child to this Game Object.
if (Array.isArray(obj)) { this.list.push(...coerceArray(obj));
this.list.push(...obj);
} else {
this.list.push(obj);
}
return this; return this;
} }