diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 2ccd70ddc29..ff9fbdf0bc8 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -779,8 +779,8 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali return this.getSpeciesForLevel(level, allowEvolving, false, (isBoss ? PartyMemberStrength.WEAKER : PartyMemberStrength.AVERAGE) + (gameMode?.isEndless ? 1 : 0)); } - getTrainerSpeciesForLevel(level: number, allowEvolving: boolean = false, strength: PartyMemberStrength, currentWave: number = 0, type: Type = Type.UNKNOWN): Species { - return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave, type); + getTrainerSpeciesForLevel(level: number, allowEvolving: boolean = false, strength: PartyMemberStrength, currentWave: number = 0): Species { + return this.getSpeciesForLevel(level, allowEvolving, true, strength, currentWave); } /** @@ -818,7 +818,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } } - getSpeciesForLevel(level: number, allowEvolving: boolean = false, forTrainer: boolean = false, strength: PartyMemberStrength = PartyMemberStrength.WEAKER, currentWave: number = 0, type: Type = Type.UNKNOWN): Species { + getSpeciesForLevel(level: number, allowEvolving: boolean = false, forTrainer: boolean = false, strength: PartyMemberStrength = PartyMemberStrength.WEAKER, currentWave: number = 0): Species { const prevolutionLevels = this.getPrevolutionLevels(); if (prevolutionLevels.length) { @@ -834,9 +834,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali return this.speciesId; } - const evolutions = forTrainer && type !== Type.UNKNOWN && pokemonEvolutions[this.speciesId].some(e => getPokemonSpecies(e.speciesId).isOfType(type)) // If this is for a trainer with specialty type and an evo exists with that type - ? pokemonEvolutions[this.speciesId].filter(e => getPokemonSpecies(e.speciesId).isOfType(type)) // Filter out mistyped evos - : pokemonEvolutions[this.speciesId]; + const evolutions = pokemonEvolutions[this.speciesId]; const easeInFunc = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeIn"); const easeOutFunc = Phaser.Tweens.Builders.GetEaseFunction("Sine.easeOut"); @@ -912,7 +910,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali for (const weight of evolutionPool.keys()) { if (randValue < weight) { - return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true, forTrainer, strength, currentWave, type); + return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true, forTrainer, strength, currentWave); } } diff --git a/src/field/trainer.ts b/src/field/trainer.ts index 5c5b75daf51..882dc767e4f 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -421,7 +421,7 @@ export default class Trainer extends Phaser.GameObjects.Container { baseSpecies = globalScene.randomSpecies(battle.waveIndex, level, false, this.config.speciesFilter); } - let ret = getPokemonSpecies(baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex, this.config.specialtyType)); + let ret = getPokemonSpecies(baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex)); let retry = false; console.log(ret.getName()); @@ -435,6 +435,21 @@ export default class Trainer extends Phaser.GameObjects.Container { } } + // Prompts reroll of party member species if doesn't fit specialty type. + // Can be removed by adding a type parameter to getTrainerSpeciesForLevel and filtering the list of evolutions for that type. + if (!retry && this.config.specialtyType > Type.UNKNOWN && !ret.isOfType(this.config.specialtyType)) { + retry = true; + console.log("Attempting reroll of species evolution to fit specialty type..."); + let evoAttempt = 0; + while (retry && evoAttempt++ < 10) { + ret = getPokemonSpecies(baseSpecies.getTrainerSpeciesForLevel(level, true, strength, globalScene.currentBattle.waveIndex)); + console.log(ret.name); + if (!ret.isOfType(this.config.specialtyType)) { + retry = false; + } + } + } + // Prompts reroll of party member species if species already present in the enemy party if (this.checkDuplicateSpecies(baseSpecies.speciesId)) { console.log("Duplicate species detected, prompting reroll...");