From 4f0b1fdcfb872c97d9c5da505a0b3aea00b763d3 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 4 Apr 2024 18:00:21 -0400 Subject: [PATCH] Fix namebox not updating with theme Fix namebox not updating with theme; ban certain species from being used by trainers --- src/data/pokemon-species.ts | 7 ++++++- src/data/trainer-config.ts | 4 ++-- src/field/pokemon.ts | 1 + src/ui/ui-theme.ts | 6 ++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index a0df67667..267b1837e 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -167,6 +167,10 @@ export abstract class PokemonSpeciesForm { return this.getRegion() > Region.NORMAL; } + isTrainerForbidden(): boolean { + return [ Species.ETERNAL_FLOETTE, Species.BLOODMOON_URSALUNA ].includes(this.speciesId); + } + isRareRegional(): boolean { switch (this.getRegion()) { case Region.HISUI: @@ -613,7 +617,8 @@ export default class PokemonSpecies extends PokemonSpeciesForm { && pokemonPrevolutions.hasOwnProperty(species.speciesId) === hasPrevolution && species.pseudoLegendary === pseudoLegendary && species.legendary === legendary - && species.mythical === mythical; + && species.mythical === mythical + && (this.isTrainerForbidden() || !species.isTrainerForbidden()); }; } diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 4ab51f1ab..a6411cd1b 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -212,7 +212,7 @@ export class TrainerConfig { this.battleBgm = 'battle_trainer'; this.victoryBgm = 'victory_trainer'; this.partyTemplates = [ trainerPartyTemplates.TWO_AVG ]; - this.speciesFilter = species => allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical); + this.speciesFilter = species => (allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical)) && !species.isTrainerForbidden(); } getKey(): string { @@ -509,7 +509,7 @@ function getRandomPartyMemberFunc(speciesPool: Species[], trainerSlot: TrainerSl function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilter, trainerSlot: TrainerSlot = TrainerSlot.TRAINER, allowLegendaries?: boolean, postProcess?: (EnemyPokemon: EnemyPokemon) => void): PartyMemberFunc { const originalSpeciesFilter = speciesFilter; - speciesFilter = (species: PokemonSpecies) => allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical) && originalSpeciesFilter(species); + speciesFilter = (species: PokemonSpecies) => (allowLegendaries || (!species.legendary && !species.pseudoLegendary && !species.mythical)) && !species.isTrainerForbidden() && originalSpeciesFilter(species); return (scene: BattleScene, level: integer, strength: PartyMemberStrength) => { const ret = scene.addEnemyPokemon(getPokemonSpecies(scene.randomSpecies(scene.currentBattle.waveIndex, level, false, speciesFilter).getTrainerSpeciesForLevel(level, true, strength)), level, trainerSlot, undefined, undefined, postProcess); return ret; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 226fea3d4..454a7c8e9 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -878,6 +878,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { && !species.pseudoLegendary && !species.legendary && !species.mythical + && !species.isTrainerForbidden() && species.speciesId !== this.species.speciesId }; diff --git a/src/ui/ui-theme.ts b/src/ui/ui-theme.ts index 3aa044249..a08acc04a 100644 --- a/src/ui/ui-theme.ts +++ b/src/ui/ui-theme.ts @@ -59,7 +59,7 @@ export function addWindow(scene: BattleScene, x: number, y: number, width: numbe export function updateWindowType(scene: BattleScene, windowTypeIndex: integer): void { const windowObjects: [Phaser.GameObjects.NineSlice, WindowVariant][] = []; - const themedObjects: Phaser.GameObjects.Image[] = []; + const themedObjects: (Phaser.GameObjects.Image | Phaser.GameObjects.NineSlice)[] = []; const traverse = (object: any) => { if (object.hasOwnProperty('children') && object.children instanceof Phaser.GameObjects.DisplayList) { const children = object.children as Phaser.GameObjects.DisplayList; @@ -71,8 +71,10 @@ export function updateWindowType(scene: BattleScene, windowTypeIndex: integer): } else if (object instanceof Phaser.GameObjects.NineSlice) { if (object.texture.key.startsWith('window_')) windowObjects.push([ object, object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.XTHIN)) ? WindowVariant.XTHIN : object.texture.key.endsWith(getWindowVariantSuffix(WindowVariant.THIN)) ? WindowVariant.THIN : WindowVariant.NORMAL ]); + else if (object.texture?.key === 'namebox') + themedObjects.push(object); } else if (object instanceof Phaser.GameObjects.Sprite) { - if ([ 'bg', 'namebox' ].includes(object.texture?.key)) + if (object.texture?.key === 'bg') themedObjects.push(object); } }