Skip to content

Commit

Permalink
Display exact HP when using Exact HP Mod (#2280)
Browse files Browse the repository at this point in the history
* Display information current and max HP when using Exact HP Mod

* why doesnt lint catch this smh
  • Loading branch information
HisuianZoroark authored Nov 18, 2024
1 parent c32f5e2 commit e4c54ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle-animations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,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();
Expand Down
2 changes: 1 addition & 1 deletion play.pokemonshowdown.com/src/battle-tooltips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ class BattleTooltips {
} else if (pokemon.maxhp === 48) {
exacthp = ' <small>(' + pokemon.hp + '/' + pokemon.maxhp + ' pixels)</small>';
}
text += '<p><small>HP:</small> ' + Pokemon.getHPText(pokemon) + exacthp + (pokemon.status ? ' <span class="status ' + pokemon.status + '">' + pokemon.status.toUpperCase() + '</span>' : '');
text += '<p><small>HP:</small> ' + Pokemon.getHPText(pokemon, this.battle.reportExactHP) + exacthp + (pokemon.status ? ' <span class="status ' + pokemon.status + '">' + pokemon.status.toUpperCase() + '</span>' : '');
if (clientPokemon) {
if (pokemon.status === 'tox') {
if (pokemon.ability === 'Poison Heal' || pokemon.ability === 'Magic Guard') {
Expand Down
7 changes: 5 additions & 2 deletions play.pokemonshowdown.com/src/battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3444,6 +3446,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;
Expand Down

0 comments on commit e4c54ac

Please sign in to comment.