From c62ddc2fe5b296ab3e5100a6209d8f24af92fd91 Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:35:16 +1000 Subject: [PATCH] Updated to make tests work --- src/modifier/modifier-type.ts | 20 +++++++++++-------- .../encounters/field-trip-encounter.test.ts | 2 +- src/ui/modifier-select-ui-handler.ts | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 3d455b687bc..9bb41d36fc5 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -168,10 +168,10 @@ export interface GeneratedPersistentModifierType { export class AddPokeballModifierType extends ModifierType { private pokeballType: PokeballType; - private count: integer; - private scene: BattleScene; + private count: number; + private currentAmount: number; - constructor(iconImage: string, pokeballType: PokeballType, count: integer) { + constructor(iconImage: string, pokeballType: PokeballType, count: number) { super("", iconImage, (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), "pb", "se/pb_bounce_1"); this.pokeballType = pokeballType; this.count = count; @@ -181,12 +181,16 @@ export class AddPokeballModifierType extends ModifierType { return i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", { "modifierCount": this.count, "pokeballName": getPokeballName(this.pokeballType), - "pokeballAmount": `${this.scene.pokeballCounts[this.pokeballType]}`, + "pokeballAmount": `${this.currentAmount}`, }); } - addScene(scene: BattleScene) { - this.scene = scene; + addAmount(currentAmount: number) { + this.currentAmount = currentAmount; + } + + getPokeballType(): PokeballType { + return this.pokeballType as PokeballType; } getDescription(scene: BattleScene): string { @@ -2153,13 +2157,13 @@ function getModifierTypeOptionWithRetry(existingOptions: ModifierTypeOption[], r allowLuckUpgrades = allowLuckUpgrades ?? true; let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, tier, undefined, 0, allowLuckUpgrades); if (candidate?.type instanceof AddPokeballModifierType) { - candidate.type.addScene(party[0].scene); + candidate.type.addAmount(party[0].scene.pokeballCounts[candidate.type.getPokeballType()]); } let r = 0; while (existingOptions.length && ++r < retryCount && existingOptions.filter(o => o.type.name === candidate?.type.name || o.type.group === candidate?.type.group).length) { candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, candidate?.type.tier ?? tier, candidate?.upgradeCount, 0, allowLuckUpgrades); if (candidate?.type instanceof AddPokeballModifierType) { - candidate.type.addScene(party[0].scene); + candidate.type.addAmount(party[0].scene.pokeballCounts[candidate.type.getPokeballType()]); } } return candidate!; diff --git a/src/test/mystery-encounter/encounters/field-trip-encounter.test.ts b/src/test/mystery-encounter/encounters/field-trip-encounter.test.ts index 7a8d951c5da..4d48f56a1f1 100644 --- a/src/test/mystery-encounter/encounters/field-trip-encounter.test.ts +++ b/src/test/mystery-encounter/encounters/field-trip-encounter.test.ts @@ -214,7 +214,7 @@ describe("Field Trip - Mystery Encounter", () => { expect(modifierSelectHandler.options.length).toEqual(5); expect(modifierSelectHandler.options[0].modifierTypeOption.type.name).toBe("X Accuracy"); expect(modifierSelectHandler.options[1].modifierTypeOption.type.name).toBe("X Speed"); - expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe("5x Great Ball"); + expect(modifierSelectHandler.options[2].modifierTypeOption.type.name).toBe("Great Ball x5\nInventory: 0"); expect(modifierSelectHandler.options[3].modifierTypeOption.type.name).toBe("IV Scanner"); expect(modifierSelectHandler.options[4].modifierTypeOption.type.name).toBe("Rarer Candy"); }); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index 3b8cd35fab3..931c1d3252e 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -678,7 +678,7 @@ class ModifierOption extends Phaser.GameObjects.Container { } if (this.modifierTypeOption.type instanceof AddPokeballModifierType) { - this.modifierTypeOption.type.addScene(this.scene as BattleScene); + this.modifierTypeOption.type.addAmount((this.scene as BattleScene).pokeballCounts[this.modifierTypeOption.type.getPokeballType()]); } this.itemText = addTextObject(this.scene, 0, 35, this.modifierTypeOption.type?.name!, TextStyle.PARTY, { align: "center" }); // TODO: is this bang correct?