Skip to content

Commit

Permalink
UI: Show total number of EVs allocated (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari authored Nov 2, 2024
1 parent 9e8ca8e commit 4117003
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/honkalculate.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,16 @@
<td><span class="totalMod">---</span>
</td>
</tr>
<tr class="totalevs">
<th scope="row">
<label>Total</label>
</th>
<td></td>
<td></td>
<td class="gen-specific g3 g4 g5 g6 g7 g8 g9">
<span class="evs calc-trigger">0</p>
</td>
</tr>
</table>
</div>
<div class="info-group info-selectors">
Expand Down
20 changes: 20 additions & 0 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@
<td><span class="totalMod">---</span>
</td>
</tr>
<tr class="totalevs">
<th scope="row">
<label>Total</label>
</th>
<td></td>
<td></td>
<td class="gen-specific g3 g4 g5 g6 g7 g8 g9">
<span class="evs calc-trigger">0</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -1339,6 +1349,16 @@
<td><span class="totalMod">---</span>
</td>
</tr>
<tr class="totalevs">
<th scope="row">
<label>Total</label>
</th>
<td></td>
<td></td>
<td class="gen-specific g3 g4 g5 g6 g7 g8 g9">
<span class="evs calc-trigger">0</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
16 changes: 16 additions & 0 deletions src/js/shared_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ $(".sd .base, .sd .evs, .sd .ivs").bind("keyup change", function () {
$(".sp .base, .sp .evs, .sp .ivs").bind("keyup change", function () {
calcStat($(this).closest(".poke-info"), 'sp');
});
$(".evs").bind('keyup change', function () {
totalEVs($(this).closest(".poke-info"));
});
$(".sl .base").keyup(function () {
calcStat($(this).closest(".poke-info"), 'sl');
});
Expand Down Expand Up @@ -746,6 +749,7 @@ $(".set-selector").change(function () {
$(this).closest('.poke-info').find(".move-pool").hide();
}
}
totalEVs(pokeObj);
if (typeof getSelectedTiers === "function") { // doesn't exist when in 1vs1 mode
var format = getSelectedTiers()[0];
var is50lvl = startsWith(format, "VGC") || startsWith(format, "Battle Spot");
Expand Down Expand Up @@ -1260,6 +1264,18 @@ function calcHP(poke) {
$currentHP.attr('data-set', true);
}

function totalEVs(poke) {
var totalEVs = 0;
for (var i = 0; i < LEGACY_STATS[gen].length; i++) {
var statName = LEGACY_STATS[gen][i];
var stat = poke.find("." + statName);
var evs = ~~stat.find(".evs").val();
totalEVs += evs;
}
poke.find(".totalevs").find(".evs").text(totalEVs);
return totalEVs;
}

function calcStat(poke, StatID) {
var stat = poke.find("." + StatID);
var base = ~~stat.find(".base").val();
Expand Down
22 changes: 22 additions & 0 deletions src/oms.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@
<td><span class="totalMod">---</span>
</td>
</tr>
<tr class="totalevs">
<th scope="row">
<label>Total</label>
</th>
<td>
</td>
<td>
</td>
<td class="gen-specific g3 g4 g5 g6 g7 g8 g9">
<span class="evs calc-trigger">0</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down Expand Up @@ -1334,6 +1346,16 @@
<td><span class="totalMod">---</span>
</td>
</tr>
<tr class="totalevs">
<th scope="row">
<label>Total</label>
</th>
<td></td>
<td></td>
<td class="gen-specific g3 g4 g5 g6 g7 g8 g9">
<span class="evs calc-trigger">0</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit 4117003

Please sign in to comment.