mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-19 22:09:27 +02:00
Compare commits
6 Commits
7948288d7b
...
d818da8d72
Author | SHA1 | Date | |
---|---|---|---|
|
d818da8d72 | ||
|
da7903ab92 | ||
|
70e7f8b4d4 | ||
|
4939a9f6f4 | ||
|
fb8562d47c | ||
|
85002ac8be |
@ -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 commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
||||||
const commonAnimNames = getEnumKeys(CommonAnim);
|
for (const commonAnimName of getEnumKeys(CommonAnim)) {
|
||||||
const commonAnimIds = getEnumValues(CommonAnim);
|
const commonAnimId = CommonAnim[commonAnimName];
|
||||||
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
commonAnimFetches.push(
|
||||||
for (let ca = 0; ca < commonAnimIds.length; ca++) {
|
globalScene
|
||||||
const commonAnimId = commonAnimIds[ca];
|
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimName)}.json`)
|
||||||
commonAnimFetches.push(
|
.then(response => response.json())
|
||||||
globalScene
|
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
||||||
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimNames[ca])}.json`)
|
);
|
||||||
.then(response => response.json())
|
}
|
||||||
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
await Promise.allSettled(commonAnimFetches);
|
||||||
);
|
|
||||||
}
|
|
||||||
Promise.allSettled(commonAnimFetches).then(() => resolve());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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: ' ' }));
|
|
||||||
})();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
@ -8483,8 +8483,6 @@ const MoveAttrs = Object.freeze({
|
|||||||
/** Map of of move attribute names to their constructors */
|
/** Map of of move attribute names to their constructors */
|
||||||
export type MoveAttrConstructorMap = typeof MoveAttrs;
|
export type MoveAttrConstructorMap = typeof MoveAttrs;
|
||||||
|
|
||||||
export const selfStatLowerMoves: MoveId[] = [];
|
|
||||||
|
|
||||||
export function initMoves() {
|
export function initMoves() {
|
||||||
allMoves.push(
|
allMoves.push(
|
||||||
new SelfStatusMove(MoveId.NONE, PokemonType.NORMAL, MoveCategory.STATUS, -1, -1, 0, 1),
|
new SelfStatusMove(MoveId.NONE, PokemonType.NORMAL, MoveCategory.STATUS, -1, -1, 0, 1),
|
||||||
@ -11540,9 +11538,4 @@ export function initMoves() {
|
|||||||
new AttackMove(MoveId.MALIGNANT_CHAIN, PokemonType.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
|
new AttackMove(MoveId.MALIGNANT_CHAIN, PokemonType.POISON, MoveCategory.SPECIAL, 100, 100, 5, 50, 0, 9)
|
||||||
.attr(StatusEffectAttr, StatusEffect.TOXIC)
|
.attr(StatusEffectAttr, StatusEffect.TOXIC)
|
||||||
);
|
);
|
||||||
allMoves.map(m => {
|
|
||||||
if (m.getAttrs("StatStageChangeAttr").some(a => a.selfTarget && a.stages < 0)) {
|
|
||||||
selfStatLowerMoves.push(m.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -1,165 +0,0 @@
|
|||||||
import { TrainerType } from "#enums/trainer-type";
|
|
||||||
import { toPascalSnakeCase } from "#utils/strings";
|
|
||||||
|
|
||||||
class TrainerNameConfig {
|
|
||||||
public urls: string[];
|
|
||||||
public femaleUrls: string[] | null;
|
|
||||||
|
|
||||||
constructor(type: TrainerType, ...urls: string[]) {
|
|
||||||
this.urls = urls.length ? urls : [toPascalSnakeCase(TrainerType[type])];
|
|
||||||
}
|
|
||||||
|
|
||||||
hasGenderVariant(...femaleUrls: string[]): TrainerNameConfig {
|
|
||||||
this.femaleUrls = femaleUrls.length ? femaleUrls : null;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TrainerNameConfigs {
|
|
||||||
[key: number]: TrainerNameConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
// used in a commented code
|
|
||||||
// biome-ignore lint/correctness/noUnusedVariables: Used by commented code
|
|
||||||
const trainerNameConfigs: TrainerNameConfigs = {
|
|
||||||
[TrainerType.ACE_TRAINER]: new TrainerNameConfig(TrainerType.ACE_TRAINER),
|
|
||||||
[TrainerType.ARTIST]: new TrainerNameConfig(TrainerType.ARTIST),
|
|
||||||
[TrainerType.BACKERS]: new TrainerNameConfig(TrainerType.BACKERS),
|
|
||||||
[TrainerType.BACKPACKER]: new TrainerNameConfig(TrainerType.BACKPACKER),
|
|
||||||
[TrainerType.BAKER]: new TrainerNameConfig(TrainerType.BAKER),
|
|
||||||
[TrainerType.BEAUTY]: new TrainerNameConfig(TrainerType.BEAUTY),
|
|
||||||
[TrainerType.BIKER]: new TrainerNameConfig(TrainerType.BIKER),
|
|
||||||
[TrainerType.BLACK_BELT]: new TrainerNameConfig(TrainerType.BLACK_BELT).hasGenderVariant("Battle_Girl"),
|
|
||||||
[TrainerType.BREEDER]: new TrainerNameConfig(TrainerType.BREEDER, "Pokémon_Breeder"),
|
|
||||||
[TrainerType.CLERK]: new TrainerNameConfig(TrainerType.CLERK),
|
|
||||||
[TrainerType.CYCLIST]: new TrainerNameConfig(TrainerType.CYCLIST),
|
|
||||||
[TrainerType.DANCER]: new TrainerNameConfig(TrainerType.DANCER),
|
|
||||||
[TrainerType.DEPOT_AGENT]: new TrainerNameConfig(TrainerType.DEPOT_AGENT),
|
|
||||||
[TrainerType.DOCTOR]: new TrainerNameConfig(TrainerType.DOCTOR).hasGenderVariant("Nurse"),
|
|
||||||
[TrainerType.FIREBREATHER]: new TrainerNameConfig(TrainerType.FIREBREATHER),
|
|
||||||
[TrainerType.FISHERMAN]: new TrainerNameConfig(TrainerType.FISHERMAN),
|
|
||||||
[TrainerType.GUITARIST]: new TrainerNameConfig(TrainerType.GUITARIST),
|
|
||||||
[TrainerType.HARLEQUIN]: new TrainerNameConfig(TrainerType.HARLEQUIN),
|
|
||||||
[TrainerType.HIKER]: new TrainerNameConfig(TrainerType.HIKER),
|
|
||||||
[TrainerType.HOOLIGANS]: new TrainerNameConfig(TrainerType.HOOLIGANS),
|
|
||||||
[TrainerType.HOOPSTER]: new TrainerNameConfig(TrainerType.HOOPSTER),
|
|
||||||
[TrainerType.INFIELDER]: new TrainerNameConfig(TrainerType.INFIELDER),
|
|
||||||
[TrainerType.JANITOR]: new TrainerNameConfig(TrainerType.JANITOR),
|
|
||||||
[TrainerType.LINEBACKER]: new TrainerNameConfig(TrainerType.LINEBACKER),
|
|
||||||
[TrainerType.MAID]: new TrainerNameConfig(TrainerType.MAID),
|
|
||||||
[TrainerType.MUSICIAN]: new TrainerNameConfig(TrainerType.MUSICIAN),
|
|
||||||
[TrainerType.HEX_MANIAC]: new TrainerNameConfig(TrainerType.HEX_MANIAC),
|
|
||||||
[TrainerType.NURSERY_AIDE]: new TrainerNameConfig(TrainerType.NURSERY_AIDE),
|
|
||||||
[TrainerType.OFFICER]: new TrainerNameConfig(TrainerType.OFFICER),
|
|
||||||
[TrainerType.PARASOL_LADY]: new TrainerNameConfig(TrainerType.PARASOL_LADY),
|
|
||||||
[TrainerType.PILOT]: new TrainerNameConfig(TrainerType.PILOT),
|
|
||||||
[TrainerType.POKEFAN]: new TrainerNameConfig(TrainerType.POKEFAN, "Poké_Fan"),
|
|
||||||
[TrainerType.PRESCHOOLER]: new TrainerNameConfig(TrainerType.PRESCHOOLER),
|
|
||||||
[TrainerType.PSYCHIC]: new TrainerNameConfig(TrainerType.PSYCHIC),
|
|
||||||
[TrainerType.RANGER]: new TrainerNameConfig(TrainerType.RANGER),
|
|
||||||
[TrainerType.RICH]: new TrainerNameConfig(TrainerType.RICH, "Gentleman").hasGenderVariant("Madame"),
|
|
||||||
[TrainerType.RICH_KID]: new TrainerNameConfig(TrainerType.RICH_KID, "Rich_Boy").hasGenderVariant("Lady"),
|
|
||||||
[TrainerType.ROUGHNECK]: new TrainerNameConfig(TrainerType.ROUGHNECK),
|
|
||||||
[TrainerType.SAILOR]: new TrainerNameConfig(TrainerType.SAILOR),
|
|
||||||
[TrainerType.SCIENTIST]: new TrainerNameConfig(TrainerType.SCIENTIST),
|
|
||||||
[TrainerType.SMASHER]: new TrainerNameConfig(TrainerType.SMASHER),
|
|
||||||
[TrainerType.SNOW_WORKER]: new TrainerNameConfig(TrainerType.SNOW_WORKER, "Worker"),
|
|
||||||
[TrainerType.STRIKER]: new TrainerNameConfig(TrainerType.STRIKER),
|
|
||||||
[TrainerType.SCHOOL_KID]: new TrainerNameConfig(TrainerType.SCHOOL_KID, "School_Kid"),
|
|
||||||
[TrainerType.SWIMMER]: new TrainerNameConfig(TrainerType.SWIMMER),
|
|
||||||
[TrainerType.TWINS]: new TrainerNameConfig(TrainerType.TWINS),
|
|
||||||
[TrainerType.VETERAN]: new TrainerNameConfig(TrainerType.VETERAN),
|
|
||||||
[TrainerType.WAITER]: new TrainerNameConfig(TrainerType.WAITER).hasGenderVariant("Waitress"),
|
|
||||||
[TrainerType.WORKER]: new TrainerNameConfig(TrainerType.WORKER),
|
|
||||||
[TrainerType.YOUNGSTER]: new TrainerNameConfig(TrainerType.YOUNGSTER).hasGenderVariant("Lass"),
|
|
||||||
};
|
|
||||||
|
|
||||||
// function used in a commented code
|
|
||||||
// biome-ignore lint/correctness/noUnusedVariables: TODO make this into a script instead of having it be in src/data...
|
|
||||||
function fetchAndPopulateTrainerNames(
|
|
||||||
url: string,
|
|
||||||
parser: DOMParser,
|
|
||||||
trainerNames: Set<string>,
|
|
||||||
femaleTrainerNames: Set<string>,
|
|
||||||
forceFemale = false,
|
|
||||||
) {
|
|
||||||
return new Promise<void>(resolve => {
|
|
||||||
fetch(`https://bulbapedia.bulbagarden.net/wiki/${url}_(Trainer_class)`)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(html => {
|
|
||||||
console.log(url);
|
|
||||||
const htmlDoc = parser.parseFromString(html, "text/html");
|
|
||||||
const trainerListHeader = htmlDoc.querySelector("#Trainer_list")?.parentElement;
|
|
||||||
if (!trainerListHeader) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const elements = [...(trainerListHeader?.parentElement?.childNodes ?? [])];
|
|
||||||
const startChildIndex = elements.indexOf(trainerListHeader);
|
|
||||||
const endChildIndex = elements.findIndex(h => h.nodeName === "H2" && elements.indexOf(h) > startChildIndex);
|
|
||||||
const tables = elements
|
|
||||||
.filter(t => {
|
|
||||||
if (t.nodeName !== "TABLE" || t["className"] !== "expandable") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const childIndex = elements.indexOf(t);
|
|
||||||
return childIndex > startChildIndex && childIndex < endChildIndex;
|
|
||||||
})
|
|
||||||
.map(t => t as Element);
|
|
||||||
console.log(url, tables);
|
|
||||||
for (const table of tables) {
|
|
||||||
const trainerRows = [...table.querySelectorAll("tr:not(:first-child)")].filter(r => r.children.length === 9);
|
|
||||||
for (const row of trainerRows) {
|
|
||||||
const nameCell = row.firstElementChild;
|
|
||||||
if (!nameCell) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const content = nameCell.innerHTML;
|
|
||||||
if (content.indexOf(" <a ") > -1) {
|
|
||||||
const female = /♀/.test(content);
|
|
||||||
if (url === "Twins") {
|
|
||||||
console.log(content);
|
|
||||||
}
|
|
||||||
const nameMatch = />([a-z]+(?: & [a-z]+)?)<\/a>/i.exec(content);
|
|
||||||
if (nameMatch) {
|
|
||||||
(female || forceFemale ? femaleTrainerNames : trainerNames).add(nameMatch[1].replace("&", "&"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/*export function scrapeTrainerNames() {
|
|
||||||
const parser = new DOMParser();
|
|
||||||
const trainerTypeNames = {};
|
|
||||||
const populateTrainerNamePromises: Promise<void>[] = [];
|
|
||||||
for (let t of Object.keys(trainerNameConfigs)) {
|
|
||||||
populateTrainerNamePromises.push(new Promise<void>(resolve => {
|
|
||||||
const trainerType = t;
|
|
||||||
trainerTypeNames[trainerType] = [];
|
|
||||||
|
|
||||||
const config = trainerNameConfigs[t] as TrainerNameConfig;
|
|
||||||
const trainerNames = new Set<string>();
|
|
||||||
const femaleTrainerNames = new Set<string>();
|
|
||||||
console.log(config.urls, config.femaleUrls)
|
|
||||||
const trainerClassRequests = config.urls.map(u => fetchAndPopulateTrainerNames(u, parser, trainerNames, femaleTrainerNames));
|
|
||||||
if (config.femaleUrls)
|
|
||||||
trainerClassRequests.push(...config.femaleUrls.map(u => fetchAndPopulateTrainerNames(u, parser, null, femaleTrainerNames, true)));
|
|
||||||
Promise.all(trainerClassRequests).then(() => {
|
|
||||||
console.log(trainerNames, femaleTrainerNames)
|
|
||||||
trainerTypeNames[trainerType] = !femaleTrainerNames.size ? Array.from(trainerNames) : [ Array.from(trainerNames), Array.from(femaleTrainerNames) ];
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
Promise.all(populateTrainerNamePromises).then(() => {
|
|
||||||
let output = 'export const trainerNamePools = {';
|
|
||||||
Object.keys(trainerTypeNames).forEach(t => {
|
|
||||||
output += `\n\t[TrainerType.${TrainerType[t]}]: ${JSON.stringify(trainerTypeNames[t])},`;
|
|
||||||
});
|
|
||||||
output += `\n};`;
|
|
||||||
console.log(output);
|
|
||||||
});
|
|
||||||
}*/
|
|
@ -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