Fix namebox not updating with theme

Fix namebox not updating with theme; ban certain species from being used by trainers
This commit is contained in:
Flashfyre 2024-04-04 18:00:21 -04:00
parent 3e99ed6bb6
commit 4f0b1fdcfb
4 changed files with 13 additions and 5 deletions

View File

@ -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());
};
}

View File

@ -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;

View File

@ -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
};

View File

@ -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);
}
}