Skip to content

Commit

Permalink
Fix searching for Ursaluna-Bloodmoon by moves (#2286)
Browse files Browse the repository at this point in the history
  • Loading branch information
dot-Comfey authored Sep 30, 2024
1 parent 9a83838 commit aed9c26
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions play.pokemonshowdown.com/src/battle-dex-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -821,9 +821,11 @@ abstract class BattleTypedSearch<T extends SearchType> {
if (this.formatType === 'letsgo') table = table['gen7letsgo'];
if (this.formatType === 'bw1') table = table['gen5bw1'];
let learnset = table.learnsets[learnsetid];
const eggMovesOnly = this.eggMovesOnly(learnsetid, speciesid);
if (learnset && (moveid in learnset) && (!this.format.startsWith('tradebacks') ? learnset[moveid].includes(genChar) :
learnset[moveid].includes(genChar) ||
(learnset[moveid].includes(`${gen + 1}`) && move.gen === gen))) {
learnset[moveid].includes(genChar) || (learnset[moveid].includes(`${gen + 1}`) && move.gen === gen)) &&
(!eggMovesOnly || (learnset[moveid].includes('e') && this.dex.gen === 9))
) {
return true;
}
learnsetid = this.nextLearnsetid(learnsetid, speciesid, true);
Expand Down Expand Up @@ -873,6 +875,15 @@ abstract class BattleTypedSearch<T extends SearchType> {

return pokemon.tier;
}
eggMovesOnly(child: ID, father: ID) {
if (this.dex.species.get(child).baseSpecies === this.dex.species.get(father).baseSpecies) return false;
const baseSpecies = father;
while (father) {
if (child === father) return false;
father = this.nextLearnsetid(father, baseSpecies);
}
return true;
}
abstract getTable(): {[id: string]: any};
abstract getDefaultResults(): SearchRow[];
abstract getBaseResults(): SearchRow[];
Expand Down Expand Up @@ -1615,15 +1626,8 @@ class BattleMoveSearch extends BattleTypedSearch<'move'> {
if (regionBornLegality && !learnsetEntry.includes(minGenCode[dex.gen])) {
continue;
}
const currentSpecies = dex.species.get(learnsetid);
const originalSpecies = dex.species.get(species.id);
let nextSpecies = this.nextLearnsetid(species.id, species.id);
while (nextSpecies) {
if (nextSpecies === learnsetid) break;
nextSpecies = this.nextLearnsetid(nextSpecies, species.id);
}
if (
currentSpecies.baseSpecies !== originalSpecies.baseSpecies && !nextSpecies &&
this.eggMovesOnly(learnsetid, species.id) &&
(!learnsetEntry.includes('e') || dex.gen !== 9)
) {
continue;
Expand Down

0 comments on commit aed9c26

Please sign in to comment.