From 3b3f8112be0829f63cabb832fa8ece4004f8bb5e Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Sun, 24 Feb 2013 17:04:52 -0700 Subject: [PATCH] More changes to HP display - show best available information when hovering over pokeballs - show an approximate percent in the log and when hovering --- js/battle.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/battle.js b/js/battle.js index 3558bd44c..05019d6de 100644 --- a/js/battle.js +++ b/js/battle.js @@ -303,7 +303,9 @@ function Pokemon(species) { name += ' (fainted)'; } else { var statustext = ''; - if (selfP.hp !== selfP.maxhp) statustext = selfP.hpDisplay(); + if (selfP.hp !== selfP.maxhp) { + statustext += selfP.hp + '/' + selfP.maxhp + ' (~' + selfP.hpWidth(100) + '%)'; + } if (selfP.status) { if (statustext) statustext += '|'; statustext += selfP.status; @@ -2542,7 +2544,11 @@ function Battle(frame, logFrame, noPreload) { break; } } else { - hiddenactions += "" + poke.getName() + " lost " + self.damageDisplay(damage) + " of its health!"; + // The server sends Math.floor(pixels * 100 / 48), but we want to + // show a rounded percent. Fortunately, this is possible. Do not + // tamper with this expression unless you understand the math. + var percent = Math.round(Math.ceil(damage * 48 / 100) / 48 * 100); + hiddenactions += "" + poke.getName() + " lost " + self.damageDisplay(damage) + " (~" + percent + "%) of its health!"; } break; case '-heal':