feat: Cards writings and balancing (M8)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Edits balance.json from the command line and keeps its compact layout.
|
||||
// node tools/bal-edit.mjs path=value [path=value ...] e.g. gain=2.8 debt.premiumCoef=0.0008
|
||||
import fs from "node:fs";
|
||||
import { format } from "./cardfmt.mjs";
|
||||
|
||||
const p = new URL("../web/data/balance.json", import.meta.url);
|
||||
const j = JSON.parse(fs.readFileSync(p, "utf8"));
|
||||
for (const a of process.argv.slice(2)) {
|
||||
const [path, val] = a.split("=");
|
||||
const keys = path.split(".");
|
||||
let o = j;
|
||||
for (const k of keys.slice(0, -1)) o = o[k] ??= {};
|
||||
o[keys.at(-1)] = JSON.parse(val);
|
||||
}
|
||||
fs.writeFileSync(p, `${format(j)}\n`);
|
||||
Reference in New Issue
Block a user