CrimeMonitor!

This commit is contained in:
2024-10-18 13:35:58 +02:00
parent aac2a5e884
commit 4c320ab609
7 changed files with 171 additions and 2 deletions

View File

@@ -0,0 +1,37 @@
/** @param {NS} ns */
export async function main(ns) {
ns.tail();
const sCrimeStatsFile = "CrimeStats.txt";
let aCrimes = [
"Shoplift",
"Rob Store",
"Mug",
"Larceny",
"Deal Drugs",
"Bond Forgery",
"Traffick Arms",
"Homicide",
"Grand Theft Auto",
"Kidnap",
"Assassination",
"Heist"
];
let aCrimeStatsList = [];
for (let i = 0; i < aCrimes.length; i++) {
let oCrimeStats = ns.singularity.getCrimeStats(aCrimes[i]);
// Create a new object starting with the name of the crime
let oCrimeWithStats = {
name: aCrimes[i], // Name of the crime as the first item
...oCrimeStats // Spread the rest of the stats into the object
};
aCrimeStatsList.push(oCrimeWithStats);
}
// Write the list of crime stats to the file as a JSON string
ns.write(sCrimeStatsFile, JSON.stringify(aCrimeStatsList, null, 2), "w");
}