Fix double battle named trainers having unevolved Pokemon (#1582)

This commit is contained in:
Jannik Tappert 2024-05-30 00:33:18 +02:00 committed by GitHub
parent 7e1b383be2
commit ac4e72c87a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View File

@ -233,7 +233,8 @@ export class TrainerConfig {
}
// If a special double trainer class was set, set it as the sprite key
if (this.trainerTypeDouble && female && isDouble) {
ret = TrainerType[this.trainerTypeDouble].toString().toLowerCase();
// Get the derived type for the double trainer since the sprite key is based on the derived type
ret = TrainerType[this.getDerivedType(this.trainerTypeDouble)].toString().toLowerCase();
}
return ret;
}
@ -271,9 +272,13 @@ export class TrainerConfig {
}
getDerivedType(): TrainerType {
let trainerType = this.trainerType;
/**
* Returns the derived trainer type for a given trainer type.
* @param trainerTypeToDeriveFrom - The trainer type to derive from. (If null, the this.trainerType property will be used.)
* @returns {TrainerType} - The derived trainer type.
*/
getDerivedType(trainerTypeToDeriveFrom: TrainerType = null): TrainerType {
let trainerType = trainerTypeToDeriveFrom ? trainerTypeToDeriveFrom : this.trainerType;
switch (trainerType) {
case TrainerType.RIVAL_2:
case TrainerType.RIVAL_3:

View File

@ -328,12 +328,17 @@ export default class Trainer extends Phaser.GameObjects.Container {
}
// If useNewSpeciesPool is true, we need to generate a new species from the new species pool, otherwise we generate a random species
const species = useNewSpeciesPool
let species = useNewSpeciesPool
? getPokemonSpecies(newSpeciesPool[Math.floor(Math.random() * newSpeciesPool.length)])
: template.isSameSpecies(index) && index > offset
? getPokemonSpecies(battle.enemyParty[offset].species.getTrainerSpeciesForLevel(level, false, template.getStrength(offset)))
: this.genNewPartyMemberSpecies(level, strength);
// If the species is from newSpeciesPool, we need to adjust it based on the level and strength
if (newSpeciesPool) {
species = getPokemonSpecies(species.getSpeciesForLevel(level, true, true, strength));
}
ret = this.scene.addEnemyPokemon(species, level, !this.isDouble() || !(index % 2) ? TrainerSlot.TRAINER : TrainerSlot.TRAINER_PARTNER);
}, this.config.hasStaticParty ? this.config.getDerivedType() + ((index + 1) << 8) : this.scene.currentBattle.waveIndex + (this.config.getDerivedType() << 10) + (((!this.config.useSameSeedForAllMembers ? index : 0) + 1) << 8));