Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});