New Folder Structure test

This commit is contained in:
Philipp
2024-10-06 10:09:10 +02:00
commit d74f083c52
115 changed files with 9187 additions and 0 deletions

77
Mizzajl/home/myLibrary.js Normal file
View File

@@ -0,0 +1,77 @@
// Custom color coding.
const cCyan = "\u001b[36m";
const cGreen = "\u001b[32m";
const cRed = "\u001b[31m";
const cReset = "\u001b[0m";
/** @param {NS} ns */
export async function main(ns) {
ns.print("This script does nothing on its own, it contains functions for other scripts to use");
}
/** @param {NS} ns */
export async function purchaseServers(ns) {
const ram = 64;
let aServers = listPurchasedServers(ns);
let nServers = aServers.length;
if (nServers >= ns.getPurchasedServerLimit()) {
return nServers;
}
if (ns.getServerMoneyAvailable("home") > ns.getPurchasedServerCost(ram)) {
let sFrontZero = "0";
if (nServers >= 9) {
sFrontZero = "";
}
let hostname = ns.purchaseServer("pserv-" + sFrontZero + (aServers.length + 1), ram);
ns.tprint("Purchased " + cCyan + hostname + cReset);
ns.toast("Purchased " + hostname, "info", 10000);
}
aServers = listPurchasedServers(ns);
return aServers.length;
}
/** @param {NS} ns */
export function listPurchasedServers(ns) {
return ns.getPurchasedServers();
}
/** @param {NS} ns */
export function getSetting(ns, sSetting) {
let oSettings = JSON.parse(ns.read("settings.txt"));
let settingEntry = oSettings.setting[sSetting];
//ns.tprint(oSettings.setting[sSetting])
//ns.tprint("settingEntry = "+settingEntry);
return settingEntry;
}
/** @param {NS} ns */
export function getGrowThreads(ns, sTarget, nHackThreads, nCores) {
let nHackAmountPercent = ns.hackAnalyze(sTarget) * nHackThreads;
let nGrowthThreads = ns.growthAnalyze(sTarget, 1 + nHackAmountPercent, nCores);
return nGrowthThreads;
}