From 11ac929a4dda2fb5825cec6f715d3e35e8eec88c Mon Sep 17 00:00:00 2001 From: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:00:31 +0200 Subject: [PATCH] fix getting the highest ivs for the iv scanner (#4022) --- src/ui/battle-message-ui-handler.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index 4c2b798558a..3bea0f21433 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -215,12 +215,11 @@ export default class BattleMessageUiHandler extends MessageUiHandler { getTopIvs(ivs: integer[], shownIvsCount: integer): Stat[] { let shownStats: Stat[] = []; if (shownIvsCount < 6) { - let highestIv = -1; + const statsPool = PERMANENT_STATS.slice(); + // Sort the stats from highest to lowest iv + statsPool.sort((s1, s2) => ivs[s2] - ivs[s1]); for (let i = 0; i < shownIvsCount; i++) { - if (ivs[i] > highestIv) { - shownStats.push(PERMANENT_STATS[i]); - highestIv = ivs[i]; - } + shownStats.push(statsPool[i]); } } else { shownStats = PERMANENT_STATS.slice();