a collection of tools for fly for fun universe skillulator.lol

rewriting skill tree script because i deleted it woops

besaid.zone 460f8fd7 8fe166be

verified
Changed files
+87 -93
apps
flyff-exporter
+26 -26
apps/flyff-exporter/package.json
··· 1 1 { 2 - "name": "flyff-exporter", 3 - "version": "1.0.0", 4 - "description": "", 5 - "main": "index.js", 6 - "scripts": { 7 - "items": "bun run src/scripts/items.ts", 8 - "jobs": "bun run src/scripts/jobs.ts", 9 - "skills": "bun run src/scripts/skills.ts", 10 - "awake": "bun run src/scripts/skillawake.ts" 11 - }, 12 - "keywords": [], 13 - "author": "Dane Miller", 14 - "license": "ISC", 15 - "engines": { 16 - "node": ">=17" 17 - }, 18 - "dependencies": { 19 - "flyff.js": "^1.3.0", 20 - "lodash": "^4.17.21" 21 - }, 22 - "devDependencies": { 23 - "@types/bun": "^1.2.11", 24 - "@types/lodash": "^4.14.191", 25 - "@types/node": "^18.11.18", 26 - "typescript": "^4.9.4" 27 - } 2 + "name": "flyff-exporter", 3 + "version": "1.0.0", 4 + "description": "", 5 + "main": "index.js", 6 + "scripts": { 7 + "items": "bun run src/scripts/items.ts", 8 + "jobs": "bun run src/scripts/jobs.ts", 9 + "skills": "bun run src/scripts/skills.ts", 10 + "tree": "bun run src/scripts/skill-tree.ts" 11 + }, 12 + "keywords": [], 13 + "author": "Dane Miller", 14 + "license": "ISC", 15 + "engines": { 16 + "node": ">=17" 17 + }, 18 + "dependencies": { 19 + "flyff.js": "^1.3.0", 20 + "lodash": "^4.17.21" 21 + }, 22 + "devDependencies": { 23 + "@types/bun": "^1.2.11", 24 + "@types/lodash": "^4.14.191", 25 + "@types/node": "^18.11.18", 26 + "typescript": "^4.9.4" 27 + } 28 28 }
-46
apps/flyff-exporter/src/scripts/items.ts
··· 1 - import * as _ from "lodash"; 2 - import { writeFile, readFile } from "node:fs/promises"; 3 - import { fetchIds } from "../utils/fetchIds"; 4 - 5 - async function main() { 6 - try { 7 - const itemIds = await fetchIds("item"); 8 - const classes: any[] = JSON.parse( 9 - await readFile("./src/data/jobs.json", { 10 - encoding: "utf-8", 11 - }) 12 - ); 13 - 14 - // put item ids into chunks to get around large request error 15 - const chunkedItemIds = chunkArray(itemIds, 399); 16 - 17 - const itemPromises = chunkedItemIds.map(async (item) => { 18 - return await ( 19 - await fetch(`https://api.flyff.com/item/${item.join(",")}`) 20 - ).json(); 21 - }); 22 - 23 - const items = await Promise.all(itemPromises); 24 - 25 - const itemsWithClassNames = items 26 - .flatMap((item) => item) 27 - .filter((item) => item.category === "weapon" || item.category === "armor") 28 - .map((item) => ({ 29 - ...item, 30 - job: classes.find((className) => className.id === item.class), 31 - })); 32 - 33 - await writeFile( 34 - "./src/data/items.json", 35 - JSON.stringify(itemsWithClassNames) 36 - ); 37 - } catch (error) { 38 - console.error(error); 39 - } 40 - } 41 - 42 - function chunkArray(array: unknown[], sizePerChunk: number) { 43 - return _.chunk(array, sizePerChunk); 44 - } 45 - 46 - main();
+40
apps/flyff-exporter/src/scripts/skill-tree.ts
··· 1 + import { FlyffClient } from "flyff.js"; 2 + 3 + const client = new FlyffClient(); 4 + 5 + async function main() { 6 + const [jobIds, skillIds] = await Promise.all([ 7 + client.job.getAllIds(), 8 + client.skill.getAllIds(), 9 + ]); 10 + const [jobs, skills] = await Promise.all([ 11 + client.job.getByListOfIds(jobIds), 12 + client.skill.getByListOfIds(skillIds), 13 + ]); 14 + 15 + const refinedJobs = jobs.map((job) => ({ 16 + id: job.id, 17 + name: job.name, 18 + parent: job.parent, 19 + icon: job.icon, 20 + })); 21 + 22 + const skillsWithJobId = skills.map((skill) => ({ 23 + id: skill.id, 24 + name: skill.name, 25 + icon: skill.icon, 26 + level: skill.level, 27 + points: skill.skillPoints, 28 + requirements: skill.requirements, 29 + job: refinedJobs.find((className) => skill.class === className.id), 30 + })); 31 + 32 + const tree = refinedJobs.map((job) => ({ 33 + ...job, 34 + skills: skillsWithJobId, 35 + })); 36 + 37 + console.dir(tree[0], { depth: Number.POSITIVE_INFINITY }); 38 + } 39 + 40 + main().catch((error) => console.error(error));
+21 -21
apps/flyff-exporter/src/scripts/skills.ts
··· 3 3 const client = new FlyffClient(); 4 4 5 5 async function main() { 6 - try { 7 - const skillIds = await client.skill.getAllIds(); 8 - const skills = await client.skill.getByListOfIds(skillIds); 6 + try { 7 + const skillIds = await client.skill.getAllIds(); 8 + const skills = await client.skill.getByListOfIds(skillIds); 9 9 10 - const classes: JobObject[] = await Bun.file("./src/data/jobs.json", { 11 - type: "application/json", 12 - }).json(); 10 + const classes: JobObject[] = await Bun.file("./src/data/jobs.json", { 11 + type: "application/json", 12 + }).json(); 13 13 14 - const cleanedSkillDataResponse = skills.map((skill) => ({ 15 - id: skill.id, 16 - name: skill.name, 17 - description: skill.description, 18 - icon: skill.icon, 19 - level: skill.level, 20 - job: classes.find((className) => skill.class === className.id), 21 - })); 14 + const cleanedSkillDataResponse = skills.map((skill) => ({ 15 + id: skill.id, 16 + name: skill.name, 17 + description: skill.description, 18 + icon: skill.icon, 19 + level: skill.level, 20 + job: classes.find((className) => skill.class === className.id), 21 + })); 22 22 23 - await Bun.write( 24 - "./src/data/skills.json", 25 - JSON.stringify(cleanedSkillDataResponse), 26 - ); 27 - } catch (error) { 28 - console.error(error); 29 - } 23 + await Bun.write( 24 + "./src/data/skills.json", 25 + JSON.stringify(cleanedSkillDataResponse, null, 2), 26 + ); 27 + } catch (error) { 28 + console.error(error); 29 + } 30 30 } 31 31 32 32 main();