Merge c85c700b98
into ca0522436a
This commit is contained in:
commit
276cbbbd8c
|
@ -1 +1 @@
|
||||||
Subproject commit acad8499a4ca488a9871902de140f635235f309a
|
Subproject commit 6c6f0af398ae11f8d96c6ac064f171d927812c85
|
|
@ -869,6 +869,12 @@ export default class BattleScene extends SceneBase {
|
||||||
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
|
return party.slice(0, Math.min(party.length, this.currentBattle?.double ? 2 : 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of Pokemon on both sides of the battle - player first, then enemy.
|
||||||
|
* Does not actually check if the pokemon are on the field or not, and always has length 4 regardless of battle type.
|
||||||
|
* @param activeOnly Whether to consider only active pokemon
|
||||||
|
* @returns array of {@linkcode Pokemon}
|
||||||
|
*/
|
||||||
public getField(activeOnly: boolean = false): Pokemon[] {
|
public getField(activeOnly: boolean = false): Pokemon[] {
|
||||||
const ret = new Array(4).fill(null);
|
const ret = new Array(4).fill(null);
|
||||||
const playerField = this.getPlayerField();
|
const playerField = this.getPlayerField();
|
||||||
|
|
|
@ -1380,8 +1380,10 @@ export class UserHpDamageAttr extends FixedDamageAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TargetHalfHpDamageAttr extends FixedDamageAttr {
|
export class TargetHalfHpDamageAttr extends FixedDamageAttr {
|
||||||
// the initial amount of hp the target had before the first hit
|
/**
|
||||||
// used for multi lens
|
* The initial amount of hp the target had before the first hit.
|
||||||
|
* Used for calculating multi lens damage.
|
||||||
|
*/
|
||||||
private initialHp: number;
|
private initialHp: number;
|
||||||
constructor() {
|
constructor() {
|
||||||
super(0);
|
super(0);
|
||||||
|
@ -1405,12 +1407,10 @@ export class TargetHalfHpDamageAttr extends FixedDamageAttr {
|
||||||
// multi lens added hit; use initialHp tracker to ensure correct damage
|
// multi lens added hit; use initialHp tracker to ensure correct damage
|
||||||
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(this.initialHp / 2);
|
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(this.initialHp / 2);
|
||||||
return true;
|
return true;
|
||||||
break;
|
|
||||||
case lensCount + 1:
|
case lensCount + 1:
|
||||||
// parental bond added hit; calc damage as normal
|
// parental bond added hit; calc damage as normal
|
||||||
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(target.hp / 2);
|
(args[0] as Utils.NumberHolder).value = Utils.toDmgValue(target.hp / 2);
|
||||||
return true;
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6109,7 +6109,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't allow wild mons to flee with U-turn et al
|
// Don't allow wild mons to flee with U-turn et al.
|
||||||
if (this.selfSwitch && !user.isPlayer() && move.category !== MoveCategory.STATUS) {
|
if (this.selfSwitch && !user.isPlayer() && move.category !== MoveCategory.STATUS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7064,7 +7064,25 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
||||||
// get the last move used (excluding status based failures) as well as the corresponding moveset slot
|
// 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 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)!;
|
||||||
const moveTargets = lastMove.targets ?? [];
|
// If the last move used can hit more than one target or has variable targets,
|
||||||
|
// re-compute the targets for the attack
|
||||||
|
// (mainly for alternating double/single battle shenanigans)
|
||||||
|
// Rampaging moves (e.g. Outrage) are not included due to being incompatible with Instruct
|
||||||
|
// TODO: Fix this once dragon darts gets smart targeting
|
||||||
|
let moveTargets = movesetMove.getMove().isMultiTarget() ? getMoveTargets(target, lastMove.move).targets : lastMove.targets;
|
||||||
|
|
||||||
|
/** In the event the instructed move's only target is a fainted opponent, redirect it to an alive ally if possible
|
||||||
|
Normally, all yet-unexecuted move phases would swap over when the enemy in question faints
|
||||||
|
(see `redirectPokemonMoves` in `battle-scene.ts`),
|
||||||
|
but since instruct adds a new move phase pre-emptively, we need to handle this interaction manually.
|
||||||
|
*/
|
||||||
|
const firstTarget = globalScene.getField()[moveTargets[0]];
|
||||||
|
if (globalScene.currentBattle.double && moveTargets.length === 1 && firstTarget.isFainted() && firstTarget !== target.getAlly()) {
|
||||||
|
const ally = firstTarget.getAlly();
|
||||||
|
if (ally.isActive()) { // ally exists, is not dead and can sponge the blast
|
||||||
|
moveTargets = [ ally.getBattlerIndex() ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
globalScene.queueMessage(i18next.t("moveTriggers:instructingMove", {
|
globalScene.queueMessage(i18next.t("moveTriggers:instructingMove", {
|
||||||
userPokemonName: getPokemonNameWithAffix(user),
|
userPokemonName: getPokemonNameWithAffix(user),
|
||||||
|
@ -7078,12 +7096,9 @@ 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);
|
||||||
const moveTargets = lastMove?.targets ?? [];
|
const uninstructableMoves = [
|
||||||
// TODO: Add a way of adding moves to list procedurally rather than a pre-defined blacklist
|
|
||||||
const unrepeatablemoves = [
|
|
||||||
// Locking/Continually Executed moves
|
// Locking/Continually Executed moves
|
||||||
Moves.OUTRAGE,
|
Moves.OUTRAGE,
|
||||||
Moves.RAGING_FURY,
|
Moves.RAGING_FURY,
|
||||||
|
@ -7138,11 +7153,11 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
||||||
// TODO: Add Max/G-Move blockage if or when they are implemented
|
// 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.)
|
if (!lastMove?.move // no move to instruct
|
||||||
|
|| !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 ?? Moves.NONE].isChargingMove() // called move is a charging/recharging move
|
|| allMoves[lastMove.move].isChargingMove() // called move is a charging/recharging move
|
||||||
|| !moveTargets.length // called move has no targets
|
|| uninstructableMoves.includes(lastMove.move)) { // called move is in the banlist
|
||||||
|| unrepeatablemoves.includes(lastMove?.move ?? Moves.NONE)) { // called move is explicitly in the banlist
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -7150,7 +7165,7 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
||||||
}
|
}
|
||||||
|
|
||||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
|
||||||
// TODO: Make the AI acutally use instruct
|
// TODO: Make the AI actually use instruct
|
||||||
/* Ideally, the AI would score instruct based on the scorings of the on-field pokemons'
|
/* 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)
|
* last used moves at the time of using Instruct (by the time the instructor gets to act)
|
||||||
* with respect to the user's side.
|
* with respect to the user's side.
|
||||||
|
@ -10260,6 +10275,8 @@ export function initMoves() {
|
||||||
.ignoresSubstitute()
|
.ignoresSubstitute()
|
||||||
.attr(RepeatMoveAttr)
|
.attr(RepeatMoveAttr)
|
||||||
.edgeCase(), // incorrect interactions with Gigaton Hammer, Blood Moon & Torment
|
.edgeCase(), // incorrect interactions with Gigaton Hammer, Blood Moon & Torment
|
||||||
|
// Also has incorrect interactions with move-calling moves (Mirror Move, Copycat/Mimic, Metronome)
|
||||||
|
// and Dancer that will need to be cleaned up separately
|
||||||
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()
|
||||||
|
|
|
@ -162,7 +162,7 @@ export function getNonVolatileStatusEffects():Array<StatusEffect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a statuss effect is non volatile.
|
* Returns whether a status effect is non volatile.
|
||||||
* Non-volatile status condition is a status that remains after being switched out.
|
* Non-volatile status condition is a status that remains after being switched out.
|
||||||
* @param status The status to check
|
* @param status The status to check
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1108,6 +1108,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
return this.getStat(Stat.HP);
|
return this.getStat(Stat.HP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the amount of hp currently missing from this {@linkcode Pokemon} (max - current) */
|
||||||
getInverseHp(): integer {
|
getInverseHp(): integer {
|
||||||
return this.getMaxHp() - this.hp;
|
return this.getMaxHp() - this.hp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
* ```
|
* ```
|
||||||
|
@ -38,7 +38,7 @@ const overrides = {} satisfies Partial<InstanceType<typeof DefaultOverrides>>;
|
||||||
* ---
|
* ---
|
||||||
* 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 {
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
|
@ -26,7 +26,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(partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {
|
constructor(partyMemberIndex: integer, moveId: Moves, learnMoveType: LearnMoveType = LearnMoveType.LEARN_MOVE, cost: number = -1) {
|
||||||
|
|
|
@ -60,4 +60,41 @@ describe("Abilities - Dancer", () => {
|
||||||
// doesn't use PP if copied move is also in moveset
|
// doesn't use PP if copied move is also in moveset
|
||||||
expect(oricorio.moveset[0]?.ppUsed).toBe(0);
|
expect(oricorio.moveset[0]?.ppUsed).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: Enable after move-calling move rework
|
||||||
|
it.todo("should not count as the last move used for mirror move/instruct", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset([ Moves.FIERY_DANCE, Moves.REVELATION_DANCE ])
|
||||||
|
.enemyMoveset([ Moves.INSTRUCT, Moves.MIRROR_MOVE, Moves.SPLASH ])
|
||||||
|
.enemySpecies(Species.DIALGA)
|
||||||
|
.enemyLevel(100);
|
||||||
|
await game.classicMode.startBattle([ Species.ORICORIO, Species.FEEBAS ]);
|
||||||
|
|
||||||
|
const [ oricorio ] = game.scene.getPlayerField();
|
||||||
|
const [ , dialga2 ] = game.scene.getEnemyField();
|
||||||
|
|
||||||
|
game.move.select(Moves.REVELATION_DANCE, BattlerIndex.PLAYER, BattlerIndex.ENEMY_2);
|
||||||
|
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2);
|
||||||
|
await game.forceEnemyMove(Moves.INSTRUCT, BattlerIndex.PLAYER);
|
||||||
|
await game.forceEnemyMove(Moves.MIRROR_MOVE, BattlerIndex.PLAYER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY_2, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // Oricorio rev dance
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // Feebas fiery dance
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // Oricorio fiery dance
|
||||||
|
await game.phaseInterceptor.to("MoveEndPhase", false);
|
||||||
|
expect(oricorio.getLastXMoves(-1)[0].move).toBe(Moves.REVELATION_DANCE); // dancer copied move doesn't appear in move history
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // dialga 2 mirror moves oricorio
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // calls instructed rev dance
|
||||||
|
let currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
||||||
|
expect(currentPhase.pokemon).toBe(dialga2);
|
||||||
|
expect(currentPhase.move.moveId).toBe(Moves.REVELATION_DANCE);
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to("MovePhase"); // dialga 1 instructs oricorio
|
||||||
|
await game.phaseInterceptor.to("MovePhase");
|
||||||
|
currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
||||||
|
expect(currentPhase.pokemon).toBe(oricorio);
|
||||||
|
expect(currentPhase.move.moveId).toBe(Moves.REVELATION_DANCE);
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
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 { 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";
|
||||||
|
@ -12,10 +15,10 @@ describe("Moves - Instruct", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
let game: GameManager;
|
let game: GameManager;
|
||||||
|
|
||||||
function instructSuccess(pokemon: Pokemon, move: Moves): void {
|
function instructSuccess(target: Pokemon, move: Moves): void {
|
||||||
expect(pokemon.getLastXMoves(-1)[0].move).toBe(move);
|
expect(target.getLastXMoves(-1)[0].move).toBe(move);
|
||||||
expect(pokemon.getLastXMoves(-1)[1].move).toBe(pokemon.getLastXMoves()[0].move);
|
expect(target.getLastXMoves(-1)[1].move).toBe(target.getLastXMoves()[0].move);
|
||||||
expect(pokemon.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2);
|
expect(target.getMoveset().find(m => m?.moveId === move)?.ppUsed).toBe(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
|
@ -36,27 +39,40 @@ describe("Moves - Instruct", () => {
|
||||||
.enemyAbility(Abilities.NO_GUARD)
|
.enemyAbility(Abilities.NO_GUARD)
|
||||||
.enemyLevel(100)
|
.enemyLevel(100)
|
||||||
.startingLevel(100)
|
.startingLevel(100)
|
||||||
.ability(Abilities.BALL_FETCH)
|
|
||||||
.moveset([ Moves.INSTRUCT, Moves.SONIC_BOOM, Moves.SPLASH, Moves.TORMENT ])
|
|
||||||
.disableCrits();
|
.disableCrits();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should repeat enemy's attack move when moving last", async () => {
|
it("should repeat target's last used move", async () => {
|
||||||
|
game.override
|
||||||
|
.moveset(Moves.INSTRUCT)
|
||||||
|
.enemyLevel(1000); // ensures shuckle no die
|
||||||
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", false); // instruct
|
||||||
|
let currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
||||||
|
expect(currentPhase.pokemon).toBe(game.scene.getPlayerPokemon());
|
||||||
|
await game.phaseInterceptor.to("MoveEndPhase");
|
||||||
|
|
||||||
|
await game.phaseInterceptor.to("MovePhase", false); // enemy repeats move
|
||||||
|
currentPhase = game.scene.getCurrentPhase() as MovePhase;
|
||||||
|
expect(currentPhase.pokemon).toBe(enemy);
|
||||||
|
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()!;
|
||||||
|
@ -72,34 +88,33 @@ 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) is fixed
|
// 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
|
game.override
|
||||||
|
.moveset(Moves.INSTRUCT)
|
||||||
.enemyLevel(5);
|
.enemyLevel(5);
|
||||||
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
|
@ -115,32 +130,31 @@ describe("Moves - Instruct", () => {
|
||||||
|
|
||||||
it("should respect enemy's status condition", async () => {
|
it("should respect enemy's status condition", async () => {
|
||||||
game.override
|
game.override
|
||||||
.moveset([ Moves.THUNDER_WAVE, Moves.INSTRUCT ])
|
.moveset([ Moves.INSTRUCT, Moves.THUNDER_WAVE ])
|
||||||
.enemyMoveset([ Moves.SPLASH, Moves.SONIC_BOOM ]);
|
.enemyMoveset(Moves.SONIC_BOOM);
|
||||||
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
await game.classicMode.startBattle([ Species.AMOONGUSS ]);
|
||||||
|
|
||||||
game.move.select(Moves.THUNDER_WAVE);
|
game.move.select(Moves.THUNDER_WAVE);
|
||||||
await game.forceEnemyMove(Moves.SONIC_BOOM);
|
|
||||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
game.move.select(Moves.INSTRUCT);
|
game.move.select(Moves.INSTRUCT);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
|
||||||
await game.move.forceStatusActivation(true);
|
|
||||||
await game.phaseInterceptor.to("MovePhase");
|
await game.phaseInterceptor.to("MovePhase");
|
||||||
|
// 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);
|
||||||
|
|
||||||
const moveHistory = game.scene.getEnemyPokemon()!.getMoveHistory();
|
const moveHistory = game.scene.getEnemyPokemon()?.getLastXMoves(-1)!;
|
||||||
expect(moveHistory.length).toBe(3);
|
expect(moveHistory.map(m => m.move)).toEqual([ Moves.SONIC_BOOM, Moves.NONE, Moves.SONIC_BOOM ]);
|
||||||
expect(moveHistory[0].move).toBe(Moves.SONIC_BOOM);
|
expect(game.scene.getPlayerPokemon()?.getInverseHp()).toBe(40);
|
||||||
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 () => {
|
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()!;
|
||||||
|
@ -153,13 +167,85 @@ 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 redirect attacking moves if enemy faints", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyMoveset(Moves.SPLASH)
|
||||||
|
.enemySpecies(Species.MAGIKARP)
|
||||||
|
.enemyLevel(1);
|
||||||
|
await game.classicMode.startBattle([ Species.HISUI_ELECTRODE, Species.KOMMO_O ]);
|
||||||
|
|
||||||
|
const [ electrode, kommo_o ] = game.scene.getPlayerField()!;
|
||||||
|
game.move.changeMoveset(electrode, Moves.CHLOROBLAST);
|
||||||
|
game.move.changeMoveset(kommo_o, Moves.INSTRUCT);
|
||||||
|
|
||||||
|
game.move.select(Moves.CHLOROBLAST, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.PLAYER);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
// Chloroblast always deals 50% max HP% recoil UNLESS you whiff
|
||||||
|
// due to lack of targets or similar,
|
||||||
|
// so all we have to do is check whether electrode fainted or not.
|
||||||
|
// Naturally, both karps should also be dead as well.
|
||||||
|
expect(electrode.isFainted()).toBe(true);
|
||||||
|
const [ karp1, karp2 ] = game.scene.getEnemyField()!;
|
||||||
|
expect(karp1.isFainted()).toBe(true);
|
||||||
|
expect(karp2.isFainted()).toBe(true);
|
||||||
|
}),
|
||||||
|
|
||||||
|
it("should allow for dancer copying of instructed dance move", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("double")
|
||||||
|
.enemyMoveset([ Moves.INSTRUCT, Moves.SPLASH ]);
|
||||||
|
await game.classicMode.startBattle([ Species.ORICORIO, Species.VOLCARONA ]);
|
||||||
|
|
||||||
|
const [ oricorio, volcarona ] = game.scene.getPlayerField();
|
||||||
|
game.move.changeMoveset(oricorio, Moves.SPLASH);
|
||||||
|
game.move.changeMoveset(volcarona, Moves.FIERY_DANCE);
|
||||||
|
|
||||||
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
|
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.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
|
// fiery dance triggered dancer successfully for a total of 4 hits
|
||||||
|
// Volcarona fiery dance has a _small_ chance to 3HKO a shuckle in worst case, so we add the hit count of both
|
||||||
|
// foes to account for spillover
|
||||||
|
instructSuccess(volcarona, Moves.FIERY_DANCE);
|
||||||
|
expect(game.scene.getEnemyField()[0].turnData.attacksReceived.length +
|
||||||
|
game.scene.getEnemyField()[1].turnData.attacksReceived.length).toBe(4);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not repeat move when switching out", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyMoveset(Moves.INSTRUCT)
|
||||||
|
.enemySpecies(Species.UNOWN);
|
||||||
|
await game.classicMode.startBattle([ Species.AMOONGUSS, Species.TOXICROAK ]);
|
||||||
|
|
||||||
|
const amoonguss = game.scene.getPlayerPokemon()!;
|
||||||
|
game.move.changeMoveset(amoonguss, Moves.SEED_BOMB);
|
||||||
|
|
||||||
|
amoonguss.battleSummonData.moveHistory = [{ move: Moves.SEED_BOMB, targets: [ BattlerIndex.ENEMY ], result: MoveResult.SUCCESS }];
|
||||||
|
|
||||||
|
game.doSwitchPokemon(1);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
const enemyMoves = game.scene.getEnemyPokemon()!.getLastXMoves(-1)!;
|
||||||
|
expect(enemyMoves[0].result).toBe(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
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);
|
||||||
|
@ -183,48 +269,46 @@ 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 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);
|
||||||
|
@ -234,31 +318,172 @@ describe("Moves - Instruct", () => {
|
||||||
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
expect(player.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not repeat dance move not known by target", async () => {
|
// TODO: Fix test code up to use learn move utility function once that gets added
|
||||||
|
it.todo("should not repeat move since forgotten by target", async () => {
|
||||||
game.override
|
game.override
|
||||||
.battleType("double")
|
.enemyLevel(5)
|
||||||
.moveset([ Moves.INSTRUCT, Moves.FIERY_DANCE ])
|
.xpMultiplier(50)
|
||||||
.enemyMoveset(Moves.SPLASH)
|
.enemySpecies(Species.WURMPLE)
|
||||||
.enemyAbility(Abilities.DANCER);
|
.enemyMoveset(Moves.INSTRUCT);
|
||||||
await game.classicMode.startBattle([ Species.SHUCKLE, Species.SHUCKLE ]);
|
await game.classicMode.startBattle([ Species.REGIELEKI ]);
|
||||||
|
|
||||||
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
const regieleki = game.scene.getPlayerPokemon()!;
|
||||||
game.move.select(Moves.FIERY_DANCE, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
// 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.ELECTRO_DRIFT);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
// setup macro to mash enter and learn hydro pump in slot 1
|
||||||
|
game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => {
|
||||||
|
game.scene.ui.getHandler().processInput(Button.ACTION);
|
||||||
|
game.onNextPrompt("LearnMovePhase", Mode.SUMMARY, () => {
|
||||||
|
game.scene.ui.getHandler().processInput(Button.ACTION);
|
||||||
|
game.onNextPrompt("LearnMovePhase", Mode.CONFIRM, () => {
|
||||||
|
game.scene.ui.getHandler().processInput(Button.ACTION);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should disregard priority of instructed move on use", async () => {
|
||||||
|
game.override
|
||||||
|
.enemyMoveset([ Moves.SPLASH, Moves.WHIRLWIND ])
|
||||||
|
.moveset(Moves.INSTRUCT);
|
||||||
|
await game.classicMode.startBattle([ Species.LUCARIO, Species.BANETTE ]);
|
||||||
|
|
||||||
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
enemyPokemon.battleSummonData.moveHistory = [{ move: Moves.WHIRLWIND, targets: [ BattlerIndex.PLAYER ], result: MoveResult.SUCCESS, virtual: false }];
|
||||||
|
|
||||||
|
game.move.select(Moves.INSTRUCT);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
|
||||||
|
// lucario instructed enemy whirlwind at 0 priority to switch itself out
|
||||||
|
const instructedMove = enemyPokemon.getLastXMoves(-1)[1];
|
||||||
|
expect(instructedMove.result).toBe(MoveResult.SUCCESS);
|
||||||
|
expect(instructedMove.move).toBe(Moves.WHIRLWIND);
|
||||||
|
expect(game.scene.getPlayerPokemon()?.species.speciesId).toBe(Species.BANETTE);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should respect moves' original priority for psychic terrain", async () => {
|
||||||
|
game.override.
|
||||||
|
battleType("double")
|
||||||
|
.moveset([ Moves.QUICK_ATTACK, Moves.SPLASH, Moves.INSTRUCT ])
|
||||||
|
.enemyMoveset([ Moves.SPLASH, Moves.PSYCHIC_TERRAIN ]);
|
||||||
|
await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.QUICK_ATTACK, BattlerIndex.PLAYER, BattlerIndex.ENEMY); // succeeds due to terrain no
|
||||||
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
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.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.getPlayerField()[0].getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
// quick attack failed when instructed
|
||||||
|
const banette = game.scene.getPlayerPokemon()!;
|
||||||
|
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 ]);
|
||||||
|
await game.classicMode.startBattle([ Species.BANETTE, Species.KLEFKI ]);
|
||||||
|
|
||||||
|
const [ banette, klefki ] = game.scene.getPlayerField()!;
|
||||||
|
game.move.changeMoveset(banette, [ Moves.VINE_WHIP, Moves.SPLASH ]);
|
||||||
|
game.move.changeMoveset(klefki, [ Moves.INSTRUCT, Moves.SPLASH ]);
|
||||||
|
|
||||||
|
game.move.select(Moves.VINE_WHIP, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
|
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); // copies vine whip
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER_2, BattlerIndex.PLAYER, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
expect(banette.getLastXMoves(-1)[1].move).toBe(Moves.VINE_WHIP);
|
||||||
|
expect(banette.getLastXMoves(-1)[2].move).toBe(Moves.VINE_WHIP);
|
||||||
|
expect(banette.getMoveset().find(m => m?.moveId === Moves.VINE_WHIP )?.ppUsed).toBe(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should cause spread moves to correctly hit targets in doubles after singles", async () => {
|
||||||
|
game.override
|
||||||
|
.battleType("even-doubles")
|
||||||
|
.moveset([ Moves.BREAKING_SWIPE, Moves.INSTRUCT, Moves.SPLASH ])
|
||||||
|
.enemyMoveset(Moves.SONIC_BOOM)
|
||||||
|
.enemySpecies(Species.AXEW)
|
||||||
|
.startingLevel(500);
|
||||||
|
await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]);
|
||||||
|
|
||||||
|
const koraidon = game.scene.getPlayerField()[0]!;
|
||||||
|
|
||||||
|
game.move.select(Moves.BREAKING_SWIPE);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
expect(koraidon.getInverseHp()).toBe(0);
|
||||||
|
expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]);
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
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);
|
||||||
|
// did not take damage since enemies died beforehand;
|
||||||
|
// last move used hit both enemies
|
||||||
|
expect(koraidon.getInverseHp()).toBe(0);
|
||||||
|
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 () => {
|
||||||
|
game.override
|
||||||
|
.battleType("even-doubles")
|
||||||
|
.moveset([ Moves.BRUTAL_SWING, Moves.INSTRUCT, Moves.SPLASH ])
|
||||||
|
.enemySpecies(Species.AXEW)
|
||||||
|
.enemyMoveset(Moves.SONIC_BOOM)
|
||||||
|
.startingLevel(500);
|
||||||
|
await game.classicMode.startBattle([ Species.KORAIDON, Species.KLEFKI ]);
|
||||||
|
|
||||||
|
const koraidon = game.scene.getPlayerField()[0]!;
|
||||||
|
|
||||||
|
game.move.select(Moves.BRUTAL_SWING);
|
||||||
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase", false);
|
||||||
|
expect(koraidon.getInverseHp()).toBe(0);
|
||||||
|
expect(koraidon.getLastXMoves(-1)[0].targets).toEqual([ BattlerIndex.ENEMY ]);
|
||||||
|
await game.toNextWave();
|
||||||
|
|
||||||
|
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);
|
||||||
|
// did not take damage since enemies died beforehand;
|
||||||
|
// last move used hit everything around it
|
||||||
|
expect(koraidon.getInverseHp()).toBe(0);
|
||||||
|
expect(koraidon.getLastXMoves(-1)[1].targets?.sort()).toEqual([ BattlerIndex.PLAYER_2, BattlerIndex.ENEMY, BattlerIndex.ENEMY_2 ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
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 ]);
|
||||||
|
|
||||||
const player = game.scene.getPlayerPokemon()!;
|
const bulbasaur = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
@ -267,34 +492,35 @@ describe("Moves - Instruct", () => {
|
||||||
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
expect(player.turnData.attacksReceived.length).toBe(10);
|
expect(bulbasaur.turnData.attacksReceived.length).toBe(10);
|
||||||
|
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
game.move.select(Moves.INSTRUCT);
|
game.move.select(Moves.INSTRUCT);
|
||||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
expect(player.turnData.attacksReceived.length).toBe(10);
|
expect(bulbasaur.turnData.attacksReceived.length).toBe(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => {
|
it("should cause multi-hit moves to hit the appropriate number of times in doubles", async () => {
|
||||||
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 ]);
|
||||||
|
|
||||||
const [ , ivysaur ] = game.scene.getPlayerField();
|
const [ , ivysaur ] = game.scene.getPlayerField();
|
||||||
|
|
||||||
game.move.select(Moves.SPLASH);
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER);
|
||||||
game.move.select(Moves.SPLASH, 1);
|
game.move.select(Moves.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
await game.forceEnemyMove(Moves.BULLET_SEED, 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 ]);
|
||||||
|
@ -303,8 +529,8 @@ describe("Moves - Instruct", () => {
|
||||||
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
expect(ivysaur.turnData.attacksReceived.length).toBe(15);
|
||||||
|
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
game.move.select(Moves.INSTRUCT, 0, BattlerIndex.ENEMY);
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER, BattlerIndex.ENEMY);
|
||||||
game.move.select(Moves.INSTRUCT, 1, BattlerIndex.ENEMY);
|
game.move.select(Moves.INSTRUCT, BattlerIndex.PLAYER_2, BattlerIndex.ENEMY);
|
||||||
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
await game.forceEnemyMove(Moves.BULLET_SEED, BattlerIndex.PLAYER_2);
|
||||||
await game.forceEnemyMove(Moves.SPLASH);
|
await game.forceEnemyMove(Moves.SPLASH);
|
||||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]);
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.ENEMY_2, BattlerIndex.PLAYER, BattlerIndex.PLAYER_2 ]);
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -453,8 +459,9 @@ export default class GameManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercepts `TurnStartPhase` and mocks the getSpeedOrder's return value {@linkcode TurnStartPhase.getSpeedOrder}
|
* Intercepts `TurnStartPhase` and mocks {@linkcode TurnStartPhase.getSpeedOrder}'s return value.
|
||||||
* Used to modify the turn order.
|
* Used to manually modify Pokemon turn order.
|
||||||
|
* Note: This *DOES NOT* account for priority, only speed.
|
||||||
* @param {BattlerIndex[]} order The turn order to set
|
* @param {BattlerIndex[]} order The turn order to set
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
@ -468,7 +475,7 @@ export default class GameManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all held items from enemy pokemon
|
* Removes all held items from enemy pokemon.
|
||||||
*/
|
*/
|
||||||
removeEnemyHeldItems(): void {
|
removeEnemyHeldItems(): void {
|
||||||
this.scene.clearEnemyHeldItemModifiers();
|
this.scene.clearEnemyHeldItemModifiers();
|
||||||
|
|
|
@ -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).
|
||||||
* @param pokemon - The pokemon being modified
|
* 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 moveset - The moveset to use
|
* @param pokemon - The {@linkcode Pokemon} being modified
|
||||||
|
* @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)) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ export class OverridesHelper extends GameManagerHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override the player (pokemon) {@linkcode Abilities | ability}
|
* Override the player (pokemon) {@linkcode Abilities | ability}.
|
||||||
* @param ability the (pokemon) {@linkcode Abilities | ability} to set
|
* @param ability the (pokemon) {@linkcode Abilities | ability} to set
|
||||||
* @returns `this`
|
* @returns `this`
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -277,6 +277,11 @@ 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;
|
||||||
|
|
Loading…
Reference in New Issue