mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
[Bug] Preventing Duplicate Species in Trainer Battles (#4368)
* no trainer repeats * Update src/field/trainer.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: frutescens <info@laptop> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
4fb76fd117
commit
50dc438930
@ -425,14 +425,32 @@ export default class Trainer extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retry && (attempt || 0) < 10) {
|
// 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) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user