From 8c366315ff3157061e385f4a112867caef2b6b73 Mon Sep 17 00:00:00 2001 From: frutescens Date: Sat, 21 Sep 2024 12:34:48 -0700 Subject: [PATCH] no trainer repeats --- src/field/trainer.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/field/trainer.ts b/src/field/trainer.ts index 1973d7216a6..3469eef8255 100644 --- a/src/field/trainer.ts +++ b/src/field/trainer.ts @@ -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) { console.log("Rerolling party member..."); ret = this.genNewPartyMemberSpecies(level, strength, (attempt || 0) + 1); @@ -433,6 +439,18 @@ export default class Trainer extends Phaser.GameObjects.Container { 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][] { if (trainerSlot && !this.isDouble()) { trainerSlot = TrainerSlot.NONE;