Skip to content

Commit

Permalink
[Move] Make Disable disable most recent move instead of oldest move (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavion3 authored Feb 18, 2025
1 parent 5fa77b7 commit 8864347
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/data/battler-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion src/data/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 21 additions & 1 deletion src/test/moves/disable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 8864347

Please sign in to comment.