Merge branch 'dev' into eslint

This commit is contained in:
Steven Evans 2018-06-24 21:58:02 -04:00
commit 877432f3ac
8 changed files with 1141 additions and 951 deletions

1463
dist/engine.bundle.js vendored

File diff suppressed because it is too large Load Diff

@ -115,7 +115,29 @@ function initBitNodes() {
"Level 1: 8%<br>" +
"Level 2: 12%<br>" +
"Level 3: 14%");
BitNodes["BitNode7"] = new BitNode(7, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic
BitNodes["BitNode7"] = new BitNode(7, "Bladeburners 2079", "More human than humans",
"In the middle of the 21st century, you were doing cutting-edge work at OmniTek Incorporated as part of the AI design team " +
"for advanced synthetic androids, or Synthoids for short. You helped achieve a major technological " +
"breakthrough in the sixth generation of the company's Synthoid design, called MK-VI, by developing a hyperintelligent AI. " +
"Many argue that this was the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, " +
"and more intelligent than the humans that had created them.<br><br>" +
"In this BitNode you will be able to access the Bladeburner API, which allows you to access Bladeburner " +
"functionality through Netscript. Furthermore: <br><br>" +
"The rank you gain from Bladeburner contracts/operations is reduced by 50%<br>" +
"Bladeburner skills cost twice as many skill points<br>" +
"Augmentations are 3x more expensive<br>" +
"Hacking and Hacknet Nodes will be significantly less profitable<br>" +
"Your hacking level is reduced by 50%<br>" +
"Hacking experience gain from scripts is reduced by 75%<br>" +
"Corporations have 80% lower valuations and are therefore less profitable<br>" +
"Working for companies is 50% less profitable<br>" +
"Crimes and Infiltration are 50% less profitable<br><br>" +
"Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " +
"its level up to a maximum of 3. This Source-File allows you to access the Bladeburner Netscript API in other " +
"BitNodes. In addition, this Source-File will increase all of your Bladeburner multipliers by:<br><br>" +
"Level 1: 8%<br>" +
"Level 2: 12%<br>" +
"Level 3: 14%");
BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps",
"You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.<br><br>" +
"In this BitNode:<br><br>" +
@ -208,6 +230,9 @@ let BitNodeMultipliers = {
InfiltrationRep: 1,
CorporationValuation: 1,
BladeburnerRank: 1,
BladeburnerSkillCost: 1,
}
function initBitNodeMultipliers() {
@ -284,6 +309,23 @@ function initBitNodeMultipliers() {
BitNodeMultipliers.FactionPassiveRepGain = 0;
BitNodeMultipliers.HackExpGain = 0.25;
break;
case 7: //Bladeburner 2079
BitNodeMultipliers.BladeburnerRank = 0.5;
BitNodeMultipliers.BladeburnerSkillCost = 2;
BitNodeMultipliers.AugmentationMoneyCost = 3;
BitNodeMultipliers.HackingLevelMultiplier = 0.5;
BitNodeMultipliers.ServerMaxMoney = 0.5;
BitNodeMultipliers.ServerStartingMoney = 0.5;
BitNodeMultipliers.ServerStartingSecurity = 1.5;
BitNodeMultipliers.ScriptHackMoney = 0.5;
BitNodeMultipliers.CompanyWorkMoney = 0.5;
BitNodeMultipliers.CrimeMoney = 0.5;
BitNodeMultipliers.InfiltrationMoney = 0.5;
BitNodeMultipliers.CorporationValuation = 0.2;
BitNodeMultipliers.HacknetNodeMoney = 0.2;
BitNodeMultipliers.FactionPassiveRepGain = 0;
BitNodeMultipliers.HackExpGain = 0.25;
break;
case 8: //Ghost of Wall Street
BitNodeMultipliers.ScriptHackMoney = 0;
BitNodeMultipliers.ManualHackMoney = 0;

@ -1,4 +1,5 @@
import {Augmentations, AugmentationNames} from "./Augmentations.js";
import {BitNodeMultipliers} from "./BitNode.js";
import {CONSTANTS} from "./Constants.js";
import {Engine} from "./engine.js";
import {Faction, Factions, factionExists,
@ -349,6 +350,10 @@ function Skill(params={name:"foo", desc:"foo"}) {
if (params.weaponAbility) {this.weaponAbility = params.weaponAbility;}
if (params.gunAbility) {this.gunAbility = params.gunAbility;}
}
Skill.prototype.calculateCost = function(currentLevel) {
return (this.baseCost + (currentLevel * this.costInc)) * BitNodeMultipliers.BladeburnerSkillCost;
}
var Skills = {};
var SkillNames = {
BladesIntuition: "Blade's Intuition",
@ -1168,7 +1173,7 @@ Bladeburner.prototype.completeAction = function() {
action.setMaxLevel(ContractSuccessesPerLevel);
}
if (action.rankGain) {
var gain = addOffset(action.rankGain * rewardMultiplier, 10);
var gain = addOffset(action.rankGain * rewardMultiplier * BitNodeMultipliers.BladeburnerRank, 10);
this.changeRank(gain);
if (isOperation && this.logging.ops) {
this.log(action.name + " successfully completed! Gained " + formatNumber(gain, 3) + " rank");
@ -1233,7 +1238,7 @@ Bladeburner.prototype.completeAction = function() {
this.blackops[action.name] = true;
var rankGain = 0;
if (action.rankGain) {
rankGain = addOffset(action.rankGain, 10);
rankGain = addOffset(action.rankGain * BitNodeMultipliers.BladeburnerRank, 10);
this.changeRank(rankGain);
}
teamLossMax = Math.ceil(teamCount/2);
@ -2671,7 +2676,7 @@ Bladeburner.prototype.updateSkillsUIElement = function(el, skill) {
if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
currentLevel = this.skills[skillName];
}
var pointCost = skill.baseCost + (currentLevel * skill.costInc);
var pointCost = skill.calculateCost(currentLevel);
el.appendChild(createElement("h2", { //Header
innerText:skill.name + " (Lvl " + currentLevel + ")", display:"inline-block"
@ -3110,7 +3115,7 @@ Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
currentLevel = this.skills[skillName];
}
var pointCost = skill.baseCost + (currentLevel * skill.costInc);
var pointCost = skill.calculateCost(currentLevel);
if (this.skillPoints >= pointCost) {
this.skillPoints -= pointCost;
this.upgradeSkill(skill);
@ -3263,24 +3268,25 @@ Bladeburner.prototype.getActionIdFromTypeAndName = function(type="", name="") {
}
}
Bladeburner.prototype.isContractNameNetscriptFn = function(name) {
return this.contracts.hasOwnProperty(name);
Bladeburner.prototype.getContractNamesNetscriptFn = function(name) {
return Object.keys(this.contracts);
}
Bladeburner.prototype.isOperationNameNetscriptFn = function(name) {
return this.operations.hasOwnProperty(name);
Bladeburner.prototype.getOperationNamesNetscriptFn = function(name) {
return Object.keys(this.operations);
}
Bladeburner.prototype.isBlackOpNameNetscriptFn = function(name) {
return BlackOperations.hasOwnProperty(name);
Bladeburner.prototype.getBlackOpNamesNetscriptFn = function(name) {
return Object.keys(BlackOperations);
}
Bladeburner.prototype.isGeneralActionNameNetscriptFn = function(name) {
return GeneralActions.hasOwnProperty(name);
Bladeburner.prototype.getGeneralActionNamesNetscriptFn = function(name) {
return Object.keys(GeneralActions);
}
Bladeburner.prototype.isSkillNameNetscriptFn = function(name) {
Bladeburner.prototype.getSkillNamesNetscriptFn = function(name) {
return Skills.hasOwnProperty(name);
return Object.keys(Skills);
}
Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) {
@ -3362,7 +3368,7 @@ Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type
case ActionTypes["Operation"]:
case ActionTypes["BlackOp"]:
case ActionTypes["BlackOperation"]:
return actionObj.getSuccessChance(this);
return actionObj.getSuccessChance(this, {est:true});
case ActionTypes["Training"]:
case ActionTypes["Field Analysis"]:
case ActionTypes["FieldAnalysis"]:
@ -3438,7 +3444,7 @@ Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript
if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
currentLevel = this.skills[skillName];
}
var cost = skill.baseCost + (currentLevel * skill.costInc);
var cost = skill.calculateCost(currentLevel);
if (this.skillPoints < cost) {
if (workerScript.shouldLog("upgradeSkill")) {

@ -148,8 +148,8 @@ function NetscriptFunctions(workerScript) {
workerScript.dynamicRamUsage += ramCost;
if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
throw makeRuntimeRejectMsg(workerScript,
"Dynamic RAM usage calculated to be greater than initial RAM usage. " +
"This is probably because you somehow circumvented the static RAM " +
"Dynamic RAM usage calculated to be greater than initial RAM usage on fn: " + fnName +
". This is probably because you somehow circumvented the static RAM " +
"calculation.<br><br>Please don't do that :(");
}
};
@ -3215,59 +3215,59 @@ function NetscriptFunctions(workerScript) {
//Bladeburner API
bladeburner : {
isContractName : function(name) {
getContractNames : function(name) {
if (workerScript.checkingRam) {
return updateStaticRam("isContractName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
return updateStaticRam("getContractNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
}
updateDynamicRam("isContractName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
updateDynamicRam("getContractNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.isContractNameNetscriptFn(name);
return Player.bladeburner.getContractNamesNetscriptFn(name);
}
throw makeRuntimeRejectMsg(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "getContractNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
isOperationName : function(name) {
getOperationNames : function(name) {
if (workerScript.checkingRam) {
return updateStaticRam("isOperationName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
return updateStaticRam("getOperationNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
}
updateDynamicRam("isOperationName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
updateDynamicRam("getOperationNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.isOperationNameNetscriptFn(name);
return Player.bladeburner.getOperationNamesNetscriptFn(name);
}
throw makeRuntimeRejectMsg(workerScript, "isOperationName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "getOperationNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
isBlackOpName : function(name) {
getBlackOpNames : function(name) {
if (workerScript.checkingRam) {
return updateStaticRam("isBlackOpName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
return updateStaticRam("getBlackOpNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
}
updateDynamicRam("isBlackOpName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
updateDynamicRam("getBlackOpNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.isBlackOpNameNetscriptFn(name);
return Player.bladeburner.getBlackOpNamesNetscriptFn(name);
}
throw makeRuntimeRejectMsg(workerScript, "isBlackOpName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "getBlackOpNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
isGeneralActionName : function(name) {
getGeneralActionNames : function(name) {
if (workerScript.checkingRam) {
return updateStaticRam("isGeneralActionName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
return updateStaticRam("getGeneralActionNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
}
updateDynamicRam("isGeneralActionName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
updateDynamicRam("getGeneralActionNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.isGeneralActionNameNetscriptFn(name);
return Player.bladeburner.getGeneralActionNamesNetscriptFn(name);
}
throw makeRuntimeRejectMsg(workerScript, "isGeneralActionName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "getGeneralActionNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
isSkillName : function(name) {
getSkillNames : function(name) {
if (workerScript.checkingRam) {
return updateStaticRam("isSkillName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
return updateStaticRam("getSkillNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
}
updateDynamicRam("isSkillName", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
updateDynamicRam("getSkillNames", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.isSkillNameNetscriptFn(name);
return Player.bladeburner.getSkillNamesNetscriptFn(name);
}
throw makeRuntimeRejectMsg(workerScript, "isSkillName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "getSkillNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
startAction : function(type="", name="") {
@ -3285,15 +3285,15 @@ function NetscriptFunctions(workerScript) {
throw makeRuntimeRejectMsg(workerScript, "startAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
stopAction : function() {
stopBladeburnerAction : function() {
if (workerScript.checkingRam) {
return updateStaticRam("stopAction", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);
return updateStaticRam("stopBladeburnerAction", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);
}
updateDynamicRam("stopAction", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);
updateDynamicRam("stopBladeburnerAction", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);
if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {
return Player.bladeburner.resetAction();
}
throw makeRuntimeRejectMsg(workerScript, "stopAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
throw makeRuntimeRejectMsg(workerScript, "stopBladeburnerAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
},
getActionTime : function(type="", name="") {
@ -3504,7 +3504,7 @@ function NetscriptFunctions(workerScript) {
}
throw makeRuntimeRejectMsg(workerScript, "joinBladeburnerFaction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
"at the Bladeburner division or because you do not have Source-File 7");
}
},
}
} //End return
} //End NetscriptFunction()

@ -194,7 +194,7 @@ function runScriptsLoop() {
} else {
try {
var ast = parse(workerScripts[i].code, {sourceType:"module"});
console.log(ast);
//console.log(ast);
} catch (e) {
console.log("Error parsing script: " + workerScripts[i].name);
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);

@ -208,7 +208,8 @@ function loadBitVerse(destroyedBitNodeNum, flume=false) {
var elemId = "bitnode-" + i.toString();
var elem = clearEventListeners(elemId);
if (elem == null) {return;}
if (i === 1 || i === 2 || i === 3 || i === 4 || i === 5 || i === 6 || i === 8 || i === 11 || i === 12) {
if (i === 1 || i === 2 || i === 3 || i === 4 || i === 5 ||
i === 6 || i === 7 || i === 8 || i === 11 || i === 12) {
elem.addEventListener("click", function() {
var bitNodeKey = "BitNode" + i;
var bitNode = BitNodes[bitNodeKey];

@ -474,19 +474,32 @@ function parseOnlyRamCalculate(server, code, workerScript) {
//
// TODO it would be simpler to just reference a dictionary.
try {
var func = workerScript.env.get(ref);
function applyFuncRam(func) {
if (typeof func === "function") {
try {
var res = func.apply(null, []);
let res = func.apply(null, []);
if (typeof res === "number") {
ram += res;
return res;
}
return 0;
} catch(e) {
console.log("ERROR applying function: " + e);
return 0;
}
} else {
return 0;
}
}
} catch (error) { continue; }
//Special logic for Bladeburner
var func;
if (ref in workerScript.env.vars.bladeburner) {
func = workerScript.env.vars.bladeburner[ref];
} else {
func = workerScript.env.get(ref);
}
ram += applyFuncRam(func);
} catch (error) {continue;}
}
return ram;

@ -164,6 +164,17 @@ function applySourceFile(srcFile) {
Player.dexterity_exp_mult *= incMult;
Player.agility_exp_mult *= incMult;
break;
case 7: //Bladeburner 2079
var mult = 0;
for (var i = 0; i < srcFile.lvl; ++i) {
mult += (8 / (Math.pow(2, i)));
}
var incMult = 1 + (mult / 100);
Player.bladeburner_max_stamina_mult *= incMult;
Player.bladeburner_stamina_gain_mult *= incMult;
Player.bladeburner_analysis_mult *= incMult;
Player.bladeburner_success_chance_mult *= incMult;
break;
case 8: //Ghost of Wall Street
var mult = 0;
for (var i = 0; i < srcFile.lvl; ++i) {