From bc773f07e3f4e538d8a5440fd8e2b346a7d42db2 Mon Sep 17 00:00:00 2001 From: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com> Date: Sun, 26 May 2024 16:48:28 +0200 Subject: [PATCH] Added a check for if it is a double battle. Otherwise a named trainer that has a potential double would show the "female" (partner) sprite if the solo battle was of female variant. (#1383) --- src/data/trainer-config.ts | 8 ++++---- src/field/trainer.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 2a35f09fbeb..62e10cb9c4c 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -226,13 +226,13 @@ export class TrainerConfig { return TrainerType[this.getDerivedType()].toString().toLowerCase(); } - getSpriteKey(female?: boolean): string { + getSpriteKey(female?: boolean,isDouble: boolean = false): string { let ret = this.getKey(); if (this.hasGenders) { ret += `_${female ? "f" : "m"}`; } // If a special double trainer class was set, set it as the sprite key - if (this.trainerTypeDouble && female) { + if (this.trainerTypeDouble && female && isDouble) { ret = TrainerType[this.trainerTypeDouble].toString().toLowerCase(); } return ret; @@ -689,8 +689,8 @@ export class TrainerConfig { loadAssets(scene: BattleScene, variant: TrainerVariant): Promise { return new Promise(resolve => { const isDouble = variant === TrainerVariant.DOUBLE; - const trainerKey = this.getSpriteKey(variant === TrainerVariant.FEMALE); - const partnerTrainerKey = this.getSpriteKey(true); + const trainerKey = this.getSpriteKey(variant === TrainerVariant.FEMALE, false); + const partnerTrainerKey = this.getSpriteKey(true,true); scene.loadAtlas(trainerKey, "trainer"); if (isDouble) { scene.loadAtlas(partnerTrainerKey, "trainer"); diff --git a/src/field/trainer.ts b/src/field/trainer.ts index 081bf6d8d18..00b7bdf527a 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -74,7 +74,7 @@ export default class Trainer extends Phaser.GameObjects.Container { console.log(Object.keys(trainerPartyTemplates)[Object.values(trainerPartyTemplates).indexOf(this.getPartyTemplate())]); const getSprite = (hasShadow?: boolean, forceFemale?: boolean) => { - const ret = this.scene.addFieldSprite(0, 0, this.config.getSpriteKey(variant === TrainerVariant.FEMALE || forceFemale)); + const ret = this.scene.addFieldSprite(0, 0, this.config.getSpriteKey(variant === TrainerVariant.FEMALE || forceFemale,this.isDouble())); ret.setOrigin(0.5, 1); ret.setPipeline(this.scene.spritePipeline, {tone: [0.0, 0.0, 0.0, 0.0], hasShadow: !!hasShadow}); return ret; @@ -105,7 +105,7 @@ export default class Trainer extends Phaser.GameObjects.Container { } getKey(forceFemale?: boolean): string { - return this.config.getSpriteKey(this.variant === TrainerVariant.FEMALE || forceFemale); + return this.config.getSpriteKey(this.variant === TrainerVariant.FEMALE || forceFemale,this.isDouble()); } /**