fixed cloud.upgradeAll server upgrade check
This commit is contained in:
parent
e77aed0065
commit
21e9d13e61
|
|
@ -21,6 +21,8 @@ export const upgradeAll = (ns: NS) => {
|
||||||
const ram = Math.pow(2, pow);
|
const ram = Math.pow(2, pow);
|
||||||
let totalCost = 0;
|
let totalCost = 0;
|
||||||
for (const serverName of cloudServerNames) {
|
for (const serverName of cloudServerNames) {
|
||||||
|
const currentRam = ns.getServerMaxRam(serverName);
|
||||||
|
if (currentRam >= ram) continue; // already at or above this tier, no cost
|
||||||
const upgradeCost = ns.cloud.getServerUpgradeCost(serverName, ram);
|
const upgradeCost = ns.cloud.getServerUpgradeCost(serverName, ram);
|
||||||
if (upgradeCost === -1) {
|
if (upgradeCost === -1) {
|
||||||
totalCost = Infinity;
|
totalCost = Infinity;
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ export const startall = (ns: NS, scriptName: string, options: StartOptions = {})
|
||||||
ns.tprint(`Hosts affected: ${hostsStartedOn}`);
|
ns.tprint(`Hosts affected: ${hostsStartedOn}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const main = (ns: NS) => {
|
export const main = (ns: NS) => {
|
||||||
// // get the arguments from the command line
|
// get the arguments from the command line
|
||||||
// const args = ns.args as string[];
|
const args = ns.args as string[];
|
||||||
// startall(ns, "super.js", { args: args });
|
startall(ns, "super.js", { args: args });
|
||||||
// };
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,5 +2,7 @@ import { NS } from "@ns";
|
||||||
import { cloud } from "./ezgame/cloud";
|
import { cloud } from "./ezgame/cloud";
|
||||||
|
|
||||||
export const main = (ns: NS) => {
|
export const main = (ns: NS) => {
|
||||||
|
const upgradeCost = ns.cloud.getServerUpgradeCost("worker-1", 2);
|
||||||
|
console.log(upgradeCost);
|
||||||
cloud.upgradeAll(ns);
|
cloud.upgradeAll(ns);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue