From fbca78cfd661001548004ba3fbffa71270d2fab2 Mon Sep 17 00:00:00 2001 From: HiZo <96159984+HisuianZoroark@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:24:19 -0400 Subject: [PATCH 1/2] Display information current and max HP when using Exact HP Mod --- play.pokemonshowdown.com/src/battle-animations.ts | 2 +- play.pokemonshowdown.com/src/battle-tooltips.ts | 2 +- play.pokemonshowdown.com/src/battle.ts | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle-animations.ts b/play.pokemonshowdown.com/src/battle-animations.ts index 7d5b959317..d7d340bbec 100644 --- a/play.pokemonshowdown.com/src/battle-animations.ts +++ b/play.pokemonshowdown.com/src/battle-animations.ts @@ -2862,7 +2862,7 @@ export class PokemonSprite extends Sprite { if (pokemon.maxhp === 48 || this.scene.battle.hardcoreMode && pokemon.maxhp === 100) { $hptext.hide(); $hptextborder.hide(); - } else if (this.scene.battle.hardcoreMode) { + } else if (this.scene.battle.hardcoreMode || this.scene.battle.reportExactHP) { $hptext.html(pokemon.hp + '/'); $hptext.show(); $hptextborder.show(); diff --git a/play.pokemonshowdown.com/src/battle-tooltips.ts b/play.pokemonshowdown.com/src/battle-tooltips.ts index ebeb171361..814a500751 100644 --- a/play.pokemonshowdown.com/src/battle-tooltips.ts +++ b/play.pokemonshowdown.com/src/battle-tooltips.ts @@ -843,7 +843,7 @@ class BattleTooltips { } else if (pokemon.maxhp === 48) { exacthp = ' (' + pokemon.hp + '/' + pokemon.maxhp + ' pixels)'; } - text += '

HP: ' + Pokemon.getHPText(pokemon) + exacthp + (pokemon.status ? ' ' + pokemon.status.toUpperCase() + '' : ''); + text += '

HP: ' + Pokemon.getHPText(pokemon, this.battle.reportExactHP) + exacthp + (pokemon.status ? ' ' + pokemon.status.toUpperCase() + '' : ''); if (clientPokemon) { if (pokemon.status === 'tox') { if (pokemon.ability === 'Poison Heal' || pokemon.ability === 'Magic Guard') { diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index a5595832f1..c4a6c03603 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -582,9 +582,10 @@ export class Pokemon implements PokemonDetails, PokemonHealth { return percentage * maxWidth / 100; } getHPText(precision = 1) { - return Pokemon.getHPText(this, precision); + return Pokemon.getHPText(this, this.side.battle.reportExactHP, precision); } - static getHPText(pokemon: PokemonHealth, precision = 1) { + static getHPText(pokemon: PokemonHealth, exactHP: boolean, precision = 1) { + if (exactHP) return pokemon.hp + '/' + pokemon.maxhp; if (pokemon.maxhp === 100) return pokemon.hp + '%'; if (pokemon.maxhp !== 48) return (100 * pokemon.hp / pokemon.maxhp).toFixed(precision) + '%'; let range = Pokemon.getPixelRange(pokemon.hp, pokemon.hpcolor); @@ -1097,6 +1098,7 @@ export class Battle { rated: string | boolean = false; rules: {[ruleName: string]: 1 | 0} = {}; isBlitz = false; + reportExactHP = false; endLastTurnPending = false; totalTimeLeft = 0; graceTimeLeft = 0; @@ -3442,6 +3444,7 @@ export class Battle { this.messageFadeTime = 40; this.isBlitz = true; } + if (ruleName === 'Exact HP Mod') this.reportExactHP = true; this.rules[ruleName] = 1; this.log(args); break; From dbba93ce781778043208de42f8166fcd7bd46b46 Mon Sep 17 00:00:00 2001 From: HiZo <96159984+HisuianZoroark@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:26:05 -0400 Subject: [PATCH 2/2] why doesnt lint catch this smh --- play.pokemonshowdown.com/src/battle.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play.pokemonshowdown.com/src/battle.ts b/play.pokemonshowdown.com/src/battle.ts index c4a6c03603..0195b31eeb 100644 --- a/play.pokemonshowdown.com/src/battle.ts +++ b/play.pokemonshowdown.com/src/battle.ts @@ -585,7 +585,7 @@ export class Pokemon implements PokemonDetails, PokemonHealth { return Pokemon.getHPText(this, this.side.battle.reportExactHP, precision); } static getHPText(pokemon: PokemonHealth, exactHP: boolean, precision = 1) { - if (exactHP) return pokemon.hp + '/' + pokemon.maxhp; + if (exactHP) return pokemon.hp + '/' + pokemon.maxhp; if (pokemon.maxhp === 100) return pokemon.hp + '%'; if (pokemon.maxhp !== 48) return (100 * pokemon.hp / pokemon.maxhp).toFixed(precision) + '%'; let range = Pokemon.getPixelRange(pokemon.hp, pokemon.hpcolor); @@ -1098,7 +1098,7 @@ export class Battle { rated: string | boolean = false; rules: {[ruleName: string]: 1 | 0} = {}; isBlitz = false; - reportExactHP = false; + reportExactHP = false; endLastTurnPending = false; totalTimeLeft = 0; graceTimeLeft = 0; @@ -3444,7 +3444,7 @@ export class Battle { this.messageFadeTime = 40; this.isBlitz = true; } - if (ruleName === 'Exact HP Mod') this.reportExactHP = true; + if (ruleName === 'Exact HP Mod') this.reportExactHP = true; this.rules[ruleName] = 1; this.log(args); break;