From 55fc31042494a39deece07a6f51719d15015682c Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Sat, 7 Sep 2024 19:04:27 +1000 Subject: [PATCH] Updated the shop to show inventory of pokeballs under pokeball count --- src/locales/en/modifier-type.json | 6 +++--- src/modifier/modifier-type.ts | 15 +++++++++++++-- src/ui/modifier-select-ui-handler.ts | 7 ++++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/locales/en/modifier-type.json b/src/locales/en/modifier-type.json index 92594d44e51..6ca89fb2f71 100644 --- a/src/locales/en/modifier-type.json +++ b/src/locales/en/modifier-type.json @@ -1,9 +1,9 @@ { "ModifierType": { "AddPokeballModifierType": { - "name": "{{modifierCount}}x {{pokeballName}}", - "description": "Receive {{pokeballName}} x{{modifierCount}} (Inventory: {{pokeballAmount}}) \nCatch Rate: {{catchRate}}", - "catchRateGenerator": "{{normalCatchRate}}x ({{boostedCatchRate}}x for uncaught Pokémon)" + "name": "Receive {{pokeballName}} x{{modifierCount}}\nInventory: {{pokeballAmount}}", + "description": "Catch Rate: {{catchRate}}", + "catchRateGenerator": "{{normalCatchRate}}x ({{boostedCatchRate}}x if Pokémon has new gender, variant, form, or ability)" }, "AddVoucherModifierType": { "name": "{{modifierCount}}x {{voucherTypeName}}", diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 36bf33858af..b76d8fdbfdd 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -163,9 +163,10 @@ export interface GeneratedPersistentModifierType { getPregenArgs(): any[]; } -class AddPokeballModifierType extends ModifierType { +export class AddPokeballModifierType extends ModifierType { private pokeballType: PokeballType; private count: integer; + private scene: BattleScene; constructor(iconImage: string, pokeballType: PokeballType, count: integer) { super("", iconImage, (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), "pb", "se/pb_bounce_1"); @@ -177,9 +178,14 @@ class AddPokeballModifierType extends ModifierType { return i18next.t("modifierType:ModifierType.AddPokeballModifierType.name", { "modifierCount": this.count, "pokeballName": getPokeballName(this.pokeballType), + "pokeballAmount": `${this.scene.pokeballCounts[this.pokeballType]}`, }); } + addScene(scene: BattleScene) { + this.scene = scene; + } + getDescription(scene: BattleScene): string { let catchRate: String = ""; if (this.pokeballType === PokeballType.ROGUE_BALL) { @@ -194,7 +200,6 @@ class AddPokeballModifierType extends ModifierType { "modifierCount": this.count, "pokeballName": getPokeballName(this.pokeballType), "catchRate": catchRate, - "pokeballAmount": `${scene.pokeballCounts[this.pokeballType]}`, }); } } @@ -1982,9 +1987,15 @@ export function getPlayerModifierTypeOptions(count: integer, party: PlayerPokemo const retryCount = Math.min(count * 5, 50); new Array(count).fill(0).map((_, i) => { let candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, modifierTiers && modifierTiers.length > i ? modifierTiers[i] : undefined); + if (candidate?.type instanceof AddPokeballModifierType) { + candidate.type.addScene(party[0].scene); + } let r = 0; while (options.length && ++r < retryCount && options.filter(o => o.type?.name === candidate?.type?.name || o.type?.group === candidate?.type?.group).length) { candidate = getNewModifierTypeOption(party, ModifierPoolType.PLAYER, candidate?.type?.tier, candidate?.upgradeCount); + if (candidate?.type instanceof AddPokeballModifierType) { + candidate.type.addScene(party[0].scene); + } } if (candidate) { options.push(candidate); diff --git a/src/ui/modifier-select-ui-handler.ts b/src/ui/modifier-select-ui-handler.ts index ca5d27f96a4..5a4953553e6 100644 --- a/src/ui/modifier-select-ui-handler.ts +++ b/src/ui/modifier-select-ui-handler.ts @@ -1,5 +1,5 @@ import BattleScene from "../battle-scene"; -import { getPlayerShopModifierTypeOptionsForWave, ModifierTypeOption, TmModifierType } from "../modifier/modifier-type"; +import { getPlayerShopModifierTypeOptionsForWave, ModifierTypeOption, TmModifierType, AddPokeballModifierType } from "../modifier/modifier-type"; import { getPokeballAtlasKey, PokeballType } from "../data/pokeball"; import { addTextObject, getTextStyleOptions, getModifierTierTextTint, getTextColor, TextStyle } from "./text"; import AwaitableUiHandler from "./awaitable-ui-handler"; @@ -426,6 +426,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler { } const type = options[this.cursor].modifierTypeOption.type; + type && ui.showText(type.getDescription(this.scene)); if (type instanceof TmModifierType) { // prepare the move overlay to be shown with the toggle @@ -619,6 +620,10 @@ class ModifierOption extends Phaser.GameObjects.Container { this.itemContainer.add(this.itemTint); } + if (this.modifierTypeOption.type instanceof AddPokeballModifierType) { + this.modifierTypeOption.type.addScene(this.scene as BattleScene); + } + this.itemText = addTextObject(this.scene, 0, 35, this.modifierTypeOption.type?.name!, TextStyle.PARTY, { align: "center" }); // TODO: is this bang correct? this.itemText.setOrigin(0.5, 0); this.itemText.setAlpha(0);