mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 22:09:27 +02:00
Compare commits
14 Commits
98e919cffc
...
abab3dcd46
Author | SHA1 | Date | |
---|---|---|---|
|
abab3dcd46 | ||
|
19af9bdb8b | ||
|
8e61b642a3 | ||
|
da7903ab92 | ||
|
70e7f8b4d4 | ||
|
0f0482d556 | ||
|
9091d236f1 | ||
|
aec7ee20ae | ||
|
54ec5904f0 | ||
|
1c73b7c269 | ||
|
07f25c7771 | ||
|
6cfc35f823 | ||
|
d21434c32a | ||
|
c36b0e2744 |
17
src/@types/typed-event-target.ts
Normal file
17
src/@types/typed-event-target.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Interface restricting the events emitted by an {@linkcode EventTarget} to a certain kind of {@linkcode Event}.
|
||||
* @typeParam T - The type to restrict the interface's access; must extend from {@linkcode Event}
|
||||
*/
|
||||
export interface TypedEventTarget<T extends Event = never> extends EventTarget {
|
||||
dispatchEvent(event: T): boolean;
|
||||
addEventListener(
|
||||
event: T["type"],
|
||||
callback: EventListenerOrEventListenerObject | null,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
removeEventListener(
|
||||
type: T["type"],
|
||||
callback: EventListenerOrEventListenerObject | null,
|
||||
options?: EventListenerOptions | boolean,
|
||||
): void;
|
||||
}
|
@ -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";
|
||||
@ -72,6 +66,7 @@ import type { TrainerSlot } from "#enums/trainer-slot";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import { TrainerVariant } from "#enums/trainer-variant";
|
||||
import { UiTheme } from "#enums/ui-theme";
|
||||
import type { BattleSceneEvent } from "#events/battle-scene";
|
||||
import { NewArenaEvent } from "#events/battle-scene";
|
||||
import { Arena, ArenaBase } from "#field/arena";
|
||||
import { DamageNumberHandler } from "#field/damage-number-handler";
|
||||
@ -127,6 +122,7 @@ import { vouchers } from "#system/voucher";
|
||||
import { trainerConfigs } from "#trainers/trainer-config";
|
||||
import type { HeldModifierConfig } from "#types/held-modifier-config";
|
||||
import type { Localizable } from "#types/locales";
|
||||
import type { TypedEventTarget } from "#types/typed-event-target";
|
||||
import { AbilityBar } from "#ui/ability-bar";
|
||||
import { ArenaFlyout } from "#ui/arena-flyout";
|
||||
import { CandyBar } from "#ui/candy-bar";
|
||||
@ -330,15 +326,9 @@ export class BattleScene extends SceneBase {
|
||||
public eventManager: TimedEventManager;
|
||||
|
||||
/**
|
||||
* Allows subscribers to listen for events
|
||||
*
|
||||
* Current Events:
|
||||
* - {@linkcode BattleSceneEventType.MOVE_USED} {@linkcode MoveUsedEvent}
|
||||
* - {@linkcode BattleSceneEventType.TURN_INIT} {@linkcode TurnInitEvent}
|
||||
* - {@linkcode BattleSceneEventType.TURN_END} {@linkcode TurnEndEvent}
|
||||
* - {@linkcode BattleSceneEventType.NEW_ARENA} {@linkcode NewArenaEvent}
|
||||
* Allows subscribers to listen for events.
|
||||
*/
|
||||
public readonly eventTarget: EventTarget = new EventTarget();
|
||||
public readonly eventTarget: TypedEventTarget<BattleSceneEvent> = new EventTarget();
|
||||
|
||||
constructor() {
|
||||
super("battle");
|
||||
@ -388,7 +378,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)),
|
||||
|
@ -44,7 +44,6 @@ import { BATTLE_STATS, EFFECTIVE_STATS, getStatKey, Stat } from "#enums/stat";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { BerryUsedEvent } from "#events/battle-scene";
|
||||
import type { EnemyPokemon, Pokemon } from "#field/pokemon";
|
||||
import { BerryModifier, HitHealModifier, PokemonHeldItemModifier } from "#modifiers/modifier";
|
||||
import { BerryModifierType } from "#modifiers/modifier-type";
|
||||
@ -4749,8 +4748,6 @@ export class CudChewConsumeBerryAbAttr extends AbAttr {
|
||||
// This doesn't count as "eating" a berry (for unnerve/stuff cheeks/unburden) as no item is consumed.
|
||||
for (const berryType of pokemon.summonData.berriesEatenLast) {
|
||||
getBerryEffectFunc(berryType)(pokemon);
|
||||
const bMod = new BerryModifier(new BerryModifierType(berryType), pokemon.id, berryType, 1);
|
||||
globalScene.eventTarget.dispatchEvent(new BerryUsedEvent(bMod)); // trigger message
|
||||
}
|
||||
|
||||
// uncomment to make cheek pouch work with cud chew
|
||||
|
@ -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,6 +6,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
import { HitResult } from "#enums/hit-result";
|
||||
import { type BattleStat, Stat } from "#enums/stat";
|
||||
import { MovesetChangedEvent } from "#events/battle-scene";
|
||||
import type { Pokemon } from "#field/pokemon";
|
||||
import { NumberHolder, randSeedInt, toDmgValue } from "#utils/common";
|
||||
import i18next from "i18next";
|
||||
@ -152,6 +153,7 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
berryName: getBerryName(berryType),
|
||||
}),
|
||||
);
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(consumer.id, ppRestoreMove));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -66,7 +66,7 @@ import {
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { MoveUsedEvent } from "#events/battle-scene";
|
||||
import { MovesetChangedEvent } from "#events/battle-scene";
|
||||
import type { EnemyPokemon, Pokemon } from "#field/pokemon";
|
||||
import {
|
||||
AttackTypeBoosterModifier,
|
||||
@ -7307,8 +7307,8 @@ export class ReducePpMoveAttr extends MoveEffectAttr {
|
||||
const lastPpUsed = movesetMove.ppUsed;
|
||||
movesetMove.ppUsed = Math.min(lastPpUsed + this.reduction, movesetMove.getMovePp());
|
||||
|
||||
globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(target.id, movesetMove.getMove(), movesetMove.ppUsed));
|
||||
globalScene.phaseManager.queueMessage(i18next.t("battle:ppReduced", { targetName: getPokemonNameWithAffix(target), moveName: movesetMove.getName(), reduction: (movesetMove.ppUsed) - lastPpUsed }));
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(target.id, movesetMove));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -7412,11 +7412,13 @@ export class MovesetCopyMoveAttr extends OverrideMoveEffectAttr {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Populate summon data with a copy of the current moveset, replacing the copying move with the copied move
|
||||
// Populate summon data with a copy of the current moveset, replacing the copying move with the copied move.
|
||||
user.summonData.moveset = user.getMoveset().slice(0);
|
||||
user.summonData.moveset[thisMoveIndex] = new PokemonMove(copiedMove.id);
|
||||
const newMove = new PokemonMove(copiedMove.id);
|
||||
user.summonData.moveset[thisMoveIndex] = newMove;
|
||||
|
||||
globalScene.phaseManager.queueMessage(i18next.t("moveTriggers:copiedMove", { pokemonName: getPokemonNameWithAffix(user), moveName: copiedMove.name }));
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(user.id, newMove));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ export const DarkDealEncounter: MysteryEncounter = MysteryEncounterBuilder.withE
|
||||
MysteryEncounterType.DARK_DEAL,
|
||||
)
|
||||
.withEncounterTier(MysteryEncounterTier.ROGUE)
|
||||
.withDisallowedChallenges(Challenges.HARDCORE)
|
||||
.withIntroSpriteConfigs([
|
||||
{
|
||||
spriteKey: "dark_deal_scientist",
|
||||
|
@ -673,6 +673,8 @@ export async function catchPokemon(
|
||||
globalScene.gameData.updateSpeciesDexIvs(pokemon.species.getRootSpeciesId(true), pokemon.ivs);
|
||||
|
||||
return new Promise(resolve => {
|
||||
const addStatus = new BooleanHolder(true);
|
||||
applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus);
|
||||
const doPokemonCatchMenu = () => {
|
||||
const end = () => {
|
||||
// Ensure the pokemon is in the enemy party in all situations
|
||||
@ -708,9 +710,7 @@ export async function catchPokemon(
|
||||
});
|
||||
};
|
||||
Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => {
|
||||
const addStatus = new BooleanHolder(true);
|
||||
applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus);
|
||||
if (!addStatus.value) {
|
||||
if (!(isObtain || addStatus.value)) {
|
||||
removePokemon();
|
||||
end();
|
||||
return;
|
||||
@ -807,10 +807,16 @@ export async function catchPokemon(
|
||||
};
|
||||
|
||||
if (showCatchObtainMessage) {
|
||||
let catchMessage: string;
|
||||
if (isObtain) {
|
||||
catchMessage = "battle:pokemonObtained";
|
||||
} else if (addStatus.value) {
|
||||
catchMessage = "battle:pokemonCaught";
|
||||
} else {
|
||||
catchMessage = "battle:pokemonCaughtButChallenge";
|
||||
}
|
||||
globalScene.ui.showText(
|
||||
i18next.t(isObtain ? "battle:pokemonObtained" : "battle:pokemonCaught", {
|
||||
pokemonName: pokemon.getNameToRender(),
|
||||
}),
|
||||
i18next.t(catchMessage, { pokemonName: pokemon.getNameToRender() }),
|
||||
null,
|
||||
doPokemonCatchMenu,
|
||||
0,
|
||||
|
@ -1,53 +1,65 @@
|
||||
import type { BerryModifier } from "#modifiers/modifier";
|
||||
import type { Move } from "#moves/move";
|
||||
// biome-ignore lint/correctness/noUnusedImports: TSDoc
|
||||
import type { PokemonSummonData } from "#data/pokemon-data";
|
||||
import type { PokemonMove } from "#moves/pokemon-move";
|
||||
|
||||
/** Alias for all {@linkcode BattleScene} events */
|
||||
/** Enum comprising all {@linkcode BattleScene} events that can be emitted. */
|
||||
export enum BattleSceneEventType {
|
||||
/**
|
||||
* Triggers when the corresponding setting is changed
|
||||
* Emitted when the corresponding setting is changed
|
||||
* @see {@linkcode CandyUpgradeNotificationChangedEvent}
|
||||
*/
|
||||
CANDY_UPGRADE_NOTIFICATION_CHANGED = "onCandyUpgradeNotificationChanged",
|
||||
|
||||
/**
|
||||
* Triggers when a move is successfully used
|
||||
* @see {@linkcode MoveUsedEvent}
|
||||
* Emitted whenever a Pokemon's moveset is changed or altered - whether from moveset-overridding effects,
|
||||
* PP consumption or restoration.
|
||||
* @see {@linkcode MovesetChangedEvent}
|
||||
*/
|
||||
MOVE_USED = "onMoveUsed",
|
||||
/**
|
||||
* Triggers when a berry gets successfully used
|
||||
* @see {@linkcode BerryUsedEvent}
|
||||
*/
|
||||
BERRY_USED = "onBerryUsed",
|
||||
MOVESET_CHANGED = "onMovesetChanged",
|
||||
|
||||
/**
|
||||
* Triggers at the start of each new encounter
|
||||
* Emitted whenever the {@linkcode PokemonSummonData} of any {@linkcode Pokemon} is reset to its initial state
|
||||
* (such as immediately before a switch-out).
|
||||
* @see {@linkcode SummonDataResetEvent}
|
||||
*/
|
||||
SUMMON_DATA_RESET = "onSummonDataReset",
|
||||
|
||||
/**
|
||||
* Emitted at the start of each new encounter
|
||||
* @see {@linkcode EncounterPhaseEvent}
|
||||
*/
|
||||
ENCOUNTER_PHASE = "onEncounterPhase",
|
||||
/**
|
||||
* Triggers on the first turn of a new battle
|
||||
* @see {@linkcode TurnInitEvent}
|
||||
*/
|
||||
TURN_INIT = "onTurnInit",
|
||||
/**
|
||||
* Triggers after a turn ends in battle
|
||||
* Emitted after a turn ends in battle
|
||||
* @see {@linkcode TurnEndEvent}
|
||||
*/
|
||||
TURN_END = "onTurnEnd",
|
||||
|
||||
/**
|
||||
* Triggers when a new {@linkcode Arena} is created during initialization
|
||||
* Emitted when a new {@linkcode Arena} is created during initialization
|
||||
* @see {@linkcode NewArenaEvent}
|
||||
*/
|
||||
NEW_ARENA = "onNewArena",
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED} events
|
||||
* @extends Event
|
||||
* Abstract container class for all {@linkcode BattleSceneEventType} events.
|
||||
*/
|
||||
export class CandyUpgradeNotificationChangedEvent extends Event {
|
||||
abstract class BattleSceneEvent extends Event {
|
||||
public declare abstract readonly type: BattleSceneEventType; // that's a mouthful!
|
||||
// biome-ignore lint/complexity/noUselessConstructor: changes the type of the type field
|
||||
constructor(type: BattleSceneEventType) {
|
||||
super(type);
|
||||
}
|
||||
}
|
||||
|
||||
export type { BattleSceneEvent };
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED} events
|
||||
*/
|
||||
export class CandyUpgradeNotificationChangedEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.CANDY_UPGRADE_NOTIFICATION_CHANGED;
|
||||
/** The new value the setting was changed to */
|
||||
public newValue: number;
|
||||
constructor(newValue: number) {
|
||||
@ -58,61 +70,62 @@ export class CandyUpgradeNotificationChangedEvent extends Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.MOVE_USED} events
|
||||
* @extends Event
|
||||
* Container class for {@linkcode BattleSceneEventType.MOVESET_CHANGED} events. \
|
||||
* Emitted whenever the moveset of any {@linkcode Pokemon} is changed, or a move's PP is increased or decreased.
|
||||
*/
|
||||
export class MoveUsedEvent extends Event {
|
||||
/** The ID of the {@linkcode Pokemon} that used the {@linkcode Move} */
|
||||
export class MovesetChangedEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.MOVESET_CHANGED;
|
||||
|
||||
/** The {@linkcode Pokemon.ID | ID} of the {@linkcode Pokemon} whose moveset has changed. */
|
||||
public pokemonId: number;
|
||||
/** The {@linkcode Move} used */
|
||||
public move: Move;
|
||||
/** The amount of PP used on the {@linkcode Move} this turn */
|
||||
public ppUsed: number;
|
||||
constructor(userId: number, move: Move, ppUsed: number) {
|
||||
super(BattleSceneEventType.MOVE_USED);
|
||||
/**
|
||||
* The {@linkcode PokemonMove} having been changed.
|
||||
* Will override the corresponding slot of the moveset flyout for that Pokemon.
|
||||
*/
|
||||
public move: PokemonMove;
|
||||
|
||||
this.pokemonId = userId;
|
||||
constructor(pokemonId: number, move: PokemonMove) {
|
||||
super(BattleSceneEventType.MOVESET_CHANGED);
|
||||
|
||||
this.pokemonId = pokemonId;
|
||||
this.move = move;
|
||||
this.ppUsed = ppUsed;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.BERRY_USED} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class BerryUsedEvent extends Event {
|
||||
/** The {@linkcode BerryModifier} being used */
|
||||
public berryModifier: BerryModifier;
|
||||
constructor(berry: BerryModifier) {
|
||||
super(BattleSceneEventType.BERRY_USED);
|
||||
|
||||
this.berryModifier = berry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.ENCOUNTER_PHASE} events
|
||||
* @extends Event
|
||||
* Container class for {@linkcode BattleSceneEventType.SUMMON_DATA_RESET} events. \
|
||||
* Emitted whenever the {@linkcode PokemonSummonData} of any {@linkcode Pokemon} is reset to its initial state
|
||||
* (such as immediately before a switch-out).
|
||||
*/
|
||||
export class EncounterPhaseEvent extends Event {
|
||||
export class SummonDataResetEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.SUMMON_DATA_RESET;
|
||||
|
||||
/** The {@linkcode Pokemon.ID | ID} of the {@linkcode Pokemon} whose data has been reset. */
|
||||
public pokemonId: number;
|
||||
|
||||
constructor(pokemonId: number) {
|
||||
super(BattleSceneEventType.SUMMON_DATA_RESET);
|
||||
|
||||
this.pokemonId = pokemonId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.ENCOUNTER_PHASE} events.
|
||||
*/
|
||||
export class EncounterPhaseEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.ENCOUNTER_PHASE;
|
||||
constructor() {
|
||||
super(BattleSceneEventType.ENCOUNTER_PHASE);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.TURN_INIT} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class TurnInitEvent extends Event {
|
||||
constructor() {
|
||||
super(BattleSceneEventType.TURN_INIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.TURN_END} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class TurnEndEvent extends Event {
|
||||
export class TurnEndEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.TURN_END;
|
||||
/** The amount of turns in the current battle */
|
||||
public turnCount: number;
|
||||
constructor(turnCount: number) {
|
||||
@ -123,9 +136,9 @@ export class TurnEndEvent extends Event {
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.NEW_ARENA} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class NewArenaEvent extends Event {
|
||||
export class NewArenaEvent extends BattleSceneEvent {
|
||||
declare type: BattleSceneEventType.NEW_ARENA;
|
||||
constructor() {
|
||||
super(BattleSceneEventType.NEW_ARENA);
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ import { SwitchType } from "#enums/switch-type";
|
||||
import type { TrainerSlot } from "#enums/trainer-slot";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
import { WeatherType } from "#enums/weather-type";
|
||||
import { MovesetChangedEvent, SummonDataResetEvent } from "#events/battle-scene";
|
||||
import { doShinySparkleAnim } from "#field/anims";
|
||||
import {
|
||||
BaseStatModifier,
|
||||
@ -2825,6 +2826,7 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if (this.summonData.moveset) {
|
||||
this.summonData.moveset[moveIndex] = move;
|
||||
}
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(this.id, move));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5082,6 +5084,10 @@ export abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
this.summonData.speciesForm = null;
|
||||
this.updateFusionPalette();
|
||||
}
|
||||
|
||||
// Emit an event to reset all temporary moveset overrides due to Mimic/Transform wearing off.
|
||||
globalScene.eventTarget.dispatchEvent(new SummonDataResetEvent(this.id));
|
||||
|
||||
this.summonData = new PokemonSummonData();
|
||||
this.tempSummonData = new PokemonTempSummonData();
|
||||
this.summonData.illusion = illusion;
|
||||
|
@ -253,8 +253,11 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
|
||||
globalScene.gameData.updateSpeciesDexIvs(pokemon.species.getRootSpeciesId(true), pokemon.ivs);
|
||||
|
||||
const addStatus = new BooleanHolder(true);
|
||||
applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus);
|
||||
|
||||
globalScene.ui.showText(
|
||||
i18next.t("battle:pokemonCaught", {
|
||||
i18next.t(addStatus.value ? "battle:pokemonCaught" : "battle:pokemonCaughtButChallenge", {
|
||||
pokemonName: getPokemonNameWithAffix(pokemon),
|
||||
}),
|
||||
null,
|
||||
@ -290,8 +293,6 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
});
|
||||
};
|
||||
Promise.all([pokemon.hideInfo(), globalScene.gameData.setPokemonCaught(pokemon)]).then(() => {
|
||||
const addStatus = new BooleanHolder(true);
|
||||
applyChallenges(ChallengeType.POKEMON_ADD_TO_PARTY, pokemon, addStatus);
|
||||
if (!addStatus.value) {
|
||||
removePokemon();
|
||||
end();
|
||||
|
@ -2,7 +2,6 @@ import { applyAbAttrs } from "#abilities/apply-ab-attrs";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { CommonAnim } from "#enums/move-anims-common";
|
||||
import { BerryUsedEvent } from "#events/battle-scene";
|
||||
import type { Pokemon } from "#field/pokemon";
|
||||
import { BerryModifier } from "#modifiers/modifier";
|
||||
import { FieldPhase } from "#phases/field-phase";
|
||||
@ -65,7 +64,6 @@ export class BerryPhase extends FieldPhase {
|
||||
berryModifier.consumed = false;
|
||||
pokemon.loseHeldItem(berryModifier);
|
||||
}
|
||||
globalScene.eventTarget.dispatchEvent(new BerryUsedEvent(berryModifier));
|
||||
}
|
||||
globalScene.updateModifiers(pokemon.isPlayer());
|
||||
|
||||
|
@ -18,7 +18,7 @@ import { MoveResult } from "#enums/move-result";
|
||||
import { isIgnorePP, isIgnoreStatus, isReflected, isVirtual, MoveUseMode } from "#enums/move-use-mode";
|
||||
import { PokemonType } from "#enums/pokemon-type";
|
||||
import { StatusEffect } from "#enums/status-effect";
|
||||
import { MoveUsedEvent } from "#events/battle-scene";
|
||||
import { MovesetChangedEvent } from "#events/battle-scene";
|
||||
import type { Pokemon } from "#field/pokemon";
|
||||
import { applyMoveAttrs } from "#moves/apply-attrs";
|
||||
import { frenzyMissFunc } from "#moves/move-utils";
|
||||
@ -317,7 +317,7 @@ export class MovePhase extends BattlePhase {
|
||||
// "commit" to using the move, deducting PP.
|
||||
const ppUsed = 1 + this.getPpIncreaseFromPressure(targets);
|
||||
this.move.usePp(ppUsed);
|
||||
globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(this.pokemon.id, move, this.move.ppUsed));
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(this.pokemon.id, this.move));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -620,10 +620,10 @@ export class MovePhase extends BattlePhase {
|
||||
}
|
||||
|
||||
if (this.failed) {
|
||||
// TODO: should this consider struggle?
|
||||
// TODO: should this consider struggle and pressure?
|
||||
const ppUsed = isIgnorePP(this.useMode) ? 0 : 1;
|
||||
this.move.usePp(ppUsed);
|
||||
globalScene.eventTarget.dispatchEvent(new MoveUsedEvent(this.pokemon?.id, this.move.getMove(), ppUsed));
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(this.pokemon.id, this.move));
|
||||
}
|
||||
|
||||
if (this.cancelled && this.pokemon.summonData.tags.some(t => t.tagType === BattlerTagType.FRENZY)) {
|
||||
|
@ -4,6 +4,7 @@ import type { BattlerIndex } from "#enums/battler-index";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { BATTLE_STATS, EFFECTIVE_STATS } from "#enums/stat";
|
||||
import { MovesetChangedEvent } from "#events/battle-scene";
|
||||
import { PokemonMove } from "#moves/pokemon-move";
|
||||
import { PokemonPhase } from "#phases/pokemon-phase";
|
||||
import i18next from "i18next";
|
||||
@ -50,12 +51,14 @@ export class PokemonTransformPhase extends PokemonPhase {
|
||||
user.setStatStage(s, target.getStatStage(s));
|
||||
}
|
||||
|
||||
user.summonData.moveset = target.getMoveset().map(m => {
|
||||
if (m) {
|
||||
user.summonData.moveset = target.getMoveset().map(oldMove => {
|
||||
if (oldMove) {
|
||||
// If PP value is less than 5, do nothing. If greater, we need to reduce the value to 5.
|
||||
return new PokemonMove(m.moveId, 0, 0, Math.min(m.getMove().pp, 5));
|
||||
const newMove = new PokemonMove(oldMove.moveId, 0, 0, Math.min(oldMove.getMove().pp, 5));
|
||||
this.emitMovesetChange(oldMove, newMove);
|
||||
return newMove;
|
||||
}
|
||||
console.warn(`Transform: somehow iterating over a ${m} value when copying moveset!`);
|
||||
console.warn(`Transform: somehow iterating over a ${oldMove} value when copying moveset!`);
|
||||
return new PokemonMove(MoveId.NONE);
|
||||
});
|
||||
|
||||
@ -86,4 +89,21 @@ export class PokemonTransformPhase extends PokemonPhase {
|
||||
|
||||
Promise.allSettled(promises).then(() => this.end());
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit an event upon transforming and changing movesets.
|
||||
* @param origMovee - The target's original {@linkcode PokemonMove} being copied
|
||||
* @param copiedMove - The new {@linkcode PokemonMove} being added to the user's moveset
|
||||
*/
|
||||
private emitMovesetChange(origMove: PokemonMove, copiedMove: PokemonMove): void {
|
||||
const user = this.getPokemon();
|
||||
const target = globalScene.getField()[this.targetIndex];
|
||||
|
||||
// Dispatch an event for the user's moveset temporarily changing.
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(user.id, copiedMove));
|
||||
// If the user is a player having transformed into an enemy, permanently reveal the corresponding move in their moveset.
|
||||
if (user.isPlayer() && target.isEnemy()) {
|
||||
globalScene.eventTarget.dispatchEvent(new MovesetChangedEvent(target.id, origMove));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,10 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
|
||||
globalScene.resetSeed();
|
||||
|
||||
const gameMode = globalScene.gameMode;
|
||||
const currentBiome = globalScene.arena.biomeType;
|
||||
const nextWaveIndex = globalScene.currentBattle.waveIndex + 1;
|
||||
const currentWaveIndex = globalScene.currentBattle.waveIndex;
|
||||
const nextWaveIndex = currentWaveIndex + 1;
|
||||
|
||||
const setNextBiome = (nextBiome: BiomeId) => {
|
||||
if (nextWaveIndex % 10 === 1) {
|
||||
@ -26,6 +28,15 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
applyChallenges(ChallengeType.PARTY_HEAL, healStatus);
|
||||
if (healStatus.value) {
|
||||
globalScene.phaseManager.unshiftNew("PartyHealPhase", false);
|
||||
} else {
|
||||
globalScene.phaseManager.unshiftNew(
|
||||
"SelectModifierPhase",
|
||||
undefined,
|
||||
undefined,
|
||||
gameMode.isFixedBattle(currentWaveIndex)
|
||||
? gameMode.getFixedBattle(currentWaveIndex).customModifierRewardSettings
|
||||
: undefined,
|
||||
);
|
||||
}
|
||||
}
|
||||
globalScene.phaseManager.unshiftNew("SwitchBiomePhase", nextBiome);
|
||||
@ -33,12 +44,12 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
};
|
||||
|
||||
if (
|
||||
(globalScene.gameMode.isClassic && globalScene.gameMode.isWaveFinal(nextWaveIndex + 9)) ||
|
||||
(globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(nextWaveIndex)) ||
|
||||
(globalScene.gameMode.hasShortBiomes && !(nextWaveIndex % 50))
|
||||
(gameMode.isClassic && gameMode.isWaveFinal(nextWaveIndex + 9)) ||
|
||||
(gameMode.isDaily && gameMode.isWaveFinal(nextWaveIndex)) ||
|
||||
(gameMode.hasShortBiomes && !(nextWaveIndex % 50))
|
||||
) {
|
||||
setNextBiome(BiomeId.END);
|
||||
} else if (globalScene.gameMode.hasRandomBiomes) {
|
||||
} else if (gameMode.hasRandomBiomes) {
|
||||
setNextBiome(this.generateNextBiome(nextWaveIndex));
|
||||
} else if (Array.isArray(biomeLinks[currentBiome])) {
|
||||
const biomes: BiomeId[] = (biomeLinks[currentBiome] as (BiomeId | [BiomeId, number])[])
|
||||
@ -73,9 +84,6 @@ export class SelectBiomePhase extends BattlePhase {
|
||||
}
|
||||
|
||||
generateNextBiome(waveIndex: number): BiomeId {
|
||||
if (!(waveIndex % 50)) {
|
||||
return BiomeId.END;
|
||||
}
|
||||
return globalScene.generateRandomBiome(waveIndex);
|
||||
return waveIndex % 50 === 0 ? BiomeId.END : globalScene.generateRandomBiome(waveIndex);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { BattlerIndex } from "#enums/battler-index";
|
||||
import { TurnInitEvent } from "#events/battle-scene";
|
||||
import type { PlayerPokemon } from "#field/pokemon";
|
||||
import {
|
||||
handleMysteryEncounterBattleStartEffects,
|
||||
@ -46,8 +45,6 @@ export class TurnInitPhase extends FieldPhase {
|
||||
}
|
||||
});
|
||||
|
||||
globalScene.eventTarget.dispatchEvent(new TurnInitEvent());
|
||||
|
||||
handleMysteryEncounterBattleStartEffects();
|
||||
|
||||
// If true, will skip remainder of current phase (and not queue CommandPhases etc.)
|
||||
|
@ -3,13 +3,9 @@ import { globalScene } from "#app/global-scene";
|
||||
import { modifierTypes } from "#data/data-lists";
|
||||
import { BattleType } from "#enums/battle-type";
|
||||
import type { BattlerIndex } from "#enums/battler-index";
|
||||
import { ChallengeType } from "#enums/challenge-type";
|
||||
import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves";
|
||||
import type { CustomModifierSettings } from "#modifiers/modifier-type";
|
||||
import { handleMysteryEncounterVictory } from "#mystery-encounters/encounter-phase-utils";
|
||||
import { PokemonPhase } from "#phases/pokemon-phase";
|
||||
import { applyChallenges } from "#utils/challenge-utils";
|
||||
import { BooleanHolder } from "#utils/common";
|
||||
|
||||
export class VictoryPhase extends PokemonPhase {
|
||||
public readonly phaseName = "VictoryPhase";
|
||||
@ -49,15 +45,19 @@ export class VictoryPhase extends PokemonPhase {
|
||||
if (globalScene.currentBattle.battleType === BattleType.TRAINER) {
|
||||
globalScene.phaseManager.pushNew("TrainerVictoryPhase");
|
||||
}
|
||||
if (globalScene.gameMode.isEndless || !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
|
||||
|
||||
const gameMode = globalScene.gameMode;
|
||||
const currentWaveIndex = globalScene.currentBattle.waveIndex;
|
||||
|
||||
if (gameMode.isEndless || !gameMode.isWaveFinal(currentWaveIndex)) {
|
||||
globalScene.phaseManager.pushNew("EggLapsePhase");
|
||||
if (globalScene.gameMode.isClassic) {
|
||||
switch (globalScene.currentBattle.waveIndex) {
|
||||
if (gameMode.isClassic) {
|
||||
switch (currentWaveIndex) {
|
||||
case ClassicFixedBossWaves.RIVAL_1:
|
||||
case ClassicFixedBossWaves.RIVAL_2:
|
||||
// Get event modifiers for this wave
|
||||
timedEventManager
|
||||
.getFixedBattleEventRewards(globalScene.currentBattle.waveIndex)
|
||||
.getFixedBattleEventRewards(currentWaveIndex)
|
||||
.map(r => globalScene.phaseManager.pushNew("ModifierRewardPhase", modifierTypes[r]));
|
||||
break;
|
||||
case ClassicFixedBossWaves.EVIL_BOSS_2:
|
||||
@ -66,59 +66,53 @@ export class VictoryPhase extends PokemonPhase {
|
||||
break;
|
||||
}
|
||||
}
|
||||
const healStatus = new BooleanHolder(globalScene.currentBattle.waveIndex % 10 === 0);
|
||||
applyChallenges(ChallengeType.PARTY_HEAL, healStatus);
|
||||
if (!healStatus.value) {
|
||||
if (currentWaveIndex % 10) {
|
||||
globalScene.phaseManager.pushNew(
|
||||
"SelectModifierPhase",
|
||||
undefined,
|
||||
undefined,
|
||||
this.getFixedBattleCustomModifiers(),
|
||||
gameMode.isFixedBattle(currentWaveIndex)
|
||||
? gameMode.getFixedBattle(currentWaveIndex).customModifierRewardSettings
|
||||
: undefined,
|
||||
);
|
||||
} else if (globalScene.gameMode.isDaily) {
|
||||
} else if (gameMode.isDaily) {
|
||||
globalScene.phaseManager.pushNew("ModifierRewardPhase", modifierTypes.EXP_CHARM);
|
||||
if (
|
||||
globalScene.currentBattle.waveIndex > 10 &&
|
||||
!globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)
|
||||
) {
|
||||
if (currentWaveIndex > 10 && !gameMode.isWaveFinal(currentWaveIndex)) {
|
||||
globalScene.phaseManager.pushNew("ModifierRewardPhase", modifierTypes.GOLDEN_POKEBALL);
|
||||
}
|
||||
} else {
|
||||
const superExpWave = !globalScene.gameMode.isEndless ? (globalScene.offsetGym ? 0 : 20) : 10;
|
||||
if (globalScene.gameMode.isEndless && globalScene.currentBattle.waveIndex === 10) {
|
||||
const superExpWave = !gameMode.isEndless ? (globalScene.offsetGym ? 0 : 20) : 10;
|
||||
if (gameMode.isEndless && currentWaveIndex === 10) {
|
||||
globalScene.phaseManager.pushNew("ModifierRewardPhase", modifierTypes.EXP_SHARE);
|
||||
}
|
||||
if (
|
||||
globalScene.currentBattle.waveIndex <= 750 &&
|
||||
(globalScene.currentBattle.waveIndex <= 500 || globalScene.currentBattle.waveIndex % 30 === superExpWave)
|
||||
) {
|
||||
if (currentWaveIndex <= 750 && (currentWaveIndex <= 500 || currentWaveIndex % 30 === superExpWave)) {
|
||||
globalScene.phaseManager.pushNew(
|
||||
"ModifierRewardPhase",
|
||||
globalScene.currentBattle.waveIndex % 30 !== superExpWave || globalScene.currentBattle.waveIndex > 250
|
||||
currentWaveIndex % 30 !== superExpWave || currentWaveIndex > 250
|
||||
? modifierTypes.EXP_CHARM
|
||||
: modifierTypes.SUPER_EXP_CHARM,
|
||||
);
|
||||
}
|
||||
if (globalScene.currentBattle.waveIndex <= 150 && !(globalScene.currentBattle.waveIndex % 50)) {
|
||||
if (currentWaveIndex <= 150 && !(currentWaveIndex % 50)) {
|
||||
globalScene.phaseManager.pushNew("ModifierRewardPhase", modifierTypes.GOLDEN_POKEBALL);
|
||||
}
|
||||
if (globalScene.gameMode.isEndless && !(globalScene.currentBattle.waveIndex % 50)) {
|
||||
if (gameMode.isEndless && !(currentWaveIndex % 50)) {
|
||||
globalScene.phaseManager.pushNew(
|
||||
"ModifierRewardPhase",
|
||||
!(globalScene.currentBattle.waveIndex % 250) ? modifierTypes.VOUCHER_PREMIUM : modifierTypes.VOUCHER_PLUS,
|
||||
!(currentWaveIndex % 250) ? modifierTypes.VOUCHER_PREMIUM : modifierTypes.VOUCHER_PLUS,
|
||||
);
|
||||
globalScene.phaseManager.pushNew("AddEnemyBuffModifierPhase");
|
||||
}
|
||||
}
|
||||
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
if (gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushNew("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushNew("NewBattlePhase");
|
||||
} else {
|
||||
globalScene.currentBattle.battleType = BattleType.CLEAR;
|
||||
globalScene.score += globalScene.gameMode.getClearScoreBonus();
|
||||
globalScene.score += gameMode.getClearScoreBonus();
|
||||
globalScene.updateScoreText();
|
||||
globalScene.phaseManager.pushNew("GameOverPhase", true);
|
||||
}
|
||||
@ -126,18 +120,4 @@ export class VictoryPhase extends PokemonPhase {
|
||||
|
||||
this.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this wave is a fixed battle with special custom modifier rewards,
|
||||
* will pass those settings to the upcoming {@linkcode SelectModifierPhase}`.
|
||||
*/
|
||||
getFixedBattleCustomModifiers(): CustomModifierSettings | undefined {
|
||||
const gameMode = globalScene.gameMode;
|
||||
const waveIndex = globalScene.currentBattle.waveIndex;
|
||||
if (gameMode.isFixedBattle(waveIndex)) {
|
||||
return gameMode.getFixedBattle(waveIndex).customModifierRewardSettings;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
@ -448,6 +448,8 @@ export function getAchievementDescription(localizationKey: string): string {
|
||||
return i18next.t("achv:FLIP_STATS.description", { context: genderStr });
|
||||
case "FLIP_INVERSE":
|
||||
return i18next.t("achv:FLIP_INVERSE.description", { context: genderStr });
|
||||
case "NUZLOCKE":
|
||||
return i18next.t("achv:NUZLOCKE.description", { context: genderStr });
|
||||
case "BREEDERS_IN_SPACE":
|
||||
return i18next.t("achv:BREEDERS_IN_SPACE.description", {
|
||||
context: genderStr,
|
||||
|
@ -1,33 +1,41 @@
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { getPokemonNameWithAffix } from "#app/messages";
|
||||
import { BerryType } from "#enums/berry-type";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { TextStyle } from "#enums/text-style";
|
||||
import { UiTheme } from "#enums/ui-theme";
|
||||
import type { BerryUsedEvent, MoveUsedEvent } from "#events/battle-scene";
|
||||
import type { MovesetChangedEvent, SummonDataResetEvent } from "#events/battle-scene";
|
||||
import { BattleSceneEventType } from "#events/battle-scene";
|
||||
import type { EnemyPokemon, Pokemon } from "#field/pokemon";
|
||||
import type { Move } from "#moves/move";
|
||||
import type { Pokemon } from "#field/pokemon";
|
||||
import type { PokemonMove } from "#moves/pokemon-move";
|
||||
// biome-ignore lint/correctness/noUnusedImports: TSDoc
|
||||
import type { BattleInfo } from "#ui/battle-info";
|
||||
import { addTextObject } from "#ui/text";
|
||||
import { fixedInt } from "#utils/common";
|
||||
|
||||
/** Container for info about a {@linkcode Move} */
|
||||
/** Container for info about a given {@linkcode PokemonMove} having been used */
|
||||
interface MoveInfo {
|
||||
/** The {@linkcode Move} itself */
|
||||
move: Move;
|
||||
|
||||
/** The maximum PP of the {@linkcode Move} */
|
||||
maxPp: number;
|
||||
/** The amount of PP used by the {@linkcode Move} */
|
||||
ppUsed: number;
|
||||
/** The name of the {@linkcode Move} having been used. */
|
||||
name: string;
|
||||
/** The {@linkcode PokemonMove} having been used. */
|
||||
move: PokemonMove;
|
||||
}
|
||||
|
||||
/** A Flyout Menu attached to each {@linkcode BattleInfo} object on the field UI */
|
||||
/**
|
||||
* A 4-length tuple consisting of all moves that each {@linkcode Pokemon} has used in the given battle.
|
||||
* Entries that are `undefined` indicate moves which have not been used yet.
|
||||
*/
|
||||
type MoveInfoTuple = [MoveInfo?, MoveInfo?, MoveInfo?, MoveInfo?];
|
||||
|
||||
/**
|
||||
* A Flyout Menu attached to each Pokemon's {@linkcode BattleInfo} object,
|
||||
* showing all revealed moves and their current PP counts.
|
||||
* @todo Stop tracking player move usages
|
||||
*/
|
||||
export class BattleFlyout extends Phaser.GameObjects.Container {
|
||||
/** Is this object linked to a player's Pokemon? */
|
||||
private player: boolean;
|
||||
|
||||
/** The Pokemon this object is linked to */
|
||||
/** The Pokemon this object is linked to. */
|
||||
private pokemon: Pokemon;
|
||||
|
||||
/** The restricted width of the flyout which should be drawn to */
|
||||
@ -52,15 +60,22 @@ export class BattleFlyout extends Phaser.GameObjects.Container {
|
||||
|
||||
/** The array of {@linkcode Phaser.GameObjects.Text} objects which are drawn on the flyout */
|
||||
private flyoutText: Phaser.GameObjects.Text[] = new Array(4);
|
||||
/** The array of {@linkcode MoveInfo} used to track moves for the {@linkcode Pokemon} linked to the flyout */
|
||||
private moveInfo: MoveInfo[] = [];
|
||||
/** An array of {@linkcode MoveInfo}s used to track moves for the {@linkcode Pokemon} linked to the flyout. */
|
||||
private moveInfo: MoveInfoTuple = [];
|
||||
/**
|
||||
* An array of {@linkcode MoveInfo}s used to track move slots
|
||||
* temporarily overridden by {@linkcode MoveId.TRANSFORM} or {@linkcode MoveId.MIMIC}.
|
||||
*
|
||||
* Reset once {@linkcode pokemon} switches out via a {@linkcode SummonDataResetEvent}.
|
||||
*/
|
||||
private tempMoveInfo: MoveInfoTuple = [];
|
||||
|
||||
/** Current state of the flyout's visibility */
|
||||
public flyoutVisible = false;
|
||||
|
||||
// Stores callbacks in a variable so they can be unsubscribed from when destroyed
|
||||
private readonly onMoveUsedEvent = (event: Event) => this.onMoveUsed(event);
|
||||
private readonly onBerryUsedEvent = (event: Event) => this.onBerryUsed(event);
|
||||
private readonly onMovesetChangedEvent = (event: MovesetChangedEvent) => this.onMovesetChanged(event);
|
||||
private readonly onSummonDataResetEvent = (event: SummonDataResetEvent) => this.onSummonDataReset(event);
|
||||
|
||||
constructor(player: boolean) {
|
||||
super(globalScene, 0, 0);
|
||||
@ -124,79 +139,90 @@ export class BattleFlyout extends Phaser.GameObjects.Container {
|
||||
}
|
||||
|
||||
/**
|
||||
* Links the given {@linkcode Pokemon} and subscribes to the {@linkcode BattleSceneEventType.MOVE_USED} event
|
||||
* @param pokemon {@linkcode Pokemon} to link to this flyout
|
||||
* Link the given {@linkcode Pokemon} to this flyout and subscribe to the {@linkcode BattleSceneEventType.MOVESET_CHANGED} event.
|
||||
* @param pokemon - The {@linkcode Pokemon} to link to this flyout
|
||||
*/
|
||||
initInfo(pokemon: EnemyPokemon) {
|
||||
public initInfo(pokemon: Pokemon): void {
|
||||
this.pokemon = pokemon;
|
||||
|
||||
this.name = `Flyout ${getPokemonNameWithAffix(this.pokemon)}`;
|
||||
this.flyoutParent.name = `Flyout Parent ${getPokemonNameWithAffix(this.pokemon)}`;
|
||||
|
||||
globalScene.eventTarget.addEventListener(BattleSceneEventType.MOVE_USED, this.onMoveUsedEvent);
|
||||
globalScene.eventTarget.addEventListener(BattleSceneEventType.BERRY_USED, this.onBerryUsedEvent);
|
||||
globalScene.eventTarget.addEventListener(BattleSceneEventType.MOVESET_CHANGED, this.onMovesetChangedEvent);
|
||||
globalScene.eventTarget.addEventListener(BattleSceneEventType.SUMMON_DATA_RESET, this.onSummonDataResetEvent);
|
||||
}
|
||||
|
||||
/** Sets and formats the text property for all {@linkcode Phaser.GameObjects.Text} in the flyoutText array */
|
||||
private setText() {
|
||||
for (let i = 0; i < this.flyoutText.length; i++) {
|
||||
const flyoutText = this.flyoutText[i];
|
||||
const moveInfo = this.moveInfo[i];
|
||||
|
||||
if (!moveInfo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const currentPp = moveInfo.maxPp - moveInfo.ppUsed;
|
||||
flyoutText.text = `${moveInfo.move.name} ${currentPp}/${moveInfo.maxPp}`;
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates all of the {@linkcode MoveInfo} objects in the moveInfo array */
|
||||
private onMoveUsed(event: Event) {
|
||||
const moveUsedEvent = event as MoveUsedEvent;
|
||||
if (!moveUsedEvent || moveUsedEvent.pokemonId !== this.pokemon?.id || moveUsedEvent.move.id === MoveId.STRUGGLE) {
|
||||
// Ignore Struggle
|
||||
/**
|
||||
* Set and formats the text property for all {@linkcode Phaser.GameObjects.Text} in the flyoutText array.
|
||||
* @param index - The 0-indexed position of the flyout text object to update
|
||||
*/
|
||||
private updateText(index: number): void {
|
||||
// Use temp move info if present, or else the regular move info.
|
||||
const moveInfo = this.tempMoveInfo[index] ?? this.moveInfo[index];
|
||||
if (!moveInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
const foundInfo = this.moveInfo.find(x => x?.move.id === moveUsedEvent.move.id);
|
||||
if (foundInfo) {
|
||||
foundInfo.ppUsed = moveUsedEvent.ppUsed;
|
||||
} else {
|
||||
this.moveInfo.push({
|
||||
move: moveUsedEvent.move,
|
||||
maxPp: moveUsedEvent.move.pp,
|
||||
ppUsed: moveUsedEvent.ppUsed,
|
||||
});
|
||||
}
|
||||
|
||||
this.setText();
|
||||
const flyoutText = this.flyoutText[index];
|
||||
const maxPP = moveInfo.move.getMovePp();
|
||||
const currentPp = -moveInfo.move.ppUsed;
|
||||
flyoutText.text = `${moveInfo.name} ${currentPp}/${maxPP}`;
|
||||
}
|
||||
|
||||
private onBerryUsed(event: Event) {
|
||||
const berryUsedEvent = event as BerryUsedEvent;
|
||||
/**
|
||||
* Update the corresponding {@linkcode MoveInfo} object in the moveInfo array.
|
||||
* @param event - The {@linkcode MovesetChangedEvent} having been emitted
|
||||
*/
|
||||
private onMovesetChanged(event: MovesetChangedEvent): void {
|
||||
// Ignore other Pokemon's moves as well as Struggle and MoveId.NONE
|
||||
if (
|
||||
!berryUsedEvent ||
|
||||
berryUsedEvent.berryModifier.pokemonId !== this.pokemon?.id ||
|
||||
berryUsedEvent.berryModifier.berryType !== BerryType.LEPPA
|
||||
event.pokemonId !== this.pokemon.id ||
|
||||
event.move.moveId === MoveId.NONE ||
|
||||
event.move.moveId === MoveId.STRUGGLE
|
||||
) {
|
||||
// We only care about Leppa berries
|
||||
return;
|
||||
}
|
||||
|
||||
const foundInfo = this.moveInfo.find(info => info.ppUsed === info.maxPp);
|
||||
if (!foundInfo) {
|
||||
// This will only happen on a de-sync of PP tracking
|
||||
return;
|
||||
}
|
||||
foundInfo.ppUsed = Math.max(foundInfo.ppUsed - 10, 0);
|
||||
// Push to either the temporary or permanent move arrays, depending on which array the move was found in.
|
||||
const isPermanent = this.pokemon.getMoveset(true).includes(event.move);
|
||||
const infoArray = isPermanent ? this.moveInfo : this.tempMoveInfo;
|
||||
|
||||
this.setText();
|
||||
const index = this.pokemon.getMoveset(isPermanent).indexOf(event.move);
|
||||
if (index === -1) {
|
||||
throw new Error("Updated move passed to move flyout was not found in moveset!");
|
||||
}
|
||||
|
||||
// Update the corresponding slot in the info array with either a new entry or an updated PP reading.
|
||||
if (infoArray[index]) {
|
||||
infoArray[index].move = event.move;
|
||||
} else {
|
||||
infoArray[index] = {
|
||||
name: event.move.getMove().name,
|
||||
move: event.move,
|
||||
};
|
||||
}
|
||||
|
||||
this.updateText(index);
|
||||
}
|
||||
|
||||
/** Animates the flyout to either show or hide it by applying a fade and translation */
|
||||
toggleFlyout(visible: boolean): void {
|
||||
/**
|
||||
* Reset the linked Pokemon's temporary moveset override when it is switched out.
|
||||
* @param event - The {@linkcode SummonDataResetEvent} having been emitted
|
||||
*/
|
||||
private onSummonDataReset(event: SummonDataResetEvent): void {
|
||||
if (event.pokemonId !== this.pokemon.id) {
|
||||
// Wrong pokemon
|
||||
return;
|
||||
}
|
||||
|
||||
this.tempMoveInfo = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Animate the flyout to either show or hide the modal.
|
||||
* @param visible - Whether the the flyout should be shown
|
||||
*/
|
||||
public toggleFlyout(visible: boolean): void {
|
||||
this.flyoutVisible = visible;
|
||||
|
||||
globalScene.tweens.add({
|
||||
@ -208,9 +234,10 @@ export class BattleFlyout extends Phaser.GameObjects.Container {
|
||||
});
|
||||
}
|
||||
|
||||
destroy(fromScene?: boolean): void {
|
||||
globalScene.eventTarget.removeEventListener(BattleSceneEventType.MOVE_USED, this.onMoveUsedEvent);
|
||||
globalScene.eventTarget.removeEventListener(BattleSceneEventType.BERRY_USED, this.onBerryUsedEvent);
|
||||
/** Destroy this element and remove all associated listeners. */
|
||||
public destroy(fromScene?: boolean): void {
|
||||
globalScene.eventTarget.removeEventListener(BattleSceneEventType.MOVESET_CHANGED, this.onMovesetChangedEvent);
|
||||
globalScene.eventTarget.removeEventListener(BattleSceneEventType.SUMMON_DATA_RESET, this.onSummonDataResetEvent);
|
||||
|
||||
super.destroy(fromScene);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,8 @@ export class RunInfoUiHandler extends UiHandler {
|
||||
this.runContainer.add(headerText);
|
||||
const runName = addTextObject(0, 0, this.runInfo.name, TextStyle.WINDOW);
|
||||
runName.setOrigin(0, 0);
|
||||
runName.setPositionRelative(headerBg, 60, 4);
|
||||
const runNameX = headerText.width / 6 + headerText.x + 4;
|
||||
runName.setPositionRelative(headerBg, runNameX, 4);
|
||||
this.runContainer.add(runName);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import { Challenges } from "#enums/challenges";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { PokeballType } from "#enums/pokeball";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { runMysteryEncounterToEnd } from "#test/mystery-encounter/encounter-test-utils";
|
||||
import { GameManager } from "#test/test-utils/game-manager";
|
||||
import Phaser from "phaser";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
@ -52,4 +54,18 @@ describe("Challenges - Limited Catch", () => {
|
||||
|
||||
expect(game.scene.getPlayerParty()).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("should allow gift Pokémon from Mystery Encounters to be added to party", async () => {
|
||||
game.override
|
||||
.mysteryEncounterChance(100)
|
||||
.mysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN)
|
||||
.startingWave(12);
|
||||
game.scene.money = 20000;
|
||||
|
||||
await game.challengeMode.runToSummon([SpeciesId.NUZLEAF]);
|
||||
|
||||
await runMysteryEncounterToEnd(game, 1);
|
||||
|
||||
expect(game.scene.getPlayerParty()).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
@ -3,6 +3,7 @@ import { Challenges } from "#enums/challenges";
|
||||
import { MoveId } from "#enums/move-id";
|
||||
import { SpeciesId } from "#enums/species-id";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
import { ExpBoosterModifier } from "#modifiers/modifier";
|
||||
import { GameManager } from "#test/test-utils/game-manager";
|
||||
import { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
|
||||
import Phaser from "phaser";
|
||||
@ -75,6 +76,7 @@ describe("Challenges - Limited Support", () => {
|
||||
await game.doKillOpponents();
|
||||
await game.toNextWave();
|
||||
|
||||
expect(game.scene.getModifiers(ExpBoosterModifier)).toHaveLength(1);
|
||||
expect(playerPokemon).not.toHaveFullHp();
|
||||
|
||||
game.move.use(MoveId.SPLASH);
|
||||
|
Loading…
Reference in New Issue
Block a user