Fixed stuff

This commit is contained in:
Bertie690 2025-01-10 20:41:34 -05:00
parent 06926a4b2d
commit 08d59f3e49
7 changed files with 133 additions and 97 deletions

View File

@ -6784,10 +6784,8 @@ export class RepeatMoveAttr extends MoveEffectAttr {
getCondition(): MoveConditionFunc { getCondition(): MoveConditionFunc {
return (user, target, move) => { 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 lastMove = target.getLastXMoves(-1).find(m => m.move !== Moves.NONE);
const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move); const movesetMove = target.getMoveset().find(m => m?.moveId === lastMove?.move);
// TODO: Add a way of adding moves to list procedurally rather than a pre-defined blacklist
const uninstructableMoves = [ const uninstructableMoves = [
// Locking/Continually Executed moves // Locking/Continually Executed moves
Moves.OUTRAGE, Moves.OUTRAGE,
@ -6844,7 +6842,7 @@ export class RepeatMoveAttr extends MoveEffectAttr {
]; ];
if (!lastMove?.move // no move to instruct if (!lastMove?.move // no move to instruct
|| !movesetMove // called move not in target's moveset (dancer, forgetting the move, etc.) || !movesetMove // called move not in target's moveset (forgetting the move, etc.)
|| movesetMove.ppUsed === movesetMove.getMovePp() // move out of pp || movesetMove.ppUsed === movesetMove.getMovePp() // move out of pp
|| allMoves[lastMove.move].isChargingMove() // called move is a charging/recharging move || allMoves[lastMove.move].isChargingMove() // called move is a charging/recharging move
|| uninstructableMoves.includes(lastMove.move)) { // called move is in the banlist || uninstructableMoves.includes(lastMove.move)) { // called move is in the banlist

View File

@ -21,7 +21,7 @@ import { WeatherType } from "#enums/weather-type";
* *
* Any override added here will be used instead of the value in {@linkcode DefaultOverrides} * Any override added here will be used instead of the value in {@linkcode DefaultOverrides}
* *
* If an override name starts with "STARTING", it will apply when a new run begins * If an override name starts with "STARTING", it will only apply when a new run begins.
* *
* @example * @example
* ``` * ```
@ -31,14 +31,19 @@ import { WeatherType } from "#enums/weather-type";
* } * }
* ``` * ```
*/ */
const overrides = {} satisfies Partial<InstanceType<typeof DefaultOverrides>>; const overrides = {
OPP_MOVESET_OVERRIDE: Moves.INSTRUCT,
XP_MULTIPLIER_OVERRIDE: 50,
BATTLE_TYPE_OVERRIDE: "single",
ITEM_REWARD_OVERRIDE: [{ name: "MEMORY_MUSHROOM", count: 1 }]
} satisfies Partial<InstanceType<typeof DefaultOverrides>>;
/** /**
* If you need to add Overrides values for local testing do that inside {@linkcode overrides} * If you need to add Overrides values for local testing do that inside {@linkcode overrides}
* --- * ---
* Defaults for Overrides that are used when testing different in game situations * Defaults for Overrides that are used when testing different in game situations
* *
* If an override name starts with "STARTING", it will apply when a new run begins * If an override name starts with "STARTING", it will only apply when a new run begins.
*/ */
class DefaultOverrides { class DefaultOverrides {
// ----------------- // -----------------

View File

@ -25,7 +25,7 @@ export enum LearnMoveType {
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
private moveId: Moves; private moveId: Moves;
private messageMode: Mode; private messageMode: Mode;
private learnMoveType; private learnMoveType: LearnMoveType;
private cost: number; private cost: number;
constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) { constructor(scene: BattleScene, partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {

View File

@ -3,6 +3,7 @@ import { Button } from "#app/enums/buttons";
import type Pokemon from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon";
import { MoveResult } from "#app/field/pokemon"; import { MoveResult } from "#app/field/pokemon";
import type { MovePhase } from "#app/phases/move-phase"; import type { MovePhase } from "#app/phases/move-phase";
import { Mode } from "#app/ui/ui";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
@ -39,18 +40,18 @@ describe("Moves - Instruct", () => {
.enemyLevel(100) .enemyLevel(100)
.startingLevel(100) .startingLevel(100)
.ability(Abilities.BALL_FETCH) .ability(Abilities.BALL_FETCH)
.moveset([ Moves.INSTRUCT, Moves.SONIC_BOOM, Moves.SPLASH, Moves.TORMENT ])
.disableCrits(); .disableCrits();
}); });
it("should repeat target's last used move", async () => { it("should repeat target's last used move", async () => {
game.override.moveset(Moves.INSTRUCT);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
game.move.changeMoveset(enemy, Moves.SONIC_BOOM); game.move.changeMoveset(enemy, Moves.SONIC_BOOM);
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.INSTRUCT);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.SONIC_BOOM);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("MovePhase"); // enemy attacks us await game.phaseInterceptor.to("MovePhase"); // enemy attacks us
@ -65,11 +66,12 @@ describe("Moves - Instruct", () => {
expect(currentPhase.move.moveId).toBe(Moves.SONIC_BOOM); expect(currentPhase.move.moveId).toBe(Moves.SONIC_BOOM);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
instructSuccess(enemy, Moves.SONIC_BOOM); instructSuccess(enemy, Moves.SONIC_BOOM);
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
}); });
it("should repeat enemy's move through substitute", async () => { it("should repeat enemy's move through substitute", async () => {
game.override.moveset([ Moves.INSTRUCT, Moves.SPLASH ]);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
@ -85,34 +87,34 @@ describe("Moves - Instruct", () => {
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM); instructSuccess(game.scene.getEnemyPokemon()!, Moves.SONIC_BOOM);
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
}); });
it("should repeat ally's attack on enemy", async () => { it("should repeat ally's attack on enemy", async () => {
game.override game.override
.battleType("double") .battleType("double")
.moveset([]); .enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.SHUCKLE ]); await game.classicMode.startBattle([ Species.AMOONGUSS, Species.SHUCKLE ]);
const [ amoonguss, shuckle ] = game.scene.getPlayerField(); const [ amoonguss, shuckle ] = game.scene.getPlayerField();
game.move.changeMoveset(amoonguss, Moves.INSTRUCT); game.move.changeMoveset(amoonguss, [ Moves.INSTRUCT, Moves.SONIC_BOOM ]);
game.move.changeMoveset(shuckle, Moves.SONIC_BOOM); game.move.changeMoveset(shuckle, [ Moves.INSTRUCT, Moves.SONIC_BOOM ]);
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2);
game.move.select(Moves.SONIC_BOOM, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); 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.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(game.scene.getEnemyField()[0].getInverseHp()).toBe(40);
instructSuccess(shuckle, Moves.SONIC_BOOM); instructSuccess(shuckle, Moves.SONIC_BOOM);
expect(game.scene.getEnemyField()[0].getInverseHp()).toBe(40);
}); });
// TODO: Enable test case once gigaton hammer (and blood moon) are reworked // TODO: Enable test case once gigaton hammer (and blood moon) are reworked
it.todo("should repeat enemy's Gigaton Hammer", async () => { it.todo("should repeat enemy's Gigaton Hammer", async () => {
game.override.enemyLevel(5); game.override
.moveset(Moves.INSTRUCT)
.enemyLevel(5);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
const enemy = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
@ -138,7 +140,8 @@ describe("Moves - Instruct", () => {
game.move.select(Moves.INSTRUCT); game.move.select(Moves.INSTRUCT);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("MovePhase"); await game.phaseInterceptor.to("MovePhase");
await game.move.forceStatusActivation(true); // force enemy's instructed move to bork and then immediately thaw out // force enemy's instructed move to bork and then immediately thaw out
await game.move.forceStatusActivation(true);
await game.move.forceStatusActivation(false); await game.move.forceStatusActivation(false);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
@ -147,26 +150,10 @@ describe("Moves - Instruct", () => {
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40); expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
}); });
it("should repeat move with no targets, but move should immediately fail", async () => {
game.override.battleType("double");
await game.classicMode.startBattle([ Species.BRUTE_BONNET, Species.VOLCARONA ]);
const [ , volcarona ] = game.scene.getPlayerField();
game.move.changeMoveset(volcarona, [ Moves.INSTRUCT, Moves.SPLASH, Moves.BUG_BITE ]);
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
game.move.select(Moves.BUG_BITE, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER_2);
await game.forceEnemyMove(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.toNextTurn();
// attack #2 failed due to brute bonnet having already fainted
instructSuccess(volcarona, Moves.BUG_BITE);
expect(volcarona.getLastXMoves(-1)[0].result).toBe(MoveResult.FAIL);
});
it("should not repeat enemy's out of pp move", async () => { it("should not repeat enemy's out of pp move", async () => {
game.override.enemySpecies(Species.UNOWN); game.override
.moveset(Moves.INSTRUCT)
.enemySpecies(Species.UNOWN);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
@ -179,13 +166,15 @@ describe("Moves - Instruct", () => {
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
const playerMove = game.scene.getPlayerPokemon()!.getLastXMoves()!; const playerMoves = game.scene.getPlayerPokemon()!.getLastXMoves(-1)!;
expect(playerMove[0].result).toBe(MoveResult.FAIL); expect(playerMoves[0].result).toBe(MoveResult.FAIL);
expect(enemyPokemon.getMoveHistory().length).toBe(1); expect(enemyPokemon.getMoveHistory().length).toBe(1);
}); });
it("should fail if no move has yet been used by target", async () => { it("should fail if no move has yet been used by target", async () => {
game.override.enemyMoveset(Moves.SPLASH); game.override
.moveset(Moves.INSTRUCT)
.enemyMoveset(Moves.SPLASH);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
game.move.select(Moves.INSTRUCT); game.move.select(Moves.INSTRUCT);
@ -209,25 +198,28 @@ describe("Moves - Instruct", () => {
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); game.move.select(Moves.DISABLE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER); 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.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); expect(game.scene.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
const enemyMove = game.scene.getEnemyPokemon()!.getLastXMoves()[0]; const enemyMove = game.scene.getEnemyField()[0]!.getLastXMoves()[0];
expect(enemyMove.result).toBe(MoveResult.FAIL); expect(enemyMove.result).toBe(MoveResult.FAIL);
expect(game.scene.getEnemyPokemon()!.getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1); expect(game.scene.getEnemyField()[0].getMoveset().find(m => m?.moveId === Moves.SONIC_BOOM)?.ppUsed).toBe(1);
}); });
it("should allow for dancer copying of instructed dance move", async () => { it("should allow for dancer copying of instructed dance move", async () => {
game.override.battleType("double"); game.override
.battleType("double")
.enemyMoveset([ Moves.INSTRUCT, Moves.SPLASH ]);
await game.classicMode.startBattle([ Species.ORICORIO, Species.VOLCARONA ]); await game.classicMode.startBattle([ Species.ORICORIO, Species.VOLCARONA ]);
const [ , volcarona ] = game.scene.getPlayerField(); const [ oricorio, volcarona ] = game.scene.getPlayerField();
game.move.changeMoveset(oricorio, Moves.SPLASH);
game.move.changeMoveset(volcarona, Moves.FIERY_DANCE); game.move.changeMoveset(volcarona, Moves.FIERY_DANCE);
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY); game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER_2);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
@ -237,36 +229,36 @@ describe("Moves - Instruct", () => {
}); });
it("should not repeat enemy's move through protect", async () => { it("should not repeat enemy's move through protect", async () => {
game.override.moveset([ Moves.INSTRUCT ]);
await game.classicMode.startBattle([ Species.AMOONGUSS ]); await game.classicMode.startBattle([ Species.AMOONGUSS ]);
const MoveToUse = Moves.PROTECT; const enemy = game.scene.getEnemyPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; game.move.changeMoveset(enemy, Moves.PROTECT);
game.move.changeMoveset(enemyPokemon, MoveToUse);
game.move.select(Moves.INSTRUCT); game.move.select(Moves.INSTRUCT);
await game.forceEnemyMove(Moves.PROTECT);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(enemyPokemon.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT); expect(enemy.getLastXMoves(-1)[0].move).toBe(Moves.PROTECT);
expect(enemyPokemon.getLastXMoves(-1)[1]).toBeUndefined(); // undefined because protect failed expect(enemy.getLastXMoves(-1)[1]).toBeUndefined(); // undefined because instruct failed and didn't repeat
expect(enemyPokemon.getMoveset().find(m => m?.moveId === Moves.PROTECT)?.ppUsed).toBe(1); expect(enemy.getMoveset().find(m => m?.moveId === Moves.PROTECT)?.ppUsed).toBe(1);
}); });
it("should not repeat enemy's charging move", async () => { it("should not repeat enemy's charging move", async () => {
game.override game.override
.enemyMoveset([ Moves.SONIC_BOOM, Moves.HYPER_BEAM ]) .moveset([ Moves.INSTRUCT ])
.enemyLevel(5); .enemyMoveset([ Moves.SONIC_BOOM, Moves.HYPER_BEAM ]);
await game.classicMode.startBattle([ Species.SHUCKLE ]); await game.classicMode.startBattle([ Species.SHUCKLE ]);
const player = game.scene.getPlayerPokemon()!; const player = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemy = game.scene.getEnemyPokemon()!;
enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.SONIC_BOOM, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }]; enemy.battleSummonData.moveHistory = [{ move: Moves.SONIC_BOOM, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }];
game.move.select(Moves.INSTRUCT); game.move.select(Moves.INSTRUCT);
await game.forceEnemyMove(Moves.HYPER_BEAM); await game.forceEnemyMove(Moves.HYPER_BEAM);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.toNextTurn(); await game.toNextTurn();
// instruct fails at copying last move due to charging turn (rather than instructing sonic boom)
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
game.move.select(Moves.INSTRUCT); game.move.select(Moves.INSTRUCT);
@ -276,42 +268,52 @@ describe("Moves - Instruct", () => {
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
// TODO: Clean test code up once learn move utility function is added
// to reduce jankiness and decrease likelihood of future borks
it("should not repeat move since forgotten by target", async () => { it("should not repeat move since forgotten by target", async () => {
game.override game.override
.battleType("double") .enemyLevel(5)
.startingWave(199) // disables level cap .xpMultiplier(50)
.enemyLevel(50) .enemySpecies(Species.WURMPLE)
.startingLevel(62) .enemyMoveset(Moves.INSTRUCT);
.enemySpecies(Species.WURMPLE); // 1 level before learning hydro pump await game.classicMode.startBattle([ Species.REGIELEKI ]);
await game.classicMode.startBattle([ Species.LUGIA ]);
const lugia = game.scene.getPlayerPokemon()!;
lugia.addExp(14647);
game.move.changeMoveset(lugia, [ Moves.BRAVE_BIRD, Moves.SPLASH, Moves.AEROBLAST, Moves.FURY_CUTTER ]); const regieleki = game.scene.getPlayerPokemon()!;
// fill out moveset with random moves
game.move.changeMoveset(regieleki, [ Moves.ELECTRO_DRIFT, Moves.SPLASH, Moves.ICE_BEAM, Moves.ANCIENT_POWER ]);
game.move.select(Moves.BRAVE_BIRD, BattlerIndex.PLAYER, BattlerIndex.ENEMY); game.move.select(Moves.ELECTRO_DRIFT);
await game.forceEnemyMove(Moves.SPLASH); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER); game.phaseInterceptor.to("FaintPhase");
await game.phaseInterceptor.to("LearnMovePhase", false); // setup macro to mash enter and learn hydro pump in slot 1
while (game.isCurrentPhase("LearnMovePhase")) { game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => {
game.scene.ui.getHandler().processInput(Button.ACTION); // mash enter to learn level up move game.scene.ui.getHandler().processInput(Button.ACTION); // mash enter to learn level up move
} game.onNextPrompt("LearnMovePhase", Mode.SUMMARY, () => {
await game.phaseInterceptor.to("TurnEndPhase", false); game.scene.ui.getHandler().processInput(Button.ACTION);
game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => {
game.scene.ui.getHandler().processInput(Button.ACTION);
});
});
});
expect(lugia.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS); await game.toNextWave();
game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.phaseInterceptor.to("TurnEndPhase", false);
expect(game.scene.getEnemyField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(game.scene.getEnemyField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL);
}); });
it("should disregard priority of instructed move on use", async () => { it("should disregard priority of instructed move on use", async () => {
game.override game.override
.enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ]) .enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ])
.disableTrainerWaves(); .moveset(Moves.INSTRUCT);
await game.classicMode.startBattle([ Species.LUCARIO, Species.BANETTE ]); await game.classicMode.startBattle([ Species.LUCARIO, Species.BANETTE ]);
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.WHIRLWIND, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }]; enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.WHIRLWIND, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }];
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2); game.move.select(Moves.INSTRUCT);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
@ -322,14 +324,13 @@ describe("Moves - Instruct", () => {
expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.BANETTE); expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.BANETTE);
}); });
it("should respect moves' original priority in psychic terrain", async () => { it("should respect moves' original priority for psychic terrain", async () => {
game.override. game.override.
battleType("double") battleType("double")
.moveset([ Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT ]) .moveset([ Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT ])
.enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]); .enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]);
await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]); await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]);
const banette = game.scene.getPlayerPokemon();
game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.forceEnemyMove(Moves.SPLASH); await game.forceEnemyMove(Moves.SPLASH);
@ -340,15 +341,42 @@ describe("Moves - Instruct", () => {
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
// quick attack failed when instructed // quick attack failed when instructed
expect(banette?.getLastXMoves(-1)[1].move).toBe(Moves.QUICK_ATTACK); const banette = game.scene.getPlayerPokemon()!;
expect(banette?.getLastXMoves(-1)[1].result).toBe(MoveResult.FAIL); expect(banette.getLastXMoves(-1)[1].move).toBe(Moves.QUICK_ATTACK);
expect(banette.getLastXMoves(-1)[1].result).toBe(MoveResult.FAIL);
});
it("should still work w/ prankster in psychic terrain", async () => {
game.override.
battleType("double")
.enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ])
.ability(Abilities.PRANKSTER);
await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]);
const [ banette, klefki ] = game.scene.getPlayerField()!;
game.move.changeMoveset(banette, Moves.VINE_WHIP);
game.move.changeMoveset(klefki, [ Moves.INSTRUCT, Moves.SPLASH ]);
game.move.select(Moves.VINE_WHIP, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
await game.forceEnemyMove(Moves.SPLASH);
await game.forceEnemyMove(Moves.PSYCHIC_TERRAIN);
await game.toNextTurn();
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false);
instructSuccess(banette, Moves.VINE_WHIP);
}); });
it("should cause spread moves to correctly hit targets in doubles after singles", async () => { it("should cause spread moves to correctly hit targets in doubles after singles", async () => {
game.override game.override
.battleType("even-doubles") .battleType("even-doubles")
.moveset([ Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH ]) .moveset([ Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH ])
.enemyMoveset(Moves.SONIC_BOOM)
.enemySpecies(Species.AXEW) .enemySpecies(Species.AXEW)
.startingLevel(500); .startingLevel(500);
await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]);
@ -356,22 +384,19 @@ describe("Moves - Instruct", () => {
const koraidon = game.scene.getPlayerField()[0]!; const koraidon = game.scene.getPlayerField()[0]!;
game.move.select(Moves.BREAKING_SWIPE); game.move.select(Moves.BREAKING_SWIPE);
await game.forceEnemyMove(Moves.SONIC_BOOM);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect (koraidon.getInverseHp()).toBe(0); expect(koraidon.getInverseHp()).toBe(0);
expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]); expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]);
await game.toNextWave(); await game.toNextWave();
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
// did not take damage since enemies died beforehand; // did not take damage since enemies died beforehand;
// last move used hit both enemies // last move used hit both enemies
expect(koraidon.getInverseHp()).toBe(0); expect(koraidon.getInverseHp()).toBe(0);
expect(koraidon.getLastXMoves(-1)[1].targets).toMatchObject([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
}); });
it("should cause AoE moves to correctly hit everyone in doubles after singles", async () => { it("should cause AoE moves to correctly hit everyone in doubles after singles", async () => {
@ -379,13 +404,13 @@ describe("Moves - Instruct", () => {
.battleType("even-doubles") .battleType("even-doubles")
.moveset([ Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH ]) .moveset([ Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH ])
.enemySpecies(Species.AXEW) .enemySpecies(Species.AXEW)
.enemyMoveset(Moves.SONIC_BOOM)
.startingLevel(500); .startingLevel(500);
await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]); await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]);
const koraidon = game.scene.getPlayerField()[0]!; const koraidon = game.scene.getPlayerField()[0]!;
game.move.select(Moves.BRUTAL_SWING); game.move.select(Moves.BRUTAL_SWING);
await game.forceEnemyMove(Moves.SONIC_BOOM);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]); await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
expect(koraidon.getInverseHp()).toBe(0); expect(koraidon.getInverseHp()).toBe(0);
@ -394,22 +419,18 @@ describe("Moves - Instruct", () => {
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER); game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER); game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
await game.forceEnemyMove(Moves.SONIC_BOOM, BattlerIndex.PLAYER);
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]); await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
await game.phaseInterceptor.to("TurnEndPhase", false); await game.phaseInterceptor.to("TurnEndPhase", false);
// did not take damage since enemies died beforehand; // did not take damage since enemies died beforehand;
// last move used hit everything around it // last move used hit everything around it
expect(koraidon.getInverseHp()).toBe(0); expect(koraidon.getInverseHp()).toBe(0);
expect(koraidon.getLastXMoves(-1)[1].targets).toEqual([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER_2 ]); expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
expect(game.scene.getPlayerField()[1].getInverseHp()).toBeGreaterThan(0);
expect(game.scene.getEnemyField()[0].getInverseHp()).toBeGreaterThan(0);
expect(game.scene.getEnemyField()[1].getInverseHp()).toBeGreaterThan(0);
}); });
it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => { it("should cause multi-hit moves to hit the appropriate number of times in singles", async () => {
game.override game.override
.enemyAbility(Abilities.SKILL_LINK) .enemyAbility(Abilities.SKILL_LINK)
.moveset([ Moves.SPLASH, Moves.INSTRUCT ])
.enemyMoveset(Moves.BULLET_SEED); .enemyMoveset(Moves.BULLET_SEED);
await game.classicMode.startBattle([ Species.BULBASAUR ]); await game.classicMode.startBattle([ Species.BULBASAUR ]);
@ -436,6 +457,7 @@ describe("Moves - Instruct", () => {
game.override game.override
.battleType("double") .battleType("double")
.enemyAbility(Abilities.SKILL_LINK) .enemyAbility(Abilities.SKILL_LINK)
.moveset([ Moves.SPLASH, Moves.INSTRUCT ])
.enemyMoveset([ Moves.BULLET_SEED, Moves.SPLASH ]) .enemyMoveset([ Moves.BULLET_SEED, Moves.SPLASH ])
.enemyLevel(5); .enemyLevel(5);
await game.classicMode.startBattle([ Species.BULBASAUR, Species.IVYSAUR ]); await game.classicMode.startBattle([ Species.BULBASAUR, Species.IVYSAUR ]);

View File

@ -129,9 +129,10 @@ export default class GameManager {
/** /**
* Adds an action to be executed on the next prompt. * Adds an action to be executed on the next prompt.
* This can be used to (among other things) simulate inputs or run functions mid-phase.
* @param phaseTarget - The target phase. * @param phaseTarget - The target phase.
* @param mode - The mode to wait for. * @param mode - The mode to wait for.
* @param callback - The callback to execute. * @param callback - The callback function to execute on next prompt.
* @param expireFn - Optional function to determine if the prompt has expired. * @param expireFn - Optional function to determine if the prompt has expired.
*/ */
onNextPrompt(phaseTarget: string, mode: Mode, callback: () => void, expireFn?: () => void, awaitingActionInput: boolean = false) { onNextPrompt(phaseTarget: string, mode: Mode, callback: () => void, expireFn?: () => void, awaitingActionInput: boolean = false) {
@ -400,6 +401,11 @@ export default class GameManager {
return updateUserInfo(); return updateUserInfo();
} }
/**
* Faints a player or enemy pokemon instantly by setting their HP to 0.
* @param pokemon The player/enemy pokemon being fainted
* @returns A promise that resolves once the fainted pokemon's FaintPhase finishes running.
*/
async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) { async killPokemon(pokemon: PlayerPokemon | EnemyPokemon) {
return new Promise<void>(async (resolve, reject) => { return new Promise<void>(async (resolve, reject) => {
pokemon.hp = 0; pokemon.hp = 0;

View File

@ -75,9 +75,10 @@ export class MoveHelper extends GameManagerHelper {
} }
/** /**
* Used when the normal moveset override can't be used (such as when it's necessary to check updated properties of the moveset). * Changes a pokemon's moveset to the given move(s).
* Used when the normal moveset override can't be used (such as when it's necessary to check or update properties of the moveset).
* @param pokemon - The {@linkcode Pokemon} being modified * @param pokemon - The {@linkcode Pokemon} being modified
* @param moveset - The {@linkcode Moves} (single or array) to set the Pokemon's moveset to * @param moveset - The {@linkcode Moves} (single or array) to change the Pokemon's moveset to
*/ */
public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void { public changeMoveset(pokemon: Pokemon, moveset: Moves | Moves[]): void {
if (!Array.isArray(moveset)) { if (!Array.isArray(moveset)) {

View File

@ -277,6 +277,10 @@ export default class UI extends Phaser.GameObjects.Container {
return true; return true;
} }
/** Process a player input of a button (delivering it to the current UI handler for processing)
* @param button The {@linkcode Button} being inputted
* @returns true if the input attempt succeeds
*/
processInput(button: Button): boolean { processInput(button: Button): boolean {
if (this.overlayActive) { if (this.overlayActive) {
return false; return false;