mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Merge 7de3c11e62
into b1c50dd69f
This commit is contained in:
commit
f64b0ae327
@ -5776,20 +5776,21 @@ export class ProtectAttr extends AddBattlerTagAttr {
|
|||||||
getCondition(): MoveConditionFunc {
|
getCondition(): MoveConditionFunc {
|
||||||
return ((user, target, move): boolean => {
|
return ((user, target, move): boolean => {
|
||||||
let timesUsed = 0;
|
let timesUsed = 0;
|
||||||
const moveHistory = user.getLastXMoves();
|
|
||||||
let turnMove: TurnMove | undefined;
|
|
||||||
|
|
||||||
while (moveHistory.length) {
|
for (const turnMove of user.tempSummonData.waveMoveHistory.slice().reverse()) {
|
||||||
turnMove = moveHistory.shift();
|
if (
|
||||||
if (!allMoves[turnMove?.move ?? MoveId.NONE].hasAttr(ProtectAttr) || turnMove?.result !== MoveResult.SUCCESS) {
|
// Quick & Wide guard increment the Protect counter without using it for fail chance
|
||||||
|
!(allMoves[turnMove.move].hasAttr(ProtectAttr) ||
|
||||||
|
[MoveId.QUICK_GUARD, MoveId.WIDE_GUARD].includes(turnMove.move)) ||
|
||||||
|
turnMove.result !== MoveResult.SUCCESS
|
||||||
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
timesUsed++;
|
|
||||||
|
timesUsed++
|
||||||
}
|
}
|
||||||
if (timesUsed) {
|
|
||||||
return !user.randBattleSeedInt(Math.pow(3, timesUsed));
|
return timesUsed === 0 || user.randBattleSeedInt(Math.pow(3, timesUsed)) === 0;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4351,6 +4351,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
turnMove.turn = globalScene.currentBattle?.turn;
|
turnMove.turn = globalScene.currentBattle?.turn;
|
||||||
this.getMoveHistory().push(turnMove);
|
this.getMoveHistory().push(turnMove);
|
||||||
|
this.tempSummonData.waveMoveHistory.push(turnMove)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4941,6 +4942,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
*/
|
*/
|
||||||
resetWaveData(): void {
|
resetWaveData(): void {
|
||||||
this.waveData = new PokemonWaveData();
|
this.waveData = new PokemonWaveData();
|
||||||
|
this.tempSummonData.waveTurnCount = 1;
|
||||||
|
this.tempSummonData.waveMoveHistory = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
resetTera(): void {
|
resetTera(): void {
|
||||||
@ -6850,7 +6853,11 @@ export class PokemonSummonData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Merge this inside `summmonData` but exclude from save if/when a save data serializer is added
|
/**
|
||||||
|
* Pokemon data that is not stored in `SummonData` to avoid being written to the save file.
|
||||||
|
*
|
||||||
|
* TODO: Merge this inside `summmonData` but exclude from save if/when a save data serializer is added
|
||||||
|
*/
|
||||||
export class PokemonTempSummonData {
|
export class PokemonTempSummonData {
|
||||||
/**
|
/**
|
||||||
* The number of turns this pokemon has spent without switching out.
|
* The number of turns this pokemon has spent without switching out.
|
||||||
@ -6861,12 +6868,21 @@ export class PokemonTempSummonData {
|
|||||||
/**
|
/**
|
||||||
* The number of turns this pokemon has spent in the active position since the start of the wave
|
* The number of turns this pokemon has spent in the active position since the start of the wave
|
||||||
* without switching out.
|
* without switching out.
|
||||||
* Reset on switch and new wave, but not stored in `SummonData` to avoid being written to the save file.
|
* Reset on switch and new wave.
|
||||||
|
*
|
||||||
* Used to evaluate "first turn only" conditions such as
|
* Used to evaluate "first turn only" conditions such as
|
||||||
* {@linkcode MoveId.FAKE_OUT | Fake Out} and {@linkcode MoveId.FIRST_IMPRESSION | First Impression}).
|
* {@linkcode MoveId.FAKE_OUT | Fake Out} and {@linkcode MoveId.FIRST_IMPRESSION | First Impression}).
|
||||||
*/
|
*/
|
||||||
waveTurnCount = 1;
|
waveTurnCount = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An array containing all moves this Pokemon has used since the start of the wave
|
||||||
|
* without switching out.
|
||||||
|
* Reset on switch and new wave.
|
||||||
|
|
||||||
|
* Used to calculate {@link https://bulbapedia.bulbagarden.net/wiki/Protection | Protecting moves}' fail chances.
|
||||||
|
*/
|
||||||
|
waveMoveHistory: TurnMove[] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,12 +58,6 @@ export class BattleEndPhase extends BattlePhase {
|
|||||||
globalScene.phaseManager.unshiftNew("GameOverPhase", true);
|
globalScene.phaseManager.unshiftNew("GameOverPhase", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const pokemon of globalScene.getField()) {
|
|
||||||
if (pokemon) {
|
|
||||||
pokemon.tempSummonData.waveTurnCount = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const pokemon of globalScene.getPokemonAllowedInBattle()) {
|
for (const pokemon of globalScene.getPokemonAllowedInBattle()) {
|
||||||
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon, false, this.isVictory);
|
applyPostBattleAbAttrs(PostBattleAbAttr, pokemon, false, this.isVictory);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
@ -24,59 +24,53 @@ describe("Moves - Baneful Bunker", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
|
|
||||||
game.override.battleStyle("single");
|
game.override
|
||||||
|
.battleStyle("single")
|
||||||
game.override.moveset(MoveId.SLASH);
|
.moveset([MoveId.SLASH, MoveId.FLASH_CANNON])
|
||||||
|
.enemySpecies(SpeciesId.TOXAPEX)
|
||||||
game.override.enemySpecies(SpeciesId.SNORLAX);
|
.enemyAbility(AbilityId.INSOMNIA)
|
||||||
game.override.enemyAbility(AbilityId.INSOMNIA);
|
.enemyMoveset(MoveId.BANEFUL_BUNKER)
|
||||||
game.override.enemyMoveset(MoveId.BANEFUL_BUNKER);
|
.startingLevel(100)
|
||||||
|
.enemyLevel(100);
|
||||||
game.override.startingLevel(100);
|
|
||||||
game.override.enemyLevel(100);
|
|
||||||
});
|
});
|
||||||
test("should protect the user and poison attackers that make contact", async () => {
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
function expectProtected() {
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
expect(game.scene.getEnemyPokemon()?.hp).toBe(game.scene.getEnemyPokemon()?.getMaxHp());
|
||||||
|
expect(game.scene.getPlayerPokemon()?.status?.effect).toBe(StatusEffect.POISON);
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should protect the user and poison attackers that make contact", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
game.move.select(MoveId.SLASH);
|
game.move.select(MoveId.SLASH);
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
||||||
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy();
|
expectProtected();
|
||||||
});
|
});
|
||||||
test("should protect the user and poison attackers that make contact, regardless of accuracy checks", async () => {
|
|
||||||
|
it("should ignore accuracy checks", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
||||||
|
|
||||||
game.move.select(MoveId.SLASH);
|
game.move.select(MoveId.SLASH);
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
await game.phaseInterceptor.to("MoveEndPhase"); // baneful bunker
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
await game.move.forceMiss();
|
await game.move.forceMiss();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
||||||
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeTruthy();
|
expectProtected();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should not poison attackers that don't make contact", async () => {
|
it("should block non-contact moves without poisoning attackers", async () => {
|
||||||
game.override.moveset(MoveId.FLASH_CANNON);
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const toxapex = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
game.move.select(MoveId.FLASH_CANNON);
|
game.move.select(MoveId.FLASH_CANNON);
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
||||||
await game.phaseInterceptor.to("MoveEffectPhase");
|
|
||||||
|
|
||||||
await game.move.forceMiss();
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
expect(enemyPokemon.hp).toBe(enemyPokemon.getMaxHp());
|
|
||||||
expect(leadPokemon.status?.effect === StatusEffect.POISON).toBeFalsy();
|
expect(toxapex.hp).toBe(toxapex.getMaxHp());
|
||||||
|
expect(charizard.status?.effect).toBeUndefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
import { BattlerTagType } from "#app/enums/battler-tag-type";
|
||||||
import { BerryPhase } from "#app/phases/berry-phase";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||||
|
import { ArenaTagSide } from "#app/data/arena-tag";
|
||||||
|
|
||||||
describe("Moves - Crafty Shield", () => {
|
describe("Moves - Crafty Shield", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -26,85 +27,103 @@ describe("Moves - Crafty Shield", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
|
|
||||||
game.override.battleStyle("double");
|
game.override
|
||||||
|
.battleStyle("double")
|
||||||
game.override.moveset([MoveId.CRAFTY_SHIELD, MoveId.SPLASH, MoveId.SWORDS_DANCE]);
|
.moveset([MoveId.CRAFTY_SHIELD, MoveId.SPLASH, MoveId.SWORDS_DANCE, MoveId.HOWL])
|
||||||
|
.enemySpecies(SpeciesId.DUSKNOIR)
|
||||||
game.override.enemySpecies(SpeciesId.SNORLAX);
|
.enemyMoveset(MoveId.GROWL)
|
||||||
game.override.enemyMoveset([MoveId.GROWL]);
|
.enemyAbility(AbilityId.INSOMNIA)
|
||||||
game.override.enemyAbility(AbilityId.INSOMNIA);
|
.startingLevel(100)
|
||||||
|
.enemyLevel(100);
|
||||||
game.override.startingLevel(100);
|
|
||||||
game.override.enemyLevel(100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from status moves", async () => {
|
it("should protect the user and allies from status moves", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.GROWL);
|
||||||
|
await game.move.forceEnemyMove(MoveId.GROWL);
|
||||||
|
|
||||||
game.move.select(MoveId.CRAFTY_SHIELD);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
|
||||||
|
expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
|
||||||
|
|
||||||
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should not protect the user and allies from attack moves", async () => {
|
it("should not protect the user and allies from attack moves", async () => {
|
||||||
game.override.enemyMoveset([MoveId.TACKLE]);
|
game.override.enemyMoveset(MoveId.TACKLE);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
|
||||||
|
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
|
expect(charizard.isFullHp()).toBe(false);
|
||||||
|
expect(blastoise.isFullHp()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not block entry hazards and field-targeted moves", async () => {
|
||||||
|
game.override.enemyMoveset([MoveId.PERISH_SONG, MoveId.TOXIC_SPIKES]);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.PERISH_SONG);
|
||||||
|
await game.move.forceEnemyMove(MoveId.TOXIC_SPIKES);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
|
expect(game.scene.arena.getTagOnSide(ArenaTagType.TOXIC_SPIKES, ArenaTagSide.PLAYER)).toBeDefined();
|
||||||
|
expect(charizard.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
|
||||||
|
expect(blastoise.getTag(BattlerTagType.PERISH_SONG)).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should protect the user and allies from moves that ignore other protection", async () => {
|
||||||
|
game.override.moveset(MoveId.CURSE);
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
game.move.select(MoveId.CRAFTY_SHIELD);
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER);
|
||||||
|
await game.move.forceEnemyMove(MoveId.CURSE, BattlerIndex.PLAYER_2);
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
expect(charizard.getTag(BattlerTagType.CURSED)).toBeDefined();
|
||||||
|
expect(blastoise.getTag(BattlerTagType.CURSED)).toBeDefined();
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
const [dusknoir1, dusknoir2] = game.scene.getEnemyField();
|
||||||
|
expect(dusknoir1.isFullHp()).toBe(false);
|
||||||
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy();
|
expect(dusknoir2.isFullHp()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from moves that ignore other protection", async () => {
|
it("should not block allies' self or ally-targeted moves", async () => {
|
||||||
game.override.enemySpecies(SpeciesId.DUSCLOPS);
|
|
||||||
game.override.enemyMoveset([MoveId.CURSE]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
game.move.select(MoveId.CRAFTY_SHIELD);
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SWORDS_DANCE, BattlerIndex.PLAYER_2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
|
||||||
|
expect(blastoise.getStatStage(Stat.ATK)).toBe(2);
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
game.move.select(MoveId.HOWL, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.CRAFTY_SHIELD, BattlerIndex.PLAYER_2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
expect(charizard.getStatStage(Stat.ATK)).toBe(1);
|
||||||
|
expect(blastoise.getStatStage(Stat.ATK)).toBe(3);
|
||||||
leadPokemon.forEach(p => expect(p.getTag(BattlerTagType.CURSED)).toBeUndefined());
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should not block allies' self-targeted moves", async () => {
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
|
||||||
|
|
||||||
game.move.select(MoveId.CRAFTY_SHIELD);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
|
|
||||||
game.move.select(MoveId.SWORDS_DANCE, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
|
||||||
|
|
||||||
expect(leadPokemon[0].getStatStage(Stat.ATK)).toBe(0);
|
|
||||||
expect(leadPokemon[1].getStatStage(Stat.ATK)).toBe(2);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
|
import { HitResult } from "#app/field/pokemon";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
describe("Moves - Endure", () => {
|
describe("Moves - Endure", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -22,7 +23,7 @@ describe("Moves - Endure", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
game.override
|
game.override
|
||||||
.moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.TOXIC, MoveId.SHEER_COLD])
|
.moveset([MoveId.THUNDER, MoveId.BULLET_SEED, MoveId.SHEER_COLD])
|
||||||
.ability(AbilityId.SKILL_LINK)
|
.ability(AbilityId.SKILL_LINK)
|
||||||
.startingLevel(100)
|
.startingLevel(100)
|
||||||
.battleStyle("single")
|
.battleStyle("single")
|
||||||
@ -32,55 +33,55 @@ describe("Moves - Endure", () => {
|
|||||||
.enemyMoveset(MoveId.ENDURE);
|
.enemyMoveset(MoveId.ENDURE);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should let the pokemon survive with 1 HP", async () => {
|
it("should let the pokemon survive with 1 HP from attacks", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
||||||
|
|
||||||
game.move.select(MoveId.THUNDER);
|
game.move.select(MoveId.THUNDER);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
expect(enemy.hp).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should let the pokemon survive with 1 HP when hit with a multihit move", async () => {
|
it("should let the pokemon survive with 1 HP from multi-strike moves", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
await game.classicMode.startBattle([SpeciesId.ARCEUS]);
|
||||||
|
|
||||||
game.move.select(MoveId.BULLET_SEED);
|
game.move.select(MoveId.BULLET_SEED);
|
||||||
await game.phaseInterceptor.to("BerryPhase");
|
await game.phaseInterceptor.to("BerryPhase");
|
||||||
|
|
||||||
expect(game.scene.getEnemyPokemon()!.hp).toBe(1);
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
expect(enemy.hp).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should let the pokemon survive against OHKO moves", async () => {
|
it("should let the pokemon survive against OHKO moves", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP]);
|
||||||
const enemy = game.scene.getEnemyPokemon()!;
|
|
||||||
|
|
||||||
game.move.select(MoveId.SHEER_COLD);
|
game.move.select(MoveId.SHEER_COLD);
|
||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
expect(enemy.isFainted()).toBeFalsy();
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
|
expect(enemy.hp).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// comprehensive indirect damage test copied from Reviver Seed test
|
// comprehensive indirect damage test copied from Reviver Seed test
|
||||||
it.each([
|
it.each([
|
||||||
{ moveType: "Damaging Move Chip Damage", move: MoveId.SALT_CURE },
|
{ moveType: "Damaging Move Chip", move: MoveId.SALT_CURE },
|
||||||
{ moveType: "Chip Damage", move: MoveId.LEECH_SEED },
|
{ moveType: "Status Move Chip", move: MoveId.LEECH_SEED },
|
||||||
{ moveType: "Trapping Chip Damage", move: MoveId.WHIRLPOOL },
|
{ moveType: "Partial Trapping move", move: MoveId.WHIRLPOOL },
|
||||||
{ moveType: "Status Effect Damage", move: MoveId.TOXIC },
|
{ moveType: "Status Effect", move: MoveId.TOXIC },
|
||||||
{ moveType: "Weather", move: MoveId.SANDSTORM },
|
{ moveType: "Weather", move: MoveId.SANDSTORM },
|
||||||
])("should not prevent fainting from $moveType", async ({ move }) => {
|
])("should not prevent fainting from $moveType Damage", async ({ move }) => {
|
||||||
game.override
|
game.override.moveset(move).enemyLevel(100);
|
||||||
.enemyLevel(1)
|
|
||||||
.startingLevel(100)
|
|
||||||
.enemySpecies(SpeciesId.MAGIKARP)
|
|
||||||
.moveset(move)
|
|
||||||
.enemyMoveset(MoveId.ENDURE);
|
|
||||||
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
|
await game.classicMode.startBattle([SpeciesId.MAGIKARP, SpeciesId.FEEBAS]);
|
||||||
|
|
||||||
const enemy = game.scene.getEnemyPokemon()!;
|
const enemy = game.scene.getEnemyPokemon()!;
|
||||||
enemy.damageAndUpdate(enemy.hp - 1);
|
enemy.hp = 2;
|
||||||
|
// force attack to do 1 dmg (for salt cure)
|
||||||
|
vi.spyOn(enemy, "getAttackDamage").mockReturnValue({ cancelled: false, result: HitResult.EFFECTIVE, damage: 1 });
|
||||||
|
|
||||||
game.move.select(move);
|
game.move.select(move);
|
||||||
await game.phaseInterceptor.to("TurnEndPhase");
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
expect(enemy.isFainted()).toBeTruthy();
|
expect(enemy.isFainted()).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { allMoves } from "#app/data/data-lists";
|
|
||||||
import { ArenaTagSide, ArenaTrapTag } from "#app/data/arena-tag";
|
|
||||||
import { BattlerIndex } from "#app/battle";
|
|
||||||
import { MoveResult } from "#app/field/pokemon";
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
import { BattlerIndex } from "#app/battle";
|
||||||
|
import { allMoves } from "#app/data/data-lists";
|
||||||
|
|
||||||
describe("Moves - Protect", () => {
|
describe("Moves - Protect", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -26,92 +25,205 @@ describe("Moves - Protect", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
|
game.override
|
||||||
game.override.battleStyle("single");
|
.battleStyle("single")
|
||||||
|
.moveset([MoveId.PROTECT, MoveId.SPIKY_SHIELD, MoveId.ENDURE, MoveId.SPLASH])
|
||||||
game.override.moveset([MoveId.PROTECT]);
|
.enemySpecies(SpeciesId.SNORLAX)
|
||||||
game.override.enemySpecies(SpeciesId.SNORLAX);
|
.enemyAbility(AbilityId.INSOMNIA)
|
||||||
|
.enemyMoveset(MoveId.LUMINA_CRASH)
|
||||||
game.override.enemyAbility(AbilityId.INSOMNIA);
|
.startingLevel(100)
|
||||||
game.override.enemyMoveset([MoveId.TACKLE]);
|
.enemyLevel(100);
|
||||||
|
|
||||||
game.override.startingLevel(100);
|
|
||||||
game.override.enemyLevel(100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user from attacks", async () => {
|
it("should protect the user from attacks and their secondary effects", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
game.move.select(MoveId.PROTECT);
|
game.move.select(MoveId.PROTECT);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(charizard.getStatStage(Stat.SPDEF)).toBe(0);
|
||||||
|
expect(charizard);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should prevent secondary effects from the opponent's attack", async () => {
|
it.each<{ numTurns: number; chance: number }>([
|
||||||
game.override.enemyMoveset([MoveId.CEASELESS_EDGE]);
|
{ numTurns: 1, chance: 3 },
|
||||||
vi.spyOn(allMoves[MoveId.CEASELESS_EDGE], "accuracy", "get").mockReturnValue(100);
|
{ numTurns: 2, chance: 9 },
|
||||||
|
{ numTurns: 3, chance: 27 },
|
||||||
|
{ numTurns: 4, chance: 81 },
|
||||||
|
])("should have a 1/$chance success rate after $numTurns successful uses", async ({ numTurns, chance }) => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
|
||||||
|
// mock RNG roll to suceed unless exactly the desired chance is hit
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range !== chance ? 0 : 1));
|
||||||
|
const conditionSpy = vi.spyOn(allMoves[MoveId.PROTECT]["conditions"][0], "apply");
|
||||||
|
|
||||||
|
// click protect many times
|
||||||
|
for (let x = 0; x < numTurns; x++) {
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
expect(conditionSpy).toHaveLastReturnedWith(true);
|
||||||
|
}
|
||||||
|
|
||||||
game.move.select(MoveId.PROTECT);
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
expect(conditionSpy).toHaveLastReturnedWith(false);
|
||||||
expect(game.scene.arena.getTagOnSide(ArenaTrapTag, ArenaTagSide.ENEMY)).toBeUndefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user from status moves", async () => {
|
it("should share fail chance with all move variants", async () => {
|
||||||
game.override.enemyMoveset([MoveId.CHARM]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
charizard.tempSummonData.waveMoveHistory = [
|
||||||
|
{ move: MoveId.ENDURE, result: MoveResult.SUCCESS, targets: [BattlerIndex.PLAYER] },
|
||||||
|
{ move: MoveId.SPIKY_SHIELD, result: MoveResult.SUCCESS, targets: [BattlerIndex.PLAYER] },
|
||||||
|
];
|
||||||
|
// force protect to fail on anything >=2 uses (1/9 chance)
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockImplementation(range => (range >= 9 ? 1 : 0));
|
||||||
|
|
||||||
game.move.select(MoveId.PROTECT);
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
|
||||||
expect(leadPokemon.getStatStage(Stat.ATK)).toBe(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should stop subsequent hits of a multi-hit move", async () => {
|
it("should reset fail chance on move failure", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
// force protect to always fail if RNG roll attempt is made
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
|
||||||
|
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPIKY_SHIELD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPIKY_SHIELD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should reset fail chance on using another move", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
// force protect to always fail if RNG roll attempt is made
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
|
||||||
|
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should reset fail chance on starting a new wave", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
// force protect to always fail if RNG roll attempt is made
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
|
||||||
|
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
// Wait until move end phase to kill opponent to ensure protect doesn't fail due to going last
|
||||||
|
await game.phaseInterceptor.to("MoveEndPhase");
|
||||||
|
await game.doKillOpponents();
|
||||||
|
await game.toNextWave();
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPIKY_SHIELD);
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not be blocked by Psychic Terrain", async () => {
|
||||||
|
game.override.ability(AbilityId.PSYCHIC_SURGE);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stop subsequent hits of multi-hit moves", async () => {
|
||||||
game.override.enemyMoveset([MoveId.TACHYON_CUTTER]);
|
game.override.enemyMoveset([MoveId.TACHYON_CUTTER]);
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
game.move.select(MoveId.PROTECT);
|
game.move.select(MoveId.PROTECT);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
expect(leadPokemon.hp).toBe(leadPokemon.getMaxHp());
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
expect(enemyPokemon.turnData.hitCount).toBe(1);
|
expect(enemyPokemon.turnData.hitCount).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should fail if the user is the last to move in the turn", async () => {
|
it("should fail if the user moves last in the turn", async () => {
|
||||||
game.override.enemyMoveset([MoveId.PROTECT]);
|
game.override.enemyMoveset(MoveId.PROTECT);
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||||
|
|
||||||
game.move.select(MoveId.PROTECT);
|
game.move.select(MoveId.PROTECT);
|
||||||
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
expect(leadPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not block Protection-bypassing moves or Future Sight", async () => {
|
||||||
|
game.override.enemyMoveset([MoveId.FUTURE_SIGHT, MoveId.MIGHTY_CLEAVE, MoveId.SPORE]);
|
||||||
|
await game.classicMode.startBattle([SpeciesId.AGGRON]);
|
||||||
|
|
||||||
|
const aggron = game.scene.getPlayerPokemon()!;
|
||||||
|
vi.spyOn(aggron, "randBattleSeedInt").mockReturnValue(0);
|
||||||
|
|
||||||
|
// Turn 1: setup future sight
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.move.forceEnemyMove(MoveId.FUTURE_SIGHT);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
// Turn 2: mighty cleave
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.move.forceEnemyMove(MoveId.MIGHTY_CLEAVE);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
|
||||||
|
|
||||||
|
aggron.hp = aggron.getMaxHp();
|
||||||
|
|
||||||
|
// turn 3: Future Sight hits
|
||||||
|
game.move.select(MoveId.PROTECT);
|
||||||
|
await game.move.forceEnemyMove(MoveId.SPORE);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(aggron.hp).toBeLessThan(aggron.getMaxHp());
|
||||||
|
expect(aggron.status?.effect).toBeUndefined(); // check that protect actually worked
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Add test
|
||||||
|
it.todo("should not reset counter when throwing balls");
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { Stat } from "#enums/stat";
|
|
||||||
import { BattlerIndex } from "#app/battle";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { MoveResult } from "#app/field/pokemon";
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
|
||||||
@ -25,80 +24,74 @@ describe("Moves - Quick Guard", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
|
|
||||||
game.override.battleStyle("double");
|
game.override
|
||||||
|
.battleStyle("double")
|
||||||
game.override.moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.FOLLOW_ME]);
|
.moveset([MoveId.QUICK_GUARD, MoveId.SPLASH, MoveId.SPIKY_SHIELD])
|
||||||
|
.enemySpecies(SpeciesId.SNORLAX)
|
||||||
game.override.enemySpecies(SpeciesId.SNORLAX);
|
.enemyMoveset(MoveId.QUICK_ATTACK)
|
||||||
game.override.enemyMoveset([MoveId.QUICK_ATTACK]);
|
.enemyAbility(AbilityId.BALL_FETCH)
|
||||||
game.override.enemyAbility(AbilityId.INSOMNIA);
|
.startingLevel(100)
|
||||||
|
.enemyLevel(100);
|
||||||
game.override.startingLevel(100);
|
|
||||||
game.override.enemyLevel(100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from priority moves", async () => {
|
it("should protect the user and allies from priority moves", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
game.move.select(MoveId.QUICK_GUARD);
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
|
|
||||||
|
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER);
|
||||||
|
await game.move.forceEnemyMove(MoveId.QUICK_ATTACK, BattlerIndex.PLAYER_2);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(blastoise.hp).toBe(blastoise.getMaxHp());
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from Prankster-boosted moves", async () => {
|
it.each<{ name: string; move: MoveId; ability: AbilityId }>([
|
||||||
game.override.enemyAbility(AbilityId.PRANKSTER);
|
{ name: "Prankster", move: MoveId.SPORE, ability: AbilityId.PRANKSTER },
|
||||||
game.override.enemyMoveset([MoveId.GROWL]);
|
{ name: "Gale Wings", move: MoveId.BRAVE_BIRD, ability: AbilityId.GALE_WINGS },
|
||||||
|
])("should protect the user and allies from $name-boosted moves", async ({ move, ability }) => {
|
||||||
|
game.override.enemyMoveset(move).enemyAbility(ability);
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
game.move.select(MoveId.QUICK_GUARD);
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
|
|
||||||
|
game.move.select(MoveId.QUICK_GUARD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER);
|
||||||
|
await game.move.forceEnemyMove(move, BattlerIndex.PLAYER_2);
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
await game.phaseInterceptor.to("BerryPhase", false);
|
||||||
|
|
||||||
playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(blastoise.hp).toBe(blastoise.getMaxHp());
|
||||||
|
expect(charizard.status?.effect).toBeUndefined();
|
||||||
|
expect(blastoise.status?.effect).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should stop subsequent hits of a multi-hit priority move", async () => {
|
it("should increment (but not respect) other protection moves' fail counters", async () => {
|
||||||
game.override.enemyMoveset([MoveId.WATER_SHURIKEN]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerField();
|
|
||||||
const enemyPokemon = game.scene.getEnemyField();
|
|
||||||
|
|
||||||
game.move.select(MoveId.QUICK_GUARD);
|
|
||||||
game.move.select(MoveId.FOLLOW_ME, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
|
||||||
|
|
||||||
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
|
|
||||||
enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should fail if the user is the last to move in the turn", async () => {
|
|
||||||
game.override.battleStyle("single");
|
game.override.battleStyle("single");
|
||||||
game.override.enemyMoveset([MoveId.QUICK_GUARD]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
// force protect to fail on anything >0 uses
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
|
||||||
|
|
||||||
game.move.select(MoveId.QUICK_GUARD);
|
game.move.select(MoveId.QUICK_GUARD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
await game.phaseInterceptor.to("BerryPhase", false);
|
game.move.select(MoveId.QUICK_GUARD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
// ignored fail chance
|
||||||
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPIKY_SHIELD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import Phaser from "phaser";
|
import Phaser from "phaser";
|
||||||
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
import { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { AbilityId } from "#enums/ability-id";
|
import { AbilityId } from "#enums/ability-id";
|
||||||
import { MoveId } from "#enums/move-id";
|
import { MoveId } from "#enums/move-id";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import { BerryPhase } from "#app/phases/berry-phase";
|
import { BattlerIndex } from "#app/battle";
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
import { MoveResult } from "#app/field/pokemon";
|
||||||
|
|
||||||
describe("Moves - Wide Guard", () => {
|
describe("Moves - Wide Guard", () => {
|
||||||
let phaserGame: Phaser.Game;
|
let phaserGame: Phaser.Game;
|
||||||
@ -25,87 +25,86 @@ describe("Moves - Wide Guard", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
game = new GameManager(phaserGame);
|
game = new GameManager(phaserGame);
|
||||||
|
|
||||||
game.override.battleStyle("double");
|
game.override
|
||||||
|
.battleStyle("double")
|
||||||
game.override.moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF]);
|
.moveset([MoveId.WIDE_GUARD, MoveId.SPLASH, MoveId.SURF, MoveId.SPIKY_SHIELD])
|
||||||
|
.enemySpecies(SpeciesId.SNORLAX)
|
||||||
game.override.enemySpecies(SpeciesId.SNORLAX);
|
.enemyMoveset([MoveId.SWIFT, MoveId.GROWL, MoveId.TACKLE])
|
||||||
game.override.enemyMoveset([MoveId.SWIFT]);
|
.enemyAbility(AbilityId.INSOMNIA)
|
||||||
game.override.enemyAbility(AbilityId.INSOMNIA);
|
.startingLevel(100)
|
||||||
|
.enemyLevel(100);
|
||||||
game.override.startingLevel(100);
|
|
||||||
game.override.enemyLevel(100);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from multi-target attack moves", async () => {
|
it("should protect the user and allies from multi-target attack and status moves", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
|
||||||
|
game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.SWIFT);
|
||||||
|
await game.move.forceEnemyMove(MoveId.GROWL);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(blastoise.hp).toBe(blastoise.getMaxHp());
|
||||||
|
expect(charizard.getStatStage(Stat.ATK)).toBe(0);
|
||||||
|
expect(blastoise.getStatStage(Stat.ATK)).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not protect the user and allies from single-target moves", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
const [charizard, blastoise] = game.scene.getPlayerField();
|
||||||
|
game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SPLASH, BattlerIndex.PLAYER_2);
|
||||||
|
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER);
|
||||||
|
await game.move.forceEnemyMove(MoveId.TACKLE, BattlerIndex.PLAYER_2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
game.move.select(MoveId.WIDE_GUARD);
|
expect(charizard.hp).toBeLessThan(charizard.getMaxHp());
|
||||||
|
expect(blastoise.hp).toBeLessThan(blastoise.getMaxHp());
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
|
||||||
|
|
||||||
leadPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should protect the user and allies from multi-target status moves", async () => {
|
it("should protect the user from its ally's multi-target move", async () => {
|
||||||
game.override.enemyMoveset([MoveId.GROWL]);
|
game.override.enemyMoveset(MoveId.SPLASH);
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
const [snorlax1, snorlax2] = game.scene.getEnemyField();
|
||||||
|
|
||||||
|
game.move.select(MoveId.WIDE_GUARD, BattlerIndex.PLAYER);
|
||||||
|
game.move.select(MoveId.SURF, BattlerIndex.PLAYER_2);
|
||||||
|
await game.phaseInterceptor.to("TurnEndPhase");
|
||||||
|
|
||||||
|
expect(charizard.hp).toBe(charizard.getMaxHp());
|
||||||
|
expect(snorlax1.hp).toBeLessThan(snorlax1.getMaxHp());
|
||||||
|
expect(snorlax2.hp).toBeLessThan(snorlax2.getMaxHp());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should increment (but not respect) other protection moves' fail counters", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
await game.classicMode.startBattle([SpeciesId.CHARIZARD]);
|
||||||
|
|
||||||
|
const charizard = game.scene.getPlayerPokemon()!;
|
||||||
|
// force protect to fail on anything other than a guaranteed success
|
||||||
|
vi.spyOn(charizard, "randBattleSeedInt").mockReturnValue(1);
|
||||||
|
|
||||||
game.move.select(MoveId.WIDE_GUARD);
|
game.move.select(MoveId.WIDE_GUARD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
|
||||||
|
|
||||||
leadPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should not protect the user and allies from single-target moves", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.TACKLE]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
|
||||||
|
|
||||||
|
// ignored fail chance
|
||||||
game.move.select(MoveId.WIDE_GUARD);
|
game.move.select(MoveId.WIDE_GUARD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
game.move.select(MoveId.SPIKY_SHIELD);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
// ignored fail chance
|
||||||
|
expect(charizard.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
||||||
expect(leadPokemon.some(p => p.hp < p.getMaxHp())).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should protect the user from its ally's multi-target move", async () => {
|
|
||||||
game.override.enemyMoveset([MoveId.SPLASH]);
|
|
||||||
|
|
||||||
await game.classicMode.startBattle([SpeciesId.CHARIZARD, SpeciesId.BLASTOISE]);
|
|
||||||
|
|
||||||
const leadPokemon = game.scene.getPlayerField();
|
|
||||||
const enemyPokemon = game.scene.getEnemyField();
|
|
||||||
|
|
||||||
game.move.select(MoveId.WIDE_GUARD);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
|
|
||||||
game.move.select(MoveId.SURF, 1);
|
|
||||||
|
|
||||||
await game.phaseInterceptor.to(BerryPhase, false);
|
|
||||||
|
|
||||||
expect(leadPokemon[0].hp).toBe(leadPokemon[0].getMaxHp());
|
|
||||||
enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(p.getMaxHp()));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user