mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 16:26:25 +00:00
Merge branch 'beta' into me-shiny-fixes
This commit is contained in:
commit
9e494c92db
@ -801,7 +801,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
/**
|
||||
* @returns An array of {@linkcode PlayerPokemon} filtered from the player's party
|
||||
* that are {@linkcode PlayerPokemon.isAllowedInBattle | allowed in battle}.
|
||||
* that are {@linkcode Pokemon.isAllowedInBattle | allowed in battle}.
|
||||
*/
|
||||
public getPokemonAllowedInBattle(): PlayerPokemon[] {
|
||||
return this.getPlayerParty().filter(p => p.isAllowedInBattle());
|
||||
@ -1270,23 +1270,27 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
const lastBattle = this.currentBattle;
|
||||
|
||||
if (lastBattle?.double && !newDouble) {
|
||||
this.tryRemovePhase(p => p instanceof SwitchPhase);
|
||||
}
|
||||
|
||||
const maxExpLevel = this.getMaxExpLevel();
|
||||
|
||||
this.lastEnemyTrainer = lastBattle?.trainer ?? null;
|
||||
this.lastMysteryEncounter = lastBattle?.mysteryEncounter;
|
||||
|
||||
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
|
||||
newDouble = false;
|
||||
}
|
||||
|
||||
if (lastBattle?.double && !newDouble) {
|
||||
this.tryRemovePhase(p => p instanceof SwitchPhase);
|
||||
this.getPlayerField().forEach(p => p.lapseTag(BattlerTagType.COMMANDED));
|
||||
}
|
||||
|
||||
this.executeWithSeedOffset(() => {
|
||||
this.currentBattle = new Battle(this.gameMode, newWaveIndex, newBattleType, newTrainer, newDouble);
|
||||
}, newWaveIndex << 3, this.waveSeed);
|
||||
this.currentBattle.incrementTurn(this);
|
||||
|
||||
if (newBattleType === BattleType.MYSTERY_ENCOUNTER) {
|
||||
// Disable double battle on mystery encounters (it may be re-enabled as part of encounter)
|
||||
this.currentBattle.double = false;
|
||||
// Will generate the actual Mystery Encounter during NextEncounterPhase, to ensure it uses proper biome
|
||||
this.currentBattle.mysteryEncounterType = mysteryEncounterType;
|
||||
}
|
||||
|
@ -6373,10 +6373,17 @@ export class RandomMovesetMoveAttr extends OverrideMoveEffectAttr {
|
||||
}
|
||||
|
||||
export class RandomMoveAttr extends OverrideMoveEffectAttr {
|
||||
/**
|
||||
* This function exists solely to allow tests to override the randomly selected move by mocking this function.
|
||||
*/
|
||||
public getMoveOverride(): Moves | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
const moveIds = Utils.getEnumValues(Moves).filter(m => !allMoves[m].hasFlag(MoveFlags.IGNORE_VIRTUAL) && !allMoves[m].name.endsWith(" (N)"));
|
||||
const moveId = moveIds[user.randSeedInt(moveIds.length)];
|
||||
const moveId = this.getMoveOverride() ?? moveIds[user.randSeedInt(moveIds.length)];
|
||||
|
||||
const moveTargets = getMoveTargets(user, moveId);
|
||||
if (!moveTargets.targets.length) {
|
||||
@ -6759,7 +6766,7 @@ export class SketchAttr extends MoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
const targetMove = target.getLastXMoves(target.battleSummonData.turnCount)
|
||||
const targetMove = target.getLastXMoves(-1)
|
||||
.find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual);
|
||||
if (!targetMove) {
|
||||
return false;
|
||||
|
@ -23,7 +23,7 @@ import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from "#app/data/balance/
|
||||
import { BattlerTag, BattlerTagLapseType, EncoreTag, GroundedTag, HighestStatBoostTag, SubstituteTag, TypeImmuneTag, getBattlerTag, SemiInvulnerableTag, TypeBoostTag, MoveRestrictionBattlerTag, ExposedTag, DragonCheerTag, CritBoostTag, TrappedTag, TarShotTag, AutotomizedTag, PowerTrickTag } from "../data/battler-tags";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { ArenaTagSide, NoCritTag, WeakenMoveScreenTag } from "#app/data/arena-tag";
|
||||
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr } from "#app/data/ability";
|
||||
import { Ability, AbAttr, StatMultiplierAbAttr, BlockCritAbAttr, BonusCritAbAttr, BypassBurnDamageReductionAbAttr, FieldPriorityMoveImmunityAbAttr, IgnoreOpponentStatStagesAbAttr, MoveImmunityAbAttr, PreDefendFullHpEndureAbAttr, ReceivedMoveDamageMultiplierAbAttr, StabBoostAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, WeightMultiplierAbAttr, allAbilities, applyAbAttrs, applyStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs, UnsuppressableAbilityAbAttr, SuppressFieldAbilitiesAbAttr, NoFusionAbilityAbAttr, MultCritAbAttr, IgnoreTypeImmunityAbAttr, DamageBoostAbAttr, IgnoreTypeStatusEffectImmunityAbAttr, ConditionalCritAbAttr, applyFieldStatMultiplierAbAttrs, FieldMultiplyStatAbAttr, AddSecondStrikeAbAttr, UserFieldStatusEffectImmunityAbAttr, UserFieldBattlerTagImmunityAbAttr, BattlerTagImmunityAbAttr, MoveTypeChangeAbAttr, FullHpResistTypeAbAttr, applyCheckTrappedAbAttrs, CheckTrappedAbAttr, PostSetStatusAbAttr, applyPostSetStatusAbAttrs, InfiltratorAbAttr, AlliedFieldDamageReductionAbAttr, PostDamageAbAttr, applyPostDamageAbAttrs, PostDamageForceSwitchAbAttr, CommanderAbAttr } from "#app/data/ability";
|
||||
import PokemonData from "#app/system/pokemon-data";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { Mode } from "#app/ui/ui";
|
||||
@ -3073,7 +3073,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
lapseTag(tagType: BattlerTagType): boolean {
|
||||
const tags = this.summonData.tags;
|
||||
const tags = this.summonData?.tags;
|
||||
if (isNullOrUndefined(tags)) {
|
||||
return false;
|
||||
}
|
||||
const tag = tags.find(t => t.tagType === tagType);
|
||||
if (tag && !(tag.lapse(this, BattlerTagLapseType.CUSTOM))) {
|
||||
tag.onRemove(this);
|
||||
@ -3215,9 +3218,21 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.getMoveHistory().push(turnMove);
|
||||
}
|
||||
|
||||
getLastXMoves(turnCount: integer = 0): TurnMove[] {
|
||||
/**
|
||||
* Returns a list of the most recent move entries in this Pokemon's move history.
|
||||
* The retrieved move entries are sorted in order from NEWEST to OLDEST.
|
||||
* @param moveCount The number of move entries to retrieve.
|
||||
* If negative, retrieve the Pokemon's entire move history (equivalent to reversing the output of {@linkcode getMoveHistory()}).
|
||||
* Default is `1`.
|
||||
* @returns A list of {@linkcode TurnMove}, as specified above.
|
||||
*/
|
||||
getLastXMoves(moveCount: number = 1): TurnMove[] {
|
||||
const moveHistory = this.getMoveHistory();
|
||||
return moveHistory.slice(turnCount >= 0 ? Math.max(moveHistory.length - (turnCount || 1), 0) : 0, moveHistory.length).reverse();
|
||||
if (moveCount >= 0) {
|
||||
return moveHistory.slice(Math.max(moveHistory.length - moveCount, 0)).reverse();
|
||||
} else {
|
||||
return moveHistory.slice(0).reverse();
|
||||
}
|
||||
}
|
||||
|
||||
getMoveQueue(): QueuedMove[] {
|
||||
@ -3638,6 +3653,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.scene.triggerPokemonBattleAnim(this, PokemonAnimType.SUBSTITUTE_ADD);
|
||||
this.getTag(SubstituteTag)!.sourceInFocus = false;
|
||||
}
|
||||
|
||||
// If this Pokemon has Commander and Dondozo as an active ally, hide this Pokemon's sprite.
|
||||
if (this.hasAbilityWithAttr(CommanderAbAttr)
|
||||
&& this.scene.currentBattle.double
|
||||
&& this.getAlly()?.species.speciesId === Species.DONDOZO) {
|
||||
this.setVisible(false);
|
||||
}
|
||||
this.summonDataPrimer = null;
|
||||
}
|
||||
this.updateInfo();
|
||||
@ -4020,8 +4042,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.resetTurnData();
|
||||
if (clearEffects) {
|
||||
this.destroySubstitute();
|
||||
this.resetSummonData();
|
||||
this.resetBattleData();
|
||||
this.resetSummonData(); // this also calls `resetBattleSummonData`
|
||||
}
|
||||
if (hideInfo) {
|
||||
this.hideInfo();
|
||||
|
@ -728,10 +728,10 @@ export abstract class PokemonHeldItemModifier extends PersistentModifier {
|
||||
//Applies to items with chance of activating secondary effects ie Kings Rock
|
||||
getSecondaryChanceMultiplier(pokemon: Pokemon): number {
|
||||
// Temporary quickfix to stop game from freezing when the opponet uses u-turn while holding on to king's rock
|
||||
if (!pokemon.getLastXMoves(0)[0]) {
|
||||
if (!pokemon.getLastXMoves()[0]) {
|
||||
return 1;
|
||||
}
|
||||
const sheerForceAffected = allMoves[pokemon.getLastXMoves(0)[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE);
|
||||
const sheerForceAffected = allMoves[pokemon.getLastXMoves()[0].move].chance >= 0 && pokemon.hasAbility(Abilities.SHEER_FORCE);
|
||||
|
||||
if (sheerForceAffected) {
|
||||
return 0;
|
||||
|
@ -26,25 +26,29 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||
|
||||
const pokemon = this.scene.getPlayerField()[this.fieldIndex];
|
||||
|
||||
// End this phase early...
|
||||
|
||||
// ...if the user is playing in Set Mode
|
||||
if (this.scene.battleStyle === BattleStyle.SET) {
|
||||
super.end();
|
||||
return;
|
||||
return super.end();
|
||||
}
|
||||
|
||||
// ...if the checked Pokemon is somehow not on the field
|
||||
if (this.scene.field.getAll().indexOf(pokemon) === -1) {
|
||||
this.scene.unshiftPhase(new SummonMissingPhase(this.scene, this.fieldIndex));
|
||||
super.end();
|
||||
return;
|
||||
return super.end();
|
||||
}
|
||||
|
||||
// ...if there are no other allowed Pokemon in the player's party to switch with
|
||||
if (!this.scene.getPlayerParty().slice(1).filter(p => p.isActive()).length) {
|
||||
super.end();
|
||||
return;
|
||||
return super.end();
|
||||
}
|
||||
|
||||
if (pokemon.getTag(BattlerTagType.FRENZY)) {
|
||||
super.end();
|
||||
return;
|
||||
// ...or if any player Pokemon has an effect that prevents the checked Pokemon from switching
|
||||
if (pokemon.getTag(BattlerTagType.FRENZY)
|
||||
|| pokemon.isTrapped()
|
||||
|| this.scene.getPlayerField().some(p => p.getTag(BattlerTagType.COMMANDED))) {
|
||||
return super.end();
|
||||
}
|
||||
|
||||
this.scene.ui.showText(i18next.t("battle:switchQuestion", { pokemonName: this.useName ? getPokemonNameWithAffix(pokemon) : i18next.t("battle:pokemon") }), null, () => {
|
||||
|
@ -36,7 +36,6 @@ import { PlayerGender } from "#enums/player-gender";
|
||||
import { Species } from "#enums/species";
|
||||
import i18next from "i18next";
|
||||
import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mystery-encounters";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
|
||||
export class EncounterPhase extends BattlePhase {
|
||||
private loaded: boolean;
|
||||
@ -486,7 +485,6 @@ export class EncounterPhase extends BattlePhase {
|
||||
}
|
||||
} else {
|
||||
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) {
|
||||
this.scene.getPlayerField().forEach((pokemon) => pokemon.lapseTag(BattlerTagType.COMMANDED));
|
||||
this.scene.pushPhase(new ReturnPhase(this.scene, 1));
|
||||
}
|
||||
this.scene.pushPhase(new ToggleDoublePositionPhase(this.scene, false));
|
||||
|
@ -138,7 +138,6 @@ export class SwitchSummonPhase extends SummonPhase {
|
||||
switchedInPokemon.setAlpha(0.5);
|
||||
}
|
||||
} else {
|
||||
switchedInPokemon.resetBattleData();
|
||||
switchedInPokemon.resetSummonData();
|
||||
}
|
||||
this.summon();
|
||||
|
@ -8,7 +8,8 @@ import { Moves } from "#enums/moves";
|
||||
import { Species } from "#enums/species";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { allMoves, RandomMoveAttr } from "#app/data/move";
|
||||
|
||||
// See also: TypeImmunityAbAttr
|
||||
describe("Abilities - Sap Sipper", () => {
|
||||
@ -27,20 +28,20 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
game = new GameManager(phaserGame);
|
||||
game.override.battleType("single");
|
||||
game.override.disableCrits();
|
||||
game.override.battleType("single")
|
||||
.disableCrits()
|
||||
.ability(Abilities.SAP_SIPPER)
|
||||
.enemySpecies(Species.RATTATA)
|
||||
.enemyAbility(Abilities.SAP_SIPPER)
|
||||
.enemyMoveset(Moves.SPLASH);
|
||||
});
|
||||
|
||||
it("raises ATK stat stage by 1 and block effects when activated against a grass attack", async() => {
|
||||
const moveToUse = Moves.LEAFAGE;
|
||||
const enemyAbility = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.DUSKULL);
|
||||
game.override.enemyAbility(enemyAbility);
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const initialEnemyHp = enemyPokemon.hp;
|
||||
@ -55,14 +56,10 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
it("raises ATK stat stage by 1 and block effects when activated against a grass status move", async() => {
|
||||
const moveToUse = Moves.SPORE;
|
||||
const enemyAbility = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(enemyAbility);
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
@ -76,14 +73,10 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
it("do not activate against status moves that target the field", async () => {
|
||||
const moveToUse = Moves.GRASSY_TERRAIN;
|
||||
const enemyAbility = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(enemyAbility);
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
game.move.select(moveToUse);
|
||||
|
||||
@ -96,14 +89,10 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
it("activate once against multi-hit grass attacks", async () => {
|
||||
const moveToUse = Moves.BULLET_SEED;
|
||||
const enemyAbility = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(enemyAbility);
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const initialEnemyHp = enemyPokemon.hp;
|
||||
@ -118,15 +107,10 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
it("do not activate against status moves that target the user", async () => {
|
||||
const moveToUse = Moves.SPIKY_SHIELD;
|
||||
const ability = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.ability(ability);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(Abilities.NONE);
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
|
||||
@ -142,18 +126,15 @@ describe("Abilities - Sap Sipper", () => {
|
||||
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
||||
});
|
||||
|
||||
// TODO Add METRONOME outcome override
|
||||
// To run this testcase, manually modify the METRONOME move to always give SAP_SIPPER, then uncomment
|
||||
it.todo("activate once against multi-hit grass attacks (metronome)", async () => {
|
||||
it("activate once against multi-hit grass attacks (metronome)", async () => {
|
||||
const moveToUse = Moves.METRONOME;
|
||||
const enemyAbility = Abilities.SAP_SIPPER;
|
||||
|
||||
game.override.moveset([ moveToUse ]);
|
||||
game.override.enemyMoveset([ Moves.SPLASH, Moves.NONE, Moves.NONE, Moves.NONE ]);
|
||||
game.override.enemySpecies(Species.RATTATA);
|
||||
game.override.enemyAbility(enemyAbility);
|
||||
const randomMoveAttr = allMoves[Moves.METRONOME].findAttr(attr => attr instanceof RandomMoveAttr) as RandomMoveAttr;
|
||||
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.BULLET_SEED);
|
||||
|
||||
await game.startBattle();
|
||||
game.override.moveset(moveToUse);
|
||||
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
const initialEnemyHp = enemyPokemon.hp;
|
||||
@ -168,11 +149,8 @@ describe("Abilities - Sap Sipper", () => {
|
||||
|
||||
it("still activates regardless of accuracy check", async () => {
|
||||
game.override.moveset(Moves.LEAF_BLADE);
|
||||
game.override.enemyMoveset(Moves.SPLASH);
|
||||
game.override.enemySpecies(Species.MAGIKARP);
|
||||
game.override.enemyAbility(Abilities.SAP_SIPPER);
|
||||
|
||||
await game.classicMode.startBattle();
|
||||
await game.classicMode.startBattle([ Species.BULBASAUR ]);
|
||||
|
||||
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
||||
|
||||
|
@ -296,7 +296,9 @@ describe("Abilities - Wimp Out", () => {
|
||||
Species.TYRUNT
|
||||
]);
|
||||
|
||||
game.move.select(Moves.SPLASH);
|
||||
game.scene.getPlayerPokemon()!.hp *= 0.51;
|
||||
|
||||
game.move.select(Moves.ENDURE);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
|
||||
confirmNoSwitch();
|
||||
|
@ -4,9 +4,10 @@ import { Species } from "#enums/species";
|
||||
import { MoveResult, PokemonMove } from "#app/field/pokemon";
|
||||
import GameManager from "#test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { StatusEffect } from "#app/enums/status-effect";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { allMoves, RandomMoveAttr } from "#app/data/move";
|
||||
|
||||
describe("Moves - Sketch", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -76,4 +77,22 @@ describe("Moves - Sketch", () => {
|
||||
expect(playerPokemon.moveset[0]?.moveId).toBe(Moves.SPLASH);
|
||||
expect(playerPokemon.moveset[1]?.moveId).toBe(Moves.GROWL);
|
||||
});
|
||||
|
||||
it("should sketch moves that call other moves", async () => {
|
||||
const randomMoveAttr = allMoves[Moves.METRONOME].findAttr(attr => attr instanceof RandomMoveAttr) as RandomMoveAttr;
|
||||
vi.spyOn(randomMoveAttr, "getMoveOverride").mockReturnValue(Moves.FALSE_SWIPE);
|
||||
|
||||
game.override.enemyMoveset([ Moves.METRONOME ]);
|
||||
await game.classicMode.startBattle([ Species.REGIELEKI ]);
|
||||
const playerPokemon = game.scene.getPlayerPokemon()!;
|
||||
playerPokemon.moveset = [ new PokemonMove(Moves.SKETCH) ];
|
||||
|
||||
// Opponent uses Metronome -> False Swipe, then player uses Sketch, which should sketch Metronome
|
||||
game.move.select(Moves.SKETCH);
|
||||
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
||||
await game.phaseInterceptor.to("TurnEndPhase");
|
||||
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
||||
expect(playerPokemon.moveset[0]?.moveId).toBe(Moves.METRONOME);
|
||||
expect(playerPokemon.hp).toBeLessThan(playerPokemon.getMaxHp()); // Make sure opponent actually used False Swipe
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user