mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-18 21:39:28 +02:00
Compare commits
4 Commits
40bc2fc298
...
3723b68c2e
Author | SHA1 | Date | |
---|---|---|---|
|
3723b68c2e | ||
|
6c0253ada4 | ||
|
018a0091f3 | ||
|
2b3b47cc07 |
@ -132,7 +132,6 @@
|
|||||||
"763": [0, 1, 1],
|
"763": [0, 1, 1],
|
||||||
"767": [0, 1, 1],
|
"767": [0, 1, 1],
|
||||||
"768": [0, 1, 1],
|
"768": [0, 1, 1],
|
||||||
"770": [0, 0, 0],
|
|
||||||
"771": [0, 2, 2],
|
"771": [0, 2, 2],
|
||||||
"772": [0, 1, 1],
|
"772": [0, 1, 1],
|
||||||
"773-fighting": [0, 1, 1],
|
"773-fighting": [0, 1, 1],
|
||||||
|
@ -5,10 +5,9 @@ import type { PokemonSpeciesForm } from "#data/pokemon-species";
|
|||||||
import { PokemonSpecies } from "#data/pokemon-species";
|
import { PokemonSpecies } from "#data/pokemon-species";
|
||||||
import { BiomeId } from "#enums/biome-id";
|
import { BiomeId } from "#enums/biome-id";
|
||||||
import { PartyMemberStrength } from "#enums/party-member-strength";
|
import { PartyMemberStrength } from "#enums/party-member-strength";
|
||||||
import type { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { PlayerPokemon } from "#field/pokemon";
|
|
||||||
import type { Starter } from "#ui/starter-select-ui-handler";
|
import type { Starter } from "#ui/starter-select-ui-handler";
|
||||||
import { randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
|
import { isNullOrUndefined, randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
|
||||||
import { getEnumValues } from "#utils/enums";
|
import { getEnumValues } from "#utils/enums";
|
||||||
import { getPokemonSpecies, getPokemonSpeciesForm } from "#utils/pokemon-utils";
|
import { getPokemonSpecies, getPokemonSpeciesForm } from "#utils/pokemon-utils";
|
||||||
|
|
||||||
@ -32,15 +31,9 @@ export function getDailyRunStarters(seed: string): Starter[] {
|
|||||||
() => {
|
() => {
|
||||||
const startingLevel = globalScene.gameMode.getStartingLevel();
|
const startingLevel = globalScene.gameMode.getStartingLevel();
|
||||||
|
|
||||||
if (/\d{18}$/.test(seed)) {
|
const eventStarters = getDailyEventSeedStarters(seed);
|
||||||
for (let s = 0; s < 3; s++) {
|
if (!isNullOrUndefined(eventStarters)) {
|
||||||
const offset = 6 + s * 6;
|
starters.push(...eventStarters);
|
||||||
const starterSpeciesForm = getPokemonSpeciesForm(
|
|
||||||
Number.parseInt(seed.slice(offset, offset + 4)) as SpeciesId,
|
|
||||||
Number.parseInt(seed.slice(offset + 4, offset + 6)),
|
|
||||||
);
|
|
||||||
starters.push(getDailyRunStarter(starterSpeciesForm, startingLevel));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,18 +65,7 @@ function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLeve
|
|||||||
const starterSpecies =
|
const starterSpecies =
|
||||||
starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
|
starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
|
||||||
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
|
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
|
||||||
const pokemon = new PlayerPokemon(
|
const pokemon = globalScene.addPlayerPokemon(starterSpecies, startingLevel, undefined, formIndex);
|
||||||
starterSpecies,
|
|
||||||
startingLevel,
|
|
||||||
undefined,
|
|
||||||
formIndex,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
const starter: Starter = {
|
const starter: Starter = {
|
||||||
species: starterSpecies,
|
species: starterSpecies,
|
||||||
dexAttr: pokemon.getDexAttr(),
|
dexAttr: pokemon.getDexAttr(),
|
||||||
@ -145,6 +127,11 @@ const dailyBiomeWeights: BiomeWeights = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getDailyStartingBiome(): BiomeId {
|
export function getDailyStartingBiome(): BiomeId {
|
||||||
|
const eventBiome = getDailyEventSeedBiome(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBiome)) {
|
||||||
|
return eventBiome;
|
||||||
|
}
|
||||||
|
|
||||||
const biomes = getEnumValues(BiomeId).filter(b => b !== BiomeId.TOWN && b !== BiomeId.END);
|
const biomes = getEnumValues(BiomeId).filter(b => b !== BiomeId.TOWN && b !== BiomeId.END);
|
||||||
|
|
||||||
let totalWeight = 0;
|
let totalWeight = 0;
|
||||||
@ -169,3 +156,126 @@ export function getDailyStartingBiome(): BiomeId {
|
|||||||
// TODO: should this use `randSeedItem`?
|
// TODO: should this use `randSeedItem`?
|
||||||
return biomes[randSeedInt(biomes.length)];
|
return biomes[randSeedInt(biomes.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this is Daily Mode and the seed is longer than a default seed
|
||||||
|
* then it has been modified and could contain a custom event seed. \
|
||||||
|
* Default seeds are always exactly 24 characters.
|
||||||
|
* @returns `true` if it is a Daily Event Seed.
|
||||||
|
*/
|
||||||
|
export function isDailyEventSeed(seed: string): boolean {
|
||||||
|
return globalScene.gameMode.isDaily && seed.length > 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/starters\d{18}/`
|
||||||
|
* where the digits alternate between 4 digits for the species ID and 2 digits for the form index
|
||||||
|
* (left padded with `0`s as necessary).
|
||||||
|
* @returns An array of {@linkcode Starter}s, or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedStarters(seed: string): Starter[] | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starters: Starter[] = [];
|
||||||
|
const match = /starters(\d{4})(\d{2})(\d{4})(\d{2})(\d{4})(\d{2})/g.exec(seed);
|
||||||
|
|
||||||
|
if (!match || match.length !== 7) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 1; i < match.length; i += 2) {
|
||||||
|
const speciesId = Number.parseInt(match[i]) as SpeciesId;
|
||||||
|
const formIndex = Number.parseInt(match[i + 1]);
|
||||||
|
|
||||||
|
if (!getEnumValues(SpeciesId).includes(speciesId)) {
|
||||||
|
console.warn("Invalid species ID used for custom daily run seed starter:", speciesId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
|
||||||
|
const startingLevel = globalScene.gameMode.getStartingLevel();
|
||||||
|
const starter = getDailyRunStarter(starterForm, startingLevel);
|
||||||
|
starters.push(starter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return starters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/boss\d{4}\d{2}/`
|
||||||
|
* where the first 4 digits are the species ID and the next 2 digits are the form index
|
||||||
|
* (left padded with `0`s as necessary).
|
||||||
|
* @returns A {@linkcode PokemonSpeciesForm} to be used for the boss, or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedBoss(seed: string): PokemonSpeciesForm | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /boss(\d{4})(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 3) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const speciesId = Number.parseInt(match[1]) as SpeciesId;
|
||||||
|
const formIndex = Number.parseInt(match[2]);
|
||||||
|
|
||||||
|
if (!getEnumValues(SpeciesId).includes(speciesId)) {
|
||||||
|
console.warn("Invalid species ID used for custom daily run seed boss:", speciesId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
|
||||||
|
return starterForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/biome\d{2}/` where the 2 digits are a biome ID (left padded with `0` if necessary).
|
||||||
|
* @returns The biome to use or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedBiome(seed: string): BiomeId | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /biome(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startingBiome = Number.parseInt(match[1]) as BiomeId;
|
||||||
|
|
||||||
|
if (!getEnumValues(BiomeId).includes(startingBiome)) {
|
||||||
|
console.warn("Invalid biome ID used for custom daily run seed:", startingBiome);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return startingBiome;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/luck\d{2}/` where the 2 digits are a number between `0` and `14`
|
||||||
|
* (left padded with `0` if necessary).
|
||||||
|
* @returns The custom luck value or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedLuck(seed: string): number | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /luck(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const luck = Number.parseInt(match[1]);
|
||||||
|
|
||||||
|
if (luck < 0 || luck > 14) {
|
||||||
|
console.warn("Invalid luck value used for custom daily run seed:", luck);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return luck;
|
||||||
|
}
|
||||||
|
@ -44,6 +44,30 @@ export abstract class PhasePriorityQueue {
|
|||||||
public clear(): void {
|
public clear(): void {
|
||||||
this.queue.splice(0, this.queue.length);
|
this.queue.splice(0, this.queue.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to remove one or more Phases from the current queue.
|
||||||
|
* @param phaseFilter - The function to select phases for removal
|
||||||
|
* @param removeCount - The maximum number of phases to remove, or `all` to remove all matching phases;
|
||||||
|
* default `1`
|
||||||
|
* @returns The number of successfully removed phases
|
||||||
|
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
||||||
|
*/
|
||||||
|
public tryRemovePhase(phaseFilter: (phase: Phase) => boolean, removeCount: number | "all" = 1): number {
|
||||||
|
if (typeof removeCount === "string") {
|
||||||
|
removeCount = Number.MAX_SAFE_INTEGER; // For the lulz
|
||||||
|
}
|
||||||
|
let numRemoved = 0;
|
||||||
|
let phaseIndex = this.queue.findIndex(phaseFilter);
|
||||||
|
if (phaseIndex === -1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
this.queue.splice(phaseIndex, 1);
|
||||||
|
numRemoved++;
|
||||||
|
} while (numRemoved < removeCount || (phaseIndex = this.queue.findIndex(phaseFilter)) !== -1);
|
||||||
|
return removeCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +103,7 @@ export class PostSummonPhasePriorityQueue extends PhasePriorityQueue {
|
|||||||
private queueAbilityPhase(phase: PostSummonPhase): void {
|
private queueAbilityPhase(phase: PostSummonPhase): void {
|
||||||
const phasePokemon = phase.getPokemon();
|
const phasePokemon = phase.getPokemon();
|
||||||
|
|
||||||
|
console.log(phasePokemon.getNameToRender());
|
||||||
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
phasePokemon.getAbilityPriorities().forEach((priority, idx) => {
|
||||||
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
this.queue.push(new PostSummonActivateAbilityPhase(phasePokemon.getBattlerIndex(), priority, !!idx));
|
||||||
globalScene.phaseManager.appendToPhase(
|
globalScene.phaseManager.appendToPhase(
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
TrappedTag,
|
TrappedTag,
|
||||||
TypeImmuneTag,
|
TypeImmuneTag,
|
||||||
} from "#data/battler-tags";
|
} from "#data/battler-tags";
|
||||||
|
import { getDailyEventSeedBoss } from "#data/daily-run";
|
||||||
import { allAbilities, allMoves } from "#data/data-lists";
|
import { allAbilities, allMoves } from "#data/data-lists";
|
||||||
import { getLevelTotalExp } from "#data/exp";
|
import { getLevelTotalExp } from "#data/exp";
|
||||||
import {
|
import {
|
||||||
@ -6256,6 +6257,11 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]]
|
this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]]
|
||||||
) {
|
) {
|
||||||
this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId];
|
this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId];
|
||||||
|
} else if (globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
|
||||||
|
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBoss)) {
|
||||||
|
this.formIndex = eventBoss.formIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dataSource) {
|
if (!dataSource) {
|
||||||
|
@ -3,7 +3,7 @@ import { CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES, CLASSIC_MODE_MYSTERY_ENCOUNTER_
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import { allChallenges, type Challenge, copyChallenge } from "#data/challenge";
|
import { allChallenges, type Challenge, copyChallenge } from "#data/challenge";
|
||||||
import { getDailyStartingBiome } from "#data/daily-run";
|
import { getDailyEventSeedBoss, getDailyStartingBiome } from "#data/daily-run";
|
||||||
import { allSpecies } from "#data/data-lists";
|
import { allSpecies } from "#data/data-lists";
|
||||||
import type { PokemonSpecies } from "#data/pokemon-species";
|
import type { PokemonSpecies } from "#data/pokemon-species";
|
||||||
import { BiomeId } from "#enums/biome-id";
|
import { BiomeId } from "#enums/biome-id";
|
||||||
@ -15,6 +15,7 @@ import type { Arena } from "#field/arena";
|
|||||||
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
|
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
|
||||||
import { applyChallenges } from "#utils/challenge-utils";
|
import { applyChallenges } from "#utils/challenge-utils";
|
||||||
import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common";
|
import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common";
|
||||||
|
import { getPokemonSpecies } from "#utils/pokemon-utils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
interface GameModeConfig {
|
interface GameModeConfig {
|
||||||
@ -211,6 +212,12 @@ export class GameMode implements GameModeConfig {
|
|||||||
|
|
||||||
getOverrideSpecies(waveIndex: number): PokemonSpecies | null {
|
getOverrideSpecies(waveIndex: number): PokemonSpecies | null {
|
||||||
if (this.isDaily && this.isWaveFinal(waveIndex)) {
|
if (this.isDaily && this.isWaveFinal(waveIndex)) {
|
||||||
|
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBoss)) {
|
||||||
|
// Cannot set form index here, it will be overriden when adding it as enemy pokemon.
|
||||||
|
return getPokemonSpecies(eventBoss.speciesId);
|
||||||
|
}
|
||||||
|
|
||||||
const allFinalBossSpecies = allSpecies.filter(
|
const allFinalBossSpecies = allSpecies.filter(
|
||||||
s =>
|
s =>
|
||||||
(s.subLegendary || s.legendary || s.mythical) &&
|
(s.subLegendary || s.legendary || s.mythical) &&
|
||||||
|
@ -6,6 +6,7 @@ import Overrides from "#app/overrides";
|
|||||||
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
|
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
|
||||||
import { tmPoolTiers, tmSpecies } from "#balance/tms";
|
import { tmPoolTiers, tmSpecies } from "#balance/tms";
|
||||||
import { getBerryEffectDescription, getBerryName } from "#data/berry";
|
import { getBerryEffectDescription, getBerryName } from "#data/berry";
|
||||||
|
import { getDailyEventSeedLuck } from "#data/daily-run";
|
||||||
import { allMoves, modifierTypes } from "#data/data-lists";
|
import { allMoves, modifierTypes } from "#data/data-lists";
|
||||||
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
|
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
|
||||||
import { getNatureName, getNatureStatMultiplier } from "#data/nature";
|
import { getNatureName, getNatureStatMultiplier } from "#data/nature";
|
||||||
@ -2921,6 +2922,12 @@ export function getPartyLuckValue(party: Pokemon[]): number {
|
|||||||
const DailyLuck = new NumberHolder(0);
|
const DailyLuck = new NumberHolder(0);
|
||||||
globalScene.executeWithSeedOffset(
|
globalScene.executeWithSeedOffset(
|
||||||
() => {
|
() => {
|
||||||
|
const eventLuck = getDailyEventSeedLuck(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventLuck)) {
|
||||||
|
DailyLuck.value = eventLuck;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
|
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
@ -2928,6 +2935,7 @@ export function getPartyLuckValue(party: Pokemon[]): number {
|
|||||||
);
|
);
|
||||||
return DailyLuck.value;
|
return DailyLuck.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
|
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
|
||||||
const luck = Phaser.Math.Clamp(
|
const luck = Phaser.Math.Clamp(
|
||||||
party
|
party
|
||||||
|
@ -355,14 +355,23 @@ export class PhaseManager {
|
|||||||
if (this.phaseQueuePrependSpliceIndex > -1) {
|
if (this.phaseQueuePrependSpliceIndex > -1) {
|
||||||
this.clearPhaseQueueSplice();
|
this.clearPhaseQueueSplice();
|
||||||
}
|
}
|
||||||
if (this.phaseQueuePrepend.length) {
|
this.phaseQueue.unshift(...this.phaseQueuePrepend);
|
||||||
while (this.phaseQueuePrepend.length) {
|
this.phaseQueuePrepend.splice(0);
|
||||||
const poppedPhase = this.phaseQueuePrepend.pop();
|
|
||||||
if (poppedPhase) {
|
const unactivatedConditionalPhases: [() => boolean, Phase][] = [];
|
||||||
this.phaseQueue.unshift(poppedPhase);
|
// Check if there are any conditional phases queued
|
||||||
}
|
for (const [condition, phase] of this.conditionalQueue) {
|
||||||
|
// Evaluate the condition associated with the phase
|
||||||
|
if (condition()) {
|
||||||
|
// If the condition is met, add the phase to the phase queue
|
||||||
|
this.pushPhase(phase);
|
||||||
|
} else {
|
||||||
|
// If the condition is not met, re-add the phase back to the end of the conditional queue
|
||||||
|
unactivatedConditionalPhases.push([condition, phase]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.conditionalQueue = unactivatedConditionalPhases;
|
||||||
|
|
||||||
if (!this.phaseQueue.length) {
|
if (!this.phaseQueue.length) {
|
||||||
this.populatePhaseQueue();
|
this.populatePhaseQueue();
|
||||||
// Clear the conditionalQueue if there are no phases left in the phaseQueue
|
// Clear the conditionalQueue if there are no phases left in the phaseQueue
|
||||||
@ -371,24 +380,6 @@ export class PhaseManager {
|
|||||||
|
|
||||||
this.currentPhase = this.phaseQueue.shift() ?? null;
|
this.currentPhase = this.phaseQueue.shift() ?? null;
|
||||||
|
|
||||||
const unactivatedConditionalPhases: [() => boolean, Phase][] = [];
|
|
||||||
// Check if there are any conditional phases queued
|
|
||||||
while (this.conditionalQueue?.length) {
|
|
||||||
// Retrieve the first conditional phase from the queue
|
|
||||||
const conditionalPhase = this.conditionalQueue.shift();
|
|
||||||
// Evaluate the condition associated with the phase
|
|
||||||
if (conditionalPhase?.[0]()) {
|
|
||||||
// If the condition is met, add the phase to the phase queue
|
|
||||||
this.pushPhase(conditionalPhase[1]);
|
|
||||||
} else if (conditionalPhase) {
|
|
||||||
// If the condition is not met, re-add the phase back to the front of the conditional queue
|
|
||||||
unactivatedConditionalPhases.push(conditionalPhase);
|
|
||||||
} else {
|
|
||||||
console.warn("condition phase is undefined/null!", conditionalPhase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.conditionalQueue.push(...unactivatedConditionalPhases);
|
|
||||||
|
|
||||||
if (this.currentPhase) {
|
if (this.currentPhase) {
|
||||||
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");
|
console.log(`%cStart Phase ${this.currentPhase.constructor.name}`, "color:green;");
|
||||||
this.currentPhase.start();
|
this.currentPhase.start();
|
||||||
@ -520,6 +511,25 @@ export class PhaseManager {
|
|||||||
this.dynamicPhaseQueues[type].push(phase);
|
this.dynamicPhaseQueues[type].push(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to remove one or more Phases from the given DynamicPhaseQueue, removing the equivalent amount of {@linkcode ActivatePriorityQueuePhase}s from the queue.
|
||||||
|
* @param type - The {@linkcode DynamicPhaseType} to check
|
||||||
|
* @param phaseFilter - The function to select phases for removal
|
||||||
|
* @param removeCount - The maximum number of phases to remove, or `all` to remove all matching phases;
|
||||||
|
* default `1`
|
||||||
|
* @todo Remove this eventually once the patchwork bug this is used for is fixed
|
||||||
|
*/
|
||||||
|
public tryRemoveDynamicPhase(
|
||||||
|
type: DynamicPhaseType,
|
||||||
|
phaseFilter: (phase: Phase) => boolean,
|
||||||
|
removeCount: number | "all" = 1,
|
||||||
|
): void {
|
||||||
|
const numRemoved = this.dynamicPhaseQueues[type].tryRemovePhase(phaseFilter, removeCount);
|
||||||
|
for (let x = 0; x < numRemoved; x++) {
|
||||||
|
this.tryRemovePhase(p => p.is("ActivatePriorityQueuePhase"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue}
|
* Unshifts the top phase from the corresponding dynamic queue onto {@linkcode phaseQueue}
|
||||||
* @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start
|
* @param type {@linkcode DynamicPhaseType} The type of dynamic phase to start
|
||||||
|
@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
|
|||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { BattleStyle } from "#enums/battle-style";
|
import { BattleStyle } from "#enums/battle-style";
|
||||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||||
|
import { DynamicPhaseType } from "#enums/dynamic-phase-type";
|
||||||
import { SwitchType } from "#enums/switch-type";
|
import { SwitchType } from "#enums/switch-type";
|
||||||
import { UiMode } from "#enums/ui-mode";
|
import { UiMode } from "#enums/ui-mode";
|
||||||
import { BattlePhase } from "#phases/battle-phase";
|
import { BattlePhase } from "#phases/battle-phase";
|
||||||
@ -66,6 +67,17 @@ export class CheckSwitchPhase extends BattlePhase {
|
|||||||
UiMode.CONFIRM,
|
UiMode.CONFIRM,
|
||||||
() => {
|
() => {
|
||||||
globalScene.ui.setMode(UiMode.MESSAGE);
|
globalScene.ui.setMode(UiMode.MESSAGE);
|
||||||
|
/*
|
||||||
|
Remove any pending `ActivatePriorityQueuePhase`s for the currently leaving Pokemon produced by the prior `SwitchSummonPhase`.
|
||||||
|
This is required to avoid triggering on-switch abilities twice on initial entrance.
|
||||||
|
TODO: Separate the animations from `SwitchSummonPhase` to another phase and call that on initial switch - this is a band-aid fix
|
||||||
|
TODO: Confirm with @emdeann what the maximum number of these things that gets unshifted can be
|
||||||
|
*/
|
||||||
|
globalScene.phaseManager.tryRemoveDynamicPhase(
|
||||||
|
DynamicPhaseType.POST_SUMMON,
|
||||||
|
p => p.is("PostSummonPhase") && p.getPokemon() === pokemon,
|
||||||
|
4,
|
||||||
|
);
|
||||||
globalScene.phaseManager.unshiftNew("SwitchPhase", SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true);
|
globalScene.phaseManager.unshiftNew("SwitchPhase", SwitchType.INITIAL_SWITCH, this.fieldIndex, false, true);
|
||||||
this.end();
|
this.end();
|
||||||
},
|
},
|
||||||
|
@ -35,31 +35,45 @@ describe("Abilities - Intimidate", () => {
|
|||||||
it("should lower all opponents' ATK by 1 stage on entry and switch", async () => {
|
it("should lower all opponents' ATK by 1 stage on entry and switch", async () => {
|
||||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
await game.classicMode.startBattle([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||||
|
|
||||||
|
const [mightyena, poochyena] = game.scene.getPlayerParty();
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const enemy = game.field.getEnemyPokemon();
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
expect(enemy.getStatStage(Stat.ATK)).toBe(-1);
|
||||||
|
expect(mightyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
|
|
||||||
game.doSwitchPokemon(1);
|
game.doSwitchPokemon(1);
|
||||||
await game.toNextTurn();
|
await game.toNextTurn();
|
||||||
|
|
||||||
|
expect(poochyena.isActive()).toBe(true);
|
||||||
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
|
expect(enemy.getStatStage(Stat.ATK)).toBe(-2);
|
||||||
|
expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: This fails due to a limitation in our switching logic - the animations and field entry occur concurrently
|
it("should trigger once on initial switch prompt without cancelling opposing abilities", async () => {
|
||||||
// inside `SummonPhase`, unshifting 2 `PostSummmonPhase`s and proccing intimidate twice
|
|
||||||
it.todo("should lower all opponents' ATK by 1 stage on initial switch prompt", async () => {
|
|
||||||
await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
await game.classicMode.runToSummon([SpeciesId.MIGHTYENA, SpeciesId.POOCHYENA]);
|
||||||
await game.classicMode.startBattleWithSwitch(1);
|
await game.classicMode.startBattleWithSwitch(1);
|
||||||
|
|
||||||
const [poochyena, mightyena] = game.scene.getPlayerField();
|
const [poochyena, mightyena] = game.scene.getPlayerParty();
|
||||||
expect(poochyena.species.speciesId).toBe(SpeciesId.POOCHYENA);
|
expect(poochyena.species.speciesId).toBe(SpeciesId.POOCHYENA);
|
||||||
|
|
||||||
const enemy = game.field.getEnemyPokemon();
|
const enemy = game.field.getEnemyPokemon();
|
||||||
expect(enemy).toHaveStatStage(Stat.ATK, -1);
|
expect(enemy).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
expect(poochyena).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
|
||||||
expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
expect(poochyena).toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
expect(mightyena).not.toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
expect(mightyena).not.toHaveAbilityApplied(AbilityId.INTIMIDATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should activate on reload with single party", async () => {
|
||||||
|
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
||||||
|
|
||||||
|
expect(game.field.getEnemyPokemon()).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
|
||||||
|
await game.reload.reloadSession();
|
||||||
|
|
||||||
|
expect(game.field.getEnemyPokemon()).toHaveStatStage(Stat.ATK, -1);
|
||||||
|
});
|
||||||
|
|
||||||
it("should lower ATK of all opponents in a double battle", async () => {
|
it("should lower ATK of all opponents in a double battle", async () => {
|
||||||
game.override.battleStyle("double");
|
game.override.battleStyle("double");
|
||||||
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
await game.classicMode.startBattle([SpeciesId.MIGHTYENA]);
|
||||||
|
Loading…
Reference in New Issue
Block a user