[Move] Make Disable disable most recent move instead of oldest move (#5321)

This commit is contained in:
Xavion3 2025-02-18 13:53:57 +11:00 committed by GitHub
parent 5fa77b7177
commit 8864347cb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View File

@ -42,6 +42,7 @@ import { Species } from "#enums/species";
import { EFFECTIVE_STATS, getStatKey, Stat, type BattleStat, type EffectiveStat } from "#enums/stat";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
import * as Utils from "../utils";
export enum BattlerTagLapseType {
FAINT,
@ -274,9 +275,9 @@ export class DisabledTag extends MoveRestrictionBattlerTag {
override onAdd(pokemon: Pokemon): void {
super.onAdd(pokemon);
const move = pokemon.getLastXMoves()
.find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual);
if (move === undefined) {
const move = pokemon.getLastXMoves(-1)
.find(m => !m.virtual);
if (Utils.isNullOrUndefined(move) || move.move === Moves.STRUGGLE || move.move === Moves.NONE) {
return;
}

View File

@ -8506,7 +8506,10 @@ export function initMoves() {
.attr(FixedDamageAttr, 20),
new StatusMove(Moves.DISABLE, Type.NORMAL, 100, 20, -1, 0, 1)
.attr(AddBattlerTagAttr, BattlerTagType.DISABLED, false, true)
.condition((user, target, move) => target.getMoveHistory().reverse().find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual) !== undefined)
.condition((user, target, move) => {
const lastRealMove = target.getLastXMoves(-1).find(m => !m.virtual);
return !Utils.isNullOrUndefined(lastRealMove) && lastRealMove.move !== Moves.NONE && lastRealMove.move !== Moves.STRUGGLE;
})
.ignoresSubstitute()
.reflectable(),
new AttackMove(Moves.ACID, Type.POISON, MoveCategory.SPECIAL, 40, 100, 30, 10, 0, 1)

View File

@ -123,6 +123,26 @@ describe("Moves - Disable", () => {
await game.toNextTurn();
expect(enemyMon.isMoveRestricted(Moves.NATURE_POWER)).toBe(true);
expect(enemyMon.isMoveRestricted(enemyMon.getLastXMoves(2)[1].move)).toBe(false);
expect(enemyMon.isMoveRestricted(enemyMon.getLastXMoves(2)[0].move)).toBe(false);
}, 20000);
it("disables most recent move", async() => {
game.override.enemyMoveset([ Moves.SPLASH, Moves.TACKLE ]);
await game.classicMode.startBattle();
const enemyMon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.SPLASH);
await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextTurn();
game.move.select(Moves.DISABLE);
await game.forceEnemyMove(Moves.TACKLE, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextTurn();
expect(enemyMon.isMoveRestricted(Moves.TACKLE)).toBe(true);
expect(enemyMon.isMoveRestricted(Moves.SPLASH)).toBe(false);
}, 20000);
});