Don't use failure text as a condition for move success

A move defining potential failure text doesn't mean it failed
This commit is contained in:
NightKev 2024-09-14 04:56:55 -07:00
parent 8e82dfae45
commit ea39ca8706
1 changed files with 13 additions and 10 deletions

View File

@ -244,15 +244,16 @@ export class MovePhase extends BattlePhase {
const move = this.move.getMove(); const move = this.move.getMove();
// Move conditions assume the move has a single target /**
// TODO: is this sustainable? * Move conditions assume the move has a single target
* TODO: is this sustainable?
*/
const passesConditions = move.applyConditions(this.pokemon, targets[0], move); const passesConditions = move.applyConditions(this.pokemon, targets[0], move);
const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new Utils.BooleanHolder(false));
const failedWithMessage = failureMessage !== null && failureMessage !== undefined; let failedDueToWeather: boolean = false;
let failedDueToWeather: boolean, failedDueToTerrain: boolean; let failedDueToTerrain: boolean = false;
if (!failedWithMessage) { if (!passesConditions) {
failedDueToWeather = this.scene.arena.isMoveWeatherCancelled(this.pokemon, move); failedDueToWeather = this.scene.arena.isMoveWeatherCancelled(this.pokemon, move);
if (!failedDueToWeather) { if (!failedDueToWeather) {
@ -260,8 +261,7 @@ export class MovePhase extends BattlePhase {
} }
} }
// @ts-expect-error const success = passesConditions && !failedDueToWeather && !failedDueToTerrain;
const success = passesConditions && !failedWithMessage && !failedDueToWeather && !failedDueToTerrain;
/** /**
* If the move has not failed, trigger ability-based user type changes and then execute it. * If the move has not failed, trigger ability-based user type changes and then execute it.
@ -283,10 +283,10 @@ export class MovePhase extends BattlePhase {
this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual }); this.pokemon.pushMoveHistory({ move: this.move.moveId, targets: this.targets, result: MoveResult.FAIL, virtual: this.move.virtual });
let failedText: string | undefined; let failedText: string | undefined;
const failureMessage = move.getFailedText(this.pokemon, targets[0], move, new Utils.BooleanHolder(false));
if (failedWithMessage) { if (failureMessage) {
failedText = failureMessage; failedText = failureMessage;
// @ts-expect-error
} else if (failedDueToTerrain) { } else if (failedDueToTerrain) {
failedText = getTerrainBlockMessage(this.pokemon, this.scene.arena.getTerrainType()); failedText = getTerrainBlockMessage(this.pokemon, this.scene.arena.getTerrainType());
} }
@ -405,6 +405,8 @@ export class MovePhase extends BattlePhase {
* to lapse on move failure/cancellation. * to lapse on move failure/cancellation.
* *
* TODO: ...this seems weird. * TODO: ...this seems weird.
* - Lapses `AFTER_MOVE` tags:
* - This handles the effects of {@linkcode Moves.SUBSTITUTE}
* - Removes the second turn of charge moves * - Removes the second turn of charge moves
* *
* TODO: handle charge moves more gracefully * TODO: handle charge moves more gracefully
@ -424,6 +426,7 @@ export class MovePhase extends BattlePhase {
this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL }); this.pokemon.pushMoveHistory({ move: Moves.NONE, result: MoveResult.FAIL });
this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT); this.pokemon.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
this.pokemon.lapseTags(BattlerTagLapseType.AFTER_MOVE);
this.pokemon.getMoveQueue().shift(); this.pokemon.getMoveQueue().shift();
} }