From 010223ef54b1a0547d6b30c9202031b0d87e77a4 Mon Sep 17 00:00:00 2001 From: Karthik99999 Date: Wed, 3 Apr 2024 20:11:25 -0700 Subject: [PATCH] actually, keep the stat check but only use it if the leftover evs are the same this makes both trapinch and amoonguss work as expected --- .../src/battle-tooltips.ts | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-tooltips.ts b/play.pokemonshowdown.com/src/battle-tooltips.ts index 2c1a23857a..e80981009e 100644 --- a/play.pokemonshowdown.com/src/battle-tooltips.ts +++ b/play.pokemonshowdown.com/src/battle-tooltips.ts @@ -2992,9 +2992,29 @@ function BattleStatOptimizer(set: PokemonSet, formatid: ID) { } const leftoverEVs = 508 - totalEVs; - if (totalEVs <= 508 && allValidEVs && leftoverEVs > curLeftoverEVs) { - curSpread = spread; - curLeftoverEVs = leftoverEVs; + if (totalEVs <= 508 && allValidEVs) { + if (leftoverEVs > curLeftoverEVs) { + curSpread = spread; + curLeftoverEVs = leftoverEVs; + } else if (leftoverEVs === curLeftoverEVs) { + // Check if we hit a jump point + let allGreaterThanOrEqual = true; + let atLeastOneGreaterThan = false; + for (const stat of Dex.statNames) { + const statVal = getStat(stat, spread.evs[stat], nature); + const curStatVal = getStat(stat, curSpread.evs?.[stat] || 0, curSpread); + if (statVal < curStatVal) { + allGreaterThanOrEqual = false; + break; + } else if (statVal > curStatVal) { + atLeastOneGreaterThan = true; + } + } + if (allGreaterThanOrEqual && atLeastOneGreaterThan) { + curSpread = spread; + curLeftoverEVs = leftoverEVs; + } + } } }