[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 <greiner@infai.org>
This commit is contained in:
kvngrnr 2024-06-09 21:30:33 +02:00 committed by GitHub
parent 8807efe002
commit aba9310ddf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 : "---"}`);