mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-07 11:46:09 -05:00
Map Planner (#1145)
* Initial * Add images * Tweaks * Proper sized bg image and weapons * Stage bg picker * Outlined weapon images for planner * First version * Lint * Add alt and title to weapon
This commit is contained in:
42
scripts/replace-weapon-names.ts
Normal file
42
scripts/replace-weapon-names.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import invariant from "tiny-invariant";
|
||||
|
||||
const DIR_PATH = path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"public",
|
||||
"img",
|
||||
"main-weapons-outlined"
|
||||
);
|
||||
const WEAPON_JSON_PATH = path.join(__dirname, "output", "weapons.json");
|
||||
|
||||
async function main() {
|
||||
const weapons = JSON.parse(fs.readFileSync(WEAPON_JSON_PATH, "utf8"));
|
||||
const files = await fs.promises.readdir(DIR_PATH);
|
||||
|
||||
for (const file of files) {
|
||||
// did we already replace the name
|
||||
if (file.includes(".webp") || file.includes("Lv01")) {
|
||||
// delete file
|
||||
await fs.promises.unlink(path.join(DIR_PATH, file));
|
||||
}
|
||||
|
||||
const weapon: any = weapons.find((weapon: any) =>
|
||||
file.includes(weapon.internalName)
|
||||
);
|
||||
invariant(weapon, `Could not find weapon for ${file}`);
|
||||
|
||||
fs.renameSync(
|
||||
path.join(DIR_PATH, file),
|
||||
path.join(DIR_PATH, `${weapon.id}.png`)
|
||||
);
|
||||
}
|
||||
|
||||
console.log("done with all");
|
||||
}
|
||||
|
||||
void main();
|
||||
Reference in New Issue
Block a user