mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
Merge 6fae3cbacd
into a54cd953a6
This commit is contained in:
commit
4292867b08
@ -1,7 +1,7 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type { Arena } from "#app/field/arena";
|
import type { Arena } from "#app/field/arena";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { BooleanHolder, NumberHolder, toDmgValue } from "#app/utils/common";
|
import { BooleanHolder, isNullOrUndefined, NumberHolder, toDmgValue } from "#app/utils/common";
|
||||||
import { allMoves } from "./data-lists";
|
import { allMoves } from "./data-lists";
|
||||||
import { MoveTarget } from "#enums/MoveTarget";
|
import { MoveTarget } from "#enums/MoveTarget";
|
||||||
import { MoveCategory } from "#enums/MoveCategory";
|
import { MoveCategory } from "#enums/MoveCategory";
|
||||||
@ -1544,6 +1544,138 @@ export class SuppressAbilitiesTag extends ArenaTag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains data related to a queued healing effect from
|
||||||
|
* {@link https://bulbapedia.bulbagarden.net/wiki/Healing_Wish_(move) | Healing Wish}
|
||||||
|
* or {@link https://bulbapedia.bulbagarden.net/wiki/Lunar_Dance_(move) | Lunar Dance}.
|
||||||
|
*/
|
||||||
|
interface PendingHealEffect {
|
||||||
|
/** The id for the {@linkcode Pokemon} that created the effect */
|
||||||
|
readonly sourceId: number;
|
||||||
|
/** The {@linkcode MoveId | id} for the move that created the effect */
|
||||||
|
readonly moveId: MoveId;
|
||||||
|
/** If `true`, also restores the target's PP when the effect activates */
|
||||||
|
readonly restorePP: boolean;
|
||||||
|
/** The `i18n` key for the message to display when the effect activates */
|
||||||
|
readonly healMessageKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arena tag to contain stored healing effects, namely from
|
||||||
|
* {@link https://bulbapedia.bulbagarden.net/wiki/Healing_Wish_(move) | Healing Wish}
|
||||||
|
* and {@link https://bulbapedia.bulbagarden.net/wiki/Lunar_Dance_(move) | Lunar Dance}.
|
||||||
|
* When a damaged Pokemon first enters the effect's {@linkcode BattlerIndex | field position},
|
||||||
|
* their HP is fully restored, and they are cured of any non-volatile status condition.
|
||||||
|
* If the effect is from Lunar Dance, their PP is also restored.
|
||||||
|
* @extends ArenaTag
|
||||||
|
*/
|
||||||
|
export class PendingHealTag extends ArenaTag {
|
||||||
|
/** All pending healing effects, organized by {@linkcode BattlerIndex} */
|
||||||
|
private pendingHeals: Partial<Record<BattlerIndex, PendingHealEffect[]>> = {};
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(ArenaTagType.PENDING_HEAL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a pending healing effect to the field. Effects under the same move *and*
|
||||||
|
* target index as an existing effect are ignored.
|
||||||
|
* @param targetIndex - The {@linkcode BattlerIndex} under which the effect applies
|
||||||
|
* @param healEffect - The {@linkcode PendingHealEffect | data} for the pending heal effect
|
||||||
|
*/
|
||||||
|
public queueHeal(targetIndex: BattlerIndex, healEffect: PendingHealEffect): void {
|
||||||
|
const existingHealEffects = this.pendingHeals[targetIndex];
|
||||||
|
if (existingHealEffects) {
|
||||||
|
if (!existingHealEffects.some(he => he.moveId === healEffect.moveId)) {
|
||||||
|
existingHealEffects.push(healEffect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.pendingHeals[targetIndex] = [healEffect];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Removes default on-remove message */
|
||||||
|
override onRemove(_arena: Arena): void {}
|
||||||
|
|
||||||
|
/** This arena tag is removed at the end of the turn if no pending healing effects are on the field */
|
||||||
|
override lapse(_arena: Arena): boolean {
|
||||||
|
for (const key in this.pendingHeals) {
|
||||||
|
if (this.pendingHeals[key].length > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a pending healing effect on the given target index. If an effect is found for
|
||||||
|
* the index, the Pokemon at that index is healed to full HP, is cured of any non-volatile status,
|
||||||
|
* and has its PP fully restored (if the effect is from Lunar Dance).
|
||||||
|
* @param arena - The {@linkcode Arena} containing this tag
|
||||||
|
* @param simulated - If `true`, suppresses changes to game state
|
||||||
|
* @param pokemon - The {@linkcode Pokemon} receiving the healing effect
|
||||||
|
* @returns `true` if the target Pokemon was healed by this effect
|
||||||
|
* @todo This should also be called when a Pokemon moves into a new position via Ally Switch
|
||||||
|
*/
|
||||||
|
override apply(arena: Arena, simulated: boolean, pokemon: Pokemon): boolean {
|
||||||
|
const targetIndex = pokemon.getBattlerIndex();
|
||||||
|
const targetEffects = this.pendingHeals[targetIndex];
|
||||||
|
|
||||||
|
if (simulated) {
|
||||||
|
return !!targetEffects?.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const healEffect = targetEffects?.find(effect => this.canApply(effect, pokemon));
|
||||||
|
if (targetEffects && healEffect) {
|
||||||
|
const { sourceId, moveId, restorePP, healMessageKey } = healEffect;
|
||||||
|
const sourcePokemon = globalScene.getPokemonById(sourceId);
|
||||||
|
if (!sourcePokemon) {
|
||||||
|
console.warn(`Source of pending ${allMoves[moveId].name} effect is undefined!`);
|
||||||
|
targetEffects.splice(targetEffects.indexOf(healEffect), 1);
|
||||||
|
// Re-evaluate after the invalid heal effect is removed
|
||||||
|
return this.apply(arena, simulated, pokemon);
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.unshiftNew(
|
||||||
|
"PokemonHealPhase",
|
||||||
|
targetIndex,
|
||||||
|
pokemon.getMaxHp(),
|
||||||
|
i18next.t(healMessageKey, { pokemonName: getPokemonNameWithAffix(sourcePokemon) }),
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
restorePP,
|
||||||
|
);
|
||||||
|
|
||||||
|
targetEffects.splice(targetEffects.indexOf(healEffect), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !isNullOrUndefined(healEffect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the given {@linkcode PendingHealEffect} can immediately heal
|
||||||
|
* the given target {@linkcode Pokemon}.
|
||||||
|
* @param healEffect - The {@linkcode PendingHealEffect} to evaluate
|
||||||
|
* @param pokemon - The {@linkcode Pokemon} to evaluate against
|
||||||
|
* @returns `true` if the Pokemon can be healed by the effect
|
||||||
|
*/
|
||||||
|
private canApply(healEffect: PendingHealEffect, pokemon: Pokemon): boolean {
|
||||||
|
return (
|
||||||
|
!pokemon.isFullHp() ||
|
||||||
|
!isNullOrUndefined(pokemon.status) ||
|
||||||
|
(healEffect.restorePP && pokemon.getMoveset().some(mv => mv.ppUsed > 0))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
override loadTag(source: ArenaTag | any): void {
|
||||||
|
super.loadTag(source);
|
||||||
|
this.pendingHeals = source.pendingHeals;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
|
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
|
||||||
export function getArenaTag(
|
export function getArenaTag(
|
||||||
tagType: ArenaTagType,
|
tagType: ArenaTagType,
|
||||||
@ -1613,6 +1745,8 @@ export function getArenaTag(
|
|||||||
return new FairyLockTag(turnCount, sourceId);
|
return new FairyLockTag(turnCount, sourceId);
|
||||||
case ArenaTagType.NEUTRALIZING_GAS:
|
case ArenaTagType.NEUTRALIZING_GAS:
|
||||||
return new SuppressAbilitiesTag(sourceId);
|
return new SuppressAbilitiesTag(sourceId);
|
||||||
|
case ArenaTagType.PENDING_HEAL:
|
||||||
|
return new PendingHealTag();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import { getTypeDamageMultiplier } from "../type";
|
|||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { BooleanHolder, NumberHolder, isNullOrUndefined, toDmgValue, randSeedItem, randSeedInt, getEnumValues, toReadableString, type Constructor, randSeedFloat } from "#app/utils/common";
|
import { BooleanHolder, NumberHolder, isNullOrUndefined, toDmgValue, randSeedItem, randSeedInt, getEnumValues, toReadableString, type Constructor, randSeedFloat } from "#app/utils/common";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
import type { ArenaTrapTag } from "../arena-tag";
|
import type { ArenaTrapTag, PendingHealTag } from "../arena-tag";
|
||||||
import { WeakenMoveTypeTag } from "../arena-tag";
|
import { WeakenMoveTypeTag } from "../arena-tag";
|
||||||
import { ArenaTagSide } from "#enums/arena-tag-side";
|
import { ArenaTagSide } from "#enums/arena-tag-side";
|
||||||
import {
|
import {
|
||||||
@ -2082,24 +2082,16 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't know which party member will be chosen, so pick the highest max HP in the party
|
globalScene.arena.addTag(ArenaTagType.PENDING_HEAL, 0, move.id, user.id);
|
||||||
const party = user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty();
|
const tag = globalScene.arena.getTag(ArenaTagType.PENDING_HEAL) as PendingHealTag;
|
||||||
const maxPartyMemberHp = party.map(p => p.getMaxHp()).reduce((maxHp: number, hp: number) => Math.max(hp, maxHp), 0);
|
if (tag) {
|
||||||
|
tag.queueHeal(user.getBattlerIndex(), {
|
||||||
const pm = globalScene.phaseManager;
|
sourceId: user.id,
|
||||||
|
moveId: move.id,
|
||||||
pm.pushPhase(
|
restorePP: this.restorePP,
|
||||||
pm.create("PokemonHealPhase",
|
healMessageKey: i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
|
||||||
user.getBattlerIndex(),
|
});
|
||||||
maxPartyMemberHp,
|
}
|
||||||
i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
this.restorePP),
|
|
||||||
true);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,6 @@ export enum ArenaTagType {
|
|||||||
WATER_FIRE_PLEDGE = "WATER_FIRE_PLEDGE",
|
WATER_FIRE_PLEDGE = "WATER_FIRE_PLEDGE",
|
||||||
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
|
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
|
||||||
FAIRY_LOCK = "FAIRY_LOCK",
|
FAIRY_LOCK = "FAIRY_LOCK",
|
||||||
NEUTRALIZING_GAS = "NEUTRALIZING_GAS"
|
NEUTRALIZING_GAS = "NEUTRALIZING_GAS",
|
||||||
|
PENDING_HEAL = "PENDING_HEAL"
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,6 @@ export class PhaseManager {
|
|||||||
|
|
||||||
/** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */
|
/** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */
|
||||||
private phaseQueuePrependSpliceIndex = -1;
|
private phaseQueuePrependSpliceIndex = -1;
|
||||||
private nextCommandPhaseQueue: Phase[] = [];
|
|
||||||
|
|
||||||
/** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */
|
/** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */
|
||||||
private dynamicPhaseQueues: PhasePriorityQueue[];
|
private dynamicPhaseQueues: PhasePriorityQueue[];
|
||||||
@ -268,11 +267,11 @@ export class PhaseManager {
|
|||||||
* @param phase {@linkcode Phase} the phase to add
|
* @param phase {@linkcode Phase} the phase to add
|
||||||
* @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue
|
* @param defer boolean on which queue to add to, defaults to false, and adds to phaseQueue
|
||||||
*/
|
*/
|
||||||
pushPhase(phase: Phase, defer = false): void {
|
pushPhase(phase: Phase): void {
|
||||||
if (this.getDynamicPhaseType(phase) !== undefined) {
|
if (this.getDynamicPhaseType(phase) !== undefined) {
|
||||||
this.pushDynamicPhase(phase);
|
this.pushDynamicPhase(phase);
|
||||||
} else {
|
} else {
|
||||||
(!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase);
|
this.phaseQueue.push(phase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +298,7 @@ export class PhaseManager {
|
|||||||
* Clears all phase-related stuff, including all phase queues, the current and standby phases, and a splice index
|
* Clears all phase-related stuff, including all phase queues, the current and standby phases, and a splice index
|
||||||
*/
|
*/
|
||||||
clearAllPhases(): void {
|
clearAllPhases(): void {
|
||||||
for (const queue of [this.phaseQueue, this.phaseQueuePrepend, this.conditionalQueue, this.nextCommandPhaseQueue]) {
|
for (const queue of [this.phaseQueue, this.phaseQueuePrepend, this.conditionalQueue]) {
|
||||||
queue.splice(0, queue.length);
|
queue.splice(0, queue.length);
|
||||||
}
|
}
|
||||||
this.dynamicPhaseQueues.forEach(queue => queue.clear());
|
this.dynamicPhaseQueues.forEach(queue => queue.clear());
|
||||||
@ -583,10 +582,6 @@ export class PhaseManager {
|
|||||||
* Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order)
|
* Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order)
|
||||||
*/
|
*/
|
||||||
private populatePhaseQueue(): void {
|
private populatePhaseQueue(): void {
|
||||||
if (this.nextCommandPhaseQueue.length) {
|
|
||||||
this.phaseQueue.push(...this.nextCommandPhaseQueue);
|
|
||||||
this.nextCommandPhaseQueue.splice(0, this.nextCommandPhaseQueue.length);
|
|
||||||
}
|
|
||||||
this.phaseQueue.push(new TurnInitPhase());
|
this.phaseQueue.push(new TurnInitPhase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,8 @@ export class PokemonHealPhase extends CommonAnimPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const hasMessage = !!this.message;
|
const hasMessage = !!this.message;
|
||||||
const healOrDamage = !pokemon.isFullHp() || this.hpHealed < 0;
|
const canRestorePP = this.fullRestorePP && pokemon.getMoveset().some(mv => mv.ppUsed > 0);
|
||||||
|
const healOrDamage = !pokemon.isFullHp() || this.hpHealed < 0 || canRestorePP;
|
||||||
const healBlock = pokemon.getTag(BattlerTagType.HEAL_BLOCK) as HealBlockTag;
|
const healBlock = pokemon.getTag(BattlerTagType.HEAL_BLOCK) as HealBlockTag;
|
||||||
let lastStatusEffect = StatusEffect.NONE;
|
let lastStatusEffect = StatusEffect.NONE;
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import { PokemonPhase } from "./pokemon-phase";
|
|||||||
import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags";
|
import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs";
|
import { applyAbAttrs } from "#app/data/abilities/apply-ab-attrs";
|
||||||
|
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||||
|
|
||||||
export class PostSummonPhase extends PokemonPhase {
|
export class PostSummonPhase extends PokemonPhase {
|
||||||
public readonly phaseName = "PostSummonPhase";
|
public readonly phaseName = "PostSummonPhase";
|
||||||
@ -16,6 +17,9 @@ export class PostSummonPhase extends PokemonPhase {
|
|||||||
if (pokemon.status?.effect === StatusEffect.TOXIC) {
|
if (pokemon.status?.effect === StatusEffect.TOXIC) {
|
||||||
pokemon.status.toxicTurnCount = 0;
|
pokemon.status.toxicTurnCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalScene.arena.applyTags(ArenaTagType.PENDING_HEAL, false, pokemon);
|
||||||
|
|
||||||
globalScene.arena.applyTags(ArenaTrapTag, false, pokemon);
|
globalScene.arena.applyTags(ArenaTrapTag, false, pokemon);
|
||||||
|
|
||||||
// If this is mystery encounter and has post summon phase tag, apply post summon effects
|
// If this is mystery encounter and has post summon phase tag, apply post summon effects
|
||||||
|
@ -285,6 +285,12 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
|
|||||||
switch (arenaEffectChangedEvent.constructor) {
|
switch (arenaEffectChangedEvent.constructor) {
|
||||||
case TagAddedEvent: {
|
case TagAddedEvent: {
|
||||||
const tagAddedEvent = arenaEffectChangedEvent as TagAddedEvent;
|
const tagAddedEvent = arenaEffectChangedEvent as TagAddedEvent;
|
||||||
|
|
||||||
|
const excludedTags = [ArenaTagType.PENDING_HEAL];
|
||||||
|
if (excludedTags.includes(tagAddedEvent.arenaTagType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const isArenaTrapTag = globalScene.arena.getTag(tagAddedEvent.arenaTagType) instanceof ArenaTrapTag;
|
const isArenaTrapTag = globalScene.arena.getTag(tagAddedEvent.arenaTagType) instanceof ArenaTrapTag;
|
||||||
let arenaEffectType: ArenaEffectType;
|
let arenaEffectType: ArenaEffectType;
|
||||||
|
|
||||||
|
246
test/moves/healing-wish-lunar-dance.test.ts
Normal file
246
test/moves/healing-wish-lunar-dance.test.ts
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
import { AbilityId } from "#enums/ability-id";
|
||||||
|
import { ArenaTagType } from "#enums/arena-tag-type";
|
||||||
|
import { Challenges } from "#enums/challenges";
|
||||||
|
import { MoveId } from "#enums/move-id";
|
||||||
|
import { MoveResult } from "#enums/move-result";
|
||||||
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
|
import { SpeciesId } from "#enums/species-id";
|
||||||
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
|
import GameManager from "#test/testUtils/gameManager";
|
||||||
|
import Phaser from "phaser";
|
||||||
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
|
describe("Moves - Lunar Dance and Healing Wish", () => {
|
||||||
|
let phaserGame: Phaser.Game;
|
||||||
|
let game: GameManager;
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
phaserGame = new Phaser.Game({
|
||||||
|
type: Phaser.HEADLESS,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
game.phaseInterceptor.restoreOg();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
game = new GameManager(phaserGame);
|
||||||
|
game.override.battleStyle("double").enemyAbility(AbilityId.BALL_FETCH).enemyMoveset(MoveId.SPLASH);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe.each([
|
||||||
|
{ moveName: "Healing Wish", moveId: MoveId.HEALING_WISH },
|
||||||
|
{ moveName: "Lunar Dance", moveId: MoveId.LUNAR_DANCE },
|
||||||
|
])("$moveName", ({ moveId }) => {
|
||||||
|
it("should sacrifice the user to restore the switched in Pokemon's HP", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
|
||||||
|
|
||||||
|
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
|
||||||
|
squirtle.hp = 1;
|
||||||
|
|
||||||
|
game.move.use(MoveId.SPLASH, 0);
|
||||||
|
game.move.use(moveId, 1);
|
||||||
|
game.doSelectPartyPokemon(2);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(bulbasaur.isFullHp());
|
||||||
|
expect(charmander.isFainted()).toBeTruthy();
|
||||||
|
expect(squirtle.isFullHp());
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should sacrifice the user to cure the switched in Pokemon's status", async () => {
|
||||||
|
game.override.statusEffect(StatusEffect.BURN);
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
|
||||||
|
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
|
game.move.use(MoveId.SPLASH, 0);
|
||||||
|
game.move.use(moveId, 1);
|
||||||
|
game.doSelectPartyPokemon(2);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(bulbasaur.status?.effect).toEqual(StatusEffect.BURN);
|
||||||
|
expect(charmander.isFainted()).toBeTruthy();
|
||||||
|
expect(squirtle.status?.effect).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail if the user has no non-fainted allies in their party", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]);
|
||||||
|
const [bulbasaur, charmander] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
|
game.move.use(MoveId.MEMENTO);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(bulbasaur.isFainted()).toBeTruthy();
|
||||||
|
expect(charmander.isActive(true)).toBeTruthy();
|
||||||
|
|
||||||
|
game.move.use(moveId);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(charmander.isFullHp());
|
||||||
|
expect(charmander.getLastXMoves()[0].result).toEqual(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should fail if the user has no challenge-eligible allies", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
// Mono normal challenge
|
||||||
|
game.challengeMode.addChallenge(Challenges.SINGLE_TYPE, PokemonType.NORMAL + 1, 0);
|
||||||
|
await game.challengeMode.startBattle([SpeciesId.RATICATE, SpeciesId.ODDISH]);
|
||||||
|
|
||||||
|
const [raticate] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
|
game.move.use(moveId);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(raticate.isFullHp());
|
||||||
|
expect(raticate.getLastXMoves()[0].result).toEqual(MoveResult.FAIL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should store its effect if the switched-in Pokemon is perfectly healthy", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER, SpeciesId.SQUIRTLE]);
|
||||||
|
|
||||||
|
const [bulbasaur, charmander, squirtle] = game.scene.getPlayerParty();
|
||||||
|
squirtle.hp = 1;
|
||||||
|
|
||||||
|
game.move.use(moveId);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(bulbasaur.isFainted()).toBeTruthy();
|
||||||
|
expect(charmander.isFullHp());
|
||||||
|
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
// Switch to damaged Squirtle. HW/LD's effect should activate
|
||||||
|
game.doSwitchPokemon(2);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
|
||||||
|
expect(squirtle.isFullHp());
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeUndefined();
|
||||||
|
|
||||||
|
// Set Charmander's HP to 1, then switch back to Charmander.
|
||||||
|
// HW/LD shouldn't activate again
|
||||||
|
charmander.hp = 1;
|
||||||
|
game.doSwitchPokemon(2);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
expect(charmander.hp).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should only store one charge of the effect at a time", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([
|
||||||
|
SpeciesId.BULBASAUR,
|
||||||
|
SpeciesId.CHARMANDER,
|
||||||
|
SpeciesId.SQUIRTLE,
|
||||||
|
SpeciesId.PIKACHU,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const [bulbasaur, charmander, squirtle, pikachu] = game.scene.getPlayerParty();
|
||||||
|
[squirtle, pikachu].forEach(p => (p.hp = 1));
|
||||||
|
|
||||||
|
// Use HW/LD and send in Charmander. HW/LD's effect should be stored
|
||||||
|
game.move.use(moveId);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(bulbasaur.isFainted()).toBeTruthy();
|
||||||
|
expect(charmander.isFullHp());
|
||||||
|
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
|
||||||
|
|
||||||
|
// Use HW/LD again, sending in Squirtle. HW/LD should activate and heal Squirtle
|
||||||
|
game.move.use(moveId);
|
||||||
|
game.doSelectPartyPokemon(2);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charmander.isFainted()).toBeTruthy();
|
||||||
|
expect(squirtle.isFullHp());
|
||||||
|
|
||||||
|
// Switch again to Pikachu. HW/LD's effect shouldn't be present
|
||||||
|
game.doSwitchPokemon(3);
|
||||||
|
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
expect(pikachu.isFullHp()).not.toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Lunar Dance should sacrifice the user to restore the switched in Pokemon's PP", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.CHARMANDER]);
|
||||||
|
const [bulbasaur, charmander] = game.scene.getPlayerParty();
|
||||||
|
[bulbasaur, charmander].forEach(p => game.move.changeMoveset(p, [MoveId.LUNAR_DANCE, MoveId.SPLASH]));
|
||||||
|
|
||||||
|
game.move.select(MoveId.SPLASH);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.doSwitchPokemon(1);
|
||||||
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
game.move.select(MoveId.LUNAR_DANCE);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(charmander.isFainted()).toBeTruthy();
|
||||||
|
bulbasaur.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(0));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should stack with each other", async () => {
|
||||||
|
game.override.battleStyle("single");
|
||||||
|
|
||||||
|
await game.classicMode.startBattle([
|
||||||
|
SpeciesId.BULBASAUR,
|
||||||
|
SpeciesId.CHARMANDER,
|
||||||
|
SpeciesId.SQUIRTLE,
|
||||||
|
SpeciesId.PIKACHU,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const [bulbasaur, charmander, squirtle, pikachu] = game.scene.getPlayerParty();
|
||||||
|
[squirtle, pikachu].forEach(p => {
|
||||||
|
p.hp = 1;
|
||||||
|
p.getMoveset().forEach(mv => (mv.ppUsed = 1));
|
||||||
|
});
|
||||||
|
|
||||||
|
game.move.use(MoveId.LUNAR_DANCE);
|
||||||
|
game.doSelectPartyPokemon(1);
|
||||||
|
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(bulbasaur.isFainted()).toBeTruthy();
|
||||||
|
expect(charmander.isFullHp());
|
||||||
|
expect(game.phaseInterceptor.log).not.toContain("PokemonHealPhase");
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
|
||||||
|
|
||||||
|
game.move.use(MoveId.HEALING_WISH);
|
||||||
|
game.doSelectPartyPokemon(2);
|
||||||
|
|
||||||
|
// Lunar Dance should apply first since it was used first, restoring Squirtle's HP and PP
|
||||||
|
await game.toNextTurn();
|
||||||
|
expect(squirtle.isFullHp());
|
||||||
|
squirtle.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(0));
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeDefined();
|
||||||
|
|
||||||
|
game.doSwitchPokemon(3);
|
||||||
|
|
||||||
|
// Healing Wish should apply on the next switch, restoring Pikachu's HP
|
||||||
|
await game.toEndOfTurn();
|
||||||
|
expect(pikachu.isFullHp());
|
||||||
|
pikachu.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(1));
|
||||||
|
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
@ -1,77 +0,0 @@
|
|||||||
import { StatusEffect } from "#app/enums/status-effect";
|
|
||||||
import { CommandPhase } from "#app/phases/command-phase";
|
|
||||||
import { AbilityId } from "#enums/ability-id";
|
|
||||||
import { MoveId } from "#enums/move-id";
|
|
||||||
import { SpeciesId } from "#enums/species-id";
|
|
||||||
import GameManager from "#test/testUtils/gameManager";
|
|
||||||
import Phaser from "phaser";
|
|
||||||
import { afterEach, beforeAll, beforeEach, describe, it, expect } from "vitest";
|
|
||||||
|
|
||||||
describe("Moves - Lunar Dance", () => {
|
|
||||||
let phaserGame: Phaser.Game;
|
|
||||||
let game: GameManager;
|
|
||||||
|
|
||||||
beforeAll(() => {
|
|
||||||
phaserGame = new Phaser.Game({
|
|
||||||
type: Phaser.HEADLESS,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
game.phaseInterceptor.restoreOg();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
game = new GameManager(phaserGame);
|
|
||||||
game.override
|
|
||||||
.statusEffect(StatusEffect.BURN)
|
|
||||||
.battleStyle("double")
|
|
||||||
.enemyAbility(AbilityId.BALL_FETCH)
|
|
||||||
.enemyMoveset(MoveId.SPLASH);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should full restore HP, PP and status of switched in pokemon, then fail second use because no remaining backup pokemon in party", async () => {
|
|
||||||
await game.classicMode.startBattle([SpeciesId.BULBASAUR, SpeciesId.ODDISH, SpeciesId.RATTATA]);
|
|
||||||
|
|
||||||
const [bulbasaur, oddish, rattata] = game.scene.getPlayerParty();
|
|
||||||
game.move.changeMoveset(bulbasaur, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
|
|
||||||
game.move.changeMoveset(oddish, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
|
|
||||||
game.move.changeMoveset(rattata, [MoveId.LUNAR_DANCE, MoveId.SPLASH]);
|
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 0);
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
// Bulbasaur should still be burned and have used a PP for splash and not at max hp
|
|
||||||
expect(bulbasaur.status?.effect).toBe(StatusEffect.BURN);
|
|
||||||
expect(bulbasaur.moveset[1]?.ppUsed).toBe(1);
|
|
||||||
expect(bulbasaur.hp).toBeLessThan(bulbasaur.getMaxHp());
|
|
||||||
|
|
||||||
// Switch out Bulbasaur for Rattata so we can swtich bulbasaur back in with lunar dance
|
|
||||||
game.doSwitchPokemon(2);
|
|
||||||
game.move.select(MoveId.SPLASH, 1);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 0);
|
|
||||||
game.move.select(MoveId.LUNAR_DANCE);
|
|
||||||
game.doSelectPartyPokemon(2);
|
|
||||||
await game.phaseInterceptor.to("SwitchPhase", false);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
// Bulbasaur should NOT have any status and have full PP for splash and be at max hp
|
|
||||||
expect(bulbasaur.status?.effect).toBeUndefined();
|
|
||||||
expect(bulbasaur.moveset[1]?.ppUsed).toBe(0);
|
|
||||||
expect(bulbasaur.isFullHp()).toBe(true);
|
|
||||||
|
|
||||||
game.move.select(MoveId.SPLASH, 0);
|
|
||||||
game.move.select(MoveId.LUNAR_DANCE);
|
|
||||||
await game.phaseInterceptor.to(CommandPhase);
|
|
||||||
await game.toNextTurn();
|
|
||||||
|
|
||||||
// Using Lunar dance again should fail because nothing in party and rattata should be alive
|
|
||||||
expect(rattata.status?.effect).toBe(StatusEffect.BURN);
|
|
||||||
expect(rattata.hp).toBeLessThan(rattata.getMaxHp());
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in New Issue
Block a user