CrimeMonitor!
This commit is contained in:
86
Mizzajl/home/CrimeMonitor.js
Normal file
86
Mizzajl/home/CrimeMonitor.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import { GetCrimeStat } from "./Library";
|
||||
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.tail();
|
||||
ns.resizeTail(1876, 412);
|
||||
ns.disableLog("sleep");
|
||||
|
||||
let aCrimes = [
|
||||
"Shoplift",
|
||||
"Rob Store",
|
||||
"Mug",
|
||||
"Larceny",
|
||||
"Deal Drugs",
|
||||
"Bond Forgery",
|
||||
"Traffick Arms",
|
||||
"Homicide",
|
||||
"Grand Theft Auto",
|
||||
"Kidnap",
|
||||
"Assassination",
|
||||
"Heist"
|
||||
];
|
||||
|
||||
while (true) {
|
||||
// Clear the ns.tail() window for a fresh update
|
||||
ns.clearLog();
|
||||
|
||||
// Header with ASCII box
|
||||
ns.printRaw("╔══════════════════╦════════════╦═════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════╦════════════╗");
|
||||
ns.printRaw("║ Crime ║ Chance ║ $/%/s ║ Hack w/xp ║ Str w/xp ║ Def w/xp ║ Dex w/xp ║ Agi w/xp ║ Cha w/xp ║ Money/s ║ Karma/s ║");
|
||||
ns.printRaw("╠══════════════════╬════════════╬═════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════╬════════════╣");
|
||||
|
||||
// Loop through each crime and display stats
|
||||
for (let i = 0; i < aCrimes.length; i++) {
|
||||
let crime = aCrimes[i];
|
||||
let chance = ns.singularity.getCrimeChance(crime); // Get chance of success
|
||||
|
||||
// Experience per second for each attribute
|
||||
let hackingExpPerSecond = await GetCrimeStat(ns, crime, "hacking_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let strengthExpPerSecond = await GetCrimeStat(ns, crime, "strength_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let defenseExpPerSecond = await GetCrimeStat(ns, crime, "defense_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let dexterityExpPerSecond = await GetCrimeStat(ns, crime, "dexterity_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let agilityExpPerSecond = await GetCrimeStat(ns, crime, "agility_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let charismaExpPerSecond = await GetCrimeStat(ns, crime, "charisma_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Success weights for each attribute
|
||||
let hackingSuccessWeight = await GetCrimeStat(ns, crime, "hacking_success_weight");
|
||||
let strengthSuccessWeight = await GetCrimeStat(ns, crime, "strength_success_weight");
|
||||
let defenseSuccessWeight = await GetCrimeStat(ns, crime, "defense_success_weight");
|
||||
let dexteritySuccessWeight = await GetCrimeStat(ns, crime, "dexterity_success_weight");
|
||||
let agilitySuccessWeight = await GetCrimeStat(ns, crime, "agility_success_weight");
|
||||
let charismaSuccessWeight = await GetCrimeStat(ns, crime, "charisma_success_weight");
|
||||
|
||||
// Money and Karma per second
|
||||
let moneyPerSecond = await GetCrimeStat(ns, crime, "money") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let karmaPerSecond = await GetCrimeStat(ns, crime, "karma") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Money per chance per second
|
||||
let nMoneyPerChancePerSecond = await GetCrimeStat(ns, crime, "money") * chance / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Format output with padding and rounding for success weight / exp per second
|
||||
let crimeDisplay = crime.padEnd(17, " ");
|
||||
let chanceDisplay = (chance * 100).toFixed(2).padEnd(11, " ");
|
||||
|
||||
let nMoneyPerChancePerSecondDisplay = nMoneyPerChancePerSecond.toFixed(0).padEnd(8, " ");
|
||||
|
||||
let hackingDisplay = `${hackingSuccessWeight.toFixed(2)} / ${hackingExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let strengthDisplay = `${strengthSuccessWeight.toFixed(2)} / ${strengthExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let defenseDisplay = `${defenseSuccessWeight.toFixed(2)} / ${defenseExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let dexterityDisplay = `${dexteritySuccessWeight.toFixed(2)} / ${dexterityExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let agilityDisplay = `${agilitySuccessWeight.toFixed(2)} / ${agilityExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let charismaDisplay = `${charismaSuccessWeight.toFixed(2)} / ${charismaExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
|
||||
let moneyDisplay = moneyPerSecond.toFixed(2).padEnd(11, " ");
|
||||
let karmaDisplay = karmaPerSecond.toFixed(4).padEnd(11, " ");
|
||||
|
||||
ns.printRaw(`║ ${crimeDisplay}║ ${chanceDisplay}║ ${nMoneyPerChancePerSecondDisplay}║ ${hackingDisplay}║ ${strengthDisplay}║ ${defenseDisplay}║ ${dexterityDisplay}║ ${agilityDisplay}║ ${charismaDisplay}║ ${moneyDisplay}║ ${karmaDisplay}║`);
|
||||
}
|
||||
|
||||
// Footer with ASCII box
|
||||
ns.printRaw("╚══════════════════╩════════════╩═════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════╩════════════╝");
|
||||
|
||||
// Wait for 1 second before updating the display again
|
||||
await ns.sleep(1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user