mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-15 13:31:40 +00:00
[Move] Partially Implement Instruct (#4857)
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: innerthunder <168692175+innerthunder@users.noreply.github.com> Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
This commit is contained in:
parent
0556e1ad50
commit
1607a694c3
@ -2469,6 +2469,24 @@ export default class BattleScene extends SceneBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to add the input phase to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()}
|
||||||
|
* @param phase {@linkcode Phase} the phase to be added
|
||||||
|
* @param targetPhase {@linkcode Phase} the type of phase to search for in {@linkcode phaseQueue}
|
||||||
|
* @returns `true` if a `targetPhase` was found to append to
|
||||||
|
*/
|
||||||
|
appendToPhase(phase: Phase, targetPhase: Constructor<Phase>): boolean {
|
||||||
|
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase);
|
||||||
|
|
||||||
|
if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) {
|
||||||
|
this.phaseQueue.splice(targetIndex + 1, 0, phase);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.unshiftPhase(phase);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a MessagePhase, either to PhaseQueuePrepend or nextCommandPhaseQueue
|
* Adds a MessagePhase, either to PhaseQueuePrepend or nextCommandPhaseQueue
|
||||||
* @param message string for MessagePhase
|
* @param message string for MessagePhase
|
||||||
|
123
src/data/move.ts
123
src/data/move.ts
@ -6728,6 +6728,126 @@ export class CopyMoveAttr extends OverrideMoveEffectAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute used for moves that causes the target to repeat their last used move.
|
||||||
|
*
|
||||||
|
* Used for [Instruct](https://bulbapedia.bulbagarden.net/wiki/Instruct_(move)).
|
||||||
|
*/
|
||||||
|
export class RepeatMoveAttr extends MoveEffectAttr {
|
||||||
|
constructor() {
|
||||||
|
super(false, { trigger: MoveEffectTrigger.POST_APPLY }); // needed to ensure correct protect interaction
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the target to re-use their last used move again
|
||||||
|
*
|
||||||
|
* @param user {@linkcode Pokemon} that used the attack
|
||||||
|
* @param target {@linkcode Pokemon} targeted by the attack
|
||||||
|
* @param move N/A
|
||||||
|
* @param args N/A
|
||||||
|
* @returns `true` if the move succeeds
|
||||||
|
*/
|
||||||
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
|
// get the last move used (excluding status based failures) as well as the corresponding moveset slot
|
||||||
|
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE)!;
|
||||||
|
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove.move)!;
|
||||||
|
const moveTargets = lastMove.targets ?? [];
|
||||||
|
|
||||||
|
user.scene.queueMessage(i18next.t("moveTriggers:instructingMove", {
|
||||||
|
userPokemonName: getPokemonNameWithAffix(user),
|
||||||
|
targetPokemonName: getPokemonNameWithAffix(target)
|
||||||
|
}));
|
||||||
|
target.getMoveQueue().unshift({ move: lastMove.move, targets: moveTargets, ignorePP: false });
|
||||||
|
target.turnData.extraTurns++;
|
||||||
|
target.scene.appendToPhase(new MovePhase(target.scene, target, moveTargets, movesetMove), MoveEndPhase);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCondition(): MoveConditionFunc {
|
||||||
|
return (user, target, move) => {
|
||||||
|
// TODO: Confirm behavior of instructing move known by target but called by another move
|
||||||
|
const lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE);
|
||||||
|
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move);
|
||||||
|
const moveTargets = lastMove?.targets ?? [];
|
||||||
|
// TODO: Add a way of adding moves to list procedurally rather than a pre-defined blacklist
|
||||||
|
const unrepeatablemoves = [
|
||||||
|
// Locking/Continually Executed moves
|
||||||
|
Moves.OUTRAGE,
|
||||||
|
Moves.RAGING_FURY,
|
||||||
|
Moves.ROLLOUT,
|
||||||
|
Moves.PETAL_DANCE,
|
||||||
|
Moves.THRASH,
|
||||||
|
Moves.ICE_BALL,
|
||||||
|
// Multi-turn Moves
|
||||||
|
Moves.BIDE,
|
||||||
|
Moves.SHELL_TRAP,
|
||||||
|
Moves.BEAK_BLAST,
|
||||||
|
Moves.FOCUS_PUNCH,
|
||||||
|
// "First Turn Only" moves
|
||||||
|
Moves.FAKE_OUT,
|
||||||
|
Moves.FIRST_IMPRESSION,
|
||||||
|
Moves.MAT_BLOCK,
|
||||||
|
// Moves with a recharge turn
|
||||||
|
Moves.HYPER_BEAM,
|
||||||
|
Moves.ETERNABEAM,
|
||||||
|
Moves.FRENZY_PLANT,
|
||||||
|
Moves.BLAST_BURN,
|
||||||
|
Moves.HYDRO_CANNON,
|
||||||
|
Moves.GIGA_IMPACT,
|
||||||
|
Moves.PRISMATIC_LASER,
|
||||||
|
Moves.ROAR_OF_TIME,
|
||||||
|
Moves.ROCK_WRECKER,
|
||||||
|
Moves.METEOR_ASSAULT,
|
||||||
|
// Charging & 2-turn moves
|
||||||
|
Moves.DIG,
|
||||||
|
Moves.FLY,
|
||||||
|
Moves.BOUNCE,
|
||||||
|
Moves.SHADOW_FORCE,
|
||||||
|
Moves.PHANTOM_FORCE,
|
||||||
|
Moves.DIVE,
|
||||||
|
Moves.ELECTRO_SHOT,
|
||||||
|
Moves.ICE_BURN,
|
||||||
|
Moves.GEOMANCY,
|
||||||
|
Moves.FREEZE_SHOCK,
|
||||||
|
Moves.SKY_DROP,
|
||||||
|
Moves.SKY_ATTACK,
|
||||||
|
Moves.SKULL_BASH,
|
||||||
|
Moves.SOLAR_BEAM,
|
||||||
|
Moves.SOLAR_BLADE,
|
||||||
|
Moves.METEOR_BEAM,
|
||||||
|
// Other moves
|
||||||
|
Moves.INSTRUCT,
|
||||||
|
Moves.KINGS_SHIELD,
|
||||||
|
Moves.SKETCH,
|
||||||
|
Moves.TRANSFORM,
|
||||||
|
Moves.MIMIC,
|
||||||
|
Moves.STRUGGLE,
|
||||||
|
// TODO: Add Max/G-Move blockage if or when they are implemented
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!movesetMove // called move not in target's moveset (dancer, forgetting the move, etc.)
|
||||||
|
|| movesetMove.ppUsed === movesetMove.getMovePp() // move out of pp
|
||||||
|
|| allMoves[lastMove?.move ?? Moves.NONE].isChargingMove() // called move is a charging/recharging move
|
||||||
|
|| !moveTargets.length // called move has no targets
|
||||||
|
|| unrepeatablemoves.includes(lastMove?.move ?? Moves.NONE)) { // called move is explicitly in the banlist
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
|
// TODO: Make the AI acutally use instruct
|
||||||
|
/* Ideally, the AI would score instruct based on the scorings of the on-field pokemons'
|
||||||
|
* last used moves at the time of using Instruct (by the time the instructor gets to act)
|
||||||
|
* with respect to the user's side.
|
||||||
|
* In 99.9% of cases, this would be the pokemon's ally (unless the target had last
|
||||||
|
* used a move like Decorate on the user or its ally)
|
||||||
|
*/
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute used for moves that reduce PP of the target's last used move.
|
* Attribute used for moves that reduce PP of the target's last used move.
|
||||||
* Used for Spite.
|
* Used for Spite.
|
||||||
@ -9892,7 +10012,8 @@ export function initMoves() {
|
|||||||
.attr(StatStageChangeAttr, [ Stat.ATK ], -1),
|
.attr(StatStageChangeAttr, [ Stat.ATK ], -1),
|
||||||
new StatusMove(Moves.INSTRUCT, Type.PSYCHIC, -1, 15, -1, 0, 7)
|
new StatusMove(Moves.INSTRUCT, Type.PSYCHIC, -1, 15, -1, 0, 7)
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.unimplemented(),
|
.attr(RepeatMoveAttr)
|
||||||
|
.edgeCase(), // incorrect interactions with Gigaton Hammer, Blood Moon & Torment
|
||||||
new AttackMove(Moves.BEAK_BLAST, Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, -3, 7)
|
new AttackMove(Moves.BEAK_BLAST, Type.FLYING, MoveCategory.PHYSICAL, 100, 100, 15, -1, -3, 7)
|
||||||
.attr(BeakBlastHeaderAttr)
|
.attr(BeakBlastHeaderAttr)
|
||||||
.ballBombMove()
|
.ballBombMove()
|
||||||
|
@ -5294,6 +5294,7 @@ export class PokemonBattleSummonData {
|
|||||||
export class PokemonTurnData {
|
export class PokemonTurnData {
|
||||||
public flinched: boolean = false;
|
public flinched: boolean = false;
|
||||||
public acted: boolean = false;
|
public acted: boolean = false;
|
||||||
|
/** How many times the move should hit the target(s) */
|
||||||
public hitCount: number = 0;
|
public hitCount: number = 0;
|
||||||
/**
|
/**
|
||||||
* - `-1` = Calculate how many hits are left
|
* - `-1` = Calculate how many hits are left
|
||||||
@ -5312,6 +5313,11 @@ export class PokemonTurnData {
|
|||||||
public switchedInThisTurn: boolean = false;
|
public switchedInThisTurn: boolean = false;
|
||||||
public failedRunAway: boolean = false;
|
public failedRunAway: boolean = false;
|
||||||
public joinedRound: boolean = false;
|
public joinedRound: boolean = false;
|
||||||
|
/**
|
||||||
|
* Used to make sure multi-hits occur properly when the user is
|
||||||
|
* forced to act again in the same turn
|
||||||
|
*/
|
||||||
|
public extraTurns: number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AiType {
|
export enum AiType {
|
||||||
|
@ -127,6 +127,14 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
|
|
||||||
user.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
|
user.lapseTags(BattlerTagLapseType.MOVE_EFFECT);
|
||||||
|
|
||||||
|
// If the user is acting again (such as due to Instruct), reset hitsLeft/hitCount so that
|
||||||
|
// the move executes correctly (ensures all hits of a multi-hit are properly calculated)
|
||||||
|
if (user.turnData.hitsLeft === 0 && user.turnData.hitCount > 0 && user.turnData.extraTurns > 0) {
|
||||||
|
user.turnData.hitsLeft = -1;
|
||||||
|
user.turnData.hitCount = 0;
|
||||||
|
user.turnData.extraTurns--;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this phase is for the first hit of the invoked move,
|
* If this phase is for the first hit of the invoked move,
|
||||||
* resolve the move's total hit count. This block combines the
|
* resolve the move's total hit count. This block combines the
|
||||||
@ -313,7 +321,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Promise that applys *all* effects from the invoked move's MoveEffectAttrs.
|
* Create a Promise that applies *all* effects from the invoked move's MoveEffectAttrs.
|
||||||
* These are ordered by trigger type (see {@linkcode MoveEffectTrigger}), and each trigger
|
* These are ordered by trigger type (see {@linkcode MoveEffectTrigger}), and each trigger
|
||||||
* type requires different conditions to be met with respect to the move's hit result.
|
* type requires different conditions to be met with respect to the move's hit result.
|
||||||
*/
|
*/
|
||||||
|
315
src/test/moves/instruct.test.ts
Normal file
315
src/test/moves/instruct.test.ts
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import type Pokemon from "#app/field/pokemon";
|
||||||
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
import { Abilities } from "#enums/abilities";
|
||||||
|
import { Moves } from "#enums/moves";
|
||||||
|
import { Species } from "#enums/species";
|
||||||
|
import GameManager from "#test/utils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Moves - Instruct", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
function instructSuccess(pokemon: Pokemon, move: Moves): void {
|
||||||
|
expect(pokemon.getLastXMoves(-1)[0].move).toBe(move);
|
||||||
|
expect(pokemon.getLastXMoves(-1)[1].move).toBe(pokemon.getLastXMoves()[0].move);
|
||||||
|
expect(pokemon.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
|
.battleType("single")
|
||||||
|
.enemySpecies(Species.SHUCKLE)
|
||||||
|
.enemyAbility(Abilities.NO_GUARD)
|
||||||
|
.enemyLevel(100)
|
||||||
|
.startingLevel(100)
|
||||||
|
.ability(Abilities.BALL_FETCH)
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.SONIC_BOOM, Moves.SPLASH, Moves.TORMENT ])
|
||||||
|
.disableCrits();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat enemy's attack move when moving last", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, Moves.SONIC_BOOM);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(enemy, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat enemy's move through substitute", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, [ Moves.SONIC_BOOM, Moves.SUBSTITUTE ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SUBSTITUTE);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should repeat ally's attack on enemy", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.moveset([]);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
const [ amoonguss, shuckle ] = game.scene.getPlayerField();
|
||||||
|
game.move.changeMoveset(amoonguss, Moves.INSTRUCT);
|
||||||
|
game.move.changeMoveset(shuckle, Moves.SONIC_BOOM);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
|
||||||
|
game.move.select(Moves.SONIC_BOOM, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getEnemyField()[0].getInverseHp()).toBe(40);
|
||||||
|
instructSuccess(shuckle, Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Enable test case once gigaton hammer (and blood moon) is fixed
|
||||||
|
it.todo("should repeat enemy's Gigaton Hammer", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemy, Moves.GIGATON_HAMMER);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
instructSuccess(enemy, Moves.GIGATON_HAMMER);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should respect enemy's status condition", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset([ Moves.THUNDER_WAVE, Moves.INSTRUCT ])
|
||||||
|
.enemyMoveset([ Moves.SPLASH, Moves.SONIC_BOOM ]);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.THUNDER_WAVE);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.move.forceStatusActivation(true);
|
||||||
|
await game.phaseInterceptor.to("MovePhase");
|
||||||
|
await game.move.forceStatusActivation(false);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
const moveHistory = game.scene.getEnemyPokemon()!.getMoveHistory();
|
||||||
|
expect(moveHistory.length).toBe(3);
|
||||||
|
expect(moveHistory[0].move).toBe(Moves.SONIC_BOOM);
|
||||||
|
expect(moveHistory[1].move).toBe(Moves.NONE);
|
||||||
|
expect(moveHistory[2].move).toBe(Moves.SONIC_BOOM);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's out of pp move", async () => {
|
||||||
|
game.override.enemySpecies(Species.UNOWN);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemyPokemon, Moves.HIDDEN_POWER);
|
||||||
|
const moveUsed = enemyPokemon.moveset.find(m => m?.moveId === Moves.HIDDEN_POWER)!;
|
||||||
|
moveUsed.ppUsed = moveUsed.getMovePp() - 1;
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.HIDDEN_POWER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
const playerMove = game.scene.getPlayerPokemon()!.getLastXMoves()!;
|
||||||
|
expect(playerMove[0].result).toBe(MoveResult.FAIL);
|
||||||
|
expect(enemyPokemon.getMoveHistory().length).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail if no move has yet been used by target", async () => {
|
||||||
|
game.override.enemyMoveset(Moves.SPLASH);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerPokemon()!.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should attempt to call enemy's disabled move, but move use itself should fail", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.DISABLE ])
|
||||||
|
.battleType("double");
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.DROWZEE ]);
|
||||||
|
|
||||||
|
const [ enemy1, enemy2 ] = game.scene.getEnemyField();
|
||||||
|
game.move.changeMoveset(enemy1, Moves.SONIC_BOOM);
|
||||||
|
game.move.changeMoveset(enemy2, Moves.SPLASH);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
const enemyMove = game.scene.getEnemyPokemon()!.getLastXMoves()[0];
|
||||||
|
expect(enemyMove.result).toBe(MoveResult.FAIL);
|
||||||
|
expect(game.scene.getEnemyPokemon()!.getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's move through protect", async () => {
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
const MoveToUse = Moves.PROTECT;
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
game.move.changeMoveset(enemyPokemon, MoveToUse);
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.PROTECT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(enemyPokemon.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT);
|
||||||
|
expect(enemyPokemon.getLastXMoves(-1)[1]).toBeUndefined(); // undefined because protect failed
|
||||||
|
expect(enemyPokemon.getMoveset().find(m => m?.moveId === Moves.PROTECT)?.ppUsed).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat enemy's charging move", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyMoveset([ Moves.SONIC_BOOM, Moves.HYPER_BEAM ])
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.SONIC_BOOM, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }];
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.forceEnemyMove(Moves.HYPER_BEAM);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat dance move not known by target", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.moveset([ Moves.INSTRUCT, Moves.FIERY_DANCE ])
|
||||||
|
.enemyMoveset(Moves.SPLASH)
|
||||||
|
.enemyAbility(Abilities.DANCER);
|
||||||
|
await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyAbility(Abilities.SKILL_LINK)
|
||||||
|
.enemyMoveset(Moves.BULLET_SEED);
|
||||||
|
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||||
|
|
||||||
|
const player = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(player.turnData.attacksReceived.length).toBe(10);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(player.turnData.attacksReceived.length).toBe(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyAbility(Abilities.SKILL_LINK)
|
||||||
|
.enemyMoveset([ Moves.BULLET_SEED, Moves.SPLASH ])
|
||||||
|
.enemyLevel(5);
|
||||||
|
await game.classicMode.startBattle([ Species.BULBASAUR, Species.IVYSAUR ]);
|
||||||
|
|
||||||
|
const [ , ivysaur ] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH);
|
||||||
|
game.move.select(Moves.SPLASH, 1);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
||||||
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,6 @@
|
|||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import type Pokemon from "#app/field/pokemon";
|
||||||
|
import { PokemonMove } from "#app/field/pokemon";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||||
@ -71,4 +73,21 @@ export class MoveHelper extends GameManagerHelper {
|
|||||||
await this.game.phaseInterceptor.to("MovePhase");
|
await this.game.phaseInterceptor.to("MovePhase");
|
||||||
vi.spyOn(Overrides, "STATUS_ACTIVATION_OVERRIDE", "get").mockReturnValue(null);
|
vi.spyOn(Overrides, "STATUS_ACTIVATION_OVERRIDE", "get").mockReturnValue(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when the normal moveset override can't be used (such as when it's necessary to check updated properties of the moveset).
|
||||||
|
* @param pokemon - The pokemon being modified
|
||||||
|
* @param moveset - The moveset to use
|
||||||
|
*/
|
||||||
|
public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void {
|
||||||
|
if (!Array.isArray(moveset)) {
|
||||||
|
moveset = [ moveset ];
|
||||||
|
}
|
||||||
|
pokemon.moveset = [];
|
||||||
|
moveset.forEach((move) => {
|
||||||
|
pokemon.moveset.push(new PokemonMove(move));
|
||||||
|
});
|
||||||
|
const movesetStr = moveset.map((moveId) => Moves[moveId]).join(", ");
|
||||||
|
console.log(`Pokemon ${pokemon.species.name}'s moveset manually set to ${movesetStr} (=[${moveset.join(", ")}])!`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user