[Refactor] Add utility method PokemonMove#isOutOfPP (#6863)

* [Refactor] Add utility method `PokemonMove#isOutOfPP`

* Update src/data/moves/pokemon-move.ts

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
Bertie690 2025-12-23 17:26:42 -05:00 committed by GitHub
parent 1c8ebbeed5
commit bcfa87ce79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,13 +93,14 @@ export class PokemonMove {
}
/**
* Sets {@link ppUsed} for this move and ensures the value does not exceed {@link getMovePp}
* @param count Amount of PP to use
* Consume up to `count` PP from this move (up to its maximum PP).
* @param count - (Default `1`) The amount of PP to use
*/
usePp(count = 1) {
public usePp(count = 1): void {
this.ppUsed = Math.min(this.ppUsed + count, this.getMovePp());
}
// TODO: Rename to `getMaxPP`; the current name is obscure and frankly stupid
getMovePp(): number {
return this.maxPpOverride || this.getMove().pp + this.ppUp * toDmgValue(this.getMove().pp / 5);
}
@ -108,6 +109,14 @@ export class PokemonMove {
return 1 - this.ppUsed / this.getMovePp();
}
/**
* @returns Whether this move is out of PP.
*/
// TODO: Replace checks comparing `getPpRatio` with 0 to use this instead
public isOutOfPp(): boolean {
return this.getMovePp() !== -1 && this.ppUsed >= this.getMovePp();
}
getName(): string {
return this.getMove().name;
}