mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-20 06:19:29 +02:00
Compare commits
24 Commits
f4e6dcb111
...
d58472d0fe
Author | SHA1 | Date | |
---|---|---|---|
|
d58472d0fe | ||
|
da7903ab92 | ||
|
70e7f8b4d4 | ||
|
1e644e453c | ||
|
c3bc15a0a9 | ||
|
9cec9fc715 | ||
|
23df04467c | ||
|
f42c1461c2 | ||
|
1d4b7666ee | ||
|
3012060954 | ||
|
991c00eda0 | ||
|
94d8d60826 | ||
|
70d49e546d | ||
|
5c1bfb4110 | ||
|
bdfe4a6a2a | ||
|
e6e4445a09 | ||
|
4dc53d2ee3 | ||
|
5781eb2715 | ||
|
bc337f022d | ||
|
93740ae3a2 | ||
|
4ab2a33578 | ||
|
7cf396f296 | ||
|
81d3fb1eea | ||
|
688bd5366d |
@ -27,13 +27,7 @@ import { UiInputs } from "#app/ui-inputs";
|
|||||||
import { biomeDepths, getBiomeName } from "#balance/biomes";
|
import { biomeDepths, getBiomeName } from "#balance/biomes";
|
||||||
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
|
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
|
||||||
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
|
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
|
||||||
import {
|
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets } from "#data/battle-anims";
|
||||||
initCommonAnims,
|
|
||||||
initMoveAnim,
|
|
||||||
loadCommonAnimAssets,
|
|
||||||
loadMoveAnimAssets,
|
|
||||||
populateAnims,
|
|
||||||
} from "#data/battle-anims";
|
|
||||||
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
|
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
|
||||||
import { battleSpecDialogue } from "#data/dialogue";
|
import { battleSpecDialogue } from "#data/dialogue";
|
||||||
import type { SpeciesFormChangeTrigger } from "#data/form-change-triggers";
|
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];
|
const defaultMoves = [MoveId.TACKLE, MoveId.TAIL_WHIP, MoveId.FOCUS_ENERGY, MoveId.STRUGGLE];
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
populateAnims(),
|
|
||||||
this.initVariantData(),
|
this.initVariantData(),
|
||||||
initCommonAnims().then(() => loadCommonAnimAssets(true)),
|
initCommonAnims().then(() => loadCommonAnimAssets(true)),
|
||||||
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
||||||
|
@ -404,22 +404,18 @@ export const chargeAnims = new Map<ChargeAnim, AnimConfig | [AnimConfig, AnimCon
|
|||||||
export const commonAnims = new Map<CommonAnim, AnimConfig>();
|
export const commonAnims = new Map<CommonAnim, AnimConfig>();
|
||||||
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
|
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
|
||||||
|
|
||||||
export function initCommonAnims(): Promise<void> {
|
export async function initCommonAnims(): Promise<void> {
|
||||||
return new Promise(resolve => {
|
|
||||||
const commonAnimNames = getEnumKeys(CommonAnim);
|
|
||||||
const commonAnimIds = getEnumValues(CommonAnim);
|
|
||||||
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
||||||
for (let ca = 0; ca < commonAnimIds.length; ca++) {
|
for (const commonAnimName of getEnumKeys(CommonAnim)) {
|
||||||
const commonAnimId = commonAnimIds[ca];
|
const commonAnimId = CommonAnim[commonAnimName];
|
||||||
commonAnimFetches.push(
|
commonAnimFetches.push(
|
||||||
globalScene
|
globalScene
|
||||||
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimNames[ca])}.json`)
|
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimName)}.json`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Promise.allSettled(commonAnimFetches).then(() => resolve());
|
await Promise.allSettled(commonAnimFetches);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initMoveAnim(move: MoveId): Promise<void> {
|
export function initMoveAnim(move: MoveId): Promise<void> {
|
||||||
@ -1396,279 +1392,3 @@ export class EncounterBattleAnim extends BattleAnim {
|
|||||||
return this.oppAnim;
|
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: ' ' }));
|
|
||||||
})();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { applyAbAttrs } from "#abilities/apply-ab-attrs";
|
import { applyAbAttrs } from "#abilities/apply-ab-attrs";
|
||||||
|
import type { TurnCommand } from "#app/battle";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import { TrickRoomTag } from "#data/arena-tag";
|
import { TrickRoomTag } from "#data/arena-tag";
|
||||||
import { allMoves } from "#data/data-lists";
|
import { allMoves } from "#data/data-lists";
|
||||||
@ -14,19 +15,20 @@ import { BooleanHolder, randSeedShuffle } from "#utils/common";
|
|||||||
|
|
||||||
export class TurnStartPhase extends FieldPhase {
|
export class TurnStartPhase extends FieldPhase {
|
||||||
public readonly phaseName = "TurnStartPhase";
|
public readonly phaseName = "TurnStartPhase";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This orders the active Pokemon on the field by speed into an BattlerIndex array and returns that array.
|
* Helper method to retrieve the current speed order of the combattants.
|
||||||
* It also checks for Trick Room and reverses the array if it is present.
|
* It also checks for Trick Room and reverses the array if it is present.
|
||||||
* @returns {@linkcode BattlerIndex[]} the battle indices of all pokemon on the field ordered by speed
|
* @returns The {@linkcode BattlerIndex}es of all on-field Pokemon, sorted in speed order.
|
||||||
*/
|
*/
|
||||||
getSpeedOrder(): BattlerIndex[] {
|
getSpeedOrder(): BattlerIndex[] {
|
||||||
const playerField = globalScene.getPlayerField().filter(p => p.isActive()) as Pokemon[];
|
const playerField = globalScene.getPlayerField().filter(p => p.isActive());
|
||||||
const enemyField = globalScene.getEnemyField().filter(p => p.isActive()) as Pokemon[];
|
const enemyField = globalScene.getEnemyField().filter(p => p.isActive());
|
||||||
|
|
||||||
// We shuffle the list before sorting so speed ties produce random results
|
// Shuffle the list before sorting so speed ties produce random results
|
||||||
let orderedTargets: Pokemon[] = playerField.concat(enemyField);
|
// This is seeded with the current turn to prevent turn order varying
|
||||||
// We seed it with the current turn to prevent an inconsistency where it
|
// based on how long since you last reloaded.
|
||||||
// was varying based on how long since you last reloaded
|
let orderedTargets = (playerField as Pokemon[]).concat(enemyField);
|
||||||
globalScene.executeWithSeedOffset(
|
globalScene.executeWithSeedOffset(
|
||||||
() => {
|
() => {
|
||||||
orderedTargets = randSeedShuffle(orderedTargets);
|
orderedTargets = randSeedShuffle(orderedTargets);
|
||||||
@ -35,25 +37,25 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
globalScene.waveSeed,
|
globalScene.waveSeed,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Next, a check for Trick Room is applied to determine sort order.
|
// Check for Trick Room and reverse sort order if active.
|
||||||
|
// Notably, Pokerogue does NOT have the "outspeed trick room" glitch at >1809 spd.
|
||||||
const speedReversed = new BooleanHolder(false);
|
const speedReversed = new BooleanHolder(false);
|
||||||
globalScene.arena.applyTags(TrickRoomTag, false, speedReversed);
|
globalScene.arena.applyTags(TrickRoomTag, false, speedReversed);
|
||||||
|
|
||||||
// Adjust the sort function based on whether Trick Room is active.
|
|
||||||
orderedTargets.sort((a: Pokemon, b: Pokemon) => {
|
orderedTargets.sort((a: Pokemon, b: Pokemon) => {
|
||||||
const aSpeed = a?.getEffectiveStat(Stat.SPD) ?? 0;
|
const aSpeed = a.getEffectiveStat(Stat.SPD);
|
||||||
const bSpeed = b?.getEffectiveStat(Stat.SPD) ?? 0;
|
const bSpeed = b.getEffectiveStat(Stat.SPD);
|
||||||
|
|
||||||
return speedReversed.value ? aSpeed - bSpeed : bSpeed - aSpeed;
|
return speedReversed.value ? aSpeed - bSpeed : bSpeed - aSpeed;
|
||||||
});
|
});
|
||||||
|
|
||||||
return orderedTargets.map(t => t.getFieldIndex() + (!t.isPlayer() ? BattlerIndex.ENEMY : BattlerIndex.PLAYER));
|
return orderedTargets.map(t => t.getFieldIndex() + (t.isEnemy() ? BattlerIndex.ENEMY : BattlerIndex.PLAYER));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This takes the result of getSpeedOrder and applies priority / bypass speed attributes to it.
|
* This takes the result of {@linkcode getSpeedOrder} and applies priority / bypass speed attributes to it.
|
||||||
* This also considers the priority levels of various commands and changes the result of getSpeedOrder based on such.
|
* This also considers the priority levels of various commands and changes the result of `getSpeedOrder` based on such.
|
||||||
* @returns {@linkcode BattlerIndex[]} the final sequence of commands for this turn
|
* @returns The `BattlerIndex`es of all on-field Pokemon sorted in action order.
|
||||||
*/
|
*/
|
||||||
getCommandOrder(): BattlerIndex[] {
|
getCommandOrder(): BattlerIndex[] {
|
||||||
let moveOrder = this.getSpeedOrder();
|
let moveOrder = this.getSpeedOrder();
|
||||||
@ -114,7 +116,8 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no difference between the move's calculated priorities, the game checks for differences in battlerBypassSpeed and returns the result.
|
// If there is no difference between the move's calculated priorities,
|
||||||
|
// check for differences in battlerBypassSpeed and returns the result.
|
||||||
if (battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
|
if (battlerBypassSpeed[a].value !== battlerBypassSpeed[b].value) {
|
||||||
return battlerBypassSpeed[a].value ? -1 : 1;
|
return battlerBypassSpeed[a].value ? -1 : 1;
|
||||||
}
|
}
|
||||||
@ -135,8 +138,6 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
const field = globalScene.getField();
|
const field = globalScene.getField();
|
||||||
const moveOrder = this.getCommandOrder();
|
const moveOrder = this.getCommandOrder();
|
||||||
|
|
||||||
let orderIndex = 0;
|
|
||||||
|
|
||||||
for (const o of this.getSpeedOrder()) {
|
for (const o of this.getSpeedOrder()) {
|
||||||
const pokemon = field[o];
|
const pokemon = field[o];
|
||||||
const preTurnCommand = globalScene.currentBattle.preTurnCommands[o];
|
const preTurnCommand = globalScene.currentBattle.preTurnCommands[o];
|
||||||
@ -153,71 +154,24 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
|
|
||||||
const phaseManager = globalScene.phaseManager;
|
const phaseManager = globalScene.phaseManager;
|
||||||
|
|
||||||
for (const o of moveOrder) {
|
moveOrder.forEach((o, index) => {
|
||||||
const pokemon = field[o];
|
const pokemon = field[o];
|
||||||
const turnCommand = globalScene.currentBattle.turnCommands[o];
|
const turnCommand = globalScene.currentBattle.turnCommands[o];
|
||||||
|
|
||||||
if (turnCommand?.skip) {
|
if (!turnCommand || turnCommand.skip) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (turnCommand?.command) {
|
// TODO: Remove `turnData.order` -
|
||||||
case Command.FIGHT: {
|
// it is used exclusively for Fusion Flare/Bolt
|
||||||
const queuedMove = turnCommand.move;
|
// and uses a really jank (and incorrect) implementation
|
||||||
pokemon.turnData.order = orderIndex++;
|
if (turnCommand.command === Command.FIGHT) {
|
||||||
if (!queuedMove) {
|
pokemon.turnData.order = index;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const move =
|
|
||||||
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ??
|
|
||||||
new PokemonMove(queuedMove.move);
|
|
||||||
if (move.getMove().hasAttr("MoveHeaderAttr")) {
|
|
||||||
phaseManager.unshiftNew("MoveHeaderPhase", pokemon, move);
|
|
||||||
}
|
}
|
||||||
|
this.handleTurnCommand(turnCommand, pokemon);
|
||||||
|
});
|
||||||
|
|
||||||
if (pokemon.isPlayer() && turnCommand.cursor === -1) {
|
// Queue various effects for the end of the turn.
|
||||||
phaseManager.pushNew(
|
|
||||||
"MovePhase",
|
|
||||||
pokemon,
|
|
||||||
turnCommand.targets || turnCommand.move!.targets,
|
|
||||||
move,
|
|
||||||
turnCommand.move!.useMode,
|
|
||||||
); //TODO: is the bang correct here?
|
|
||||||
} else {
|
|
||||||
phaseManager.pushNew(
|
|
||||||
"MovePhase",
|
|
||||||
pokemon,
|
|
||||||
turnCommand.targets || turnCommand.move!.targets,
|
|
||||||
move,
|
|
||||||
queuedMove.useMode,
|
|
||||||
); // TODO: is the bang correct here?
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Command.BALL:
|
|
||||||
phaseManager.unshiftNew("AttemptCapturePhase", turnCommand.targets![0] % 2, turnCommand.cursor!); //TODO: is the bang correct here?
|
|
||||||
break;
|
|
||||||
case Command.POKEMON:
|
|
||||||
{
|
|
||||||
const switchType = turnCommand.args?.[0] ? SwitchType.BATON_PASS : SwitchType.SWITCH;
|
|
||||||
phaseManager.unshiftNew(
|
|
||||||
"SwitchSummonPhase",
|
|
||||||
switchType,
|
|
||||||
pokemon.getFieldIndex(),
|
|
||||||
turnCommand.cursor!,
|
|
||||||
true,
|
|
||||||
pokemon.isPlayer(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Command.RUN:
|
|
||||||
{
|
|
||||||
// Running (like ball throwing) is a team action taking up both Pokemon's turns.
|
|
||||||
phaseManager.unshiftNew("AttemptRunPhase");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
phaseManager.pushNew("CheckInterludePhase");
|
phaseManager.pushNew("CheckInterludePhase");
|
||||||
|
|
||||||
// TODO: Re-order these phases to be consistent with mainline turn order:
|
// TODO: Re-order these phases to be consistent with mainline turn order:
|
||||||
@ -239,4 +193,52 @@ export class TurnStartPhase extends FieldPhase {
|
|||||||
*/
|
*/
|
||||||
this.end();
|
this.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleTurnCommand(turnCommand: TurnCommand, pokemon: Pokemon) {
|
||||||
|
switch (turnCommand?.command) {
|
||||||
|
case Command.FIGHT:
|
||||||
|
this.handleFightCommand(turnCommand, pokemon);
|
||||||
|
break;
|
||||||
|
case Command.BALL:
|
||||||
|
globalScene.phaseManager.unshiftNew("AttemptCapturePhase", turnCommand.targets![0] % 2, turnCommand.cursor!); //TODO: is the bang correct here?
|
||||||
|
break;
|
||||||
|
case Command.POKEMON:
|
||||||
|
globalScene.phaseManager.unshiftNew(
|
||||||
|
"SwitchSummonPhase",
|
||||||
|
turnCommand.args?.[0] ? SwitchType.BATON_PASS : SwitchType.SWITCH,
|
||||||
|
pokemon.getFieldIndex(),
|
||||||
|
turnCommand.cursor!, // TODO: Is this bang correct?
|
||||||
|
true,
|
||||||
|
pokemon.isPlayer(),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case Command.RUN:
|
||||||
|
globalScene.phaseManager.unshiftNew("AttemptRunPhase");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleFightCommand(turnCommand: TurnCommand, pokemon: Pokemon) {
|
||||||
|
const queuedMove = turnCommand.move;
|
||||||
|
if (!queuedMove) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: This seems somewhat dubious
|
||||||
|
const move =
|
||||||
|
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ??
|
||||||
|
new PokemonMove(queuedMove.move);
|
||||||
|
|
||||||
|
if (move.getMove().hasAttr("MoveHeaderAttr")) {
|
||||||
|
globalScene.phaseManager.unshiftNew("MoveHeaderPhase", pokemon, move);
|
||||||
|
}
|
||||||
|
|
||||||
|
globalScene.phaseManager.pushNew(
|
||||||
|
"MovePhase",
|
||||||
|
pokemon,
|
||||||
|
turnCommand.targets ?? queuedMove.targets,
|
||||||
|
move,
|
||||||
|
queuedMove.useMode,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2142,7 +2142,12 @@ class PartyCancelButton extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
this.partyCancelPb = partyCancelPb;
|
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);
|
this.add(partyCancelText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user