Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display exact HP when using Exact HP Mod #2280

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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();
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 @@ -3442,6 +3444,7 @@ export class Battle {
this.messageFadeTime = 40;
this.isBlitz = true;
}
if (ruleName === 'Exact HP Mod') this.reportExactHP = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you making a new property instead of checking this.rules['Exact HP Mod']

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was primarily was looking at something else was implemented and decided to mirror, if it should be checked that way then sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left blitz and species clause when I added the rules object just to minimize refactoring at the time, but I think any new code that needs rules should just use the rules object if the only thing that needs to be checked is if the rule is in play.

this.rules[ruleName] = 1;
this.log(args);
break;
Expand Down
Loading