Added growthAnalyze() NS function. Fixed GH issue #492. In Gang mechanic, added new hacking augs/upgrades. Also rebalanced defense upgrades. Added new 'compact' main menu configuration

This commit is contained in:
danielyxie
2018-11-19 21:54:03 -08:00
parent 1a47e81001
commit 66d50a7ae4
13 changed files with 222 additions and 52 deletions
+29 -2
View File
@@ -33,7 +33,7 @@ import {Script, findRunningScript, RunningScript,
isScriptFilename} from "./Script";
import {Server, getServer, AddToAllServers,
AllServers, processSingleServerGrowth,
GetServerByHostname} from "./Server";
GetServerByHostname, numCycleForGrowth} from "./Server";
import {Settings} from "./Settings";
import {SpecialServerIps} from "./SpecialServerIps";
import {Stock} from "./Stock";
@@ -463,7 +463,21 @@ function NetscriptFunctions(workerScript) {
return Promise.resolve(moneyAfter/moneyBefore);
});
},
weaken : function(ip){
growthAnalyze : function(ip, growth) {
if (workerScript.checkingRam) {
return updateStaticRam("growthAnalyze", CONSTANTS.ScriptGrowthAnalyzeRamCost);
}
updateDynamicRam("growthAnalyze", CONSTANTS.ScriptGrowthAnalyzeRamCost);
// Check argument validity
const server = safeGetServer(ip, 'growthAnalyze');
if (isNaN(growth)) {
throw makeRuntimeRejectMsg(workerScript, `Invalid growth argument passed into growthAnalyze: ${growth}. Must be numeric`);
}
return numCycleForGrowth(server, Number(growth));
},
weaken : function(ip) {
if (workerScript.checkingRam) {
return updateStaticRam("weaken", CONSTANTS.ScriptWeakenRamCost);
}
@@ -3869,6 +3883,19 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getEquipmentCost", e));
}
},
getEquipmentType : function(equipName) {
if (workerScript.checkingRam) {
return updateStaticRam("getEquipmentType", CONSTANTS.ScriptGangApiBaseRamCost / 2);
}
updateDynamicRam("getEquipmentType", CONSTANTS.ScriptGangApiBaseRamCost / 2);
nsGang.checkGangApiAccess(workerScript, "getEquipmentType");
try {
return Player.gang.getUpgradeType(equipName);
} catch(e) {
throw makeRuntimeRejectMsg(workerScript, nsGang.unknownGangApiExceptionMessage("getEquipmentType", e));
}
},
purchaseEquipment : function(memberName, equipName) {
if (workerScript.checkingRam) {
return updateStaticRam("purchaseEquipment", CONSTANTS.ScriptGangApiBaseRamCost);