From 41170032e3b1add1abe5db19399b3aecdd6589ec Mon Sep 17 00:00:00 2001
From: shrianshChari <30420527+shrianshChari@users.noreply.github.com>
Date: Sat, 2 Nov 2024 14:04:45 -0400
Subject: [PATCH] UI: Show total number of EVs allocated (#660)
---
src/honkalculate.template.html | 10 ++++++++++
src/index.template.html | 20 ++++++++++++++++++++
src/js/shared_controls.js | 16 ++++++++++++++++
src/oms.template.html | 22 ++++++++++++++++++++++
4 files changed, 68 insertions(+)
diff --git a/src/honkalculate.template.html b/src/honkalculate.template.html
index f67e87c91..f819ad0a2 100644
--- a/src/honkalculate.template.html
+++ b/src/honkalculate.template.html
@@ -381,6 +381,16 @@
---
|
+
+
+
+ |
+ |
+ |
+
+ 0
+ |
+
diff --git a/src/index.template.html b/src/index.template.html
index d527c0f73..bc48e90b1 100644
--- a/src/index.template.html
+++ b/src/index.template.html
@@ -429,6 +429,16 @@
---
|
+
+
+
+ |
+ |
+ |
+
+ 0
+ |
+
@@ -1339,6 +1349,16 @@
---
|
+
+
+
+ |
+ |
+ |
+
+ 0
+ |
+
diff --git a/src/js/shared_controls.js b/src/js/shared_controls.js
index 97ddf326a..f12eef1a2 100644
--- a/src/js/shared_controls.js
+++ b/src/js/shared_controls.js
@@ -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');
});
@@ -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");
@@ -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();
diff --git a/src/oms.template.html b/src/oms.template.html
index ccc4d9f20..76e08ceb5 100644
--- a/src/oms.template.html
+++ b/src/oms.template.html
@@ -425,6 +425,18 @@
---
|
+
+
+
+ |
+
+ |
+
+ |
+
+ 0
+ |
+
@@ -1334,6 +1346,16 @@
---
|
+
+
+
+ |
+ |
+ |
+
+ 0
+ |
+