From 97b10d9ebf03fedaf014e6e9cdabd218783da5a0 Mon Sep 17 00:00:00 2001 From: pyuk-bot Date: Sun, 7 Apr 2024 13:08:03 -0500 Subject: [PATCH 1/3] Fix optimizer output when new spread has a 0 --- play.pokemonshowdown.com/src/battle-tooltips.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-tooltips.ts b/play.pokemonshowdown.com/src/battle-tooltips.ts index 7b8f1a4652..0aa73f73f9 100644 --- a/play.pokemonshowdown.com/src/battle-tooltips.ts +++ b/play.pokemonshowdown.com/src/battle-tooltips.ts @@ -3015,15 +3015,13 @@ function BattleStatOptimizer(set: PokemonSet, formatid: ID) { minus?: StatNameExceptHP, } = {evs: {...origSpread.evs}, plus: bestPlus, minus: bestMinus}; if (bestPlus !== origNature.plus || bestMinus !== origNature.minus) { - if (bestPlusMinEVs) newSpread.evs[bestPlus] = bestPlusMinEVs; - if (bestMinusMinEVs) newSpread.evs[bestMinus] = bestMinusMinEVs; + newSpread.evs[bestPlus] = bestPlusMinEVs!; + newSpread.evs[bestMinus] = bestMinusMinEVs!; if (origNature.plus && origNature.plus !== bestPlus && origNature.plus !== bestMinus) { - const oldPlusEVs = getMinEVs(origNature.plus, newSpread); - if (oldPlusEVs) newSpread.evs[origNature.plus] = oldPlusEVs; + newSpread.evs[origNature.plus] = getMinEVs(origNature.plus, newSpread); } if (origNature.minus && origNature.minus !== bestPlus && origNature.minus !== bestMinus) { - const oldMinusEVS = getMinEVs(origNature.minus, newSpread); - if (oldMinusEVS) newSpread.evs[origNature.minus] = oldMinusEVS; + newSpread.evs[origNature.minus] = getMinEVs(origNature.minus, newSpread); } for (const stat of Dex.statNames) { if (!newSpread.evs[stat]) delete newSpread.evs[stat]; From 3394e875eff9844adb833743018e5969e923a083 Mon Sep 17 00:00:00 2001 From: MacChaeger Date: Sun, 7 Apr 2024 16:01:43 -0500 Subject: [PATCH 2/3] Add test for 0 EV output --- test/ev-optimizer.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/ev-optimizer.test.js b/test/ev-optimizer.test.js index 4f1035a6ac..05ad288646 100644 --- a/test/ev-optimizer.test.js +++ b/test/ev-optimizer.test.js @@ -94,6 +94,19 @@ describe('EV Optimizer', () => { }, 'gen9'); assert.equal(mew2, null); + const greatTusk = BattleStatOptimizer({ + species: "Great Tusk", + nature: "Jolly", + evs: {hp: 136, atk: 92, def: 100, spd: 72, spe: 108}, + level: 100 + }, 'gen9'); + assert.deepStrictEqual(greatTusk, { + evs: {hp: 136, atk: 92, spd: 72, spe: 200}, + plus: 'def', + minus: 'spa', + savedEVs: 8, + }); + const mienfoo = BattleStatOptimizer({ species: "Mienfoo", nature: "Jolly", From 9c80671f00e08e5af854e1c814186a3ee5076d11 Mon Sep 17 00:00:00 2001 From: pyuk-bot Date: Sun, 7 Apr 2024 21:29:02 -0500 Subject: [PATCH 3/3] Update test/ev-optimizer.test.js Co-authored-by: Karthik <32044378+Karthik99999@users.noreply.github.com> --- test/ev-optimizer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ev-optimizer.test.js b/test/ev-optimizer.test.js index 05ad288646..2aaa262c37 100644 --- a/test/ev-optimizer.test.js +++ b/test/ev-optimizer.test.js @@ -94,7 +94,7 @@ describe('EV Optimizer', () => { }, 'gen9'); assert.equal(mew2, null); - const greatTusk = BattleStatOptimizer({ + const greatTusk = BattleStatOptimizer({ species: "Great Tusk", nature: "Jolly", evs: {hp: 136, atk: 92, def: 100, spd: 72, spe: 108},