mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 22:09:27 +02:00
Compare commits
13 Commits
a5b4210e0d
...
011aee826d
Author | SHA1 | Date | |
---|---|---|---|
|
011aee826d | ||
|
da7903ab92 | ||
|
70e7f8b4d4 | ||
|
ce3fe897c3 | ||
|
605d61cec9 | ||
|
d55cfbcf38 | ||
|
8f9fca50a1 | ||
|
6018e11233 | ||
|
d798ebb545 | ||
|
f771e29b0f | ||
|
d2f8495c1f | ||
|
6fae3cbacd | ||
|
b552779316 |
@ -27,13 +27,7 @@ import { UiInputs } from "#app/ui-inputs";
|
||||
import { biomeDepths, getBiomeName } from "#balance/biomes";
|
||||
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
|
||||
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
|
||||
import {
|
||||
initCommonAnims,
|
||||
initMoveAnim,
|
||||
loadCommonAnimAssets,
|
||||
loadMoveAnimAssets,
|
||||
populateAnims,
|
||||
} from "#data/battle-anims";
|
||||
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets } from "#data/battle-anims";
|
||||
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
|
||||
import { battleSpecDialogue } from "#data/dialogue";
|
||||
import type { SpeciesFormChangeTrigger } from "#data/form-change-triggers";
|
||||
@ -388,7 +382,6 @@ export class BattleScene extends SceneBase {
|
||||
const defaultMoves = [MoveId.TACKLE, MoveId.TAIL_WHIP, MoveId.FOCUS_ENERGY, MoveId.STRUGGLE];
|
||||
|
||||
await Promise.all([
|
||||
populateAnims(),
|
||||
this.initVariantData(),
|
||||
initCommonAnims().then(() => loadCommonAnimAssets(true)),
|
||||
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -404,22 +404,18 @@ export const chargeAnims = new Map<ChargeAnim, AnimConfig | [AnimConfig, AnimCon
|
||||
export const commonAnims = new Map<CommonAnim, AnimConfig>();
|
||||
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
|
||||
|
||||
export function initCommonAnims(): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
const commonAnimNames = getEnumKeys(CommonAnim);
|
||||
const commonAnimIds = getEnumValues(CommonAnim);
|
||||
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
||||
for (let ca = 0; ca < commonAnimIds.length; ca++) {
|
||||
const commonAnimId = commonAnimIds[ca];
|
||||
commonAnimFetches.push(
|
||||
globalScene
|
||||
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimNames[ca])}.json`)
|
||||
.then(response => response.json())
|
||||
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
||||
);
|
||||
}
|
||||
Promise.allSettled(commonAnimFetches).then(() => resolve());
|
||||
});
|
||||
export async function initCommonAnims(): Promise<void> {
|
||||
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
||||
for (const commonAnimName of getEnumKeys(CommonAnim)) {
|
||||
const commonAnimId = CommonAnim[commonAnimName];
|
||||
commonAnimFetches.push(
|
||||
globalScene
|
||||
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimName)}.json`)
|
||||
.then(response => response.json())
|
||||
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
||||
);
|
||||
}
|
||||
await Promise.allSettled(commonAnimFetches);
|
||||
}
|
||||
|
||||
export function initMoveAnim(move: MoveId): Promise<void> {
|
||||
@ -1396,279 +1392,3 @@ export class EncounterBattleAnim extends BattleAnim {
|
||||
return this.oppAnim;
|
||||
}
|
||||
}
|
||||
|
||||
export async function populateAnims() {
|
||||
const commonAnimNames = getEnumKeys(CommonAnim).map(k => k.toLowerCase());
|
||||
const commonAnimMatchNames = commonAnimNames.map(k => k.replace(/_/g, ""));
|
||||
const commonAnimIds = getEnumValues(CommonAnim);
|
||||
const chargeAnimNames = getEnumKeys(ChargeAnim).map(k => k.toLowerCase());
|
||||
const chargeAnimMatchNames = chargeAnimNames.map(k => k.replace(/_/g, " "));
|
||||
const chargeAnimIds = getEnumValues(ChargeAnim);
|
||||
const commonNamePattern = /name: (?:Common:)?(Opp )?(.*)/;
|
||||
const moveNameToId = {};
|
||||
// Exclude MoveId.NONE;
|
||||
for (const move of getEnumValues(MoveId).slice(1)) {
|
||||
// KARATE_CHOP => KARATECHOP
|
||||
const moveName = MoveId[move].toUpperCase().replace(/_/g, "");
|
||||
moveNameToId[moveName] = move;
|
||||
}
|
||||
|
||||
const seNames: string[] = []; //(await fs.readdir('./public/audio/se/battle_anims/')).map(se => se.toString());
|
||||
|
||||
const animsData: any[] = []; //battleAnimRawData.split('!ruby/array:PBAnimation').slice(1); // TODO: add a proper type
|
||||
for (let a = 0; a < animsData.length; a++) {
|
||||
const fields = animsData[a].split("@").slice(1);
|
||||
|
||||
const nameField = fields.find(f => f.startsWith("name: "));
|
||||
|
||||
let isOppMove: boolean | undefined;
|
||||
let commonAnimId: CommonAnim | undefined;
|
||||
let chargeAnimId: ChargeAnim | undefined;
|
||||
if (!nameField.startsWith("name: Move:") && !(isOppMove = nameField.startsWith("name: OppMove:"))) {
|
||||
const nameMatch = commonNamePattern.exec(nameField)!; // TODO: is this bang correct?
|
||||
const name = nameMatch[2].toLowerCase();
|
||||
if (commonAnimMatchNames.indexOf(name) > -1) {
|
||||
commonAnimId = commonAnimIds[commonAnimMatchNames.indexOf(name)];
|
||||
} else if (chargeAnimMatchNames.indexOf(name) > -1) {
|
||||
isOppMove = nameField.startsWith("name: Opp ");
|
||||
chargeAnimId = chargeAnimIds[chargeAnimMatchNames.indexOf(name)];
|
||||
}
|
||||
}
|
||||
const nameIndex = nameField.indexOf(":", 5) + 1;
|
||||
const animName = nameField.slice(nameIndex, nameField.indexOf("\n", nameIndex));
|
||||
if (!moveNameToId.hasOwnProperty(animName) && !commonAnimId && !chargeAnimId) {
|
||||
continue;
|
||||
}
|
||||
const anim = commonAnimId || chargeAnimId ? new AnimConfig() : new AnimConfig();
|
||||
if (anim instanceof AnimConfig) {
|
||||
(anim as AnimConfig).id = moveNameToId[animName];
|
||||
}
|
||||
if (commonAnimId) {
|
||||
commonAnims.set(commonAnimId, anim);
|
||||
} else if (chargeAnimId) {
|
||||
chargeAnims.set(chargeAnimId, !isOppMove ? anim : [chargeAnims.get(chargeAnimId) as AnimConfig, anim]);
|
||||
} else {
|
||||
moveAnims.set(
|
||||
moveNameToId[animName],
|
||||
!isOppMove ? (anim as AnimConfig) : [moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig],
|
||||
);
|
||||
}
|
||||
for (let f = 0; f < fields.length; f++) {
|
||||
const field = fields[f];
|
||||
const fieldName = field.slice(0, field.indexOf(":"));
|
||||
const fieldData = field.slice(fieldName.length + 1, field.lastIndexOf("\n")).trim();
|
||||
switch (fieldName) {
|
||||
case "array": {
|
||||
const framesData = fieldData.split(" - - - ").slice(1);
|
||||
for (let fd = 0; fd < framesData.length; fd++) {
|
||||
anim.frames.push([]);
|
||||
const frameData = framesData[fd];
|
||||
const focusFramesData = frameData.split(" - - ");
|
||||
for (let tf = 0; tf < focusFramesData.length; tf++) {
|
||||
const values = focusFramesData[tf].replace(/ {6}- /g, "").split("\n");
|
||||
const targetFrame = new AnimFrame(
|
||||
Number.parseFloat(values[0]),
|
||||
Number.parseFloat(values[1]),
|
||||
Number.parseFloat(values[2]),
|
||||
Number.parseFloat(values[11]),
|
||||
Number.parseFloat(values[3]),
|
||||
Number.parseInt(values[4]) === 1,
|
||||
Number.parseInt(values[6]) === 1,
|
||||
Number.parseInt(values[5]),
|
||||
Number.parseInt(values[7]),
|
||||
Number.parseInt(values[8]),
|
||||
Number.parseInt(values[12]),
|
||||
Number.parseInt(values[13]),
|
||||
Number.parseInt(values[14]),
|
||||
Number.parseInt(values[15]),
|
||||
Number.parseInt(values[16]),
|
||||
Number.parseInt(values[17]),
|
||||
Number.parseInt(values[18]),
|
||||
Number.parseInt(values[19]),
|
||||
Number.parseInt(values[21]),
|
||||
Number.parseInt(values[22]),
|
||||
Number.parseInt(values[23]),
|
||||
Number.parseInt(values[24]),
|
||||
Number.parseInt(values[20]) === 1,
|
||||
Number.parseInt(values[25]),
|
||||
Number.parseInt(values[26]) as AnimFocus,
|
||||
);
|
||||
anim.frames[fd].push(targetFrame);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "graphic": {
|
||||
const graphic = fieldData !== "''" ? fieldData : "";
|
||||
anim.graphic = graphic.indexOf(".") > -1 ? graphic.slice(0, fieldData.indexOf(".")) : graphic;
|
||||
break;
|
||||
}
|
||||
case "timing": {
|
||||
const timingEntries = fieldData.split("- !ruby/object:PBAnimTiming ").slice(1);
|
||||
for (let t = 0; t < timingEntries.length; t++) {
|
||||
const timingData = timingEntries[t]
|
||||
.replace(/\n/g, " ")
|
||||
.replace(/[ ]{2,}/g, " ")
|
||||
.replace(/[a-z]+: ! '', /gi, "")
|
||||
.replace(/name: (.*?),/, 'name: "$1",')
|
||||
.replace(
|
||||
/flashColor: !ruby\/object:Color { alpha: ([\d.]+), blue: ([\d.]+), green: ([\d.]+), red: ([\d.]+)}/,
|
||||
"flashRed: $4, flashGreen: $3, flashBlue: $2, flashAlpha: $1",
|
||||
);
|
||||
const frameIndex = Number.parseInt(/frame: (\d+)/.exec(timingData)![1]); // TODO: is the bang correct?
|
||||
let resourceName = /name: "(.*?)"/.exec(timingData)![1].replace("''", ""); // TODO: is the bang correct?
|
||||
const timingType = Number.parseInt(/timingType: (\d)/.exec(timingData)![1]); // TODO: is the bang correct?
|
||||
let timedEvent: AnimTimedEvent | undefined;
|
||||
switch (timingType) {
|
||||
case 0:
|
||||
if (resourceName && resourceName.indexOf(".") === -1) {
|
||||
let ext: string | undefined;
|
||||
["wav", "mp3", "m4a"].every(e => {
|
||||
if (seNames.indexOf(`${resourceName}.${e}`) > -1) {
|
||||
ext = e;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (!ext) {
|
||||
ext = ".wav";
|
||||
}
|
||||
resourceName += `.${ext}`;
|
||||
}
|
||||
timedEvent = new AnimTimedSoundEvent(frameIndex, resourceName);
|
||||
break;
|
||||
case 1:
|
||||
timedEvent = new AnimTimedAddBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
|
||||
break;
|
||||
case 2:
|
||||
timedEvent = new AnimTimedUpdateBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
|
||||
break;
|
||||
}
|
||||
if (!timedEvent) {
|
||||
continue;
|
||||
}
|
||||
const propPattern = /([a-z]+): (.*?)(?:,|\})/gi;
|
||||
let propMatch: RegExpExecArray;
|
||||
while ((propMatch = propPattern.exec(timingData)!)) {
|
||||
// TODO: is this bang correct?
|
||||
const prop = propMatch[1];
|
||||
let value: any = propMatch[2];
|
||||
switch (prop) {
|
||||
case "bgX":
|
||||
case "bgY":
|
||||
value = Number.parseFloat(value);
|
||||
break;
|
||||
case "volume":
|
||||
case "pitch":
|
||||
case "opacity":
|
||||
case "colorRed":
|
||||
case "colorGreen":
|
||||
case "colorBlue":
|
||||
case "colorAlpha":
|
||||
case "duration":
|
||||
case "flashScope":
|
||||
case "flashRed":
|
||||
case "flashGreen":
|
||||
case "flashBlue":
|
||||
case "flashAlpha":
|
||||
case "flashDuration":
|
||||
value = Number.parseInt(value);
|
||||
break;
|
||||
}
|
||||
if (timedEvent.hasOwnProperty(prop)) {
|
||||
timedEvent[prop] = value;
|
||||
}
|
||||
}
|
||||
if (!anim.frameTimedEvents.has(frameIndex)) {
|
||||
anim.frameTimedEvents.set(frameIndex, []);
|
||||
}
|
||||
anim.frameTimedEvents.get(frameIndex)!.push(timedEvent); // TODO: is this bang correct?
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "position":
|
||||
anim.position = Number.parseInt(fieldData);
|
||||
break;
|
||||
case "hue":
|
||||
anim.hue = Number.parseInt(fieldData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
|
||||
const animReplacer = (k, v) => {
|
||||
if (k === "id" && !v) {
|
||||
return undefined;
|
||||
}
|
||||
if (v instanceof Map) {
|
||||
return Object.fromEntries(v);
|
||||
}
|
||||
if (v instanceof AnimTimedEvent) {
|
||||
v["eventType"] = v.getEventType();
|
||||
}
|
||||
return v;
|
||||
};
|
||||
|
||||
const animConfigProps = ["id", "graphic", "frames", "frameTimedEvents", "position", "hue"];
|
||||
const animFrameProps = [
|
||||
"x",
|
||||
"y",
|
||||
"zoomX",
|
||||
"zoomY",
|
||||
"angle",
|
||||
"mirror",
|
||||
"visible",
|
||||
"blendType",
|
||||
"target",
|
||||
"graphicFrame",
|
||||
"opacity",
|
||||
"color",
|
||||
"tone",
|
||||
"flash",
|
||||
"locked",
|
||||
"priority",
|
||||
"focus",
|
||||
];
|
||||
const propSets = [animConfigProps, animFrameProps];
|
||||
|
||||
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
|
||||
const animComparator = (a: Element, b: Element) => {
|
||||
let props: string[];
|
||||
for (let p = 0; p < propSets.length; p++) {
|
||||
props = propSets[p];
|
||||
// @ts-expect-error TODO
|
||||
const ai = props.indexOf(a.key);
|
||||
if (ai === -1) {
|
||||
continue;
|
||||
}
|
||||
// @ts-expect-error TODO
|
||||
const bi = props.indexOf(b.key);
|
||||
|
||||
return ai < bi ? -1 : ai > bi ? 1 : 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*for (let ma of moveAnims.keys()) {
|
||||
const data = moveAnims.get(ma);
|
||||
(async () => {
|
||||
await fs.writeFile(`../public/battle-anims/${Moves[ma].toLowerCase().replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
||||
})();
|
||||
}
|
||||
|
||||
for (let ca of chargeAnims.keys()) {
|
||||
const data = chargeAnims.get(ca);
|
||||
(async () => {
|
||||
await fs.writeFile(`../public/battle-anims/${chargeAnimNames[chargeAnimIds.indexOf(ca)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
||||
})();
|
||||
}
|
||||
|
||||
for (let cma of commonAnims.keys()) {
|
||||
const data = commonAnims.get(cma);
|
||||
(async () => {
|
||||
await fs.writeFile(`../public/battle-anims/common-${commonAnimNames[commonAnimIds.indexOf(cma)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
||||
})();
|
||||
}*/
|
||||
}
|
||||
|
@ -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 {
|
||||
@ -2110,24 +2110,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;
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -2142,7 +2142,12 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
|
||||
|
||||
this.partyCancelPb = partyCancelPb;
|
||||
|
||||
const partyCancelText = addTextObject(-10, -7, i18next.t("partyUiHandler:cancel"), TextStyle.PARTY_CANCEL_BUTTON);
|
||||
const partyCancelText = addTextObject(
|
||||
-10,
|
||||
-7,
|
||||
i18next.t("partyUiHandler:cancelButton"),
|
||||
TextStyle.PARTY_CANCEL_BUTTON,
|
||||
);
|
||||
this.add(partyCancelText);
|
||||
}
|
||||
|
||||
|
245
test/moves/healing-wish-lunar-dance.test.ts
Normal file
245
test/moves/healing-wish-lunar-dance.test.ts
Normal 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();
|
||||
});
|
||||
});
|
@ -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());
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user