Compare commits

...

12 Commits

Author SHA1 Message Date
Dean
a9fa05fca3
Merge ce3fe897c3 into 6c0253ada4 2025-08-11 10:06:11 -04:00
Jimmybald1
6c0253ada4
[Misc] Expanded Daily Run custom seeds (#6248)
* Modify custom starters and added boss, biome and luck custom seed overrides

* Added form index to boss custom seed

* Fix circular dependency in daily-run.ts

* Review for PR 6248

- Use early returns

- Update TSDocs

- Use `getEnumValues` instead of `Object.values` for `enum`s

- Add console logging for invalid seeds

---------

Co-authored-by: Jimmybald1 <147992650+IBBCalc@users.noreply.github.com>
Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-08-10 23:43:31 -04:00
Dean
ce3fe897c3
Update src/data/arena-tag.ts
Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com>
2025-08-05 13:31:48 -07:00
Dean
605d61cec9 Update test import 2025-08-02 19:27:03 -07:00
Dean
d55cfbcf38 Update tag for serialization 2025-08-02 17:36:58 -07:00
Dean
8f9fca50a1 Merge branch 'beta' into pr/emdeann/6027 2025-08-02 16:56:54 -07:00
Dean
6018e11233 Use message directly instead of as key in tag 2025-08-02 16:55:41 -07:00
Dean
d798ebb545 Code review 2025-07-23 11:49:42 -07:00
Dean
f771e29b0f Fix test 2025-07-15 20:04:39 -07:00
Dean
d2f8495c1f Merge branch 'beta' of https://github.com/pagefaultgames/pokerogue into hwish 2025-07-15 20:00:33 -07:00
Dean
6fae3cbacd Implement PendingHealTag 2025-06-23 16:54:50 -07:00
Dean
b552779316 Remove NCPQ 2025-06-22 21:21:05 -07:00
13 changed files with 565 additions and 129 deletions

View File

@ -10,6 +10,7 @@ import { allMoves } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { ArenaTagSide } from "#enums/arena-tag-side";
import { ArenaTagType } from "#enums/arena-tag-type";
import type { BattlerIndex } from "#enums/battler-index";
import { BattlerTagType } from "#enums/battler-tag-type";
import { HitResult } from "#enums/hit-result";
import { CommonAnim } from "#enums/move-anims-common";
@ -28,7 +29,7 @@ import type {
SerializableArenaTagType,
} from "#types/arena-tags";
import type { Mutable } from "#types/type-helpers";
import { BooleanHolder, NumberHolder, toDmgValue } from "#utils/common";
import { BooleanHolder, isNullOrUndefined, NumberHolder, toDmgValue } from "#utils/common";
import i18next from "i18next";
/**
@ -1583,6 +1584,138 @@ export class SuppressAbilitiesTag extends SerializableArenaTag {
}
}
/**
* Interface containing 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 {@linkcode Pokemon.id | PID} of the {@linkcode Pokemon} that created the effect. */
readonly sourceId: number;
/** The {@linkcode MoveId} of 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 message to display when the effect activates */
readonly healMessage: 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.
*/
export class PendingHealTag extends SerializableArenaTag {
public readonly tagType = ArenaTagType.PENDING_HEAL;
/** All pending healing effects, organized by {@linkcode BattlerIndex} */
public readonly pendingHeals: Partial<Record<BattlerIndex, PendingHealEffect[]>> = {};
constructor() {
super(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, healMessage } = 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(),
healMessage,
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: BaseArenaTag & Pick<PendingHealTag, "tagType" | "pendingHeals">): void {
super.loadTag(source);
(this as Mutable<this>).pendingHeals = source.pendingHeals;
}
}
// TODO: swap `sourceMove` and `sourceId` and make `sourceMove` an optional parameter
export function getArenaTag(
tagType: ArenaTagType,
@ -1646,6 +1779,8 @@ export function getArenaTag(
return new FairyLockTag(turnCount, sourceId);
case ArenaTagType.NEUTRALIZING_GAS:
return new SuppressAbilitiesTag(sourceId);
case ArenaTagType.PENDING_HEAL:
return new PendingHealTag();
default:
return null;
}
@ -1694,5 +1829,6 @@ export type ArenaTagTypeMap = {
[ArenaTagType.GRASS_WATER_PLEDGE]: GrassWaterPledgeTag;
[ArenaTagType.FAIRY_LOCK]: FairyLockTag;
[ArenaTagType.NEUTRALIZING_GAS]: SuppressAbilitiesTag;
[ArenaTagType.PENDING_HEAL]: PendingHealTag;
[ArenaTagType.NONE]: NoneTag;
};

View File

@ -5,10 +5,9 @@ import type { PokemonSpeciesForm } from "#data/pokemon-species";
import { PokemonSpecies } from "#data/pokemon-species";
import { BiomeId } from "#enums/biome-id";
import { PartyMemberStrength } from "#enums/party-member-strength";
import type { SpeciesId } from "#enums/species-id";
import { PlayerPokemon } from "#field/pokemon";
import { SpeciesId } from "#enums/species-id";
import type { Starter } from "#ui/starter-select-ui-handler";
import { randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
import { isNullOrUndefined, randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
import { getEnumValues } from "#utils/enums";
import { getPokemonSpecies, getPokemonSpeciesForm } from "#utils/pokemon-utils";
@ -32,15 +31,9 @@ export function getDailyRunStarters(seed: string): Starter[] {
() => {
const startingLevel = globalScene.gameMode.getStartingLevel();
if (/\d{18}$/.test(seed)) {
for (let s = 0; s < 3; s++) {
const offset = 6 + s * 6;
const starterSpeciesForm = getPokemonSpeciesForm(
Number.parseInt(seed.slice(offset, offset + 4)) as SpeciesId,
Number.parseInt(seed.slice(offset + 4, offset + 6)),
);
starters.push(getDailyRunStarter(starterSpeciesForm, startingLevel));
}
const eventStarters = getDailyEventSeedStarters(seed);
if (!isNullOrUndefined(eventStarters)) {
starters.push(...eventStarters);
return;
}
@ -72,18 +65,7 @@ function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLeve
const starterSpecies =
starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
const pokemon = new PlayerPokemon(
starterSpecies,
startingLevel,
undefined,
formIndex,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
);
const pokemon = globalScene.addPlayerPokemon(starterSpecies, startingLevel, undefined, formIndex);
const starter: Starter = {
species: starterSpecies,
dexAttr: pokemon.getDexAttr(),
@ -145,6 +127,11 @@ const dailyBiomeWeights: BiomeWeights = {
};
export function getDailyStartingBiome(): BiomeId {
const eventBiome = getDailyEventSeedBiome(globalScene.seed);
if (!isNullOrUndefined(eventBiome)) {
return eventBiome;
}
const biomes = getEnumValues(BiomeId).filter(b => b !== BiomeId.TOWN && b !== BiomeId.END);
let totalWeight = 0;
@ -169,3 +156,126 @@ export function getDailyStartingBiome(): BiomeId {
// TODO: should this use `randSeedItem`?
return biomes[randSeedInt(biomes.length)];
}
/**
* If this is Daily Mode and the seed is longer than a default seed
* then it has been modified and could contain a custom event seed. \
* Default seeds are always exactly 24 characters.
* @returns `true` if it is a Daily Event Seed.
*/
export function isDailyEventSeed(seed: string): boolean {
return globalScene.gameMode.isDaily && seed.length > 24;
}
/**
* Expects the seed to contain `/starters\d{18}/`
* where the digits alternate between 4 digits for the species ID and 2 digits for the form index
* (left padded with `0`s as necessary).
* @returns An array of {@linkcode Starter}s, or `null` if no valid match.
*/
export function getDailyEventSeedStarters(seed: string): Starter[] | null {
if (!isDailyEventSeed(seed)) {
return null;
}
const starters: Starter[] = [];
const match = /starters(\d{4})(\d{2})(\d{4})(\d{2})(\d{4})(\d{2})/g.exec(seed);
if (!match || match.length !== 7) {
return null;
}
for (let i = 1; i < match.length; i += 2) {
const speciesId = Number.parseInt(match[i]) as SpeciesId;
const formIndex = Number.parseInt(match[i + 1]);
if (!getEnumValues(SpeciesId).includes(speciesId)) {
console.warn("Invalid species ID used for custom daily run seed starter:", speciesId);
return null;
}
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
const startingLevel = globalScene.gameMode.getStartingLevel();
const starter = getDailyRunStarter(starterForm, startingLevel);
starters.push(starter);
}
return starters;
}
/**
* Expects the seed to contain `/boss\d{4}\d{2}/`
* where the first 4 digits are the species ID and the next 2 digits are the form index
* (left padded with `0`s as necessary).
* @returns A {@linkcode PokemonSpeciesForm} to be used for the boss, or `null` if no valid match.
*/
export function getDailyEventSeedBoss(seed: string): PokemonSpeciesForm | null {
if (!isDailyEventSeed(seed)) {
return null;
}
const match = /boss(\d{4})(\d{2})/g.exec(seed);
if (!match || match.length !== 3) {
return null;
}
const speciesId = Number.parseInt(match[1]) as SpeciesId;
const formIndex = Number.parseInt(match[2]);
if (!getEnumValues(SpeciesId).includes(speciesId)) {
console.warn("Invalid species ID used for custom daily run seed boss:", speciesId);
return null;
}
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
return starterForm;
}
/**
* Expects the seed to contain `/biome\d{2}/` where the 2 digits are a biome ID (left padded with `0` if necessary).
* @returns The biome to use or `null` if no valid match.
*/
export function getDailyEventSeedBiome(seed: string): BiomeId | null {
if (!isDailyEventSeed(seed)) {
return null;
}
const match = /biome(\d{2})/g.exec(seed);
if (!match || match.length !== 2) {
return null;
}
const startingBiome = Number.parseInt(match[1]) as BiomeId;
if (!getEnumValues(BiomeId).includes(startingBiome)) {
console.warn("Invalid biome ID used for custom daily run seed:", startingBiome);
return null;
}
return startingBiome;
}
/**
* Expects the seed to contain `/luck\d{2}/` where the 2 digits are a number between `0` and `14`
* (left padded with `0` if necessary).
* @returns The custom luck value or `null` if no valid match.
*/
export function getDailyEventSeedLuck(seed: string): number | null {
if (!isDailyEventSeed(seed)) {
return null;
}
const match = /luck(\d{2})/g.exec(seed);
if (!match || match.length !== 2) {
return null;
}
const luck = Number.parseInt(match[1]);
if (luck < 0 || luck > 14) {
console.warn("Invalid luck value used for custom daily run seed:", luck);
return null;
}
return luck;
}

View File

@ -6,7 +6,7 @@ import { loggedInUser } from "#app/account";
import type { GameMode } from "#app/game-mode";
import { globalScene } from "#app/global-scene";
import { getPokemonNameWithAffix } from "#app/messages";
import type { ArenaTrapTag } from "#data/arena-tag";
import type { ArenaTrapTag, PendingHealTag } from "#data/arena-tag";
import { WeakenMoveTypeTag } from "#data/arena-tag";
import { MoveChargeAnim } from "#data/battle-anims";
import {
@ -2094,24 +2094,15 @@ export class SacrificialFullRestoreAttr extends SacrificialAttr {
return false;
}
// We don't know which party member will be chosen, so pick the highest max HP in the party
const party = user.isPlayer() ? globalScene.getPlayerParty() : globalScene.getEnemyParty();
const maxPartyMemberHp = party.map(p => p.getMaxHp()).reduce((maxHp: number, hp: number) => Math.max(hp, maxHp), 0);
const pm = globalScene.phaseManager;
pm.pushPhase(
pm.create("PokemonHealPhase",
user.getBattlerIndex(),
maxPartyMemberHp,
i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
true,
false,
false,
true,
false,
this.restorePP),
true);
// Add a tag to the field if it doesn't already exist, then queue a delayed healing effect in the user's current slot.
globalScene.arena.addTag(ArenaTagType.PENDING_HEAL, 0, move.id, user.id); // Arguments after first go completely unused
const tag = globalScene.arena.getTag(ArenaTagType.PENDING_HEAL) as PendingHealTag;
tag.queueHeal(user.getBattlerIndex(), {
sourceId: user.id,
moveId: move.id,
restorePP: this.restorePP,
healMessage: i18next.t(this.moveMessage, { pokemonName: getPokemonNameWithAffix(user) }),
});
return true;
}

View File

@ -36,5 +36,6 @@ export enum ArenaTagType {
WATER_FIRE_PLEDGE = "WATER_FIRE_PLEDGE",
GRASS_WATER_PLEDGE = "GRASS_WATER_PLEDGE",
FAIRY_LOCK = "FAIRY_LOCK",
NEUTRALIZING_GAS = "NEUTRALIZING_GAS"
NEUTRALIZING_GAS = "NEUTRALIZING_GAS",
PENDING_HEAL = "PENDING_HEAL"
}

View File

@ -39,6 +39,7 @@ import {
TrappedTag,
TypeImmuneTag,
} from "#data/battler-tags";
import { getDailyEventSeedBoss } from "#data/daily-run";
import { allAbilities, allMoves } from "#data/data-lists";
import { getLevelTotalExp } from "#data/exp";
import {
@ -6256,6 +6257,11 @@ export class EnemyPokemon extends Pokemon {
this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]]
) {
this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId];
} else if (globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
if (!isNullOrUndefined(eventBoss)) {
this.formIndex = eventBoss.formIndex;
}
}
if (!dataSource) {

View File

@ -3,7 +3,7 @@ import { CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES, CLASSIC_MODE_MYSTERY_ENCOUNTER_
import { globalScene } from "#app/global-scene";
import Overrides from "#app/overrides";
import { allChallenges, type Challenge, copyChallenge } from "#data/challenge";
import { getDailyStartingBiome } from "#data/daily-run";
import { getDailyEventSeedBoss, getDailyStartingBiome } from "#data/daily-run";
import { allSpecies } from "#data/data-lists";
import type { PokemonSpecies } from "#data/pokemon-species";
import { BiomeId } from "#enums/biome-id";
@ -15,6 +15,7 @@ import type { Arena } from "#field/arena";
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
import { applyChallenges } from "#utils/challenge-utils";
import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common";
import { getPokemonSpecies } from "#utils/pokemon-utils";
import i18next from "i18next";
interface GameModeConfig {
@ -211,6 +212,12 @@ export class GameMode implements GameModeConfig {
getOverrideSpecies(waveIndex: number): PokemonSpecies | null {
if (this.isDaily && this.isWaveFinal(waveIndex)) {
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
if (!isNullOrUndefined(eventBoss)) {
// Cannot set form index here, it will be overriden when adding it as enemy pokemon.
return getPokemonSpecies(eventBoss.speciesId);
}
const allFinalBossSpecies = allSpecies.filter(
s =>
(s.subLegendary || s.legendary || s.mythical) &&

View File

@ -6,6 +6,7 @@ import Overrides from "#app/overrides";
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
import { tmPoolTiers, tmSpecies } from "#balance/tms";
import { getBerryEffectDescription, getBerryName } from "#data/berry";
import { getDailyEventSeedLuck } from "#data/daily-run";
import { allMoves, modifierTypes } from "#data/data-lists";
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
import { getNatureName, getNatureStatMultiplier } from "#data/nature";
@ -2921,6 +2922,12 @@ export function getPartyLuckValue(party: Pokemon[]): number {
const DailyLuck = new NumberHolder(0);
globalScene.executeWithSeedOffset(
() => {
const eventLuck = getDailyEventSeedLuck(globalScene.seed);
if (!isNullOrUndefined(eventLuck)) {
DailyLuck.value = eventLuck;
return;
}
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
},
0,
@ -2928,6 +2935,7 @@ export function getPartyLuckValue(party: Pokemon[]): number {
);
return DailyLuck.value;
}
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
const luck = Phaser.Math.Clamp(
party

View File

@ -229,7 +229,6 @@ export class PhaseManager {
/** overrides default of inserting phases to end of phaseQueuePrepend array. Useful for inserting Phases "out of order" */
private phaseQueuePrependSpliceIndex = -1;
private nextCommandPhaseQueue: Phase[] = [];
/** Storage for {@linkcode PhasePriorityQueue}s which hold phases whose order dynamically changes */
private dynamicPhaseQueues: PhasePriorityQueue[];
@ -285,13 +284,12 @@ export class PhaseManager {
/**
* Adds a phase to nextCommandPhaseQueue, as long as boolean passed in is false
* @param phase {@linkcode Phase} the phase to add
* @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) {
this.pushDynamicPhase(phase);
} else {
(!defer ? this.phaseQueue : this.nextCommandPhaseQueue).push(phase);
this.phaseQueue.push(phase);
}
}
@ -318,7 +316,7 @@ export class PhaseManager {
* Clears all phase-related stuff, including all phase queues, the current and standby phases, and a splice index
*/
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);
}
this.dynamicPhaseQueues.forEach(queue => queue.clear());
@ -600,10 +598,6 @@ export class PhaseManager {
* Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order)
*/
private populatePhaseQueue(): void {
if (this.nextCommandPhaseQueue.length) {
this.phaseQueue.push(...this.nextCommandPhaseQueue);
this.nextCommandPhaseQueue.splice(0, this.nextCommandPhaseQueue.length);
}
this.phaseQueue.push(new TurnInitPhase());
}

View File

@ -63,7 +63,8 @@ export class PokemonHealPhase extends CommonAnimPhase {
}
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;
let lastStatusEffect = StatusEffect.NONE;

View File

@ -2,6 +2,7 @@ import { applyAbAttrs } from "#abilities/apply-ab-attrs";
import { globalScene } from "#app/global-scene";
import { ArenaTrapTag } from "#data/arena-tag";
import { MysteryEncounterPostSummonTag } from "#data/battler-tags";
import { ArenaTagType } from "#enums/arena-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type";
import { StatusEffect } from "#enums/status-effect";
import { PokemonPhase } from "#phases/pokemon-phase";
@ -16,6 +17,9 @@ export class PostSummonPhase extends PokemonPhase {
if (pokemon.status?.effect === StatusEffect.TOXIC) {
pokemon.status.toxicTurnCount = 0;
}
globalScene.arena.applyTags(ArenaTagType.PENDING_HEAL, false, pokemon);
globalScene.arena.applyTags(ArenaTrapTag, false, pokemon);
// If this is mystery encounter and has post summon phase tag, apply post summon effects

View File

@ -287,6 +287,12 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
switch (arenaEffectChangedEvent.constructor) {
case 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;
let arenaEffectType: ArenaEffectType;

View File

@ -0,0 +1,245 @@
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/test-utils/game-manager";
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()).toBe(true);
expect(charmander.isFainted()).toBe(true);
expect(squirtle.isFullHp()).toBe(true);
});
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).toBe(StatusEffect.BURN);
expect(charmander.isFainted()).toBe(true);
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()).toBe(true);
expect(charmander.isActive(true)).toBe(true);
game.move.use(moveId);
await game.toEndOfTurn();
expect(charmander.isFullHp());
expect(charmander.getLastXMoves()[0].result).toBe(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.field.getPlayerPokemon();
game.move.use(moveId);
await game.toNextTurn();
expect(raticate.isFullHp()).toBe(true);
expect(raticate.getLastXMoves()[0].result).toEqual(MoveResult.FAIL);
});
it("should store its effect if the switched-in Pokemon would be unaffected", 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.toNextTurn();
// Bulbasaur fainted and stored a healing effect
expect(bulbasaur.isFainted()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
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
await game.toEndOfTurn();
expect(squirtle.isFullHp()).toBe(true);
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()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
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);
expect(charmander.isFainted()).toBe(true);
expect(squirtle.isFullHp()).toBe(true);
expect(squirtle.isFullHp());
// Switch again to Pikachu. HW/LD's effect shouldn't be present
game.doSwitchPokemon(3);
expect(pikachu.isFullHp()).toBe(false);
});
});
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();
game.move.use(MoveId.SPLASH);
await game.toNextTurn();
game.doSwitchPokemon(1);
await game.toNextTurn();
game.move.use(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()).toBe(true);
expect(charmander.isFullHp()).toBe(true);
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()).toBe(true);
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()).toBe(true);
pikachu.getMoveset().forEach(mv => expect(mv.ppUsed).toBe(1));
expect(game.scene.arena.getTag(ArenaTagType.PENDING_HEAL)).toBeUndefined();
});
});

View File

@ -1,73 +0,0 @@
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import { StatusEffect } from "#enums/status-effect";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } 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.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.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.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());
});
});