From aba9310ddfb6198c72cfbb31828c9b798b91137d Mon Sep 17 00:00:00 2001 From: kvngrnr <67913362+kvngrnr@users.noreply.github.com> Date: Sun, 9 Jun 2024 21:30:33 +0200 Subject: [PATCH] [Enhancement] Color code for used PP in fight UI (#2014) * Colorcode pp in fight ui if only half/quarter of maxPP is left * Use three-level color coding for remaining pp * use if/else for calculating pp color --------- Co-authored-by: Kevin Greiner --- src/ui/fight-ui-handler.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ui/fight-ui-handler.ts b/src/ui/fight-ui-handler.ts index f738fba5573..0ed3671ad18 100644 --- a/src/ui/fight-ui-handler.ts +++ b/src/ui/fight-ui-handler.ts @@ -179,6 +179,18 @@ export default class FightUiHandler extends UiHandler { const pp = maxPP - pokemonMove.ppUsed; this.ppText.setText(`${Utils.padInt(pp, 2, " ")}/${Utils.padInt(maxPP, 2, " ")}`); + const ppPercentLeft = pp / maxPP; + let ppColor = "white"; + if (ppPercentLeft <= 0.5) { + ppColor = "yellow"; + } + if (ppPercentLeft <= 0.25) { + ppColor = "orange"; + } + if (pp === 0) { + ppColor = "red"; + } + this.ppText.setColor(ppColor); this.powerText.setText(`${power >= 0 ? power : "---"}`); this.accuracyText.setText(`${accuracy >= 0 ? accuracy : "---"}`);