import * as fs from "node:fs";
import Logging from "log-like-a-zombie";
let log = new Logging('ConsumableConversion');
log.i(`RR Config Conversion Tool by @zombieb`);
class FinalConsumableItem {
constructor() {
this.Count = 99;
this.CreatedAt = new Date().toISOString();
this.Id = Math.floor(Math.random() * (999999999 - 100000000 + 1)) + 100000000;
this.UnlockedLevel = 0;
this.InitialCount = 0;
this.IsActive = false;
this.Category = 4;
this.ActiveDurationMinutes = 99;
this.PlatformMask = -1;
}
}
// Read only db
const db = JSON.parse(fs.readFileSync('./raw.json'));
log.d(`Imported raw config`);
let final = [];
const coerce = (val, i, arr) => {
let d = new FinalConsumableItem();
d.ConsumableItemDesc = val.consumableName;
final.push(d);
}
db.consumablePrefabData.forEach(coerce);
fs.writeFileSync('./rawNew.json', Buffer.from(JSON.stringify(final)), {encoding:'utf8',flag:'w'});