mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-08 01:12:17 +02:00
Move cancellation logic back to tag
Wanted to increase similarity to the existing code base to avoid that stupid hyper beam error but it's still happening here
This commit is contained in:
parent
b6a5f29873
commit
f6b41e33f1
@ -101,13 +101,26 @@ export abstract class DisablingBattlerTag extends BattlerTag {
|
||||
public abstract moveIsDisabled(move: Moves): boolean;
|
||||
|
||||
constructor(tagType: BattlerTagType, turnCount: integer, sourceMove?: Moves, sourceId?: integer) {
|
||||
super(tagType, BattlerTagLapseType.TURN_END, turnCount, sourceMove, sourceId);
|
||||
super(tagType, [ BattlerTagLapseType.PRE_MOVE, BattlerTagLapseType.TURN_END ], turnCount, sourceMove, sourceId);
|
||||
}
|
||||
|
||||
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
|
||||
if (!super.lapse(pokemon, lapseType)) {
|
||||
// Duration has expired
|
||||
return false;
|
||||
if (lapseType === BattlerTagLapseType.PRE_MOVE) {
|
||||
// Cancel the affected pokemon's selected move
|
||||
const phase = pokemon.scene.getCurrentPhase() as MovePhase;
|
||||
const move = phase.move;
|
||||
|
||||
if (!this.moveIsDisabled(move.moveId)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
pokemon.scene.queueMessage(this.interruptedText(pokemon, move.moveId));
|
||||
phase.fail();
|
||||
} else if (lapseType === BattlerTagLapseType.TURN_END) {
|
||||
// On turn end, subtract from lifetime and remove this tag if 0
|
||||
if (!super.lapse(pokemon, lapseType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -3634,7 +3634,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
if (!this.isFainted()) {
|
||||
// If this Pokemon hasn't fainted, make sure the HP wasn't set over the new maximum
|
||||
this.hp = Math.min(this.hp, this.stats[Stat.HP]);
|
||||
this.status = getRandomStatus(this.status, pokemon.status); // Get a random valid status between the two
|
||||
this.status = getRandomStatus(this.status!, pokemon.status!); // Get a random valid status between the two // TODO: are the bangs correct?
|
||||
} else if (!pokemon.isFainted()) {
|
||||
// If this Pokemon fainted but the other hasn't, make sure the HP wasn't set to zero
|
||||
this.hp = Math.max(this.hp, 1);
|
||||
@ -4331,12 +4331,12 @@ export class PokemonMove {
|
||||
* @param ignorePp If true, skips the PP check
|
||||
* @returns True if the move can be selected and used by the Pokemon, otherwise false.
|
||||
*/
|
||||
isUsable(pokemon: Pokemon, ignorePp?: boolean): boolean {
|
||||
isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreDisableTags?: boolean): boolean {
|
||||
if (!this.moveId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pokemon.isMoveDisabled(this.moveId)) {
|
||||
if (!ignoreDisableTags && pokemon.isMoveDisabled(this.moveId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2666,8 +2666,8 @@ export class MovePhase extends BattlePhase {
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
canMove(): boolean {
|
||||
return this.pokemon.isActive(true) && this.move.isUsable(this.pokemon, this.ignorePp) && !!this.targets.length;
|
||||
canMove(ignoreDisableTags?: boolean): boolean {
|
||||
return this.pokemon.isActive(true) && this.move.isUsable(this.pokemon, this.ignorePp, ignoreDisableTags) && !!this.targets.length;
|
||||
}
|
||||
|
||||
/**Signifies the current move should fail but still use PP */
|
||||
@ -2685,13 +2685,8 @@ export class MovePhase extends BattlePhase {
|
||||
|
||||
console.log(Moves[this.move.moveId]);
|
||||
|
||||
if (!this.canMove()) {
|
||||
if (this.move.moveId && this.pokemon.isMoveDisabled(this.move.moveId)) {
|
||||
const interruptingTag = this.pokemon.getDisablingTag(this.move.moveId)!;
|
||||
this.scene.queueMessage(interruptingTag.interruptedText(this.pokemon, this.move.moveId));
|
||||
this.pokemon.pushMoveHistory({ move: this.move.moveId, result: MoveResult.FAIL, virtual: false });
|
||||
this.fail();
|
||||
} else if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) { // if the move PP was reduced from Spite or otherwise, the move fails
|
||||
if (!this.canMove(true)) {
|
||||
if (this.pokemon.isActive(true) && this.move.ppUsed >= this.move.getMovePp()) { // if the move PP was reduced from Spite or otherwise, the move fails
|
||||
this.fail();
|
||||
this.showMoveText();
|
||||
this.showFailedText();
|
||||
|
Loading…
Reference in New Issue
Block a user