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)

This commit is contained in:
Jannik Tappert 2024-05-26 16:48:28 +02:00 committed by GitHub
parent 5f82449120
commit bc773f07e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -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<void> {
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");

View File

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