mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Fixed comment styling for all top-level src files
This commit is contained in:
parent
df89cc5002
commit
221b81d802
@ -51,7 +51,7 @@ const updateHeaderHtml = (server) => {
|
||||
return;
|
||||
}
|
||||
|
||||
// convert it to a string, as that's how it's stored it will come out of the data attributes
|
||||
// Convert it to a string, as that's how it's stored it will come out of the data attributes
|
||||
const ramPercentage = '' + roundToTwo(server.ramUsed / server.maxRam);
|
||||
if (accordion.header.dataset.ramPercentage !== ramPercentage) {
|
||||
accordion.header.dataset.ramPercentage = ramPercentage;
|
||||
@ -86,14 +86,16 @@ function createActiveScriptsServerPanel(server) {
|
||||
panelList: panelScriptList,
|
||||
scripts: {}, // Holds references to li elements for each active script
|
||||
scriptHdrs: {}, // Holds references to header elements for each active script
|
||||
scriptStats: {} //Holds references to the p elements containing text for each active script
|
||||
scriptStats: {}, // Holds references to the p elements containing text for each active script
|
||||
};
|
||||
|
||||
return li;
|
||||
}
|
||||
|
||||
//Deletes the info for a particular server (Dropdown header + Panel with all info)
|
||||
//in the Active Scripts page if it exists
|
||||
/**
|
||||
* Deletes the info for a particular server (Dropdown header + Panel with all info)
|
||||
* in the Active Scripts page if it exists
|
||||
*/
|
||||
function deleteActiveScriptsServerPanel(server) {
|
||||
let hostname = server.hostname;
|
||||
if (ActiveScriptsUI[hostname] == null) {
|
||||
@ -103,7 +105,7 @@ function deleteActiveScriptsServerPanel(server) {
|
||||
|
||||
// Make sure it's empty
|
||||
if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) {
|
||||
console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting");
|
||||
console.warn("Tried to delete Active Scripts Server panel that still has scripts. Aborting");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -115,7 +117,7 @@ function deleteActiveScriptsServerPanel(server) {
|
||||
function addActiveScriptsItem(workerscript) {
|
||||
var server = getServer(workerscript.serverIp);
|
||||
if (server == null) {
|
||||
console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()");
|
||||
console.warn("Invalid server IP for workerscript in addActiveScriptsItem()");
|
||||
return;
|
||||
}
|
||||
let hostname = server.hostname;
|
||||
@ -142,8 +144,10 @@ function addActiveScriptsItem(workerscript) {
|
||||
panel.classList.remove("accordion-panel");
|
||||
panel.classList.add("active-scripts-script-panel");
|
||||
|
||||
//Handle the constant elements on the panel that don't change after creation
|
||||
//Threads, args, kill/log button
|
||||
/**
|
||||
* Handle the constant elements on the panel that don't change after creation:
|
||||
* Threads, args, kill/log button
|
||||
*/
|
||||
panel.appendChild(createElement("p", {
|
||||
innerHTML: "Threads: " + workerscript.scriptRef.threads + "<br>" +
|
||||
"Args: " + arrayToString(workerscript.args)
|
||||
@ -221,11 +225,13 @@ function deleteActiveScriptsItem(workerscript) {
|
||||
}.bind(null, workerscript));
|
||||
}
|
||||
|
||||
//Update the ActiveScriptsItems array
|
||||
function updateActiveScriptsItems(maxTasks=150) {
|
||||
//Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
|
||||
//We'll limit this to 150 at a time in case someone decides to start a bunch of scripts all at once...
|
||||
let numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
|
||||
/**
|
||||
* Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
|
||||
* We'll limit this to 150 at a time for performance (in case someone decides to start a
|
||||
* bunch of scripts all at once...)
|
||||
*/
|
||||
const numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
|
||||
for (let i = 0; i < numTasks; ++i) {
|
||||
let task = ActiveScriptsTasks.shift();
|
||||
try {
|
||||
@ -237,7 +243,7 @@ function updateActiveScriptsItems(maxTasks=150) {
|
||||
}
|
||||
|
||||
if (!routing.isOn(Page.ActiveScripts)) { return; }
|
||||
var total = 0;
|
||||
let total = 0;
|
||||
for (var i = 0; i < workerScripts.length; ++i) {
|
||||
try {
|
||||
total += updateActiveScriptsItemContent(workerScripts[i]);
|
||||
@ -249,10 +255,10 @@ function updateActiveScriptsItems(maxTasks=150) {
|
||||
getElementById("active-scripts-total-production-active").innerText = numeralWrapper.formatMoney(total);
|
||||
getElementById("active-scripts-total-prod-aug-total").innerText = numeralWrapper.formatMoney(Player.scriptProdSinceLastAug);
|
||||
getElementById("active-scripts-total-prod-aug-avg").innerText = numeralWrapper.formatMoney(Player.scriptProdSinceLastAug / (Player.playtimeSinceLastAug/1000));
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
//Updates the content of the given item in the Active Scripts list
|
||||
function updateActiveScriptsItemContent(workerscript) {
|
||||
var server = getServer(workerscript.serverIp);
|
||||
if (server == null) {
|
||||
|
10
src/Alias.ts
10
src/Alias.ts
@ -20,7 +20,7 @@ export function loadGlobalAliases(saveString: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
//Print all aliases to terminal
|
||||
// Prints all aliases to terminal
|
||||
export function printAliases(): void {
|
||||
for (var name in Aliases) {
|
||||
if (Aliases.hasOwnProperty(name)) {
|
||||
@ -34,7 +34,7 @@ export function printAliases(): void {
|
||||
}
|
||||
}
|
||||
|
||||
//True if successful, false otherwise
|
||||
// Returns true if successful, false otherwise
|
||||
export function parseAliasDeclaration(dec: string, global: boolean=false) {
|
||||
var re = /^([_|\w|!|%|,|@]+)="(.+)"$/;
|
||||
var matches = dec.match(re);
|
||||
@ -90,8 +90,10 @@ export function removeAlias(name: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Returns the original string with any aliases substituted in
|
||||
//Aliases only applied to "whole words", one level deep
|
||||
/**
|
||||
* Returns the original string with any aliases substituted in.
|
||||
* Aliases are only applied to "whole words", one level deep
|
||||
*/
|
||||
export function substituteAliases(origCommand: string): string {
|
||||
const commandArray = origCommand.split(" ");
|
||||
if (commandArray.length > 0){
|
||||
|
@ -49,14 +49,18 @@ const MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to g
|
||||
|
||||
const DifficultyToTimeFactor = 10; // Action Difficulty divided by this to get base action time
|
||||
|
||||
//The difficulty multiplier affects stamina loss and hp loss of an action. Also affects
|
||||
//experience gain. Its formula is:
|
||||
//difficulty ^ exponentialFactor + difficulty / linearFactor
|
||||
/**
|
||||
* The difficulty multiplier affects stamina loss and hp loss of an action. Also affects
|
||||
* experience gain. Its formula is:
|
||||
* difficulty ^ exponentialFactor + difficulty / linearFactor
|
||||
*/
|
||||
const DiffMultExponentialFactor = 0.28;
|
||||
const DiffMultLinearFactor = 650;
|
||||
|
||||
// These factors are used to calculate action time.
|
||||
// They affect how much action time is reduced based on your agility and dexterity
|
||||
/**
|
||||
* These factors are used to calculate action time.
|
||||
* They affect how much action time is reduced based on your agility and dexterity
|
||||
*/
|
||||
const EffAgiLinearFactor = 10e3;
|
||||
const EffDexLinearFactor = 10e3;
|
||||
const EffAgiExponentialFactor = 0.04;
|
||||
@ -87,11 +91,12 @@ const HrcHpGain = 2; // HP Gained from Hyperbolic Regeneration chambe
|
||||
const HrcStaminaGain = 1; // Percentage Stamina gained from Hyperbolic Regeneration Chamber
|
||||
|
||||
// DOM related variables
|
||||
var ActiveActionCssClass = "bladeburner-active-action";
|
||||
const ActiveActionCssClass = "bladeburner-active-action";
|
||||
|
||||
|
||||
// Console related stuff
|
||||
var consoleHistoryIndex = 0;
|
||||
var consoleHelpText = {
|
||||
let consoleHistoryIndex = 0;
|
||||
const consoleHelpText = {
|
||||
helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.<br><br>" +
|
||||
"automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks<br>" +
|
||||
"clear/cls Clear the console<br>" +
|
||||
@ -163,10 +168,6 @@ var consoleHelpText = {
|
||||
// Keypresses for Console
|
||||
$(document).keydown(function(event) {
|
||||
if (routing.isOn(Page.Bladeburner)) {
|
||||
//if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
|
||||
// DomElems.consoleInput.focus();
|
||||
//}
|
||||
|
||||
if (!(Player.bladeburner instanceof Bladeburner)) { return; }
|
||||
let consoleHistory = Player.bladeburner.consoleHistory;
|
||||
|
||||
@ -272,9 +273,11 @@ City.prototype.improveCommunityEstimate = function(n=1) {
|
||||
}
|
||||
}
|
||||
|
||||
//@params options:
|
||||
// estChange(int): How much the estimate should change by
|
||||
// estOffset(int): Add offset to estimate (offset by percentage)
|
||||
/**
|
||||
* @params options:
|
||||
* estChange(int): How much the estimate should change by
|
||||
* estOffset(int): Add offset to estimate (offset by percentage)
|
||||
*/
|
||||
City.prototype.changePopulationByCount = function(n, params={}) {
|
||||
if (isNaN(n)) {throw new Error("NaN passed into City.changePopulationByCount()");}
|
||||
this.pop += n;
|
||||
@ -285,10 +288,12 @@ City.prototype.changePopulationByCount = function(n, params={}) {
|
||||
this.popEst = Math.max(this.popEst, 0);
|
||||
}
|
||||
|
||||
//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
|
||||
//@params options:
|
||||
// changeEstEqually(bool) - Change the population estimate by an equal amount
|
||||
// nonZero (bool) - Set to true to ensure that population always changes by at least 1
|
||||
/**
|
||||
* @p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
|
||||
* @params options:
|
||||
* changeEstEqually(bool) - Change the population estimate by an equal amount
|
||||
* nonZero (bool) - Set to true to ensure that population always changes by at least 1
|
||||
*/
|
||||
City.prototype.changePopulationByPercentage = function(p, params={}) {
|
||||
if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
|
||||
if (p === 0) {return;}
|
||||
@ -347,16 +352,20 @@ function Skill(params={name:"foo", desc:"foo"}) {
|
||||
|
||||
if (params.maxLvl) {this.maxLvl = params.maxLvl;}
|
||||
|
||||
//These benefits are additive. So total multiplier will be level (handled externally) times the
|
||||
//effects below
|
||||
/**
|
||||
* These benefits are additive. So total multiplier will be level (handled externally) times the
|
||||
* effects below
|
||||
*/
|
||||
if (params.successChanceAll) {this.successChanceAll = params.successChanceAll;}
|
||||
if (params.successChanceStealth) {this.successChanceStealth = params.successChanceStealth;}
|
||||
if (params.successChanceKill) {this.successChanceKill = params.successChanceKill;}
|
||||
if (params.successChanceContract) {this.successChanceContract = params.successChanceContract;}
|
||||
if (params.successChanceOperation) {this.successChanceOperation = params.successChanceOperation;}
|
||||
|
||||
//This multiplier affects everything that increases synthoid population/community estimate
|
||||
//e.g. Field analysis, Investigation Op, Undercover Op
|
||||
/**
|
||||
* This multiplier affects everything that increases synthoid population/community estimate
|
||||
* e.g. Field analysis, Investigation Op, Undercover Op
|
||||
*/
|
||||
if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
|
||||
|
||||
if (params.actionTime) {this.actionTime = params.actionTime;}
|
||||
@ -379,8 +388,8 @@ function Skill(params={name:"foo", desc:"foo"}) {
|
||||
Skill.prototype.calculateCost = function(currentLevel) {
|
||||
return Math.floor((this.baseCost + (currentLevel * this.costInc)) * BitNodeMultipliers.BladeburnerSkillCost);
|
||||
}
|
||||
var Skills = {};
|
||||
var SkillNames = {
|
||||
const Skills = {};
|
||||
const SkillNames = {
|
||||
BladesIntuition: "Blade's Intuition",
|
||||
Cloak: "Cloak",
|
||||
Marksman: "Marksman",
|
||||
@ -402,10 +411,7 @@ function Action(params={}) {
|
||||
this.name = params.name ? params.name : "";
|
||||
this.desc = params.desc ? params.desc : "";
|
||||
|
||||
//Difficulty scales with level
|
||||
//Exact formula is not set in stone
|
||||
//Initial design: baseDifficulty * (difficultyFac ^ level)?
|
||||
//difficulty Fac is slightly greater than 1
|
||||
// Difficulty scales with level. See getDifficulty() method
|
||||
this.level = 1;
|
||||
this.maxLevel = 1;
|
||||
this.autoLevel = true;
|
||||
@ -430,8 +436,10 @@ function Action(params={}) {
|
||||
this.isStealth = params.isStealth ? true : false;
|
||||
this.isKill = params.isKill ? true : false;
|
||||
|
||||
//Number of this contract remaining, and its growth rate
|
||||
//Growth rate is an integer and the count will increase by that integer every "cycle"
|
||||
/**
|
||||
* Number of this contract remaining, and its growth rate
|
||||
* Growth rate is an integer and the count will increase by that integer every "cycle"
|
||||
*/
|
||||
this.count = params.count ? params.count : getRandomInt(1e3, 25e3);
|
||||
this.countGrowth = params.countGrowth ? params.countGrowth : getRandomInt(1, 5);
|
||||
|
||||
@ -440,8 +448,8 @@ function Action(params={}) {
|
||||
this.weights = params.weights ? params.weights : defaultWeights;
|
||||
|
||||
// Check to make sure weights are summed properly
|
||||
var sum = 0;
|
||||
for (var weight in this.weights) {
|
||||
let sum = 0;
|
||||
for (const weight in this.weights) {
|
||||
if (this.weights.hasOwnProperty(weight)) {
|
||||
sum += this.weights[weight];
|
||||
}
|
||||
@ -452,9 +460,9 @@ function Action(params={}) {
|
||||
}
|
||||
|
||||
// Diminishing returns of stats (stat ^ decay where 0 <= decay <= 1)
|
||||
var defaultDecays = {hack:0.9,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.9,int:0.9};
|
||||
const defaultDecays = { hack: 0.9, str: 0.9, def: 0.9, dex: 0.9, agi: 0.9, cha: 0.9, int: 0.9 };
|
||||
this.decays = params.decays ? params.decays : defaultDecays;
|
||||
for (var decay in this.decays) {
|
||||
for (const decay in this.decays) {
|
||||
if (this.decays.hasOwnProperty(decay)) {
|
||||
if (this.decays[decay] > 1) {
|
||||
throw new Error("Invalid decays when constructing " +
|
||||
@ -471,9 +479,11 @@ Action.prototype.getDifficulty = function() {
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
//@inst - Bladeburner Object
|
||||
//@params - options:
|
||||
// est (bool): Get success chance estimate instead of real success chance
|
||||
/**
|
||||
* @inst - Bladeburner Object
|
||||
* @params - options:
|
||||
* est (bool): Get success chance estimate instead of real success chance
|
||||
*/
|
||||
Action.prototype.getSuccessChance = function(inst, params={}) {
|
||||
if (inst == null) {throw new Error("Invalid Bladeburner instance passed into Action.getSuccessChance");}
|
||||
var difficulty = this.getDifficulty();
|
||||
@ -545,8 +555,10 @@ Action.prototype.getSuccessChance = function(inst, params={}) {
|
||||
return Math.min(1, competence / difficulty);
|
||||
}
|
||||
|
||||
//Tests for success. Should be called when an action has completed
|
||||
// @inst - Bladeburner Object
|
||||
/**
|
||||
* Tests for success. Should be called when an action has completed
|
||||
* @param inst {Bladeburner} - Bladeburner instance
|
||||
*/
|
||||
Action.prototype.attempt = function(inst) {
|
||||
return (Math.random() < this.getSuccessChance(inst));
|
||||
}
|
||||
@ -593,9 +605,9 @@ Action.fromJSON = function(value) {
|
||||
return Generic_fromJSON(Action, value.data);
|
||||
}
|
||||
Reviver.constructors.Action = Action;
|
||||
var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
|
||||
const GeneralActions = {}; // Training, Field Analysis, Recruitment, etc.
|
||||
|
||||
//Action Identifier
|
||||
// Action Identifier enum
|
||||
const ActionTypes = Object.freeze({
|
||||
"Idle": 1,
|
||||
"Contract": 2,
|
||||
@ -609,29 +621,37 @@ const ActionTypes = Object.freeze({
|
||||
"Diplomacy": 8,
|
||||
"Hyperbolic Regeneration Chamber": 9,
|
||||
});
|
||||
|
||||
function ActionIdentifier(params={}) {
|
||||
if (params.name) {this.name = params.name;}
|
||||
if (params.type) {this.type = params.type;}
|
||||
}
|
||||
|
||||
ActionIdentifier.prototype.toJSON = function() {
|
||||
return Generic_toJSON("ActionIdentifier", this);
|
||||
}
|
||||
|
||||
ActionIdentifier.fromJSON = function(value) {
|
||||
return Generic_fromJSON(ActionIdentifier, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.ActionIdentifier = ActionIdentifier;
|
||||
|
||||
// Contracts
|
||||
function Contract(params={}) {
|
||||
Action.call(this, params);
|
||||
}
|
||||
|
||||
Contract.prototype = Object.create(Action.prototype);
|
||||
|
||||
Contract.prototype.toJSON = function() {
|
||||
return Generic_toJSON("Contract", this);
|
||||
}
|
||||
|
||||
Contract.fromJSON = function(value) {
|
||||
return Generic_fromJSON(Contract, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.Contract = Contract;
|
||||
|
||||
// Operations
|
||||
@ -640,13 +660,17 @@ function Operation(params={}) {
|
||||
this.reqdRank = params.reqdRank ? params.reqdRank : 100;
|
||||
this.teamCount = params.teamCount ? params.teamCount : 0; //# of team members to use
|
||||
}
|
||||
|
||||
Operation.prototype = Object.create(Action.prototype);
|
||||
|
||||
Operation.prototype.toJSON = function() {
|
||||
return Generic_toJSON("Operation", this);
|
||||
}
|
||||
|
||||
Operation.fromJSON = function(value) {
|
||||
return Generic_fromJSON(Operation, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.Operation = Operation;
|
||||
|
||||
// Black Operations
|
||||
@ -657,15 +681,20 @@ function BlackOperation(params={}) {
|
||||
this.count = 1;
|
||||
this.countGrowth = 0;
|
||||
}
|
||||
|
||||
BlackOperation.prototype = Object.create(Action.prototype);
|
||||
|
||||
BlackOperation.prototype.toJSON = function() {
|
||||
return Generic_toJSON("BlackOperation", this);
|
||||
}
|
||||
|
||||
BlackOperation.fromJSON = function(value) {
|
||||
return Generic_fromJSON(BlackOperation, value.data);
|
||||
}
|
||||
|
||||
Reviver.constructors.BlackOperation = BlackOperation;
|
||||
var BlackOperations = {};
|
||||
|
||||
const BlackOperations = {};
|
||||
|
||||
function Bladeburner(params={}) {
|
||||
this.numHosp = 0; // Number of hospitalizations
|
||||
@ -708,9 +737,11 @@ function Bladeburner(params={}) {
|
||||
this.calculateMaxStamina();
|
||||
this.stamina = this.maxStamina;
|
||||
|
||||
//Contracts and Operations objects. These objects have unique
|
||||
//properties because they are randomized in each instance and have stats like
|
||||
//successes/failures, so they need to be saved/loaded by the game.
|
||||
/**
|
||||
* Contracts and Operations objects. These objects have unique
|
||||
* properties because they are randomized in each instance and have stats like
|
||||
* successes/failures, so they need to be saved/loaded by the game.
|
||||
*/
|
||||
this.contracts = {};
|
||||
this.operations = {};
|
||||
|
||||
@ -871,7 +902,7 @@ Bladeburner.prototype.storeCycles = function(numCycles=1) {
|
||||
}
|
||||
|
||||
Bladeburner.prototype.process = function() {
|
||||
//Extreme condition...if Operation Daedalus is complete trigger the BitNode
|
||||
// Edge case condition...if Operation Daedalus is complete trigger the BitNode
|
||||
if (redPillFlag === false && this.blackops.hasOwnProperty("Operation Daedalus")) {
|
||||
return hackWorldDaemon(Player.bitNodeN);
|
||||
}
|
||||
@ -1081,8 +1112,10 @@ Bladeburner.prototype.upgradeSkill = function(skill) {
|
||||
}
|
||||
|
||||
Bladeburner.prototype.getActionObject = function(actionId) {
|
||||
//Given an ActionIdentifier object, returns the corresponding
|
||||
//GeneralAction, Contract, Operation, or BlackOperation object
|
||||
/**
|
||||
* Given an ActionIdentifier object, returns the corresponding
|
||||
* GeneralAction, Contract, Operation, or BlackOperation object
|
||||
*/
|
||||
switch (actionId.type) {
|
||||
case ActionTypes["Contract"]:
|
||||
return this.contracts[actionId.name];
|
||||
@ -1564,14 +1597,18 @@ Bladeburner.prototype.getDiplomacyEffectiveness = function() {
|
||||
return (100 - charismaEff) / 100;
|
||||
}
|
||||
|
||||
//Process stat gains from Contracts, Operations, and Black Operations
|
||||
//@action(Action obj) - Derived action class
|
||||
//@success(bool) - Whether action was successful
|
||||
/**
|
||||
* Process stat gains from Contracts, Operations, and Black Operations
|
||||
* @param action(Action obj) - Derived action class
|
||||
* @param success(bool) - Whether action was successful
|
||||
*/
|
||||
Bladeburner.prototype.gainActionStats = function(action, success) {
|
||||
var difficulty = action.getDifficulty();
|
||||
|
||||
//Gain multiplier based on difficulty. If this changes then the
|
||||
//same variable calculated in completeAction() needs to change too
|
||||
/**
|
||||
* Gain multiplier based on difficulty. If this changes then the
|
||||
* same variable calculated in completeAction() needs to change too
|
||||
*/
|
||||
var difficultyMult = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
|
||||
|
||||
var time = this.actionTimeToComplete;
|
||||
@ -1706,7 +1743,7 @@ Bladeburner.prototype.triggerMigration = function(sourceCityName) {
|
||||
destCity.pop += count;
|
||||
}
|
||||
|
||||
var DomElems = {};
|
||||
let DomElems = {};
|
||||
|
||||
Bladeburner.prototype.initializeDomElementRefs = function() {
|
||||
DomElems = {
|
||||
@ -1971,8 +2008,10 @@ Bladeburner.prototype.createOverviewContent = function() {
|
||||
for (var i = 0; i < CityNames.length; ++i) {
|
||||
(function(inst, i) {
|
||||
popupArguments.push(createElement("div", {
|
||||
//Reusing this css class...it adds a border and makes it
|
||||
//so that background color changes when you hover
|
||||
/**
|
||||
* Reusing this css class...it adds a border and makes it
|
||||
* so that background color changes when you hover
|
||||
*/
|
||||
class:"cmpy-mgmt-find-employee-option",
|
||||
innerText:CityNames[i],
|
||||
clickListener:()=>{
|
||||
@ -2260,10 +2299,10 @@ Bladeburner.prototype.createSkillsContent = function() {
|
||||
DomElems.actionsAndSkillsDesc.innerHTML += "Exp Gain: x" + mult + "<br>";
|
||||
break;
|
||||
case "weaponAbility":
|
||||
//DomElems.actionsAndSkillsDesc.innerHTML +=
|
||||
// TODO in the future if items are ever implemented
|
||||
break;
|
||||
case "gunAbility":
|
||||
//DomElems.actionsAndSkillsDesc.innerHTML
|
||||
// TODO in the future if items are ever implemented
|
||||
break;
|
||||
default:
|
||||
console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
|
||||
@ -2902,7 +2941,7 @@ Bladeburner.prototype.executeConsoleCommands = function(commands) {
|
||||
}
|
||||
}
|
||||
|
||||
//A single command
|
||||
// Execute a single console command
|
||||
Bladeburner.prototype.executeConsoleCommand = function(command) {
|
||||
command = command.trim();
|
||||
command = command.replace(/\s\s+/g, ' '); // Replace all whitespace w/ a single space
|
||||
@ -2940,9 +2979,11 @@ Bladeburner.prototype.executeConsoleCommand = function(command) {
|
||||
}
|
||||
|
||||
Bladeburner.prototype.parseCommandArguments = function(command) {
|
||||
//Returns an array with command and its arguments in each index.
|
||||
//e.g. skill "blade's intuition" foo returns [skill, blade's intuition, foo]
|
||||
//The input to this fn will be trimmed and will have all whitespace replaced w/ a single space
|
||||
/**
|
||||
* Returns an array with command and its arguments in each index.
|
||||
* e.g. skill "blade's intuition" foo returns [skill, blade's intuition, foo]
|
||||
* The input to this fn will be trimmed and will have all whitespace replaced w/ a single space
|
||||
*/
|
||||
const args = [];
|
||||
let start = 0, i = 0;
|
||||
while (i < command.length) {
|
||||
@ -3234,10 +3275,10 @@ Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
|
||||
this.postToConsole("Stamina: x" + mult);
|
||||
break;
|
||||
case "weaponAbility":
|
||||
//DomElems.actionsAndSkillsDesc.innerHTML +=
|
||||
// TODO if items are ever implemented
|
||||
break;
|
||||
case "gunAbility":
|
||||
//DomElems.actionsAndSkillsDesc.innerHTML
|
||||
// TODO if items are ever implemented
|
||||
break;
|
||||
default:
|
||||
console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
|
||||
@ -3851,10 +3892,12 @@ Bladeburner.fromJSON = function(value) {
|
||||
}
|
||||
Reviver.constructors.Bladeburner = Bladeburner;
|
||||
|
||||
//This initialized Bladeburner-related data that is NOT saved/loaded
|
||||
// eg: Skill Objects, BLack Operations
|
||||
//Any data that is saved/loaded should go in Bladeburner object
|
||||
// eg: contracts, operations
|
||||
/**
|
||||
* This initialized Bladeburner-related data that is NOT saved/loaded
|
||||
* eg: Skill Objects, BLack Operations
|
||||
* Any data that is saved/loaded should go in Bladeburner object
|
||||
* eg: contracts, operations
|
||||
*/
|
||||
function initBladeburner() {
|
||||
// Skills
|
||||
Skills[SkillNames.BladesIntuition] = new Skill({
|
||||
@ -3872,8 +3915,8 @@ function initBladeburner() {
|
||||
successChanceStealth:5.5
|
||||
});
|
||||
|
||||
//TODO Marksman
|
||||
//TODO Weapon Proficiency
|
||||
// TODO Marksman - If items are ever implemented
|
||||
// TODO Weapon Proficiency - If items are ever implemented
|
||||
|
||||
Skills[SkillNames.ShortCircuit] = new Skill({
|
||||
name:SkillNames.ShortCircuit,
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
import { Engine } from "./engine";
|
||||
import { setTimeoutRef } from "./utils/SetTimeoutRef";
|
||||
|
||||
@ -8,7 +9,12 @@ import { isString } from "../utils/helpers/isString";
|
||||
|
||||
export let cinematicTextFlag = false;
|
||||
|
||||
// Lines must be an array of strings
|
||||
/**
|
||||
* Print a message using a hacking-style "typing" effect.
|
||||
* Note that this clears the UI so that the text from this is the only thing visible.
|
||||
*
|
||||
* @param lines {string[]} Array of strings to print, where each element is a separate line
|
||||
*/
|
||||
export function writeCinematicText(lines) {
|
||||
cinematicTextFlag = true;
|
||||
|
||||
|
@ -130,14 +130,15 @@ function getRandomReward() {
|
||||
});
|
||||
|
||||
switch (reward.type) {
|
||||
case CodingContractRewardType.FactionReputation:
|
||||
case CodingContractRewardType.FactionReputation: {
|
||||
// Get a random faction that player is a part of. That
|
||||
// faction must allow hacking contracts
|
||||
var numFactions = factionsThatAllowHacking.length;
|
||||
var randFaction = factionsThatAllowHacking[getRandomInt(0, numFactions - 1)];
|
||||
reward.name = randFaction;
|
||||
break;
|
||||
case CodingContractRewardType.CompanyReputation:
|
||||
}
|
||||
case CodingContractRewardType.CompanyReputation: {
|
||||
const allJobs = Object.keys(Player.jobs);
|
||||
if (allJobs.length > 0) {
|
||||
reward.name = allJobs[getRandomInt(0, allJobs.length - 1)];
|
||||
@ -145,6 +146,7 @@ function getRandomReward() {
|
||||
reward.type = CodingContractRewardType.Money;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ import { IMap } from "./types";
|
||||
export let CONSTANTS: IMap<any> = {
|
||||
Version: "0.46.1",
|
||||
|
||||
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||
//the player will have this level assuming no multipliers. Multipliers can cause skills to go above this.
|
||||
/** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||
* and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||
* the player will have this level assuming no multipliers. Multipliers can cause skills to go above this.
|
||||
*/
|
||||
MaxSkillLevel: 975,
|
||||
|
||||
// Milliseconds per game cycle
|
||||
@ -19,13 +20,14 @@ export let CONSTANTS: IMap<any> = {
|
||||
// How much reputation is needed to join a megacorporation's faction
|
||||
CorpFactionRepRequirement: 200e3,
|
||||
|
||||
/* Base costs */
|
||||
// Base RAM costs
|
||||
BaseCostFor1GBOfRamHome: 32000,
|
||||
BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM
|
||||
|
||||
// Cost to travel to another city
|
||||
TravelCost: 200e3,
|
||||
|
||||
/* Faction and Company favor */
|
||||
// Faction and Company favor-related things
|
||||
BaseFavorToDonate: 150,
|
||||
DonateMoneyToRepDivisor: 1e6,
|
||||
FactionReputationToFavorBase: 500,
|
||||
@ -33,12 +35,10 @@ export let CONSTANTS: IMap<any> = {
|
||||
CompanyReputationToFavorBase: 500,
|
||||
CompanyReputationToFavorMult: 1.02,
|
||||
|
||||
/* Augmentation */
|
||||
//NeuroFlux Governor cost multiplier as you level up
|
||||
// NeuroFlux Governor Augmentation cost multiplier
|
||||
NeuroFluxGovernorLevelMult: 1.14,
|
||||
|
||||
/* Netscript Constants */
|
||||
//RAM Costs for different commands
|
||||
// RAM Costs for Netscript functions
|
||||
ScriptBaseRamCost: 1.6,
|
||||
ScriptDomRamCost: 25,
|
||||
ScriptWhileRamCost: 0,
|
||||
@ -55,15 +55,15 @@ export let CONSTANTS: IMap<any> = {
|
||||
ScriptExecRamCost: 1.3,
|
||||
ScriptSpawnRamCost: 2.0,
|
||||
ScriptScpRamCost: 0.6,
|
||||
ScriptKillRamCost: 0.5, //Kill and killall
|
||||
ScriptKillRamCost: 0.5,
|
||||
ScriptHasRootAccessRamCost: 0.05,
|
||||
ScriptGetHostnameRamCost: 0.05, //getHostname() and getIp()
|
||||
ScriptGetHackingLevelRamCost: 0.05, //getHackingLevel()
|
||||
ScriptGetMultipliersRamCost: 4.0, //getHackingMultipliers() and getBitNodeMultipliers()
|
||||
ScriptGetHostnameRamCost: 0.05,
|
||||
ScriptGetHackingLevelRamCost: 0.05,
|
||||
ScriptGetMultipliersRamCost: 4.0,
|
||||
ScriptGetServerRamCost: 0.1,
|
||||
ScriptFileExistsRamCost: 0.1,
|
||||
ScriptIsRunningRamCost: 0.1,
|
||||
ScriptHacknetNodesRamCost: 4.0, //Base cost for accessing Hacknet Node API
|
||||
ScriptHacknetNodesRamCost: 4.0,
|
||||
ScriptHNUpgLevelRamCost: 0.4,
|
||||
ScriptHNUpgRamRamCost: 0.6,
|
||||
ScriptHNUpgCoreRamCost: 0.8,
|
||||
@ -75,7 +75,7 @@ export let CONSTANTS: IMap<any> = {
|
||||
ScriptGetPurchasedServerMaxRam: 0.05,
|
||||
ScriptRoundRamCost: 0.05,
|
||||
ScriptReadWriteRamCost: 1.0,
|
||||
ScriptArbScriptRamCost: 1.0, // Functions that apply to all scripts regardless of args
|
||||
ScriptArbScriptRamCost: 1.0,
|
||||
ScriptGetScriptRamCost: 0.1,
|
||||
ScriptGetHackTimeRamCost: 0.05,
|
||||
ScriptGetFavorToDonate: 0.10,
|
||||
@ -94,7 +94,7 @@ export let CONSTANTS: IMap<any> = {
|
||||
|
||||
NumNetscriptPorts: 20,
|
||||
|
||||
//Server constants
|
||||
// Server-related constants
|
||||
HomeComputerMaxRam: 1073741824, // 2 ^ 30
|
||||
ServerBaseGrowthRate: 1.03, // Unadjusted Growth rate
|
||||
ServerMaxGrowthRate: 1.0035, // Maximum possible growth rate (max rate accounting for server security)
|
||||
@ -109,16 +109,16 @@ export let CONSTANTS: IMap<any> = {
|
||||
AugmentationRepMultiplier: 2.5, // Used for balancing rep cost without having to readjust every value
|
||||
MultipleAugMultiplier: 1.9,
|
||||
|
||||
//How much a TOR router costs
|
||||
TorRouterCost: 200000,
|
||||
// TOR Router
|
||||
TorRouterCost: 200e3,
|
||||
|
||||
//Infiltration constants
|
||||
// Infiltration
|
||||
InfiltrationBribeBaseAmount: 100e3, //Amount per clearance level
|
||||
InfiltrationMoneyValue: 5e3, //Convert "secret" value to money
|
||||
InfiltrationRepValue: 1.4, //Convert "secret" value to faction reputation
|
||||
InfiltrationExpPow: 0.8,
|
||||
|
||||
//Stock market constants
|
||||
// Stock market
|
||||
WSEAccountCost: 200e6,
|
||||
TIXAPICost: 5e9,
|
||||
MarketData4SCost: 1e9,
|
||||
@ -139,6 +139,7 @@ export let CONSTANTS: IMap<any> = {
|
||||
IntelligenceHackingMissionBaseExpGain: 0.03, // Hacking Mission difficulty multiplied by this to get exp gain
|
||||
|
||||
// Hacking Missions
|
||||
// TODO Move this into Hacking Mission implementation
|
||||
HackingMissionRepToDiffConversion: 10000, // Faction rep is divided by this to get mission difficulty
|
||||
HackingMissionRepToRewardConversion: 7, // Faction rep divided byt his to get mission rep reward
|
||||
HackingMissionSpamTimeIncrease: 25000, // How much time limit increase is gained when conquering a Spam Node (ms)
|
||||
@ -192,7 +193,7 @@ export let CONSTANTS: IMap<any> = {
|
||||
"-Miscellaneous Nodes slowly raise their defense over time<br><br>" +
|
||||
"-Nodes slowly regenerate health over time.",
|
||||
|
||||
/* Time Constants */
|
||||
// Time-related constants
|
||||
MillisecondsPer20Hours: 72000000,
|
||||
GameCyclesPer20Hours: 72000000 / 200,
|
||||
|
||||
@ -220,7 +221,7 @@ export let CONSTANTS: IMap<any> = {
|
||||
MillisecondsPerFiveMinutes: 300000,
|
||||
GameCyclesPerFiveMinutes: 300000 / 200,
|
||||
|
||||
/* Player Work / Action related Constants */
|
||||
// Player Work & Action
|
||||
FactionWorkHacking: "Faction Hacking Work",
|
||||
FactionWorkField: "Faction Field Work",
|
||||
FactionWorkSecurity: "Faction Security Work",
|
||||
@ -263,7 +264,8 @@ export let CONSTANTS: IMap<any> = {
|
||||
CrimeAssassination: "assassinate a high-profile target",
|
||||
CrimeHeist: "pull off the ultimate heist",
|
||||
|
||||
/* Coding Contract Constants */
|
||||
// Coding Contract
|
||||
// TODO Move this into Coding contract impelmentation?
|
||||
CodingContractBaseFactionRepGain: 2500,
|
||||
CodingContractBaseCompanyRepGain: 4000,
|
||||
CodingContractBaseMoneyGain: 75e6,
|
||||
|
@ -33,7 +33,12 @@ import ReactDOM from "react-dom";
|
||||
|
||||
const Component = React.Component;
|
||||
|
||||
const validSFN = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12];
|
||||
// Update as additional BitNodes get implemented
|
||||
const validSFN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
|
||||
// Some dev menu buttons just add a lot of something for convenience
|
||||
const tonsPP = 1e27;
|
||||
const tonsP = 1e12;
|
||||
|
||||
|
||||
class ValueAdjusterComponent extends Component {
|
||||
@ -189,13 +194,13 @@ class DevMenuComponent extends Component {
|
||||
}
|
||||
|
||||
tonsOfExp() {
|
||||
Player.gainHackingExp(1e27);
|
||||
Player.gainStrengthExp(1e27);
|
||||
Player.gainDefenseExp(1e27);
|
||||
Player.gainDexterityExp(1e27);
|
||||
Player.gainAgilityExp(1e27);
|
||||
Player.gainCharismaExp(1e27);
|
||||
Player.gainIntelligenceExp(1e27);
|
||||
Player.gainHackingExp(tonsPP);
|
||||
Player.gainStrengthExp(tonsPP);
|
||||
Player.gainDefenseExp(tonsPP);
|
||||
Player.gainDexterityExp(tonsPP);
|
||||
Player.gainAgilityExp(tonsPP);
|
||||
Player.gainCharismaExp(tonsPP);
|
||||
Player.gainIntelligenceExp(tonsPP);
|
||||
Player.updateSkillLevels();
|
||||
}
|
||||
|
||||
@ -298,7 +303,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
tonsOfRep() {
|
||||
for (const i in Factions) {
|
||||
Factions[i].playerReputation = 1e27;
|
||||
Factions[i].playerReputation = tonsPP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +315,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
tonsOfFactionFavor() {
|
||||
for (const i in Factions) {
|
||||
Factions[i].favor = 1e27;
|
||||
Factions[i].favor = tonsPP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -456,7 +461,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
tonsOfRepCompanies() {
|
||||
for (const c in Companies) {
|
||||
Companies[c].playerReputation = 1e12;
|
||||
Companies[c].playerReputation = tonsP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,7 +473,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
tonsOfFavorCompanies() {
|
||||
for (const c in Companies) {
|
||||
Companies[c].favor = 1e12;
|
||||
Companies[c].favor = tonsP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -493,7 +498,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
addTonsBladeburnerRank() {
|
||||
if (!!Player.bladeburner) {
|
||||
Player.bladeburner.changeRank(1e12);
|
||||
Player.bladeburner.changeRank(tonsP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,13 +518,13 @@ class DevMenuComponent extends Component {
|
||||
|
||||
addTonsBladeburnerCycles() {
|
||||
if (!!Player.bladeburner) {
|
||||
Player.bladeburner.storedCycles += 1e12;
|
||||
Player.bladeburner.storedCycles += tonsP;
|
||||
}
|
||||
}
|
||||
|
||||
addTonsGangCycles() {
|
||||
if (!!Player.gang) {
|
||||
Player.gang.storedCycles = 1e12;
|
||||
Player.gang.storedCycles = tonsP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,7 +544,7 @@ class DevMenuComponent extends Component {
|
||||
|
||||
addTonsCorporationCycles() {
|
||||
if (!!Player.corporation) {
|
||||
Player.corporation.storedCycles = 1e12;
|
||||
Player.corporation.storedCycles = tonsP;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1187,7 +1192,6 @@ class DevMenuComponent extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const devMenuContainerId = "dev-menu-container";
|
||||
|
||||
export function createDevMenu() {
|
||||
|
28
src/Gang.js
28
src/Gang.js
@ -1,6 +1,7 @@
|
||||
/*
|
||||
Also add police clashes
|
||||
balance point to keep them from running out of control
|
||||
/**
|
||||
* TODO
|
||||
* Add police clashes
|
||||
* balance point to keep them from running out of control
|
||||
*/
|
||||
|
||||
import { gangMemberTasksMetadata } from "./data/gangmembertasks";
|
||||
@ -144,12 +145,12 @@ export function loadAllGangs(saveString) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param facName - Name of corresponding faction
|
||||
* @param hacking - Boolean indicating whether or not its a hacking gang
|
||||
* @param facName {string} Name of corresponding faction
|
||||
* @param hacking {bollean} Whether or not its a hacking gang
|
||||
*/
|
||||
export function Gang(facName, hacking=false) {
|
||||
this.facName = facName;
|
||||
this.members = []; //Array of GangMembers
|
||||
this.members = [];
|
||||
this.wanted = 1;
|
||||
this.respect = 1;
|
||||
|
||||
@ -569,10 +570,9 @@ Gang.fromJSON = function(value) {
|
||||
|
||||
Reviver.constructors.Gang = Gang;
|
||||
|
||||
/*** Gang Member object ***/
|
||||
function GangMember(name) {
|
||||
this.name = name;
|
||||
this.task = "Unassigned"; //GangMemberTask object
|
||||
this.task = "Unassigned";
|
||||
|
||||
this.earnedRespect = 0;
|
||||
|
||||
@ -605,10 +605,10 @@ function GangMember(name) {
|
||||
this.cha_asc_mult = 1;
|
||||
|
||||
this.upgrades = []; // Names of upgrades
|
||||
this.augmentations = []; //Names only
|
||||
this.augmentations = []; // Names of augmentations only
|
||||
}
|
||||
|
||||
//Same formula for Player
|
||||
// Same skill calculation formula as Player
|
||||
GangMember.prototype.calculateSkill = function(exp, mult=1) {
|
||||
return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1);
|
||||
}
|
||||
@ -777,9 +777,11 @@ GangMember.prototype.ascend = function() {
|
||||
|
||||
// Returns the multipliers that would be gained from ascension
|
||||
GangMember.prototype.getAscensionResults = function() {
|
||||
// Calculate ascension bonus to stat multipliers.
|
||||
// This is based on the current number of multipliers from Non-Augmentation upgrades
|
||||
// + Ascension Bonus = N% of current bonus from Augmentations
|
||||
/**
|
||||
* Calculate ascension bonus to stat multipliers.
|
||||
* This is based on the current number of multipliers from Non-Augmentation upgrades
|
||||
* + Ascension Bonus = N% of current bonus from Augmentations
|
||||
*/
|
||||
let hack = 1;
|
||||
let str = 1;
|
||||
let def = 1;
|
||||
|
@ -1,8 +1,9 @@
|
||||
/**
|
||||
* Lore / world building literature files that can be found on servers.
|
||||
* These files can be read by the player
|
||||
*/
|
||||
import { dialogBoxCreate } from "../utils/DialogBox";
|
||||
|
||||
/* Literature.js
|
||||
* Lore / world building literature that can be found on servers
|
||||
*/
|
||||
function Literature(title, filename, txt) {
|
||||
this.title = title;
|
||||
this.fn = filename;
|
||||
@ -10,10 +11,9 @@ function Literature(title, filename, txt) {
|
||||
}
|
||||
|
||||
function showLiterature(fn) {
|
||||
var litObj = Literatures[fn];
|
||||
const litObj = Literatures[fn];
|
||||
if (litObj == null) { return; }
|
||||
var txt = "<i>" + litObj.title + "</i><br><br>" +
|
||||
litObj.txt;
|
||||
const txt = `<i>${litObj.title}</i><br><br>${litObj.txt}`;
|
||||
dialogBoxCreate(txt);
|
||||
}
|
||||
|
||||
@ -430,7 +430,10 @@ function initLiterature() {
|
||||
fn = "the-secret-war.lit";
|
||||
txt = ""
|
||||
Literatures[fn] = new Literature(title, fn, txt);
|
||||
|
||||
}
|
||||
|
||||
export {Literatures, initLiterature, showLiterature};
|
||||
export {
|
||||
Literatures,
|
||||
initLiterature,
|
||||
showLiterature
|
||||
};
|
||||
|
@ -84,9 +84,10 @@ function Node(type, stats) {
|
||||
this.action = null;
|
||||
this.targetedCount = 0; // Count of how many connections this node is the target of
|
||||
|
||||
//Holds the JsPlumb Connection object for this Node,
|
||||
//where this Node is the Source (since each Node
|
||||
//can only have 1 outgoing Connection)
|
||||
/**
|
||||
* Holds the JsPlumb Connection object for this Node, where this Node is the Source (since each Node
|
||||
* can only have 1 outgoing Connection)
|
||||
*/
|
||||
this.conn = null;
|
||||
}
|
||||
|
||||
@ -170,9 +171,11 @@ Node.prototype.untarget = function() {
|
||||
--this.targetedCount;
|
||||
}
|
||||
|
||||
//Hacking mission instance
|
||||
//Takes in the reputation of the Faction for which the mission is
|
||||
//being conducted
|
||||
/**
|
||||
* Hacking mission instance
|
||||
* @param rep {number} How much reputation the player has for the faction
|
||||
* @param fac {Faction} Faction for which this mission is being conducted
|
||||
*/
|
||||
function HackingMission(rep, fac) {
|
||||
this.faction = fac;
|
||||
|
||||
@ -482,11 +485,7 @@ HackingMission.prototype.createPageDom = function() {
|
||||
}
|
||||
node.action = NodeActions.Fortify;
|
||||
});
|
||||
// if (this.selectedNode.conn) {
|
||||
// var endpoints = this.selectedNode.conn.endpoints;
|
||||
// endpoints[0].detachFrom(endpoints[1]);
|
||||
// }
|
||||
})
|
||||
});
|
||||
|
||||
var timeDisplay = document.createElement("p");
|
||||
|
||||
@ -513,8 +512,10 @@ HackingMission.prototype.setActionButtonsActive = function(nodeType=null) {
|
||||
this.actionButtons[i].classList.remove("a-link-button-inactive");
|
||||
}
|
||||
|
||||
//For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled
|
||||
//0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn
|
||||
/**
|
||||
* For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled
|
||||
* 0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn
|
||||
*/
|
||||
if (nodeType) {
|
||||
switch (nodeType) {
|
||||
case NodeTypes.Firewall:
|
||||
@ -837,9 +838,11 @@ HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
|
||||
txtEl.innerHTML = txt;
|
||||
}
|
||||
|
||||
//Gets a Node DOM element's corresponding Node object using its
|
||||
//element id. Function accepts either the DOM element object or the ID as
|
||||
//an argument
|
||||
/**
|
||||
* Gets a Node DOM element's corresponding Node object using its
|
||||
* element id. Function accepts either the DOM element object or the ID as
|
||||
* an argument
|
||||
*/
|
||||
HackingMission.prototype.getNodeFromElement = function(el) {
|
||||
var id;
|
||||
if (isString(el)) {
|
||||
@ -902,9 +905,11 @@ function clearAllSelectedNodes(hackMissionInst) {
|
||||
}
|
||||
}
|
||||
|
||||
//Configures a DOM element representing a player-owned node to
|
||||
//be selectable and actionable
|
||||
//Note: Does NOT change its css class. This is handled by Node.setControlledBy...
|
||||
/**
|
||||
* Configures a DOM element representing a player-owned node to
|
||||
* be selectable and actionable.
|
||||
* Note: Does NOT change its css class. This is handled by Node.setControlledBy...
|
||||
*/
|
||||
HackingMission.prototype.configurePlayerNodeElement = function(el) {
|
||||
var nodeObj = this.getNodeFromElement(el);
|
||||
if (nodeObj == null) {console.log("Error getting Node object");}
|
||||
@ -927,8 +932,10 @@ HackingMission.prototype.configurePlayerNodeElement = function(el) {
|
||||
}
|
||||
}
|
||||
|
||||
//Configures a DOM element representing an enemy-node by removing
|
||||
//any event listeners
|
||||
/**
|
||||
* Configures a DOM element representing an enemy-node by removing
|
||||
* any event listeners
|
||||
*/
|
||||
HackingMission.prototype.configureEnemyNodeElement = function(el) {
|
||||
// Deselect node if it was the selected node
|
||||
var nodeObj = this.getNodeFromElement(el);
|
||||
@ -941,8 +948,10 @@ HackingMission.prototype.configureEnemyNodeElement = function(el) {
|
||||
}
|
||||
}
|
||||
|
||||
//Returns bool indicating whether a node is reachable by player
|
||||
//by checking if any of the adjacent nodes are owned by the player
|
||||
/**
|
||||
* Returns bool indicating whether a node is reachable by player
|
||||
* by checking if any of the adjacent nodes are owned by the player
|
||||
*/
|
||||
HackingMission.prototype.nodeReachable = function(node) {
|
||||
var x = node.pos[0], y = node.pos[1];
|
||||
if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;}
|
||||
@ -1379,9 +1388,11 @@ HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
|
||||
if (nodeObj == null) {return;}
|
||||
switch(nodeObj.type) {
|
||||
case NodeTypes.Core:
|
||||
//Select a single RANDOM target from miscNodes and player's Nodes
|
||||
//If it is reachable, it will target it. If not, no target will
|
||||
//be selected for now, and the next time process() gets called this will repeat
|
||||
/**
|
||||
* Select a single RANDOM target from miscNodes and player's Nodes
|
||||
* If it is reachable, it will target it. If not, no target will
|
||||
* be selected for now, and the next time process() gets called this will repeat
|
||||
*/
|
||||
if (nodeObj.conn == null) {
|
||||
if (this.miscNodes.length === 0) {
|
||||
// Randomly pick a player node and attack it if its reachable
|
||||
|
@ -479,8 +479,7 @@ function NetscriptFunctions(workerScript) {
|
||||
const percentHacked = calculatePercentMoneyHacked(server);
|
||||
let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax));
|
||||
if (isNaN(maxThreadNeeded)) {
|
||||
//Server has a 'max money' of 0 (probably).
|
||||
//We'll set this to an arbitrarily large value
|
||||
// Server has a 'max money' of 0 (probably). We'll set this to an arbitrarily large value
|
||||
maxThreadNeeded = 1e6;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Implementation for what happens when you destroy a BitNode
|
||||
*/
|
||||
import { BitNodes } from "./BitNode/BitNode";
|
||||
import { Engine } from "./engine";
|
||||
import { Player } from "./Player";
|
||||
@ -18,8 +21,7 @@ import { clearEventListeners } from "../utils/uiHelpers/clearEventListeners";
|
||||
import { removeChildrenFromElement } from "../utils/uiHelpers/removeChildrenFromElement";
|
||||
|
||||
|
||||
/* RedPill.js
|
||||
* Implements what happens when you have Red Pill augmentation and then hack the world daemon */
|
||||
|
||||
|
||||
// Returns promise
|
||||
function writeRedPillLine(line) {
|
||||
@ -100,8 +102,6 @@ function hackWorldDaemon(currentNodeNumber, flume=false) {
|
||||
});
|
||||
}
|
||||
|
||||
//The bitNode name passed in will have a hyphen between number (e.g. BitNode-1)
|
||||
//This needs to be removed
|
||||
function giveSourceFile(bitNodeNumber) {
|
||||
var sourceFileKey = "SourceFile"+ bitNodeNumber.toString();
|
||||
var sourceFile = SourceFiles[sourceFileKey];
|
||||
|
@ -115,12 +115,11 @@ BitburnerSaveObject.prototype.saveGame = function(db) {
|
||||
}
|
||||
|
||||
request.onsuccess = function(e) {
|
||||
//console.log("Saved game to IndexedDB!");
|
||||
// TODO anything here?
|
||||
}
|
||||
|
||||
try {
|
||||
window.localStorage.setItem("bitburnerSave", saveString);
|
||||
//console.log("Saved game to LocalStorage!");
|
||||
} catch(e) {
|
||||
if (e.code == 22) {
|
||||
createStatusText("Save failed for localStorage! Check console(F12)");
|
||||
@ -482,7 +481,7 @@ function loadImportedGame(saveObj, saveString) {
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
|
||||
|
||||
/* Process offline progress */
|
||||
// Process offline progress
|
||||
var offlineProductionFromScripts = loadAllRunningScripts(); // This also takes care of offline production for those scripts
|
||||
if (Player.isWorking) {
|
||||
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
|
||||
@ -624,8 +623,6 @@ BitburnerSaveObject.fromJSON = function(value) {
|
||||
|
||||
Reviver.constructors.BitburnerSaveObject = BitburnerSaveObject;
|
||||
|
||||
//Import game
|
||||
|
||||
function openImportFileHandler(evt) {
|
||||
var file = evt.target.files[0];
|
||||
if (!file) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Player } from "./Player";
|
||||
import { BitNodes } from "./BitNode/BitNode";
|
||||
|
||||
/* SourceFile.js */
|
||||
// Each SourceFile corresponds to a BitNode with the same number
|
||||
function SourceFile(number, info="") {
|
||||
var bitnodeKey = "BitNode" + number;
|
||||
|
@ -279,7 +279,6 @@ $(document).keydown(function(event) {
|
||||
}
|
||||
|
||||
// TODO AFTER THIS:
|
||||
|
||||
// alt + d deletes word after cursor
|
||||
// ^w deletes word before cursor
|
||||
// ^k clears line after cursor
|
||||
@ -1809,7 +1808,6 @@ let Terminal = {
|
||||
}
|
||||
|
||||
var dashes = titleDashes + "--";
|
||||
//var dashes = Array(d * 2 + 1).join("-");
|
||||
var c = "NO";
|
||||
if (s.hasAdminRights) {c = "YES";}
|
||||
post(`${dashes}Root Access: ${c}${!isHacknet ? ", Required hacking skill: " + s.requiredHackingSkill : ""}`);
|
||||
|
124
src/engine.jsx
124
src/engine.jsx
@ -155,7 +155,8 @@ import "../css/grid.min.css";
|
||||
import "../css/dev-menu.css";
|
||||
|
||||
|
||||
/* Shortcuts to navigate through the game
|
||||
/**
|
||||
* Shortcuts to navigate through the game
|
||||
* Alt-t - Terminal
|
||||
* Alt-c - Character
|
||||
* Alt-e - Script editor
|
||||
@ -242,6 +243,7 @@ const Engine = {
|
||||
},
|
||||
|
||||
// Display objects
|
||||
// TODO-Refactor this into its own component
|
||||
Display: {
|
||||
// Progress bar
|
||||
progress: null,
|
||||
@ -279,7 +281,6 @@ const Engine = {
|
||||
_lastUpdate: new Date().getTime(),
|
||||
_idleSpeed: 200, // Speed (in ms) at which the main loop is updated
|
||||
|
||||
/* Load content when a main menu button is clicked */
|
||||
loadTerminalContent: function() {
|
||||
Engine.hideAllContent();
|
||||
Engine.Display.terminalContent.style.display = "block";
|
||||
@ -425,7 +426,6 @@ const Engine = {
|
||||
loadWorkInProgressContent: function() {
|
||||
Engine.hideAllContent();
|
||||
var mainMenu = document.getElementById("mainmenu-container");
|
||||
//mainMenu.style.visibility = "hidden";
|
||||
mainMenu.style.visibility = "hidden";
|
||||
Engine.Display.workInProgressContent.style.display = "block";
|
||||
routing.navigateTo(Page.WorkInProgress);
|
||||
@ -602,11 +602,12 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
/* Display character info */
|
||||
/// Display character info
|
||||
updateCharacterInfo: function() {
|
||||
displayCharacterInfo(Engine.Display.characterInfo, Player);
|
||||
},
|
||||
|
||||
// TODO Refactor this into Faction implementation
|
||||
displayFactionsInfo: function() {
|
||||
removeChildrenFromElement(Engine.Display.factionsContent);
|
||||
|
||||
@ -685,7 +686,7 @@ const Engine = {
|
||||
Engine.Display.factionsContent.appendChild(invitationsList);
|
||||
},
|
||||
|
||||
/* Main Event Loop */
|
||||
// Main Game Loop
|
||||
idleTimer: function() {
|
||||
// Get time difference
|
||||
var _thisUpdate = new Date().getTime();
|
||||
@ -760,7 +761,6 @@ const Engine = {
|
||||
// Corporation
|
||||
if (Player.corporation instanceof Corporation) {
|
||||
// Stores cycles in a "buffer". Processed separately using Engine Counters
|
||||
//This is to avoid constant DOM redraws when Corporation is catching up
|
||||
Player.corporation.storeCycles(numCycles);
|
||||
}
|
||||
|
||||
@ -798,22 +798,25 @@ const Engine = {
|
||||
processHacknetEarnings(numCycles);
|
||||
},
|
||||
|
||||
//Counters for the main event loop. Represent the number of game cycles are required
|
||||
//for something to happen.
|
||||
/**
|
||||
* Counters for the main event loop. Represent the number of game cycles that
|
||||
* are required for something to happen. These counters are in game cycles,
|
||||
* which is once every 200ms
|
||||
*/
|
||||
Counters: {
|
||||
autoSaveCounter: 300, //Autosave every minute
|
||||
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
||||
autoSaveCounter: 300,
|
||||
updateSkillLevelsCounter: 10,
|
||||
updateDisplays: 3,
|
||||
updateDisplaysMed: 9,
|
||||
updateDisplaysLong: 15,
|
||||
updateActiveScriptsDisplay: 5,
|
||||
createProgramNotifications: 10, //Checks whether any programs can be created and notifies
|
||||
checkFactionInvitations: 100, //Check whether you qualify for any faction invitations
|
||||
createProgramNotifications: 10,
|
||||
checkFactionInvitations: 100,
|
||||
passiveFactionGrowth: 600,
|
||||
messages: 150,
|
||||
sCr: 1500,
|
||||
mechanicProcess: 5, // Processes certain mechanics (Corporation, Bladeburner)
|
||||
contractGeneration: 3000 //Generate Coding Contracts
|
||||
contractGeneration: 3000, // Generate Coding Contracts
|
||||
},
|
||||
|
||||
decrementAllCounters: function(numCycles = 1) {
|
||||
@ -824,8 +827,10 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
//Checks if any counters are 0 and if they are, executes whatever
|
||||
//is necessary and then resets the counter
|
||||
/**
|
||||
* Checks if any counters are 0. If they are, executes whatever
|
||||
* is necessary and then resets the counter
|
||||
*/
|
||||
checkCounters: function() {
|
||||
if (Engine.Counters.autoSaveCounter <= 0) {
|
||||
if (Settings.AutosaveInterval == null) {
|
||||
@ -962,7 +967,8 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
|
||||
// Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly
|
||||
// TODO Refactor this into Terminal module
|
||||
_totalActionTime: 0,
|
||||
_actionTimeLeft: 0,
|
||||
_actionTimeStr: "Time left: ",
|
||||
@ -997,8 +1003,10 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
//Used when initializing a game
|
||||
//elems should be an array of all DOM elements under the header
|
||||
/**
|
||||
* Collapses a main menu header. Used when initializing the game.
|
||||
* @param elems {HTMLElement[]} Elements under header
|
||||
*/
|
||||
closeMainMenuHeader: function(elems) {
|
||||
for (var i = 0; i < elems.length; ++i) {
|
||||
elems[i].style.maxHeight = null;
|
||||
@ -1007,8 +1015,10 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
//Used when initializing the game
|
||||
//elems should be an array of all DOM elements under the header
|
||||
/**
|
||||
* Expands a main menu header. Used when initializing the game.
|
||||
* @param elems {HTMLElement[]} Elements under header
|
||||
*/
|
||||
openMainMenuHeader: function(elems) {
|
||||
for (var i = 0; i < elems.length; ++i) {
|
||||
elems[i].style.maxHeight = elems[i].scrollHeight + "px";
|
||||
@ -1016,10 +1026,12 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
//Used in game when clicking on a main menu header (NOT FOR INITIALIZATION)
|
||||
//open is a boolean specifying whether its being opened or closed
|
||||
//elems is an array of DOM elements for main menu tabs (li)
|
||||
//links is an array of DOM elements for main menu links (a)
|
||||
/**
|
||||
* Used in game when clicking on a main menu header (NOT used for initialization)
|
||||
* @param open {boolean} Whether header is being opened or closed
|
||||
* @param elems {HTMLElement[]} li Elements under header
|
||||
* @param links {HTMLElement[]} a elements under header
|
||||
*/
|
||||
toggleMainMenuHeader: function(open, elems, links) {
|
||||
for (var i = 0; i < elems.length; ++i) {
|
||||
if (open) {
|
||||
@ -1046,28 +1058,27 @@ const Engine = {
|
||||
|
||||
load: function(saveString) {
|
||||
// Initialize main menu accordion panels to all start as "open"
|
||||
var terminal = document.getElementById("terminal-tab");
|
||||
var createScript = document.getElementById("create-script-tab");
|
||||
var activeScripts = document.getElementById("active-scripts-tab");
|
||||
var createProgram = document.getElementById("create-program-tab");
|
||||
var stats = document.getElementById("stats-tab");
|
||||
var factions = document.getElementById("factions-tab");
|
||||
var augmentations = document.getElementById("augmentations-tab");
|
||||
var hacknetnodes = document.getElementById("hacknet-nodes-tab");
|
||||
var city = document.getElementById("city-tab");
|
||||
var travel = document.getElementById("travel-tab");
|
||||
var job = document.getElementById("job-tab");
|
||||
var stockmarket = document.getElementById("stock-market-tab");
|
||||
var bladeburner = document.getElementById("bladeburner-tab");
|
||||
var corp = document.getElementById("corporation-tab");
|
||||
var gang = document.getElementById("gang-tab");
|
||||
var tutorial = document.getElementById("tutorial-tab");
|
||||
var options = document.getElementById("options-tab");
|
||||
var dev = document.getElementById("dev-tab");
|
||||
const terminal = document.getElementById("terminal-tab");
|
||||
const createScript = document.getElementById("create-script-tab");
|
||||
const activeScripts = document.getElementById("active-scripts-tab");
|
||||
const createProgram = document.getElementById("create-program-tab");
|
||||
const stats = document.getElementById("stats-tab");
|
||||
const factions = document.getElementById("factions-tab");
|
||||
const augmentations = document.getElementById("augmentations-tab");
|
||||
const hacknetnodes = document.getElementById("hacknet-nodes-tab");
|
||||
const city = document.getElementById("city-tab");
|
||||
const travel = document.getElementById("travel-tab");
|
||||
const job = document.getElementById("job-tab");
|
||||
const stockmarket = document.getElementById("stock-market-tab");
|
||||
const bladeburner = document.getElementById("bladeburner-tab");
|
||||
const corp = document.getElementById("corporation-tab");
|
||||
const gang = document.getElementById("gang-tab");
|
||||
const tutorial = document.getElementById("tutorial-tab");
|
||||
const options = document.getElementById("options-tab");
|
||||
const dev = document.getElementById("dev-tab");
|
||||
|
||||
// Load game from save or create new game
|
||||
if (loadGame(saveString)) {
|
||||
console.log("Loaded game from save");
|
||||
initBitNodes();
|
||||
initBitNodeMultipliers(Player);
|
||||
initSourceFiles();
|
||||
@ -1088,7 +1099,7 @@ const Engine = {
|
||||
var lastUpdate = Player.lastUpdate;
|
||||
var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
|
||||
|
||||
/* Process offline progress */
|
||||
// Process offline progress
|
||||
var offlineProductionFromScripts = loadAllRunningScripts(); // This also takes care of offline production for those scripts
|
||||
if (Player.isWorking) {
|
||||
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
|
||||
@ -1210,14 +1221,13 @@ const Engine = {
|
||||
initSingularitySFFlags();
|
||||
|
||||
// Open main menu accordions for new game
|
||||
//Main menu accordions
|
||||
var hackingHdr = document.getElementById("hacking-menu-header");
|
||||
const hackingHdr = document.getElementById("hacking-menu-header");
|
||||
hackingHdr.classList.toggle("opened");
|
||||
var characterHdr = document.getElementById("character-menu-header");
|
||||
const characterHdr = document.getElementById("character-menu-header");
|
||||
characterHdr.classList.toggle("opened");
|
||||
var worldHdr = document.getElementById("world-menu-header");
|
||||
const worldHdr = document.getElementById("world-menu-header");
|
||||
worldHdr.classList.toggle("opened");
|
||||
var helpHdr = document.getElementById("help-menu-header");
|
||||
const helpHdr = document.getElementById("help-menu-header");
|
||||
helpHdr.classList.toggle("opened");
|
||||
|
||||
// Hide tabs that wont be revealed until later
|
||||
@ -1323,7 +1333,7 @@ const Engine = {
|
||||
}
|
||||
},
|
||||
|
||||
/* Initialization */
|
||||
// Initialization
|
||||
init: function() {
|
||||
// Import game link
|
||||
document.getElementById("import-game-link").onclick = function() {
|
||||
@ -1494,7 +1504,7 @@ const Engine = {
|
||||
Engine.loadWorkInProgressContent();
|
||||
}
|
||||
|
||||
//character overview screen
|
||||
// Character overview screen
|
||||
document.getElementById("character-overview-container").style.display = "block";
|
||||
|
||||
// Remove classes from links (they might be set from tutorial)
|
||||
@ -1565,7 +1575,7 @@ const Engine = {
|
||||
// Run main loop
|
||||
Engine.idleTimer();
|
||||
|
||||
//Scripts
|
||||
// Script-processing loop
|
||||
runScriptsLoop();
|
||||
}
|
||||
};
|
||||
@ -1576,9 +1586,11 @@ window.onload = function() {
|
||||
return Engine.load(null); // Will try to load from localstorage
|
||||
}
|
||||
|
||||
//DB is called bitburnerSave
|
||||
//Object store is called savestring
|
||||
//key for the Object store is called save
|
||||
/**
|
||||
* DB is called bitburnerSave
|
||||
* Object store is called savestring
|
||||
* key for the Object store is called save
|
||||
*/
|
||||
indexedDbRequest = window.indexedDB.open("bitburnerSave", 1);
|
||||
|
||||
indexedDbRequest.onerror = function(e) {
|
||||
@ -1599,7 +1611,7 @@ window.onload = function() {
|
||||
}
|
||||
|
||||
request.onsuccess = function(e) {
|
||||
Engine.load(request.result); //Is this right?
|
||||
Engine.load(request.result);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user