From 3f9e7b4839dfa26d2ebadd66c81359f8dc7932ea Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Fri, 19 Apr 2024 00:58:59 -0400 Subject: [PATCH] Working fix to shiny crash issue --- src/data/pokemon-species.ts | 8 ++++---- src/field/pokemon.ts | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 924c66277..c89656469 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -211,7 +211,7 @@ export abstract class PokemonSpeciesForm { return `${/_[1-3]$/.test(spriteId) ? 'variant/' : ''}${spriteId}`; } - getSpriteId(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string { + getSpriteId(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer, back?: boolean): string { if (formIndex === undefined || this instanceof PokemonForm) formIndex = this.formIndex; @@ -222,10 +222,10 @@ export abstract class PokemonSpeciesForm { let variantSet: VariantSet; let config = variantData; - baseSpriteKey.split('__').map(p => config = variantData[p]); + `${back ? 'back__' : ''}${baseSpriteKey}`.split('__').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; - return `${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? 'shiny__' : ''}${baseSpriteKey}${shiny && variantSet && variantSet[variant || 0] === 2 ? `_${variant + 1}` : ''}`; + return `${back ? 'back__' : ''}${shiny && (!variantSet || (!variant && !variantSet[variant || 0])) ? 'shiny__' : ''}${baseSpriteKey}${shiny && variantSet && variantSet[variant || 0] === 2 ? `_${variant + 1}` : ''}`; } getSpriteKey(female: boolean, formIndex?: integer, shiny?: boolean, variant?: integer): string { @@ -386,7 +386,7 @@ export abstract class PokemonSpeciesForm { spritePath = `exp/${spritePath}`; let variantSet: VariantSet; let config = variantData; - spritePath.split('/').map(p => config = variantData[p]); + spritePath.split('/').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; if (variantSet && variantSet[variant] === 1) { const populateVariantColors = (key: string): Promise => { diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 993d5bb41..6fd584d53 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -310,7 +310,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { const battleSpritePath = this.getBattleSpriteAtlasPath(back, ignoreOverride); let variantSet: VariantSet; let config = variantData; - battleSpritePath.split('/').map(p => config = variantData[p]); + battleSpritePath.split('/').map(p => config ? config = config[p] : null); variantSet = config as VariantSet; if (variantSet && variantSet[this.variant] === 1) { if (variantColorCache.hasOwnProperty(key)) @@ -367,7 +367,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) back = this.isPlayer(); - return `${back ? 'back__' : ''}${this.getSpriteId(ignoreOverride)}`; + return this.getSpeciesForm(ignoreOverride).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant, back); } getSpriteKey(ignoreOverride?: boolean): string { @@ -385,7 +385,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getFusionBattleSpriteId(back?: boolean, ignoreOverride?: boolean): string { if (back === undefined) back = this.isPlayer(); - return `${back ? 'back__' : ''}${this.getFusionSpriteId(ignoreOverride)}`; + return this.getFusionSpeciesForm(ignoreOverride).getSpriteId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant, back); } getFusionBattleSpriteKey(back?: boolean, ignoreOverride?: boolean): string {