Working fix to shiny crash issue

This commit is contained in:
Flashfyre 2024-04-19 00:58:59 -04:00
parent e2824b9b5d
commit 3f9e7b4839
2 changed files with 7 additions and 7 deletions

View File

@ -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<void> => {

View File

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