|
25 | 25 | let turboGameCount = $state(0); |
26 | 26 | let rankedWarning = $state(""); |
27 | 27 | let turboWarning = $state(""); |
28 | | - let minBenchmarkGames = $state(5); |
29 | 28 | let activeBenchmark = $derived(selectedGameMode === 23 ? turboBenchmark : rankedBenchmark); |
30 | 29 | let showBracketOverlays = $state(/** @type {Set<string>} */ (new Set())); |
31 | 30 |
|
|
58 | 57 | ]); |
59 | 58 |
|
60 | 59 | onMount(async () => { |
61 | | - try { |
62 | | - const settings = await invoke("get_settings"); |
63 | | - minBenchmarkGames = settings.min_benchmark_games ?? 5; |
64 | | - } catch { /* use default */ } |
65 | 60 | await loadAnalysis(); |
66 | 61 | await loadBenchmarks(); |
67 | 62 | }); |
|
108 | 103 | rankedGameCount = rankedPoints.length; |
109 | 104 | turboGameCount = turboPoints.length; |
110 | 105 |
|
111 | | - const minGames = minBenchmarkGames; |
112 | 106 | const confidentGames = 30; |
113 | 107 |
|
114 | 108 | // Ranked benchmark |
115 | 109 | if (rankedGameCount > 0) { |
116 | | - if (rankedGameCount < minGames) { |
117 | | - const need = minGames - rankedGameCount; |
118 | | - rankedWarning = `Need ${need} more ranked game${need === 1 ? '' : 's'} to show rank.`; |
119 | | - } else { |
120 | | - const rankedAvg = rankedPoints.reduce((/** @type {number} */ sum, /** @type {any} */ p) => sum + p.last_hits, 0) / rankedGameCount; |
121 | | - if (rankedGameCount < confidentGames) { |
122 | | - const need = confidentGames - rankedGameCount; |
123 | | - rankedWarning = `Confidence is low. Need ${need} more ranked game${need === 1 ? '' : 's'} for a more confident rank.`; |
124 | | - } |
125 | | - try { |
126 | | - rankedBenchmark = await invoke("get_hero_benchmark", { |
127 | | - heroId, |
128 | | - mode: "ranked", |
129 | | - statName: "last_hits_10min", |
130 | | - userValue: rankedAvg, |
131 | | - userHeroId: heroId, |
132 | | - userGameMode: 22, |
133 | | - }); |
134 | | - } catch (e) { |
135 | | - console.warn("Ranked benchmark load failed:", e); |
136 | | - } |
| 110 | + const rankedAvg = rankedPoints.reduce((/** @type {number} */ sum, /** @type {any} */ p) => sum + p.last_hits, 0) / rankedGameCount; |
| 111 | + if (rankedGameCount < confidentGames) { |
| 112 | + rankedWarning = `Based on only ${rankedGameCount} ranked game${rankedGameCount === 1 ? '' : 's'} — rank may be inaccurate.`; |
| 113 | + } |
| 114 | + try { |
| 115 | + rankedBenchmark = await invoke("get_hero_benchmark", { |
| 116 | + heroId, |
| 117 | + mode: "ranked", |
| 118 | + statName: "last_hits_10min", |
| 119 | + userValue: rankedAvg, |
| 120 | + userHeroId: heroId, |
| 121 | + userGameMode: 22, |
| 122 | + }); |
| 123 | + } catch (e) { |
| 124 | + console.warn("Ranked benchmark load failed:", e); |
137 | 125 | } |
138 | 126 | } |
139 | 127 |
|
140 | 128 | // Turbo benchmark |
141 | 129 | if (turboGameCount > 0) { |
142 | | - if (turboGameCount < minGames) { |
143 | | - const need = minGames - turboGameCount; |
144 | | - turboWarning = `Need ${need} more turbo game${need === 1 ? '' : 's'} to show rank.`; |
145 | | - } else { |
146 | | - const turboAvg = turboPoints.reduce((/** @type {number} */ sum, /** @type {any} */ p) => sum + p.last_hits, 0) / turboGameCount; |
147 | | - if (turboGameCount < confidentGames) { |
148 | | - const need = confidentGames - turboGameCount; |
149 | | - turboWarning = `Confidence is low. Need ${need} more turbo game${need === 1 ? '' : 's'} for a more confident rank.`; |
150 | | - } |
151 | | - try { |
152 | | - turboBenchmark = await invoke("get_hero_benchmark", { |
153 | | - heroId, |
154 | | - mode: "turbo", |
155 | | - statName: "last_hits_10min", |
156 | | - userValue: turboAvg, |
157 | | - userHeroId: heroId, |
158 | | - userGameMode: 23, |
159 | | - }); |
160 | | - } catch (e) { |
161 | | - console.warn("Turbo benchmark load failed:", e); |
162 | | - } |
| 130 | + const turboAvg = turboPoints.reduce((/** @type {number} */ sum, /** @type {any} */ p) => sum + p.last_hits, 0) / turboGameCount; |
| 131 | + if (turboGameCount < confidentGames) { |
| 132 | + turboWarning = `Based on only ${turboGameCount} turbo game${turboGameCount === 1 ? '' : 's'} — rank may be inaccurate.`; |
| 133 | + } |
| 134 | + try { |
| 135 | + turboBenchmark = await invoke("get_hero_benchmark", { |
| 136 | + heroId, |
| 137 | + mode: "turbo", |
| 138 | + statName: "last_hits_10min", |
| 139 | + userValue: turboAvg, |
| 140 | + userHeroId: heroId, |
| 141 | + userGameMode: 23, |
| 142 | + }); |
| 143 | + } catch (e) { |
| 144 | + console.warn("Turbo benchmark load failed:", e); |
163 | 145 | } |
164 | 146 | } |
165 | 147 |
|
|
0 commit comments