From 87c1f5e50fa4e042b09fd5ebe12afc8fa9573a70 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 21 Apr 2024 11:50:50 -0400 Subject: [PATCH] Fix Poke Ball localization --- src/battle-scene.ts | 7 +++++-- src/modifier/modifier-type.ts | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index f462f50e1..26fbe1b2f 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -17,7 +17,7 @@ import { TextStyle, addTextObject } from './ui/text'; import { Moves } from "./data/enums/moves"; import { allMoves } from "./data/move"; import { initMoves } from './data/move'; -import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave } from './modifier/modifier-type'; +import { ModifierPoolType, getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getModifierPoolForType } from './modifier/modifier-type'; import AbilityBar from './ui/ability-bar'; import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, IncrementMovePriorityAbAttr, applyAbAttrs, initAbilities } from './data/ability'; import { Abilities } from "./data/enums/abilities"; @@ -795,7 +795,10 @@ export default class BattleScene extends SceneBase { this.trainer.setVisible(true); if (reloadI18n) { - const localizable: Localizable[] = [ ...allMoves ]; + const localizable: Localizable[] = [ + ...allMoves, + ...Utils.getEnumValues(ModifierPoolType).map(mpt => getModifierPoolForType(mpt)).map(mp => Object.values(mp).flat().map(mt => mt.modifierType).filter(mt => 'localize' in mt).map(lpb => lpb as unknown as Localizable)).flat() + ]; for (let item of localizable) item.localize(); } diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 77d709547..6197db237 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -19,6 +19,7 @@ import { VoucherType, getVoucherTypeIcon, getVoucherTypeName } from '../system/v import { FormChangeItem, SpeciesFormChangeItemTrigger, pokemonFormChanges } from '../data/pokemon-forms'; import { ModifierTier } from './modifier-tier'; import { Nature, getNatureName, getNatureStatMultiplier } from '#app/data/nature'; +import { Localizable } from '#app/plugins/i18n'; const outputModifierData = false; const useMaxWeightForOutput = false; @@ -131,10 +132,19 @@ export interface GeneratedPersistentModifierType { getPregenArgs(): any[]; } -class AddPokeballModifierType extends ModifierType { +class AddPokeballModifierType extends ModifierType implements Localizable { + private pokeballType: PokeballType; + private count: integer; + constructor(pokeballType: PokeballType, count: integer, iconImage?: string) { - super(`${count}x ${getPokeballName(pokeballType)}`, `Receive ${getPokeballName(pokeballType)} x${count}\nCatch Rate: ${getPokeballCatchMultiplier(pokeballType) > -1 ? `${getPokeballCatchMultiplier(pokeballType)}x` : 'Certain'}`, - (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), iconImage, 'pb', 'pb_bounce_1'); + super('', '', (_type, _args) => new Modifiers.AddPokeballModifier(this, pokeballType, count), iconImage, 'pb', 'pb_bounce_1'); + this.pokeballType = pokeballType; + this.count = count; + } + + localize() { + this.name = `${this.count}x ${getPokeballName(this.pokeballType)}`; + this.description = `Receive ${getPokeballName(this.pokeballType)} x${this.count}\nCatch Rate: ${getPokeballCatchMultiplier(this.pokeballType) > -1 ? `${getPokeballCatchMultiplier(this.pokeballType)}x` : 'Certain'}`; } }