mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
Added PRE_MOVE lapse code to handle early tag expiration from PP-less encored move
This commit is contained in:
parent
2772fc5b30
commit
a0994c0151
@ -917,7 +917,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
public moveId: Moves;
|
||||
|
||||
constructor(sourceId: number) {
|
||||
super(BattlerTagType.ENCORE, BattlerTagLapseType.AFTER_MOVE, 3, Moves.ENCORE, sourceId);
|
||||
super(BattlerTagType.ENCORE, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.AFTER_MOVE ], 3, Moves.ENCORE, sourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -973,6 +973,24 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the encored move has run out of PP, Encore ends early. Otherwise, Encore lapses based on the AFTER_MOVE battler tag lapse type.
|
||||
* @param pokemon
|
||||
* @param lapseType
|
||||
* @returns `true` to persist | `false` to end and be removed
|
||||
*/
|
||||
override lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||
const encoredMove = pokemon.getMoveset().find(m => m?.moveId === this.moveId);
|
||||
if (encoredMove && encoredMove?.getPpRatio() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return super.lapse(pokemon, lapseType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the move matches the moveId stored within the tag and returns a boolean value
|
||||
* @param move {@linkcode Moves} the move selected
|
||||
|
Loading…
Reference in New Issue
Block a user