[Bug] Prevent Duplicate Signature Species in Trainer Battles

This commit is contained in:
xsn34kzx 2024-12-30 22:13:41 -05:00
parent 6946abadb8
commit af03b707a4

View File

@ -426,7 +426,7 @@ 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, baseSpecies)) {
if (this.checkDuplicateSpecies(baseSpecies.speciesId)) {
console.log("Duplicate species detected, prompting reroll...");
retry = true;
}
@ -441,17 +441,23 @@ export default class Trainer extends Phaser.GameObjects.Container {
/**
* Checks if the enemy trainer already has the Pokemon species in their party
* @param {PokemonSpecies} species {@linkcode PokemonSpecies}
* @param {PokemonSpecies} baseSpecies {@linkcode PokemonSpecies} - baseSpecies of the Pokemon if species is forced to evolve
* @param {PokemonSpecies} baseSpecies {@linkcode Species} - The base species of the current Pokemon
* @returns `true` if the species is already present in the party
*/
checkDuplicateSpecies(species: PokemonSpecies, baseSpecies: PokemonSpecies): boolean {
const staticPartyPokemon = (signatureSpecies[TrainerType[this.config.trainerType]] ?? []).flat(1);
const currentPartySpecies = this.scene.getEnemyParty().map(p => {
return p.species.speciesId;
checkDuplicateSpecies(baseSpecies: Species): boolean {
const staticSpecies = (signatureSpecies[TrainerType[this.config.trainerType]] ?? []).flat(1).map(s => {
let root = s;
while (pokemonPrevolutions.hasOwnProperty(root)) {
root = pokemonPrevolutions[root];
}
return root;
});
return currentPartySpecies.includes(species.speciesId) || staticPartyPokemon.includes(baseSpecies.speciesId);
const currentSpecies = this.scene.getEnemyParty().map(p => {
return p.species.getRootSpeciesId();
});
return currentSpecies.includes(baseSpecies) || staticSpecies.includes(baseSpecies);
}
getPartyMemberMatchupScores(trainerSlot: TrainerSlot = TrainerSlot.NONE, forSwitch: boolean = false): [integer, integer][] {