no trainer repeats

This commit is contained in:
frutescens 2024-09-21 12:34:48 -07:00
parent 35cd615363
commit 8c366315ff

View File

@ -425,6 +425,12 @@ export default class Trainer extends Phaser.GameObjects.Container {
} }
} }
// Prompts reroll of party member species if species already present in the enemy party
if (this.checkDuplicateSpecies(ret)) {
console.log("Duplicate species detected, prompting reroll...");
retry = true;
}
if (retry && (attempt || 0) < 10) { if (retry && (attempt || 0) < 10) {
console.log("Rerolling party member..."); console.log("Rerolling party member...");
ret = this.genNewPartyMemberSpecies(level, strength, (attempt || 0) + 1); ret = this.genNewPartyMemberSpecies(level, strength, (attempt || 0) + 1);
@ -433,6 +439,18 @@ export default class Trainer extends Phaser.GameObjects.Container {
return ret; return ret;
} }
/**
* Checks if the enemy trainer already has the Pokemon species in their party
* @param {PokemonSpecies} species {@linkcode PokemonSpecies}
* @returns `true` if the species is already present in the party
*/
checkDuplicateSpecies(species: PokemonSpecies): boolean {
const currentPartySpecies = this.scene.getEnemyParty().map(p => {
return p.species.speciesId;
});
return currentPartySpecies.includes(species.speciesId);
}
getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch: boolean = false): [integer, integer][] { getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch: boolean = false): [integer, integer][] {
if (trainerSlot && !this.isDouble()) { if (trainerSlot && !this.isDouble()) {
trainerSlot = TrainerSlot.NONE; trainerSlot = TrainerSlot.NONE;