mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-24 18:49:16 +01:00
[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:
parent
1c8ebbeed5
commit
bcfa87ce79
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user