0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g 0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g Level: RAM: Cores: Node name: Production: " + mat.name + ": " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qty, 3) +
- "(" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalGain, 3) + "/s)" +
- "Buy: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.buy, 3) +
- "/s MP: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.bCost, 2) +
+ var innerTxt = " " + mat.name + ": " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qty, 3) +
+ "(" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalGain, 3) + "/s)" +
+ "Buy: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.buy, 3) +
+ "/s MP: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.bCost, 2) +
"Market Price: The price you would pay if " +
"you were to buy this material on the market Quality: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qlt, 2) +
+ " Quality: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qlt, 2) +
"The quality of your material. Higher quality " +
"will lead to more sales " + product.name + ": " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][0], 3) + //Quantity
- "(" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalGain, 3) + "/s)" +
- "Prod: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][1], 3) + "/s Rating: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.rat, 3) +
- "Quality: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.qlt, 3) + " " + product.name + ": " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][0], 3) + //Quantity
+ "(" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalGain, 3) + "/s)" +
+ "Prod: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][1], 3) + "/s Rating: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.rat, 3) +
+ "Quality: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.qlt, 3) + " Est. Production Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(product.pCost / ProductProductionCostRatio).format("$0.000a") +
"An estimate of the material cost it takes to create this Product. Advertising Multiplier: x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalAdvertisingFac, 3) +
+ " Advertising Multiplier: x" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(totalAdvertisingFac, 3) +
"Total multiplier for this industry's sales due to its awareness and popularity Level: RAM: Cores: Node name: Production:
" + e);
- workerScripts[i].env.stopFlag = true;
- continue;
- }
- workerScripts[i].running = true;
- p = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["evaluate"])(ast, workerScripts[i]);
- }
-
- //Once the code finishes (either resolved or rejected, doesnt matter), set its
- //running status to false
- p.then(function(w) {
- console.log("Stopping script " + w.name + " because it finished running naturally");
- w.running = false;
- w.env.stopFlag = true;
- w.scriptRef.log("Script finished running");
- }).catch(function(w) {
- if (w instanceof Error) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else if (w.constructor === Array && w.length === 2 && w[0] === "RETURNSTATEMENT") {
- //Script ends with a return statement
- console.log("Script returning with value: " + w[1]);
- //TODO maybe do something with this in the future
- return;
- } else if (w instanceof WorkerScript) {
- if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w.errorMessage)) {
- var errorTextArray = w.errorMessage.split("|");
- if (errorTextArray.length != 4) {
- console.log("ERROR: Something wrong with Error text in evaluator...");
- console.log("Error text: " + errorText);
- return;
- }
- var serverIp = errorTextArray[1];
- var scriptName = errorTextArray[2];
- var errorMsg = errorTextArray[3];
-
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime error:
Server Ip: " + serverIp +
- "
Script name: " + scriptName +
- "
Args:" + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(w.args) + "
" + errorMsg);
- w.scriptRef.log("Script crashed with runtime error");
- } else {
- w.scriptRef.log("Script killed");
- }
- w.running = false;
- w.env.stopFlag = true;
-
- } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
- console.log(w);
- }
- });
- }
- }
-
- setTimeout(runScriptsLoop, 6000);
-}
-
-//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
-//all of its promises recursively, and when it does so it will no longer be running.
-//The runScriptsLoop() will then delete the script from worker scripts
-function killWorkerScript(runningScriptObj, serverIp) {
- for (var i = 0; i < workerScripts.length; i++) {
- if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
- workerScripts[i].env.stopFlag = true;
- Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(workerScripts[i]);
- //Recursively kill all functions
- var curr = workerScripts[i];
- while (curr.fnWorker) {
- curr.fnWorker.env.stopFlag = true;
- Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(curr.fnWorker);
- curr = curr.fnWorker;
- }
- return true;
- }
- }
- return false;
-}
-
-//Queues a script to be run
-function addWorkerScript(runningScriptObj, server) {
- var filename = runningScriptObj.filename;
-
- //Update server's ram usage
- var threads = 1;
- if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
- threads = runningScriptObj.threads;
- } else {
- runningScriptObj.threads = 1;
- }
- var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
- * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
- var ramAvailable = server.maxRam - server.ramUsed;
- if (ramUsage > ramAvailable) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
- "the game and the script's RAM usage increased (either because of an update to the game or " +
- "your changes to the script.)");
+ //Theme
+ if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
+ console.log("ERROR: Cannot find Theme Settings");
return;
}
- server.ramUsed += ramUsage;
-
- //Create the WorkerScript
- var s = new WorkerScript(runningScriptObj);
- s.serverIp = server.ip;
- s.ramUsage = ramUsage;
-
- //Add the WorkerScript to the Active Scripts list
- Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["addActiveScriptsItem"])(s);
-
- //Add the WorkerScript
- workerScripts.push(s);
- return;
-}
-
-//Updates the online running time stat of all running scripts
-function updateOnlineScriptTimes(numCycles = 1) {
- var time = (numCycles * _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
- for (var i = 0; i < workerScripts.length; ++i) {
- workerScripts[i].scriptRef.onlineRunningTime += time;
- }
-}
-
-
-
-
-/***/ }),
-/* 20 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockMarket", function() { return StockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockSymbols", function() { return StockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolToStockMap", function() { return SymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockSymbols", function() { return initStockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockMarket", function() { return initStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSymbolToStockMap", function() { return initSymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stockMarketCycle", function() { return stockMarketCycle; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyStock", function() { return buyStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellStock", function() { return sellStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shortStock", function() { return shortStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellShort", function() { return sellShort; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPrices", function() { return updateStockPrices; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayStockMarketContent", function() { return displayStockMarketContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockTicker", function() { return updateStockTicker; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPlayerPosition", function() { return updateStockPlayerPosition; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadStockMarket", function() { return loadStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setStockMarketContentCreated", function() { return setStockMarketContentCreated; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placeOrder", function() { return placeOrder; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOrder", function() { return cancelOrder; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Order", function() { return Order; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OrderTypes", function() { return OrderTypes; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionTypes", function() { return PositionTypes; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(30);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(9);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(12);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-let StockPriceCap = 1e9; //Put a limit on how high a price can go
-
-function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
- this.symbol = symbol;
- this.name = name;
- this.price = initPrice;
-
- this.playerShares = 0;
- this.playerAvgPx = 0;
- this.playerShortShares = 0;
- this.playerAvgShortPx = 0;
- this.mv = mv;
- this.b = b;
- this.otlkMag = otlkMag;
-
- this.posTxtEl = null;
-}
-
-Stock.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Stock", this);
-}
-
-Stock.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Stock, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Stock = Stock;
-
-var OrderTypes = {
- LimitBuy: "Limit Buy Order",
- LimitSell: "Limit Sell Order",
- StopBuy: "Stop Buy Order",
- StopSell: "Stop Sell Order"
-}
-
-var PositionTypes = {
- Long: "L",
- Short: "S"
-}
-
-function placeOrder(stock, shares, price, type, position, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- var order = new Order(stock, shares, price, type, position);
- if (isNaN(shares) || isNaN(price)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- }
- return false;
- }
- if (StockMarket["Orders"] == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- }
- StockMarket["Orders"][stock.symbol].push(order);
- //Process to see if it should be executed immediately
- processOrders(order.stock, order.type, order.pos);
- updateStockOrderList(order.stock);
- return true;
-}
-
-//Returns true if successfully cancels an order, false otherwise
-function cancelOrder(params, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (StockMarket["Orders"] == null) {return false;}
- if (params.order && params.order instanceof Order) {
- var order = params.order;
- //An 'Order' object is passed in
- var stockOrders = StockMarket["Orders"][order.stock.symbol];
- for (var i = 0; i < stockOrders.length; ++i) {
- if (order == stockOrders[i]) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- return true;
- }
- }
- return false;
- } else if (params.stock && params.shares && params.price && params.type &&
- params.pos && params.stock instanceof Stock) {
- //Order properties are passed in. Need to look for the order
- var stockOrders = StockMarket["Orders"][params.stock.symbol];
- var orderTxt = params.stock.symbol + " - " + params.shares + " @ " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(params.price).format('$0.000a');
- for (var i = 0; i < stockOrders.length; ++i) {
- var order = stockOrders[i];
- if (params.shares === order.shares &&
- params.price === order.price &&
- params.type === order.type &&
- params.pos === order.pos) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- if (tixApi) {
- workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt);
- }
- return true;
- }
- }
- if (tixApi) {
- workerScript.scriptRef.log("Failed to cancel order: " + orderTxt);
- }
- return false;
- }
- return false;
-}
-
-function executeOrder(order) {
- var stock = order.stock;
- var orderBook = StockMarket["Orders"];
- var stockOrders = orderBook[stock.symbol];
- var res = true;
- console.log("Executing the following order:");
- console.log(order);
- switch (order.type) {
- case OrderTypes.LimitBuy:
- case OrderTypes.StopBuy:
- if (order.pos === PositionTypes.Long) {
- res = buyStock(order.stock, order.shares) && res;
- } else if (order.pos === PositionTypes.Short) {
- res = shortStock(order.stock, order.shares) && res;
- }
- break;
- case OrderTypes.LimitSell:
- case OrderTypes.StopSell:
- if (order.pos === PositionTypes.Long) {
- res = sellStock(order.stock, order.shares) && res;
- } else if (order.pos === PositionTypes.Short) {
- res = sellShort(order.stock, order.shares) && res;
- }
- break;
- }
- if (res) {
- //Remove order from order book
- for (var i = 0; i < stockOrders.length; ++i) {
- if (order == stockOrders[i]) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- return;
- }
- }
- console.log("ERROR: Could not find the following Order in Order Book: ");
- console.log(order);
- } else {
- console.log("Order failed to execute");
- }
-}
-
-function Order(stock, shares, price, type, position) {
- this.stock = stock;
- this.shares = shares;
- this.price = price;
- this.type = type;
- this.pos = position;
-}
-
-Order.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Order", this);
-}
-
-Order.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Order, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Order = Order;
-
-let StockMarket = {} //Full name to stock object
-let StockSymbols = {} //Full name to symbol
-let SymbolToStockMap = {}; //Symbol to Stock object
-
-function loadStockMarket(saveString) {
- if (saveString === "") {
- StockMarket = {};
- } else {
- StockMarket = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
- }
-}
-
-function initStockSymbols() {
- //Stocks for companies at which you can work
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff] = "FNS";
-
- //Stocks for other companies
- StockSymbols["Sigma Cosmetics"] = "SGC";
- StockSymbols["Joes Guns"] = "JGN";
- StockSymbols["Catalyst Ventures"] = "CTYS";
- StockSymbols["Microdyne Technologies"] = "MDYN";
- StockSymbols["Titan Laboratories"] = "TITN";
-}
-
-function initStockMarket() {
- for (var stk in StockMarket) {
- if (StockMarket.hasOwnProperty(stk)) {
- delete StockMarket[stk];
- }
- }
-
- var ecorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
- var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[ecorp] = ecorpStk;
-
- var megacorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
- var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(25000, 33000));
- StockMarket[megacorp] = megacorpStk;
-
- var blade = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
- var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 22000));
- StockMarket[blade] = bladeStk;
-
- var clarke = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
- var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
- StockMarket[clarke] = clarkeStk;
-
- var omnitek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
- var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(35000, 40000));
- StockMarket[omnitek] = omnitekStk;
-
- var foursigma = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
- var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(60000, 70000));
- StockMarket[foursigma] = foursigmaStk;
-
- var kuaigong = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
- var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 24000));
- StockMarket[kuaigong] = kuaigongStk;
-
- var fulcrum = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
- var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(30000, 35000));
- StockMarket[fulcrum] = fulcrumStk;
-
- var storm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
- var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(21000, 24000));
- StockMarket[storm] = stormStk;
-
- var defcomm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
- var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
- StockMarket[defcomm] = defcommStk;
-
- var helios = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
- var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(12000, 16000));
- StockMarket[helios] = heliosStk;
-
- var vitalife = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
- var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 12000));
- StockMarket[vitalife] = vitalifeStk;
-
- var icarus = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
- var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(16000, 20000));
- StockMarket[icarus] = icarusStk;
-
- var universalenergy = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
- var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[universalenergy] = universalenergyStk;
-
- var aerocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
- var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
- StockMarket[aerocorp] = aerocorpStk;
-
- var omnia = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
- var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(9000, 12000));
- StockMarket[omnia] = omniaStk;
-
- var solaris = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
- var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[solaris] = solarisStk;
-
- var globalpharm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
- var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[globalpharm] = globalpharmStk;
-
- var nova = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
- var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[nova] = novaStk;
-
- var watchdog = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
- var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[watchdog] = watchdogStk;
-
- var lexocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
- var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[lexocorp] = lexocorpStk;
-
- var rho = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
- var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
- StockMarket[rho] = rhoStk;
-
- var alpha = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
- var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[alpha] = alphaStk;
-
- var syscore = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
- var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(4000, 7000))
- StockMarket[syscore] = syscoreStk;
-
- var computek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
- var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 5000));
- StockMarket[computek] = computekStk;
-
- var netlink = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
- var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 4000));
- StockMarket[netlink] = netlinkStk;
-
- var omega = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
- var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
- StockMarket[omega] = omegaStk;
-
- var fns = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
- var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(1000, 4000));
- StockMarket[fns] = fnsStk;
-
- var sigmacosm = "Sigma Cosmetics";
- var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 3000));
- StockMarket[sigmacosm] = sigmacosmStk;
-
- var joesguns = "Joes Guns";
- var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
- StockMarket[joesguns] = joesgunsStk;
-
- var catalyst = "Catalyst Ventures";
- var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
- StockMarket[catalyst] = catalystStk;
-
- var microdyne = "Microdyne Technologies";
- var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[microdyne] = microdyneStk;
-
- var titanlabs = "Titan Laboratories";
- var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
- StockMarket[titanlabs] = titanlabsStk;
-
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
-}
-
-function initSymbolToStockMap() {
- for (var name in StockSymbols) {
- if (StockSymbols.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (stock == null) {
- console.log("ERROR finding stock");
- continue;
- }
- var symbol = StockSymbols[name];
- SymbolToStockMap[symbol] = stock;
- }
- }
-}
-
-function stockMarketCycle() {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- var thresh = 0.6;
- if (stock.b) {thresh = 0.4;}
- if (Math.random() < thresh) {
- stock.b = !stock.b;
- }
- }
- }
-}
-
-//Returns true if successful, false otherwise
-function buyStock(stock, shares) {
- if (stock == null || shares < 0 || isNaN(shares)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
- return false;
- }
- shares = Math.round(shares);
- if (shares == 0) {return false;}
-
- var totalPrice = stock.price * shares;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this. You need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2).toString() + ".");
- return false;
- }
-
- var origTotal = stock.playerShares * stock.playerAvgPx;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShares += shares;
- stock.playerAvgPx = newTotal / stock.playerShares;
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellStock(stock, shares) {
- if (shares == 0) {return false;}
- if (stock == null || shares < 0 || isNaN(shares)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell stock. This may be a bug, contact developer");
- return false;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShares) {shares = stock.playerShares;}
- if (shares === 0) {return false;}
- var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(gains);
- stock.playerShares -= shares;
- if (stock.playerShares == 0) {
- stock.playerAvgPx = 0;
- }
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
- "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(gains, 2));
- return true;
-}
-
-//Returns true if successful and false otherwise
-function shortStock(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (stock == null || isNaN(shares) || shares < 0) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to initiate a short position in a stock. This is probably " +
- "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
- }
- return false;
- }
- shares = Math.round(shares);
- if (shares === 0) {return false;}
-
- var totalPrice = stock.price * shares;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " +
- "money to purchase this short position. You need " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)'));
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + ".");
- }
-
- return false;
- }
-
- var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShortShares += shares;
- stock.playerAvgShortPx = newTotal / stock.playerShortShares;
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
- workerScript.scriptRef.log("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. Paid " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)') + " in commission fees.");
- }
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
- }
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellShort(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (stock == null || isNaN(shares) || shares < 0) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell a short position in a stock. This is probably " +
- "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
- }
- return false;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}
- if (shares === 0) {return false;}
-
- var origCost = shares * stock.playerAvgShortPx;
- var profit = ((stock.playerAvgShortPx - stock.price) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
- if (isNaN(profit)) {profit = 0;}
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(origCost + profit);
- if (tixApi) {
- workerScript.scriptRef.onlineMoneyMade += profit;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].scriptProdSinceLastAug += profit;
- }
-
- stock.playerShortShares -= shares;
- if (stock.playerShortShares === 0) {
- stock.playerAvgShortPx = 0;
- }
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
- workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
- "a total of " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(origCost + profit).format('($0.000a)'));
- }
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold your short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
- "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(origCost + profit, 2));
- }
-
- return true;
-}
-
-function updateStockPrices() {
- var v = Math.random();
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- var av = (v * stock.mv) / 100;
- if (isNaN(av)) {av = .02;}
-
- var chc = 50;
- if (stock.b) {
- chc = (chc + stock.otlkMag)/100;
- if (isNaN(chc)) {chc = 0.5;}
- } else {
- chc = (chc - stock.otlkMag)/100;
- if (isNaN(chc)) {chc = 0.5;}
- }
- if (stock.price >= StockPriceCap) {
- chc = -1; //Limit on stock price
- stock.b = false;
- }
-
- var c = Math.random();
- if (c < chc) {
- stock.price *= (1 + av);
- processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);
- processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);
- processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);
- processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
- updateStockTicker(stock, true);
- }
- } else {
- stock.price /= (1 + av);
- processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);
- processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);
- processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);
- processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
- updateStockTicker(stock, false);
- }
- }
-
- var otlkMagChange = stock.otlkMag * av;
- if (stock.otlkMag <= 0.1) {
- otlkMagChange = 1;
- }
- if (c < 0.5) {
- stock.otlkMag += otlkMagChange;
- } else {
- stock.otlkMag -= otlkMagChange;
- }
- if (stock.otlkMag < 0) {
- stock.otlkMag *= -1;
- stock.b = !stock.b;
- }
-
- }
- }
-}
-
-//Checks and triggers any orders for the specified stock
-function processOrders(stock, orderType, posType) {
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- return; //Newly created, so no orders to process
- }
- var stockOrders = orderBook[stock.symbol];
- if (stockOrders == null || !(stockOrders.constructor === Array)) {
- console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()");
- stockOrders = [];
- return;
- }
- for (var i = 0; i < stockOrders.length; ++i) {
- var order = stockOrders[i];
- if (order.type === orderType && order.pos === posType) {
- switch(order.type) {
- case OrderTypes.LimitBuy:
- if (order.pos === PositionTypes.Long && stock.price <= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.LimitSell:
- if (order.pos === PositionTypes.Long && stock.price >= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.StopBuy:
- if (order.pos === PositionTypes.Long && stock.price >= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.StopSell:
- if (order.pos === PositionTypes.Long && stock.price <= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- default:
- console.log("Invalid order type: " + order.type);
- return;
- }
- }
- }
-}
-
-function setStockMarketContentCreated(b) {
- stockMarketContentCreated = b;
-}
-
-var stockMarketContentCreated = false;
-var stockMarketPortfolioMode = false;
-var COMM = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
-function displayStockMarketContent() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = false;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = false;}
-
- //Purchase WSE Account button
- var wseAccountButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-account");
- wseAccountButton.innerText = "Buy WSE Account - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost, 2).toString();
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost)) {
- wseAccountButton.setAttribute("class", "a-link-button");
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount){
- wseAccountButton.innerText = "WSE Account - Purchased";
- wseAccountButton.setAttribute("class", "a-link-button-bought");
- } else {
- wseAccountButton.setAttribute("class", "a-link-button-inactive");
- }
- wseAccountButton.addEventListener("click", function() {
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = true;
- initStockMarket();
- initSymbolToStockMap();
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost);
- displayStockMarketContent();
- return false;
- });
-
- //Purchase TIX API Access account
- var tixApiAccessButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-tix-api");
- tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost, 2).toString();
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost)) {
- tixApiAccessButton.setAttribute("class", "a-link-button");
- } else if(_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess) {
- tixApiAccessButton.innerText = "Trade Information eXchange (TIX) API Access - Purchased"
- tixApiAccessButton.setAttribute("class", "a-link-button-bought");
- } else {
- tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
- }
- tixApiAccessButton.addEventListener("click", function() {
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = true;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost);
- displayStockMarketContent();
- return false;
- });
-
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
-
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- stockMarketContentCreated = false;
- while (stockList.firstChild) {
- stockList.removeChild(stockList.firstChild);
- }
- return;
- }
-
- //Create stock market content if you have an account
- if (!stockMarketContentCreated && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- console.log("Creating Stock Market UI");
- document.getElementById("stock-market-commission").innerHTML =
- "Commission Fees: Every transaction you make has a $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " commission fee.
" +
- "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
- "This means all your positions are lost, so make sure to sell your stocks before installing " +
- "Augmentations!";
-
- var investopediaButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-investopedia");
- investopediaButton.addEventListener("click", function() {
- var txt = "When making a transaction on the stock market, there are two " +
- "types of positions: Long and Short. A Long position is the typical " +
- "scenario where you buy a stock and earn a profit if the price of that " +
- "stock increases. Meanwhile, a Short position is the exact opposite. " +
- "In a Short position you purchase shares of a stock and earn a profit " +
- "if the price of that stock decreases. This is also called 'shorting' a stock.
" +
- "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.
" +
- "There are three different types of orders you can make to buy or sell " +
- "stocks on the exchange: Market Order, Limit Order, and Stop Order. " +
- "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " +
- "later on in the game.
" +
- "When you place a Market Order to buy or sell a stock, the order executes " +
- "immediately at whatever the current price of the stock is. For example " +
- "if you choose to short a stock with 5000 shares using a Market Order, " +
- "you immediately purchase those 5000 shares in a Short position at whatever " +
- "the current market price is for that stock.
" +
- "A Limit Order is an order that only executes under certain conditions. " +
- "A Limit Order is used to buy or sell a stock at a specified price or better. " +
- "For example, lets say you purchased a Long position of 100 shares of some stock " +
- "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " +
- "at $50 or better. The Limit Order will execute when the price of the stock reaches a " +
- "value of $50 or higher.
" +
- "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " +
- "at a specified price (before the price gets 'worse'). For example, lets say you purchased " +
- "a Short position of 100 shares of some stock at a price of $100 per share. " +
- "The current price of the stock is $80 (a profit of $20 per share). You can place a " +
- "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " +
- "This can be used to lock in your profits and limit any losses.
" +
- "Here is a summary of how each order works and when they execute:
" +
- "In a LONG Position:
" +
- "A Limit Order to buy will execute if the stock's price <= order's price
" +
- "A Limit Order to sell will execute if the stock's price >= order's price
" +
- "A Stop Order to buy will execute if the stock's price >= order's price
" +
- "A Stop Order to sell will execute if the stock's price <= order's price
" +
- "In a SHORT Position:
" +
- "A Limit Order to buy will execute if the stock's price >= order's price
" +
- "A Limit Order to sell will execute if the stock's price <= order's price
" +
- "A Stop Order to buy will execute if the stock's price <= order's price
" +
- "A Stop Order to sell will execute if the stock's price >= order's price.";
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])(txt);
- return false;
- });
-
- //Switch to Portfolio Mode Button
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
-
- //Expand/Collapse tickers buttons
- var expandBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-expand-tickers"),
- collapseBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-collapse-tickers"),
- stockList = document.getElementById("stock-market-list");
- if (expandBtn) {
- expandBtn.addEventListener("click", ()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (!tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
- if (collapseBtn) {
- collapseBtn.addEventListener("click",()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
-
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers(); //Clicking headers opens/closes panels
- stockMarketContentCreated = true;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- updateStockTicker(stock, null);
- updateStockOrderList(stock);
- }
- }
- }
-}
-
-//Displays only stocks you have position/order in
-function switchToPortfolioMode() {
- stockMarketPortfolioMode = true;
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
- "Displays all stocks on the WSE";
- modeBtn.addEventListener("click", switchToDisplayAllMode);
- }
- while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
-
- //Get Order book (create it if it hasn't been created)
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- }
-
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- var stockOrders = orderBook[stock.symbol];
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- stockOrders.length === 0) {continue;}
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers();
-}
-
-//Displays all stocks
-function switchToDisplayAllMode() {
- stockMarketPortfolioMode = false;
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
- while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers();
-}
-
-function createStockTicker(stock) {
- if (!(stock instanceof Stock)) {
- console.log("Invalid stock in createStockSticker()");
- return;
- }
- var tickerId = "stock-market-ticker-" + stock.symbol;
- var li = document.createElement("li"), hdr = document.createElement("button");
- hdr.classList.add("accordion-header");
- hdr.setAttribute("id", tickerId + "-hdr");
- hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price;
-
- //Div for entire panel
- var stockDiv = document.createElement("div");
- stockDiv.classList.add("accordion-panel");
- stockDiv.setAttribute("id", tickerId + "-panel");
-
- /* Create panel DOM */
- var qtyInput = document.createElement("input"),
- longShortSelect = document.createElement("select"),
- orderTypeSelect = document.createElement("select"),
- buyButton = document.createElement("span"),
- sellButton = document.createElement("span"),
- buyMaxButton = document.createElement("span"),
- sellAllButton = document.createElement("span"),
- positionTxt = document.createElement("p"),
- orderList = document.createElement("ul");
-
- qtyInput.classList.add("stock-market-input");
- qtyInput.placeholder = "Quantity (Shares)";
- qtyInput.setAttribute("id", tickerId + "-qty-input");
- qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " +
- " || (47Long Position: " +
- "Shares in the long position will increase " +
- "in value if the price of the corresponding stock increases
" +
- "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShares, 0) +
- "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgPx).format('$0.000a') +
- " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalCost).format('$0.000a') + ")" +
- "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(gains).format('$0.000a') +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(percentageGains*100, 2) + "%)
";
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 2)) {
- stock.posTxtEl.innerHTML +=
- "Short Position: " +
- "Shares in short position will increase " +
- "in value if the price of the corresponding stock decreases
" +
- "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShortShares, 0) +
- "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgShortPx).format('$0.000a') +
- " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortTotalCost).format('$0.000a') + ")" +
- "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortGains).format('$0.000a') +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shortPercentageGains*100, 2) + "%)" +
- "Orders:
";
- }
-
-}
-
-function updateStockOrderList(stock) {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
- var tickerId = "stock-market-ticker-" + stock.symbol;
- var orderList = document.getElementById(tickerId + "-order-list");
- if (orderList == null) {
- if (!stockMarketPortfolioMode) {console.log("ERROR: Could not find order list for " + stock.symbol);}
- return;
- }
-
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- console.log("ERROR: Could not find order book in stock market");
- return;
- }
- var stockOrders = orderBook[stock.symbol];
- if (stockOrders == null) {
- console.log("ERROR: Could not find orders for: " + stock.symbol);
- return;
- }
-
- if (stockMarketPortfolioMode) {
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
- StockMarket["Orders"][stock.symbol].length === 0) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-panel");
- return;
- } else {
- //If the ticker hasn't been created, create it (handles updating)
- //If it has been created, continue normally
- if (document.getElementById(tickerId + "-hdr") == null) {
- createStockTicker(stock);
- setStockTickerClickHandlers();
- return;
- }
- }
- }
-
- //Remove everything from list
- while (orderList.firstChild) {
- orderList.removeChild(orderList.firstChild);
- }
-
- for (var i = 0; i < stockOrders.length; ++i) {
- (function() {
- var order = stockOrders[i];
- var li = document.createElement("li");
- li.style.padding = "4px";
- var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position");
- li.style.color = "white";
- li.innerText = order.type + " - " + posText + " - " +
- order.shares + " @ $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(order.price, 2);
-
- var cancelButton = document.createElement("span");
- cancelButton.classList.add("stock-market-order-cancel-btn");
- cancelButton.classList.add("a-link-button");
- cancelButton.innerHTML = "Cancel Order";
- cancelButton.addEventListener("click", function() {
- cancelOrder({order: order}, null);
- return false;
- });
- li.appendChild(cancelButton);
- orderList.appendChild(li);
- }());
-
+ if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) &&
+ /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) &&
+ /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) {
+ document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor);
+ document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor);
+ document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor);
}
}
@@ -17231,7 +14398,10 @@ function updateStockOrderList(stock) {
/***/ }),
-/* 21 */
+/* 18 */
+/*!*************************!*\
+ !*** ./src/Terminal.js ***!
+ \*************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -17240,36 +14410,37 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; });
-/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
-/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(50);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(32);
-/* harmony import */ var _HelpText__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(69);
+/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 25);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 20);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 59);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _HelpText__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText */ 67);
/* harmony import */ var _HelpText__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_HelpText__WEBPACK_IMPORTED_MODULE_6__);
-/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(24);
-/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(52);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(28);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(6);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(19);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(13);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 49);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(37);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(25);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(8);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(22);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(18);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(43);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./RedPill.js */ 34);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./TextFile */ 58);
/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_TextFile__WEBPACK_IMPORTED_MODULE_19__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(2);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(1);
-/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(49);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(12);
-/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(122);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/LogBox.js */ 47);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! jszip */ 122);
/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_24__);
-/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(121);
+/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! file-saver */ 121);
/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_25__);
@@ -17568,7 +14739,7 @@ $(document).keyup(function(e) {
// index - index of argument that is being "tab completed". By default is 0, the first argument
function tabCompletion(command, arg, allPossibilities, index=0) {
if (!(allPossibilities.constructor === Array)) {return;}
- if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["containsAllStrings"])(allPossibilities)) {return;}
+ if (!Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["containsAllStrings"])(allPossibilities)) {return;}
if (!command.startsWith("./")) {
command = command.toLowerCase();
@@ -17603,7 +14774,7 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
document.getElementById("terminal-input-text-box").value = val;
document.getElementById("terminal-input-text-box").focus();
} else {
- var longestStartSubstr = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["longestCommonStart"])(allPossibilities);
+ var longestStartSubstr = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["longestCommonStart"])(allPossibilities);
//If the longest common starting substring of remaining possibilities is the same
//as whatevers already in terminal, just list all possible options. Otherwise,
//change the input in the terminal to the longest common starting substr
@@ -17738,7 +14909,7 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
allPos.push(currServ.programs[i]);
}
for (var i = 0; i < currServ.messages.length; ++i) {
- if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["isString"])(currServ.messages[i]) &&
+ if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["isString"])(currServ.messages[i]) &&
currServ.messages[i].endsWith(".lit")) {
allPos.push(currServ.messages[i]);
}
@@ -17943,11 +15114,11 @@ let Terminal = {
server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount);
- post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP");
+ post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP");
} else { //Failure
//Player only gains 25% exp for failure? TODO Can change this later to balance
_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].gainHackingExp(expGainedOnFailure)
- post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP");
+ post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP");
}
}
@@ -17969,10 +15140,10 @@ let Terminal = {
else {rootAccess = "NO";}
post("Root Access: " + rootAccess);
post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().requiredHackingSkill);
- post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().hackDifficulty, 5), 3));
- post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].calculateHackingChance() * 100, 5), 2) + "%");
- post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].calculateHackingTime(), 5), 3) + " seconds");
- post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().moneyAvailable, 5), 2));
+ post("Estimated server security level: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().hackDifficulty, 5), 3));
+ post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].calculateHackingChance() * 100, 5), 2) + "%");
+ post("Estimated time to hack: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].calculateHackingTime(), 5), 3) + " seconds");
+ post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().moneyAvailable, 5), 2));
post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().numOpenPortsRequired);
if (_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().sshPortOpen) {
post("SSH port: Open")
@@ -18473,7 +15644,7 @@ let Terminal = {
var scriptBaseRamUsage = currServ.scripts[i].ramUsage;
var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1);
- post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)");
+ post("This script requires " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)");
return;
}
}
@@ -18553,7 +15724,7 @@ let Terminal = {
} else if (delTarget.endsWith(".lit")) {
for (var i = 0; i < s.messages.length; ++i) {
var f = s.messages[i];
- if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["isString"])(f) && f === delTarget) {
+ if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["isString"])(f) && f === delTarget) {
s.messages.splice(i, 1);
return;
}
@@ -18612,11 +15783,11 @@ let Terminal = {
post("Incorrect usage of scan-analyze command. depth argument must be positive numeric");
return;
}
- if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) &&
- !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) {
+ if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1.name) &&
+ !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2.name)) {
post("You cannot scan-analyze with that high of a depth. Maximum depth is 3");
return;
- } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) {
+ } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2.name)) {
post("You cannot scan-analyze with that high of a depth. Maximum depth is 5");
return;
} else if (depth > 10) {
@@ -18837,7 +16008,7 @@ let Terminal = {
var spacesThread = Array(numSpacesThread+1).join(" ");
//Calculate and transform RAM usage
- ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB";
+ ramUsage = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB";
var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage];
post(entry.join(""));
@@ -19017,7 +16188,7 @@ let Terminal = {
}
if (d == 0) {continue;} //Don't print current server
var titleDashes = Array((d-1) * 4 + 1).join("-");
- if (_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink.name)) {
post("" + titleDashes + "> " + s.hostname + "", false);
} else {
post("" + titleDashes + ">" + s.hostname + "");
@@ -19050,9 +16221,9 @@ let Terminal = {
if (commandArray.length != 1) {
post("Incorrect usage of free command. Usage: free"); return;
}
- post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().maxRam, 2) + " GB");
- post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().ramUsed, 2) + " GB");
- post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().ramUsed, 2) + " GB");
+ post("Total: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().maxRam, 2) + " GB");
+ post("Used: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().ramUsed, 2) + " GB");
+ post("Available: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].getCurrentServer().ramUsed, 2) + " GB");
},
//First called when the "run [program]" command is called. Checks to see if you
@@ -19082,7 +16253,7 @@ let Terminal = {
programName = splitArgs[0];
}
switch (programName) {
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram.name:
if (s.hasAdminRights) {
post("You already have root access to this computer. There is no reason to run NUKE.exe");
} else {
@@ -19095,7 +16266,7 @@ let Terminal = {
}
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram.name:
if (s.sshPortOpen) {
post("SSH Port (22) is already open!");
} else {
@@ -19104,7 +16275,7 @@ let Terminal = {
++s.openPortCount;
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram.name:
if (s.ftpPortOpen) {
post("FTP Port (21) is already open!");
} else {
@@ -19113,7 +16284,7 @@ let Terminal = {
++s.openPortCount;
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram.name:
if (s.smtpPortOpen) {
post("SMTP Port (25) is already open!");
} else {
@@ -19122,7 +16293,7 @@ let Terminal = {
++s.openPortCount;
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram.name:
if (s.httpPortOpen) {
post("HTTP Port (80) is already open!");
} else {
@@ -19131,7 +16302,7 @@ let Terminal = {
++s.openPortCount;
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram.name:
if (s.sqlPortOpen) {
post("SQL Port (1433) is already open!");
} else {
@@ -19140,7 +16311,7 @@ let Terminal = {
++s.openPortCount;
}
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler.name:
if (splitArgs.length != 2) {
post("Must pass a server hostname or IP as an argument for ServerProfiler.exe");
return;
@@ -19154,24 +16325,24 @@ let Terminal = {
post("Server base security level: " + serv.baseDifficulty);
post("Server current security level: " + serv.hackDifficulty);
post("Server growth rate: " + serv.serverGrowth);
- post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s");
- post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s");
- post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s");
+ post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s");
+ post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s");
+ post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_20__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s");
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink.name:
post("This executable cannot be run.");
post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'.");
post("When using scan-analyze, click on a server's hostname to connect to it.");
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1.name:
post("This executable cannot be run.");
post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5.");
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2.name:
post("This executable cannot be run.");
post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10.");
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight.name:
post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].augmentations.length + " / 30");
post("Money: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(_Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].money.toNumber()).format('($0.000a)') + " / " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(1e11).format('($0.000a)'));
@@ -19184,7 +16355,7 @@ let Terminal = {
post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].dexterity + " / 1500");
post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_13__["Player"].agility + " / 1500");
break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume:
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume.name:
var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_23__["yesNoBoxGetYesButton"])(),
noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_23__["yesNoBoxGetNoButton"])();
yesBtn.innerHTML = "Travel to BitNode Nexus";
@@ -19306,143 +16477,13 @@ let Terminal = {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 22 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; });
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
-
-
-/* Settings.js */
-let Settings = {
- CodeInstructionRunTime: 50,
- MaxLogCapacity: 50,
- MaxPortCapacity: 50,
- SuppressMessages: false,
- SuppressFactionInvites: false,
- SuppressTravelConfirmation: false,
- AutosaveInterval: 60,
- DisableHotkeys: false,
- ThemeHighlightColor: "#ffffff",
- ThemeFontColor: "#66ff33",
- ThemeBackgroundColor: "#000000",
- EditorTheme: "Monokai",
- EditorKeybinding: "ace",
-}
-
-function loadSettings(saveString) {
- Settings = JSON.parse(saveString);
-}
-
-function initSettings() {
- Settings.CodeInstructionRunTime = 50;
- Settings.MaxLogCapacity = 50;
- Settings.MaxPortCapacity = 50;
- Settings.SuppressMessages = false;
- Settings.SuppressFactionInvites = false;
- Settings.SuppressTravelConfirmation = false,
- Settings.AutosaveInterval = 60;
- Settings.DisableHotkeys = false;
-}
-
-function setSettingsLabels() {
- var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
- var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
- var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel");
- var suppressMsgs = document.getElementById("settingsSuppressMessages");
- var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites")
- var suppressTravelConfirmation = document.getElementById("settingsSuppressTravelConfirmation");
- var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
- var disableHotkeys = document.getElementById("settingsDisableHotkeys");
-
- //Initialize values on labels
- nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
- nsLogLimit.innerHTML = Settings.MaxLogCapacity;
- nsPortLimit.innerHTML = Settings.MaxPortCapacity;
- suppressMsgs.checked = Settings.SuppressMessages;
- suppressFactionInv.checked = Settings.SuppressFactionInvites;
- suppressTravelConfirmation.checked = Settings.SuppressTravelConfirmation;
- autosaveInterval.innerHTML = Settings.AutosaveInterval;
- disableHotkeys.checked = Settings.DisableHotkeys;
-
- //Set handlers for when input changes
- var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
- var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
- var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
- var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal");
- nsExecTimeInput.value = Settings.CodeInstructionRunTime;
- nsLogRangeInput.value = Settings.MaxLogCapacity;
- nsPortRangeInput.value = Settings.MaxPortCapacity;
- nsAutosaveIntervalInput.value = Settings.AutosaveInterval;
-
- nsExecTimeInput.oninput = function() {
- nsExecTime.innerHTML = this.value + 'ms';
- Settings.CodeInstructionRunTime = this.value;
- };
-
- nsLogRangeInput.oninput = function() {
- nsLogLimit.innerHTML = this.value;
- Settings.MaxLogCapacity = this.value;
- };
-
- nsPortRangeInput.oninput = function() {
- nsPortLimit.innerHTML = this.value;
- Settings.MaxPortCapacity = this.value;
- };
-
- nsAutosaveIntervalInput.oninput = function() {
- autosaveInterval.innerHTML = this.value;
- Settings.AutosaveInterval = Number(this.value);
- if (Number(this.value) === 0) {
- _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity;
- } else {
- _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5;
- }
- };
-
- suppressMsgs.onclick = function() {
- Settings.SuppressMessages = this.checked;
- };
-
- suppressFactionInv.onclick = function() {
- Settings.SuppressFactionInvites = this.checked;
- };
-
- suppressTravelConfirmation.onclick = function() {
- Settings.SuppressTravelConfirmation = this.checked;
- };
-
- disableHotkeys.onclick = function() {
- Settings.DisableHotkeys = this.checked;
- }
-
- //Theme
- if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
- console.log("ERROR: Cannot find Theme Settings");
- return;
- }
- if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) &&
- /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) &&
- /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) {
- document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor);
- document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor);
- document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor);
- }
-}
-
-
-
-
-/***/ }),
-/* 23 */
+/* 19 */
+/*!************************************************!*\
+ !*** ./node_modules/decimal.js/decimal.es6.js ***!
+ \************************************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -24232,7 +21273,186 @@ PI = new Decimal(pi);
/***/ }),
-/* 24 */
+/* 20 */
+/*!******************************!*\
+ !*** ./src/CreateProgram.js ***!
+ \******************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Programs", function() { return Programs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayCreateProgramContent", function() { return displayCreateProgramContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNumAvailableCreateProgram", function() { return getNumAvailableCreateProgram; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initCreateProgramButtons", function() { return initCreateProgramButtons; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+// a function that returns a requirement for a program that requires only that
+// the player has at least the given skill level.
+function requireLevel(lvl) {
+ return function() {
+ return _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= lvl;
+ }
+}
+
+function Program(name, create) {
+ this.name = name;
+ this.create = create;
+}
+
+Program.prototype.htmlID = function() {
+ const name = this.name.endsWith('.exe') ? this.name.slice(0, -('.exe'.length)) : this.name;
+ return "create-program-"+name;
+}
+
+/* Create programs */
+const Programs = {
+ NukeProgram: new Program("NUKE.exe", {
+ level: 1,
+ tooltip:"This virus is used to gain root access to a machine if enough ports are opened.",
+ req: requireLevel(1),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes,
+ }),
+ BruteSSHProgram: new Program("BruteSSH.exe", {
+ level: 50,
+ tooltip:"This program executes a brute force attack that opens SSH ports",
+ req: requireLevel(50),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes * 2,
+ }),
+ FTPCrackProgram: new Program("FTPCrack.exe", {
+ level: 100,
+ tooltip:"This program cracks open FTP ports",
+ req: requireLevel(100),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour,
+ }),
+ RelaySMTPProgram: new Program("relaySMTP.exe", {
+ level: 250,
+ tooltip:"This program opens SMTP ports by redirecting data",
+ req: requireLevel(250),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours,
+ }),
+ HTTPWormProgram: new Program("HTTPWorm.exe", {
+ level: 500,
+ tooltip:"This virus opens up HTTP ports",
+ req: requireLevel(500),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer4Hours,
+ }),
+ SQLInjectProgram: new Program("SQLInject.exe", {
+ level: 750,
+ tooltip:"This virus opens SQL ports",
+ req: requireLevel(750),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer8Hours,
+ }),
+ DeepscanV1: new Program("DeepscanV1.exe", {
+ level: 75,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 5",
+ req: requireLevel(75),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour,
+ }),
+ DeepscanV2: new Program("DeepscanV2.exe", {
+ level: 400,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 10",
+ req: requireLevel(400),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours,
+ }),
+ ServerProfiler: new Program("ServerProfiler.exe", {
+ level: 75,
+ tooltip:"This program is used to display hacking and Netscript-related information about servers",
+ req: requireLevel(75),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour,
+ }),
+ AutoLink: new Program("AutoLink.exe", {
+ level: 25,
+ tooltip:"This program allows you to directly connect to other servers through the 'scan-analyze' command",
+ req: requireLevel(25),
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour,
+ }),
+ BitFlume: new Program("b1t_flum3.exe", {
+ level: 5,
+ tooltip:"This program creates a portal to the BitNode Nexus (allows you to restart and switch BitNodes)",
+ req: function() {return _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].sourceFiles.length > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 5},
+ time: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes / 5,
+ }),
+ // special because you can't create it.
+ Flight: new Program("fl1ght.exe"),
+};
+
+// this has the same key as 'Programs', not program names
+const aLinks = {};
+
+function displayCreateProgramContent() {
+ for(const key in aLinks) {
+ const p = Programs[key]
+ aLinks[key].style.display = "none";
+ if(!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(p.name) && p.create.req()){
+ aLinks[key].style.display = "inline-block";
+ }
+ }
+}
+
+//Returns the number of programs that are currently available to be created
+function getNumAvailableCreateProgram() {
+ var count = 0;
+ for(const key in Programs) {
+ if(Programs[key].create === undefined) { // a program we can't create
+ continue
+ }
+ if(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs[key].name)) { // can't create it twice
+ continue
+ }
+
+ if(!Programs[key].create.req()) { // if you don't fullfill the creation requirement
+ continue
+ }
+
+ count++;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable === false && count > 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable = true;
+ document.getElementById("create-program-tab").style.display = "list-item";
+ document.getElementById("hacking-menu-header").click();
+ document.getElementById("hacking-menu-header").click();
+ }
+ return count;
+}
+
+function initCreateProgramButtons() {
+ var createProgramList = document.getElementById("create-program-list");
+ for(const key in Programs) {
+ if(Programs[key].create === undefined) {
+ continue
+ }
+ const elem = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class: "a-link-button", id: Programs[key].htmlID(), innerText: Programs[key].name,
+ tooltip: Programs[key].create.tooltip,
+ });
+ aLinks[key] = elem;
+ createProgramList.appendChild(elem);
+ }
+
+ for(const key in aLinks) {
+ const p = Programs[key]
+ aLinks[key].addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(p.name, p.create.time, p.create.level);
+ return false;
+ });
+ }
+}
+
+
+
+
+/***/ }),
+/* 21 */
+/*!************************************!*\
+ !*** ./src/InteractiveTutorial.js ***!
+ \************************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -24243,10 +21463,10 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialNextStep", function() { return iTutorialNextStep; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currITutorialStep", function() { return currITutorialStep; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialIsRunning", function() { return iTutorialIsRunning; });
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
@@ -24913,7 +22133,658 @@ function iTutorialSetText(txt) {
/***/ }),
-/* 25 */
+/* 22 */
+/*!********************************!*\
+ !*** ./src/NetscriptWorker.js ***!
+ \********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerScript", function() { return WorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "workerScripts", function() { return workerScripts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPorts", function() { return NetscriptPorts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptsLoop", function() { return runScriptsLoop; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killWorkerScript", function() { return killWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addWorkerScript", function() { return addWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateOnlineScriptTimes", function() { return updateOnlineScriptTimes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeWorkerScripts", function() { return prestigeWorkerScripts; });
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 82);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptJSEvaluator.js */ 83);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptPort.js */ 65);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function WorkerScript(runningScriptObj) {
+ this.name = runningScriptObj.filename;
+ this.running = false;
+ this.serverIp = null;
+ this.code = runningScriptObj.scriptRef.code;
+ this.env = new _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__["Environment"](this);
+ this.env.set("args", runningScriptObj.args.slice());
+ this.output = "";
+ this.ramUsage = 0;
+ this.scriptRef = runningScriptObj;
+ this.errorMessage = "";
+ this.args = runningScriptObj.args.slice();
+ this.delay = null;
+ this.fnWorker = null; //Workerscript for a function call
+ this.checkingRam = false;
+ this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM. Used for static RAM evaluation
+ this.disableLogs = {}; //Stores names of fns that should have logs disabled
+
+ //Properties used for dynamic RAM evaluation
+ this.dynamicRamUsage = 1.4;
+ this.dynamicLoadedFns = {};
+}
+
+//Returns the server on which the workerScript is running
+WorkerScript.prototype.getServer = function() {
+ return _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][this.serverIp];
+}
+
+//Returns the Script object for the underlying script
+WorkerScript.prototype.getScript = function() {
+ let server = this.getServer();
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename === this.name) {
+ return server.scripts[i];
+ }
+ }
+ console.log("ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong");
+ return null;
+}
+
+WorkerScript.prototype.shouldLog = function(fn) {
+ return (this.disableLogs.ALL == null && this.disableLogs[fn] == null);
+}
+
+WorkerScript.prototype.log = function(txt) {
+ this.scriptRef.log(txt);
+}
+
+//Array containing all scripts that are running across all servers, to easily run them all
+let workerScripts = [];
+
+var NetscriptPorts = [];
+for (var i = 0; i < _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NumNetscriptPorts; ++i) {
+ NetscriptPorts.push(new _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__["NetscriptPort"]());
+}
+
+function prestigeWorkerScripts() {
+ for (var i = 0; i < workerScripts.length; ++i) {
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+ workerScripts[i].env.stopFlag = true;
+ }
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(5000); //Force UI to update
+ workerScripts.length = 0;
+}
+
+// JS script promises need a little massaging to have the same guarantees as netscript
+// promises. This does said massaging and kicks the script off. It returns a promise
+// that resolves or rejects when the corresponding worker script is done.
+function startJsScript(workerScript) {
+ workerScript.running = true;
+
+ // The name of the currently running netscript function, to prevent concurrent
+ // calls to hack, grow, etc.
+ let runningFn = null;
+
+ // We need to go through the environment and wrap each function in such a way that it
+ // can be called at most once at a time. This will prevent situations where multiple
+ // hack promises are outstanding, for example.
+ function wrap(propName, f) {
+ // This function unfortunately cannot be an async function, because we don't
+ // know if the original one was, and there's no way to tell.
+ return function (...args) {
+ // Wrap every netscript function with a check for the stop flag.
+ // This prevents cases where we never stop because we are only calling
+ // netscript functions that don't check this.
+ // This is not a problem for legacy Netscript because it also checks the
+ // stop flag in the evaluator.
+ if (workerScript.env.stopFlag) {throw workerScript;}
+
+ if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep.
+
+ const msg = "Concurrent calls to Netscript functions not allowed! " +
+ "Did you forget to await hack(), grow(), or some other " +
+ "promise-returning function? (Currently running: %s tried to run: %s)"
+ if (runningFn) {
+ workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, runningFn, propName), null)
+ throw workerScript;
+ }
+ runningFn = propName;
+ let result = f(...args);
+ if (result && result.finally !== undefined) {
+ return result.finally(function () {
+ runningFn = null;
+ });
+ } else {
+ runningFn = null;
+ return result;
+ }
+ }
+ };
+
+ for (let prop in workerScript.env.vars) {
+ if (typeof workerScript.env.vars[prop] !== "function") continue;
+ workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
+ }
+
+ // Note: the environment that we pass to the JS script only needs to contain the functions visible
+ // to that script, which env.vars does at this point.
+ return Object(_NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__["executeJSScript"])(workerScript.getServer().scripts,
+ workerScript).then(function (mainReturnValue) {
+ if (mainReturnValue === undefined) return workerScript;
+ return [mainReturnValue, workerScript];
+ }).catch(e => {
+ if (e instanceof Error) {
+ workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(
+ workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || ""));
+ throw workerScript;
+ } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(e)) {
+ workerScript.errorMessage = e;
+ throw workerScript;
+ }
+ throw e; // Don't know what to do with it, let's rethrow.
+ });
+}
+
+//Loop through workerScripts and run every script that is not currently running
+function runScriptsLoop() {
+ var scriptDeleted = false;
+
+ //Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
+ for (var i = workerScripts.length - 1; i >= 0; i--) {
+ if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
+ scriptDeleted = true;
+ //Delete script from the runningScripts array on its host serverIp
+ var ip = workerScripts[i].serverIp;
+ var name = workerScripts[i].name;
+
+ //Free RAM
+ _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed -= workerScripts[i].ramUsage;
+
+ //Delete script from Active Scripts
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+
+ for (var j = 0; j < _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.length; j++) {
+ if (_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].filename == name &&
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].args, workerScripts[i].args)) {
+ _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.splice(j, 1);
+ break;
+ }
+ }
+
+ //Delete script from workerScripts
+ workerScripts.splice(i, 1);
+ }
+ }
+ if (scriptDeleted) {Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])();} //Force Update
+
+
+ //Run any scripts that haven't been started
+ for (var i = 0; i < workerScripts.length; i++) {
+ //If it isn't running, start the script
+ if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
+ let p = null; // p is the script's result promise.
+ if (workerScripts[i].name.endsWith(".js") || workerScripts[i].name.endsWith(".ns")) {
+ p = startJsScript(workerScripts[i]);
+ } else {
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__["parse"])(workerScripts[i].code, {sourceType:"module"});
+ //console.log(ast);
+ } catch (e) {
+ console.log("Error parsing script: " + workerScripts[i].name);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Syntax ERROR in " + workerScripts[i].name + ":
" + e);
+ workerScripts[i].env.stopFlag = true;
+ continue;
+ }
+ workerScripts[i].running = true;
+ p = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["evaluate"])(ast, workerScripts[i]);
+ }
+
+ //Once the code finishes (either resolved or rejected, doesnt matter), set its
+ //running status to false
+ p.then(function(w) {
+ console.log("Stopping script " + w.name + " because it finished running naturally");
+ w.running = false;
+ w.env.stopFlag = true;
+ w.scriptRef.log("Script finished running");
+ }).catch(function(w) {
+ if (w instanceof Error) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
+ console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString());
+ return;
+ } else if (w.constructor === Array && w.length === 2 && w[0] === "RETURNSTATEMENT") {
+ //Script ends with a return statement
+ console.log("Script returning with value: " + w[1]);
+ //TODO maybe do something with this in the future
+ return;
+ } else if (w instanceof WorkerScript) {
+ if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w.errorMessage)) {
+ var errorTextArray = w.errorMessage.split("|");
+ if (errorTextArray.length != 4) {
+ console.log("ERROR: Something wrong with Error text in evaluator...");
+ console.log("Error text: " + errorText);
+ return;
+ }
+ var serverIp = errorTextArray[1];
+ var scriptName = errorTextArray[2];
+ var errorMsg = errorTextArray[3];
+
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime error:
Server Ip: " + serverIp +
+ "
Script name: " + scriptName +
+ "
Args:" + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(w.args) + "
" + errorMsg);
+ w.scriptRef.log("Script crashed with runtime error");
+ } else {
+ w.scriptRef.log("Script killed");
+ }
+ w.running = false;
+ w.env.stopFlag = true;
+
+ } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
+ console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: " + w.toString());
+ return;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
+ console.log(w);
+ }
+ });
+ }
+ }
+
+ setTimeout(runScriptsLoop, 6000);
+}
+
+//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
+//all of its promises recursively, and when it does so it will no longer be running.
+//The runScriptsLoop() will then delete the script from worker scripts
+function killWorkerScript(runningScriptObj, serverIp) {
+ for (var i = 0; i < workerScripts.length; i++) {
+ if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
+ workerScripts[i].env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(workerScripts[i]);
+ //Recursively kill all functions
+ var curr = workerScripts[i];
+ while (curr.fnWorker) {
+ curr.fnWorker.env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(curr.fnWorker);
+ curr = curr.fnWorker;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+//Queues a script to be run
+function addWorkerScript(runningScriptObj, server) {
+ var filename = runningScriptObj.filename;
+
+ //Update server's ram usage
+ var threads = 1;
+ if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
+ threads = runningScriptObj.threads;
+ } else {
+ runningScriptObj.threads = 1;
+ }
+ var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
+ * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+ if (ramUsage > ramAvailable) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
+ "the game and the script's RAM usage increased (either because of an update to the game or " +
+ "your changes to the script.)");
+ return;
+ }
+ server.ramUsed += ramUsage;
+
+ //Create the WorkerScript
+ var s = new WorkerScript(runningScriptObj);
+ s.serverIp = server.ip;
+ s.ramUsage = ramUsage;
+
+ //Add the WorkerScript to the Active Scripts list
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["addActiveScriptsItem"])(s);
+
+ //Add the WorkerScript
+ workerScripts.push(s);
+ return;
+}
+
+//Updates the online running time stat of all running scripts
+function updateOnlineScriptTimes(numCycles = 1) {
+ var time = (numCycles * _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
+ for (var i = 0; i < workerScripts.length; ++i) {
+ workerScripts[i].scriptRef.onlineRunningTime += time;
+ }
+}
+
+
+
+
+/***/ }),
+/* 23 */
+/*!***********************!*\
+ !*** ./src/Crimes.js ***!
+ \***********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeSuccess", function() { return determineCrimeSuccess; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findCrime", function() { return findCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Crimes", function() { return Crimes; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+
+
+
+
+
+function Crime(name, type, time, money, difficulty, karma, params) {
+ this.name = name;
+ this.type = type;
+ this.time = time;
+ this.money = money;
+ this.difficulty = difficulty;
+ this.karma = karma;
+
+ this.hacking_success_weight = params.hacking_success_weight ? params.hacking_success_weight : 0;
+ this.strength_success_weight = params.strength_success_weight ? params.strength_success_weight : 0;
+ this.defense_success_weight = params.defense_success_weight ? params.defense_success_weight : 0;
+ this.dexterity_success_weight = params.dexterity_success_weight ? params.dexterity_success_weight : 0;
+ this.agility_success_weight = params.agility_success_weight ? params.agility_success_weight : 0;
+ this.charisma_success_weight = params.charisma_success_weight ? params.charisma_success_weight : 0;
+
+ this.hacking_exp = params.hacking_exp ? params.hacking_exp : 0;
+ this.strength_exp = params.strength_exp ? params.strength_exp : 0;
+ this.defense_exp = params.defense_exp ? params.defense_exp : 0;
+ this.dexterity_exp = params.dexterity_exp ? params.dexterity_exp : 0;
+ this.agility_exp = params.agility_exp ? params.agility_exp : 0;
+ this.charisma_exp = params.charisma_exp ? params.charisma_exp : 0;
+ this.intelligence_exp = params.intelligence_exp ? params.intelligence_exp : 0;
+
+ this.kills = params.kills ? params.kills : 0;
+}
+
+Crime.prototype.commit = function(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = this.type;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(
+ this.hacking_exp/div,
+ this.strength_exp/div,
+ this.defense_exp/div,
+ this.dexterity_exp/div,
+ this.agility_exp/div,
+ this.charisma_exp/div,
+ this.money/div, this.time, singParams);
+ return this.time;
+}
+
+Crime.prototype.successRate = function() {
+ var chance = (this.hacking_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill +
+ this.strength_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength +
+ this.defense_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense +
+ this.dexterity_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity +
+ this.agility_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility +
+ this.charisma_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma +
+ _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeWeight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence);
+ chance /= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ chance /= this.difficulty;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+const Crimes = {
+ Shoplift: new Crime("Shoplift", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift, 2e3, 15e3, 1/20, 0.1, {
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ dexterity_exp: 2,
+ agility_exp: 2,
+ }),
+
+ RobStore: new Crime("Rob Store", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore, 60e3, 400e3, 1/5, 0.5, {
+ hacking_exp: 30,
+ dexterity_exp: 45,
+ agility_exp: 45,
+
+ hacking_success_weight: 0.5 ,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+
+ intelligence_exp: 0.25 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Mug: new Crime("Mug", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug, 4e3, 36e3, 1/5, 0.25, {
+ strength_exp: 3,
+ defense_exp: 3,
+ dexterity_exp: 3,
+ agility_exp: 3,
+
+ strength_success_weight: 1.5,
+ defense_success_weight: 0.5,
+ dexterity_success_weight: 1.5,
+ agility_success_weight: 0.5,
+ }),
+
+ Larceny: new Crime("Larceny", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny, 90e3, 800e3, 1/3, 1.5, {
+ hacking_exp: 45,
+ dexterity_exp: 60,
+ agility_exp: 60,
+
+ hacking_skill_success_weight: 0.5,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ intelligence_exp: 0.5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ DealDrugs: new Crime("Deal Drugs", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs, 10e3, 120e3, 1, 0.5, {
+ dexterity_exp: 5,
+ agility_exp: 5,
+ charisma_exp: 10,
+
+ charisma_success_weight: 3,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+ }),
+
+ BondForgery: new Crime("Bond Forgery", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery, 300e3, 4.5e6, 1/2, 0.1, {
+ hacking_exp: 100,
+ dexterity_exp: 150,
+ charisma_exp: 15,
+
+ hacking_skill_success_weight: 0.05,
+ dexterity_success_weight: 1.25,
+
+ intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ TraffickArms: new Crime("Traffick Arms", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms, 40e3, 600e3, 2, 1, {
+ strength_exp: 20,
+ defense_exp: 20,
+ dexterity_exp: 20,
+ agility_exp: 20,
+ charisma_exp: 40,
+
+ charisma_success_weight: 1,
+ strength_success_weight: 1,
+ defense_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+ }),
+
+ Homicide: new Crime("Homicide", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide, 3e3, 45e3, 1, 3, {
+ strength_exp: 2,
+ defense_exp: 2,
+ dexterity_exp: 2,
+ agility_exp: 2,
+
+ strength_success_weight: 2,
+ defense_success_weight: 2,
+ dexterity_success_weight: 0.5,
+ agility_success_weight: 0.5,
+
+ kills: 1,
+ }),
+
+ GrandTheftAuto: new Crime("Grand Theft Auto", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto, 80e3, 1.6e6, 8, 5, {
+ strength_exp: 20,
+ defense_exp: 20,
+ dexterity_exp: 20,
+ agility_exp: 80,
+ charisma_exp: 40,
+
+ hacking_skill_success_weight: 1,
+ strength_success_weight: 1,
+ dexterity_success_weight: 4,
+ agility_success_weight: 2,
+ charisma_success_weight: 2,
+
+ intelligence_exp: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Kidnap: new Crime("Kidnap", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap, 120e3, 3.6e6, 5, 6, {
+ strength_exp: 80,
+ defense_exp: 80,
+ dexterity_exp: 80,
+ agility_exp: 80,
+ charisma_exp: 80,
+
+ charisma_success_weight: 1,
+ strength_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Assassination: new Crime("Assassination", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination, 300e3, 12e6, 8, 10, {
+ strength_exp: 300,
+ defense_exp: 300,
+ dexterity_exp: 300,
+ agility_exp: 300,
+
+ strength_success_weight: 1,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+
+ intelligence_exp: 5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+
+ kills: 1,
+ }),
+
+ Heist: new Crime("Heist", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist, 600e3, 120e6, 18, 15, {
+ hacking_exp: 450,
+ strength_exp: 450,
+ defense_exp: 450,
+ dexterity_exp: 450,
+ agility_exp: 450,
+ charisma_exp: 450,
+
+ hacking_skill_success_weight: 1,
+ strength_success_weight: 1,
+ defense_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+ charisma_success_weight: 1,
+
+ intelligence_exp: 10 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+};
+
+function determineCrimeSuccess(type, moneyGained) {
+ var chance = 0;
+ var found = false;
+ for(const i in Crimes) {
+ const crime = Crimes[i];
+ if(crime.type == type) {
+ chance = crime.successRate();
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ console.log(crime);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
+ return;
+ }
+
+ if (Math.random() <= chance) {
+ //Success
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].gainMoney(moneyGained);
+ return true;
+ } else {
+ //Failure
+ return false;
+ }
+}
+
+function findCrime(roughName) {
+ if (roughName.includes("shoplift")) {
+ return Crimes.Shoplift;
+ } else if (roughName.includes("rob") && roughName.includes("store")) {
+ return Crimes.RobStore;
+ } else if (roughName.includes("mug")) {
+ return Crimes.Mug;
+ } else if (roughName.includes("larceny")) {
+ return Crimes.Larceny;
+ } else if (roughName.includes("drugs")) {
+ return Crimes.DealDrugs;
+ } else if (roughName.includes("bond") && roughName.includes("forge")) {
+ return Crimes.BondForgery;
+ } else if (roughName.includes("traffick") && roughName.includes("arms")) {
+ return Crimes.TraffickArms;
+ } else if (roughName.includes("homicide")) {
+ return Crimes.Homicide;
+ } else if (roughName.includes("grand") && roughName.includes("auto")) {
+ return Crimes.GrandTheftAuto;
+ } else if (roughName.includes("kidnap")) {
+ return Crimes.Kidnap;
+ } else if (roughName.includes("assassinate")) {
+ return Crimes.Assassination;
+ } else if (roughName.includes("heist")) {
+ return Crimes.Heist;
+ }
+ return null;
+}
+
+
+
+
+/***/ }),
+/* 24 */
+/*!***********************!*\
+ !*** ./src/Script.js ***!
+ \***********************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -24926,43 +22797,44 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllServersMap", function() { return AllServersMap; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptEditorInit", function() { return scriptEditorInit; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptFilename", function() { return isScriptFilename; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(32);
-/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(24);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(30);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(19);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(0);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(22);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(21);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(43);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 26);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 18);
+/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile */ 58);
/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_TextFile__WEBPACK_IMPORTED_MODULE_11__);
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(35);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(9);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(1);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(2);
-var ace = __webpack_require__(200);
-var beautify = __webpack_require__(199).js_beautify;
-__webpack_require__(197);
-__webpack_require__(196);
-__webpack_require__(195);
-__webpack_require__(194);
-__webpack_require__(193);
-__webpack_require__(192);
-__webpack_require__(191);
-__webpack_require__(190);
-__webpack_require__(189);
-__webpack_require__(188);
-__webpack_require__(187);
-__webpack_require__(186);
-__webpack_require__(185);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_16__);
+var ace = __webpack_require__(/*! brace */ 200);
+var beautify = __webpack_require__(/*! js-beautify */ 199).js_beautify;
+__webpack_require__(/*! brace/mode/javascript */ 197);
+__webpack_require__(/*! ../netscript */ 196);
+__webpack_require__(/*! brace/theme/chaos */ 195);
+__webpack_require__(/*! brace/theme/chrome */ 194);
+__webpack_require__(/*! brace/theme/monokai */ 193);
+__webpack_require__(/*! brace/theme/solarized_dark */ 192);
+__webpack_require__(/*! brace/theme/solarized_light */ 191);
+__webpack_require__(/*! brace/theme/terminal */ 190);
+__webpack_require__(/*! brace/theme/twilight */ 189);
+__webpack_require__(/*! brace/theme/xcode */ 188);
+__webpack_require__(/*! brace/keybinding/vim */ 187);
+__webpack_require__(/*! brace/keybinding/emacs */ 186);
+__webpack_require__(/*! brace/ext/language_tools */ 185);
// Importing this doesn't work for some reason.
-const walk = __webpack_require__(184);
+const walk = __webpack_require__(/*! acorn/dist/walk */ 184);
@@ -25179,7 +23051,7 @@ function updateScriptEditorContent() {
var codeCopy = code.repeat(1);
var ramUsage = calculateRamUsage(codeCopy);
if (ramUsage !== -1) {
- scriptEditorRamText.innerText = "RAM: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(ramUsage, 2).toString() + "GB";
+ scriptEditorRamText.innerText = "RAM: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(ramUsage, 2).toString() + "GB";
} else {
scriptEditorRamText.innerText = "RAM: Syntax Error";
}
@@ -25749,7 +23621,7 @@ function scriptCalculateOfflineProduction(runningScriptObj) {
console.log(runningScriptObj.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
runningScriptObj.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
var growth = Object(_Server_js__WEBPACK_IMPORTED_MODULE_8__["processSingleServerGrowth"])(serv, timesGrown * 450);
- runningScriptObj.log(serv.hostname + " grown by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(growth * 100 - 100, 6) + "% from grow() calls made while offline");
+ runningScriptObj.log(serv.hostname + " grown by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(growth * 100 - 100, 6) + "% from grow() calls made while offline");
}
}
@@ -25945,4592 +23817,13 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Reviver"].constructors.AllS
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 26 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bladeburner", function() { return Bladeburner; });
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(37);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(21);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(9);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(2);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
-
-var CyclesPerSecond = 5; //Game cycle is 200 ms
-
-var StaminaGainPerSecond = 0.0085;
-var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty
-var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain
-
-var 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
-var DiffMultExponentialFactor = 0.28;
-var DiffMultLinearFactor = 650;
-
-var EffAgiLinearFactor = 90e3;
-var EffDexLinearFactor = 90e3;
-var EffAgiExponentialFactor = 0.031;
-var EffDexExponentialFactor = 0.03;
-
-var BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action
-
-var PopulationThreshold = 1e9; //Population at which success rates start being affected
-var ChaosThreshold = 50; //City chaos level after which it starts making tasks harder
-
-var BaseStatGain = 1; //Base stat gain per second
-var BaseIntGain = 0.001; //Base intelligence stat gain
-
-var ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value
-
-var RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank
-var RankNeededForFaction = 25;
-
-var ContractSuccessesPerLevel = 3; //How many successes you need to level up a contract
-var OperationSuccessesPerLevel = 2.5; //How many successes you need to level up an op
-
-var RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point
-
-var ContractBaseMoneyGain = 10e3; //Base Money Gained per contract
-
-//DOM related variables
-var ActiveActionCssClass = "bladeburner-active-action";
-
-//Console related stuff
-var consoleHistory = []; //Console command history
-var consoleHistoryIndex = 0;
-var consoleHelpText = {
- helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.
" +
- "automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks
" +
- "clear/cls Clear the console
" +
- "help [cmd] Display this help text, or help text for a specific command
" +
- "log [en/dis] [type] Enable or disable logging for events and actions
" +
- "skill [action] [name] Level or display info about your Bladeburner skills
" +
- "start [type] [name] Start a Bladeburner action/task
" +
- "stop Stops your current Bladeburner action/task
",
- automate:"automate [var] [val] [hi/low]
" +
- "A simple way to automate your Bladeburner actions. This console command can be used " +
- "to automatically start an action when your stamina rises above a certain threshold, and " +
- "automatically switch to another action when your stamina drops below another threshold.
" +
- "automate status - Check the current status of your automation and get a brief description of what it'll do
" +
- "automate en - Enable the automation feature
" +
- "automate dis - Disable the automation feature
" +
- "There are four properties that must be set for this automation to work properly. Here is how to set them:
" +
- "automate stamina 100 high
" +
- "automate contract Tracking high
" +
- "automate stamina 50 low
" +
- 'automate general "Field Analysis" low
' +
- "Using the four console commands above will set the automation to perform Tracking contracts " +
- "if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below " +
- "50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must " +
- "exactly match whatever the name is in the UI.",
- clear:"clear
Clears the console",
- cls:"cls
Clears the console",
- help:"help [command]
" +
- "Running 'help' with no arguments displays the general help text, which lists all console commands " +
- "and a brief description of what they do. A command can be specified to get more specific help text " +
- "about that particular command. For example:
" +
- "help automate
" +
- "will display specific information about using the automate console command",
- log:"log [en/dis] [type]
" +
- "Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged " +
- "in the console. There are also random events that are logged in the console as well. The five categories of " +
- "things that get logged are:
" +
- "[general, contracts, ops, blackops, events]
" +
- "The logging for these categories can be enabled or disabled like so:
" +
- "log dis contracts - Disables logging that occurs when contracts are completed
" +
- "log en contracts - Enables logging that occurs when contracts are completed
" +
- "log dis events - Disables logging for Bladeburner random events
" +
- "Logging can be universally enabled/disabled using the 'all' keyword:
" +
- "log dis all
" +
- "log en all",
- skill:"skill [action] [name]
" +
- "Level or display information about your skills.
" +
- "To display information about all of your skills and your multipliers, use:
" +
- "skill list
" +
- "To display information about a specific skill, specify the name of the skill afterwards. " +
- "Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If " +
- "the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
" +
- "skill list Reaper
" +
- 'skill list "Digital Observer"
' +
- "This console command can also be used to level up skills:
" +
- "skill level [skill name]",
- start:"start [type] [name]
" +
- "Start an action. An action is specified by its type and its name. The " +
- "name is case-sensitive. It must appear exactly as it does in the UI. If " +
- "the name of the action has whitespace, enclose it in double quotation marks. " +
- "Valid action types include:
" +
- "[general, contract, op, blackop]
" +
- "Examples:
" +
- 'start contract Tracking
' +
- 'start op "Undercover Operation"
',
- stop:"stop
" +
- "Stop your current action and go idle",
-}
-
-//Keypresses for Console
-$(document).keydown(function(event) {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
- //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
- // DomElems.consoleInput.focus();
- //}
-
- if (!(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner instanceof Bladeburner)) {return;}
-
- //NOTE: Keycodes imported from Terminal.js
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].ENTER) {
- event.preventDefault();
- var command = DomElems.consoleInput.value;
- if (command.length > 0) {
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.postToConsole("> " + command);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.resetConsoleInput();
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.executeConsoleCommands(command);
- }
- }
-
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].UPARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len === 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- if (i !== 0) {
- --consoleHistoryIndex;
- }
-
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);
- }
-
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].DOWNARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len == 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- //Latest command, put nothing
- if (i == len || i == len-1) {
- consoleHistoryIndex = len;
- DomElems.consoleInput.value = "";
- } else {
- ++consoleHistoryIndex;
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- }
- }
- }
-});
-
-function City(params={}) {
- this.name = params.name ? params.name : _Location_js__WEBPACK_IMPORTED_MODULE_5__["Locations"].Sector12;
-
- //Synthoid population and estimate
- this.pop = params.pop ? params.pop : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(800e6, 1.2*PopulationThreshold);
- this.popEst = this.pop * (Math.random() + 0.5);
-
- //Number of Synthoid communities population and estimate
- this.comms = params.comms ? params.comms : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 40);
- this.commsEst = this.comms + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-2, 2);
- if (this.commsEst < 0) {this.commsEst = 0;}
- this.chaos = 0;
-}
-
-City.prototype.improvePopulationEstimateByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passeed into City.improvePopulationEstimateByCount()");}
- if (this.popEst < this.pop) {
- this.popEst += n;
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst -= n;
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
-City.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {
- p = p*skillMult;
- if (isNaN(p)) {throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()");}
- if (this.popEst < this.pop) {
- ++this.popEst; //In case estimate is 0
- this.popEst *= (1 + (p/100));
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst *= (1 - (p/100));
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-City.prototype.improveCommunityEstimate = function(n=1) {
- if (isNaN(n)) {throw new Error("NaN passed into City.improveCommunityEstimate()");}
- if (this.commsEst < this.comms) {
- this.commsEst += n;
- if (this.commsEst > this.comms) {this.commsEst = this.comms;}
- } else if (this.commsEst > this.comms) {
- this.commsEst -= n;
- if (this.commsEst < this.comms) {this.commsEst = this.comms;}
- }
-}
-
-//@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;
- if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}
- if (params.estOffset) {
- this.popEst = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(this.popEst, params.estOffset);
- }
- 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
-City.prototype.changePopulationByPercentage = function(p, params={}) {
- if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
- if (p === 0) {return;}
- var change = Math.round(this.pop * (p/100));
-
- //Population always changes by at least 1
- if (params.nonZero && change === 0) {
- p > 0 ? change = 1 : change = -1;
- }
-
- this.pop += change;
- if (params.changeEstEqually) {
- this.popEst += change;
- if (this.popEst < 0) {this.popEst = 0;}
- }
- return change;
-}
-
-City.prototype.changeChaosByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passed into City.changeChaosByCount()");}
- if (n === 0) {return;}
- this.chaos += n;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
-City.prototype.changeChaosByPercentage = function(p) {
- if (isNaN(p)) {throw new Error("NaN passed into City.chaosChaosByPercentage()");}
- if (p === 0) {return;}
- var change = this.chaos * (p/100);
- this.chaos += change;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-City.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("City", this);
-}
-City.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(City, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.City = City;
-
-function Skill(params={name:"foo", desc:"foo"}) {
- if (params.name) {
- this.name = params.name;
- } else {
- throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor");
- }
- if (params.desc) {
- this.desc = params.desc;
- } else {
- throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor");
- }
- this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points
- this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level
-
- if (params.maxLvl) {this.maxLvl = params.maxLvl;}
-
- //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
- if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
-
- if (params.actionTime) {this.actionTime = params.actionTime;}
- if (params.effHack) {this.effHack = params.effHack;}
- if (params.effStr) {this.effStr = params.effStr;}
- if (params.effDef) {this.effDef = params.effDef;}
- if (params.effDex) {this.effDex = params.effDex;}
- if (params.effAgi) {this.effAgi = params.effAgi;}
- if (params.effCha) {this.effCha = params.effCha;}
-
- if (params.stamina) {this.stamina = params.stamina;}
-
- //Equipment
- 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)) * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerSkillCost;
-}
-var Skills = {};
-var SkillNames = {
- BladesIntuition: "Blade's Intuition",
- Reaper: "Reaper",
- Cloak: "Cloak",
- Marksman: "Marksman",
- WeaponProficiency: "Weapon Proficiency",
- Overclock: "Overclock",
- EvasiveSystem: "Evasive System",
- ShortCircuit: "Short-Circuit",
- DigitalObserver: "Digital Observer",
- Datamancer: "Datamancer",
- Tracer: "Tracer",
- CybersEdge: "Cyber's Edge"
-}
-
-//Base Class for Contracts, Operations, and BlackOps
-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
- this.level = 1;
- this.maxLevel = 1;
- this.autoLevel = true;
- this.baseDifficulty = params.baseDifficulty ? Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(params.baseDifficulty, 10) : 100;
- this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;
-
- //Rank increase/decrease is affected by this exponent
- this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;
-
- this.successes = 0;
- this.failures = 0;
-
- //All of these scale with level/difficulty
- this.rankGain = params.rankGain ? params.rankGain : 0;
- if (params.rankLoss) {this.rankLoss = params.rankLoss;}
- if (params.hpLoss) {
- this.hpLoss = params.hpLoss;
- this.hpLost = 0;
- }
-
- //Action Category. Current categories are stealth and kill
- 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"
- this.count = params.count ? params.count : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1e3, 25e3);
- this.countGrowth = params.countGrowth ? params.countGrowth : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5);
-
- //Weighting of each stat in determining action success rate
- var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};
- this.weights = params.weights ? params.weights : defaultWeights;
-
- //Check to make sure weights are summed properly
- var sum = 0;
- for (var weight in this.weights) {
- if (this.weights.hasOwnProperty(weight)) {
- sum += this.weights[weight];
- }
- }
- if (sum - 1 >= 10 * Number.EPSILON) {
- throw new Error("Invalid weights when constructing Action " + this.name +
- ". The weights should sum up to 1. They sum up to :" + 1);
- }
-
- //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};
- this.decays = params.decays ? params.decays : defaultDecays;
- for (var decay in this.decays) {
- if (this.decays.hasOwnProperty(decay)) {
- if (this.decays[decay] > 1) {
- throw new Error("Invalid decays when constructing " +
- "Action " + this.name + ". " +
- "Decay value cannot be greater than 1");
- }
- }
- }
-}
-
-Action.prototype.getDifficulty = function() {
- var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);
- if (isNaN(difficulty)) {throw new Error("Calculated NaN in Action.getDifficulty()");}
- return difficulty;
-}
-
-//@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();
- var competence = 0;
- for (var stat in this.weights) {
- if (this.weights.hasOwnProperty(stat)) {
- var playerStatLvl = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queryStatFromString(stat);
- var key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
- var effMultiplier = inst.skillMultipliers[key];
- if (effMultiplier == null) {
- console.log("ERROR: Failed to find Bladeburner Skill multiplier for: " + stat);
- effMultiplier = 1;
- }
- competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));
- }
- }
- competence *= inst.calculateStaminaPenalty();
-
- //For Operations, factor in team members
- if (this instanceof Operation || this instanceof BlackOperation) {
- if (this.teamCount && this.teamCount > 0) {
- this.teamCount = Math.min(this.teamCount, inst.teamSize);
- var teamMultiplier = Math.pow(this.teamCount, 0.05);
- competence *= teamMultiplier;
- }
- }
-
- //Lower city population results in lower chances
- if (!(this instanceof BlackOperation)) {
- var city = inst.getCurrentCity();
- if (params.est) {
- competence *= (city.popEst / PopulationThreshold);
- } else {
- competence *= (city.pop / PopulationThreshold);
- }
-
- //Too high of a chaos results in lower chances
- if (city.chaos > ChaosThreshold) {
- var diff = 1 + (city.chaos - ChaosThreshold);
- var mult = Math.pow(diff, 0.1);
- difficulty *= mult;
- }
-
- //For Raid Operations, no communities = fail
- if (this instanceof Operation && this.name === "Raid") {
- if (city.comms <= 0) {return 0;}
- }
- }
-
- //Factor skill multipliers into success chance
- competence *= inst.skillMultipliers.successChanceAll;
- if (this instanceof Operation || this instanceof BlackOperation) {
- competence *= inst.skillMultipliers.successChanceOperation;
- }
- if (this instanceof Contract) {
- competence *= inst.skillMultipliers.successChanceContract;
- }
- if (this.isStealth) {
- competence *= inst.skillMultipliers.successChanceStealth;
- }
- if (this.isKill) {
- competence *= inst.skillMultipliers.successChanceKill;
- }
-
- //Augmentation multiplier
- competence *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult;
-
- if (isNaN(competence)) {throw new Error("Competence calculated as NaN in Action.getSuccessChance()");}
- return Math.min(1, competence / difficulty);
-}
-
-//Tests for success. Should be called when an action has completed
-// @inst - Bladeburner Object
-Action.prototype.attempt = function(inst) {
- return (Math.random() < this.getSuccessChance(inst));
-}
-
-Action.prototype.getActionTime = function(inst) {
- var difficulty = this.getDifficulty();
- var baseTime = difficulty / DifficultyToTimeFactor;
- var skillFac = inst.skillMultipliers.actionTime; //Always < 1
-
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * inst.skillMultipliers.effAgi;
- var effDexterity = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity * inst.skillMultipliers.effDex;
- var statFac = 0.5 * (Math.pow(effAgility, EffAgiExponentialFactor) +
- Math.pow(effDexterity, EffDexExponentialFactor) +
- (effAgility / EffAgiLinearFactor) +
- (effDexterity / EffDexLinearFactor)); //Always > 1
-
- baseTime = Math.max(1, baseTime * skillFac / statFac);
-
- if (this instanceof Contract) {
- return Math.ceil(baseTime);
- } else if (this instanceof Operation) {
- return Math.ceil(baseTime);
- } else if (this instanceof BlackOperation) {
- return Math.ceil(baseTime * 1.5);
- } else {
- throw new Error("Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation");
- }
-}
-
-Action.prototype.getSuccessesNeededForNextLevel = function(baseSuccessesPerLevel) {
- return Math.ceil((0.5) * (this.maxLevel) * (2 * baseSuccessesPerLevel + (this.maxLevel-1)));
-}
-
-Action.prototype.setMaxLevel = function(baseSuccessesPerLevel) {
- if (this.successes >= this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel)) {
- ++this.maxLevel;
- }
-}
-
-Action.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Action", this);
-}
-Action.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Action, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Action = Action;
-var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
-
-//Action Identifier
-var ActionTypes = Object.freeze({
- "Idle": 1,
- "Contract": 2,
- "Operation": 3,
- "BlackOp": 4,
- "BlackOperation": 4,
- "Training": 5,
- "Recruitment": 6,
- "FieldAnalysis": 7,
- "Field Analysis": 7
-});
-function ActionIdentifier(params={}) {
- if (params.name) {this.name = params.name;}
- if (params.type) {this.type = params.type;}
-}
-ActionIdentifier.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("ActionIdentifier", this);
-}
-ActionIdentifier.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(ActionIdentifier, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.ActionIdentifier = ActionIdentifier;
-
-//Contracts
-function Contract(params={}) {
- Action.call(this, params);
-}
-Contract.prototype = Object.create(Action.prototype);
-Contract.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Contract", this);
-}
-Contract.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Contract, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Contract = Contract;
-
-//Operations
-function Operation(params={}) {
- Action.call(this, 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 Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Operation", this);
-}
-Operation.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Operation, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Operation = Operation;
-
-//Black Operations
-function BlackOperation(params={}) {
- Operation.call(this, params);
-
- //Black ops are one time missions
- this.count = 1;
- this.countGrowth = 0;
-}
-BlackOperation.prototype = Object.create(Action.prototype);
-BlackOperation.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("BlackOperation", this);
-}
-BlackOperation.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(BlackOperation, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.BlackOperation = BlackOperation;
-var BlackOperations = {};
-
-function Bladeburner(params={}) {
- this.numHosp = 0; //Number of hospitalizations
- this.moneyLost = 0; //Money lost due to hospitalizations
- this.rank = 0;
- this.maxRank = 0; //Used to determine skill points
-
- this.skillPoints = 0;
- this.totalSkillPoints = 0;
-
- this.teamSize = 0; //Number of team members
- this.teamLost = 0; //Number of team members lost
-
- this.storedCycles = 0;
-
- this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 600); //5-10 minutes
-
- //These times are in seconds
- this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)
- this.actionTimeCurrent = 0;
-
- //ActionIdentifier Object
- var idleActionType = ActionTypes["Idle"];
- this.action = new ActionIdentifier({type:idleActionType});
-
- this.cities = {};
- for (var i = 0; i < CityNames.length; ++i) {
- this.cities[CityNames[i]] = new City({name:CityNames[i]});
- }
- this.city = _Location_js__WEBPACK_IMPORTED_MODULE_5__["Locations"].Sector12;
-
- //Map of SkillNames -> level
- this.skills = {};
- this.skillMultipliers = {};
- this.updateSkillMultipliers(); //Calls resetSkillMultipliers()
-
- //Max Stamina is based on stats and Bladeburner-specific bonuses
- this.staminaBonus = 0; //Gained from training
- this.maxStamina = 0;
- 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.
- this.contracts = {};
- this.operations = {};
-
- //Object that contains name of all Black Operations that have been completed
- this.blackops = {};
-
- //Flags for whether these actions should be logged to console
- this.logging = {
- general:true,
- contracts:true,
- ops:true,
- blackops:true,
- events:true,
- }
-
- //Simple automation values
- this.automateEnabled = false;
- this.automateActionHigh = 0;
- this.automateThreshHigh = 0; //Stamina Threshold
- this.automateActionLow = 0;
- this.automateThreshLow = 0; //Stamina Threshold
-
- //Initialization
- initBladeburner();
- this.initializeDomElementRefs();
- if (params.new) {this.create();}
-}
-
-Bladeburner.prototype.prestige = function() {
- this.resetAction();
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"]["Bladeburners"];
- if (this.rank >= RankNeededForFaction) {
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
- }
-}
-
-Bladeburner.prototype.create = function() {
- this.contracts["Tracking"] = new Contract({
- name:"Tracking",
- desc:"Identify and locate Synthoids. This contract involves reconnaissance " +
- "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
" +
- "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " +
- "whatever city you are currently in.",
- baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,
- rankGain:0.3, hpLoss:0.5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5),
- weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},
- isStealth:true
- });
- this.contracts["Bounty Hunter"] = new Contract({
- name:"Bounty Hunter",
- desc:"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
" +
- "Successfully completing a Bounty Hunter contract will lower the population in your " +
- "current city, and will also increase its chaos level.",
- baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,
- rankGain:0.9, hpLoss:1,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 3),
- weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
- this.contracts["Retirement"] = new Contract({
- name:"Retirement",
- desc:"Hunt down and retire (kill) rogue Synthoids.
" +
- "Successfully copmleting a Retirement contract will lower the population in your current " +
- "city, and will also increase its chaos level.",
- baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,
- rankGain:0.6, hpLoss:1,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1,4),
- weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
-
- this.operations["Investigation"] = new Operation({
- name:"Investigation",
- desc:"As a field agent, investigate and identify Synthoid " +
- "populations, movements, and operations.
Successful " +
- "Investigation ops will increase the accuracy of your " +
- "synthoid data.
" +
- "You will NOT lose HP from failed Investigation ops.",
- baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,
- rankGain:2, rankLoss:0.2,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(50, 400), countGrowth:1,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},
- decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Undercover Operation"] = new Operation({
- name:"Undercover Operation",
- desc:"Conduct undercover operations to identify hidden " +
- "and underground Synthoid communities and organizations.
" +
- "Successful Undercover ops will increase the accuracy of your synthoid " +
- "data.",
- baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,
- rankGain:4, rankLoss:0.4, hpLoss:2,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(50, 300), countGrowth:1,
- weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Sting Operation"] = new Operation({
- name:"Sting Operation",
- desc:"Conduct a sting operation to bait and capture particularly " +
- "notorious Synthoid criminals.",
- baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,
- rankGain:5, rankLoss:0.5, hpLoss:2.5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25,400), countGrowth:0.75,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Raid"] = new Operation({
- name:"Raid",
- desc:"Lead an assault on a known Synthoid community. Note that " +
- "there must be an existing Synthoid community in your current city " +
- "in order for this Operation to be successful",
- baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,
- rankGain:50,rankLoss:2.5,hpLoss:50,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 150), countGrowth:0.2,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isKill:true
- });
- this.operations["Stealth Retirement Operation"] = new Operation({
- name:"Stealth Retirement Operation",
- desc:"Lead a covert operation to retire Synthoids. The " +
- "objective is to complete the task without " +
- "drawing any attention. Stealth and discretion are key.",
- baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,
- rankGain:20, rankLoss:2, hpLoss:10,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 250), countGrowth:0.1,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isStealth:true, isKill:true
- });
- this.operations["Assassination"] = new Operation({
- name:"Assassination",
- desc:"Assassinate Synthoids that have been identified as " +
- "important, high-profile social and political leaders " +
- "in the Synthoid communities.",
- baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,
- rankGain:40, rankLoss:4, hpLoss:5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 200), countGrowth:0.1,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},
- isStealth:true, isKill:true
- });
-}
-
-Bladeburner.prototype.storeCycles = function(numCycles=1) {
- this.storedCycles += numCycles;
-}
-
-Bladeburner.prototype.process = function() {
- //Extreme condition...if Operation Daedalus is complete trigger the BitNode
- if (_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["redPillFlag"] === false && this.blackops.hasOwnProperty("Operation Daedalus")) {
- return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN);
- }
-
- //If the Player starts doing some other actions, set action to idle and alert
- if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].BladesSimulacrum].owned === false && _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].isWorking) {
- if (this.action.type !== ActionTypes["Idle"]) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Your Bladeburner action was cancelled because you started " +
- "doing something else");
- }
- this.resetAction();
- }
-
- //A 'tick' for this mechanic is one second (= 5 game cycles)
- if (this.storedCycles >= CyclesPerSecond) {
- var seconds = Math.floor(this.storedCycles / CyclesPerSecond);
- seconds = Math.min(seconds, 5); //Max of 5 'ticks'
- this.storedCycles -= seconds * CyclesPerSecond;
-
- //Stamina
- this.calculateMaxStamina();
- this.stamina += (this.calculateStaminaGainPerSecond() * seconds);
- this.stamina = Math.min(this.maxStamina, this.stamina);
-
- //Count increase for contracts/operations
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- var contract = this.contracts[contractName];
- contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);
- }
- }
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- var op = this.operations[operationName];
- op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);
- }
- }
-
- //Chaos goes down very slowly
- for (var i = 0; i < CityNames.length; ++i) {
- var city = this.cities[CityNames[i]];
- if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
- city.chaos -= (0.0001 * seconds);
- city.chaos = Math.max(0, city.chaos);
- }
-
- //Random Events
- this.randomEventCounter -= seconds;
- if (this.randomEventCounter <= 0) {
- this.randomEvent();
- this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 600);
- }
-
- this.processAction(seconds);
-
- //Automation
- if (this.automateEnabled) {
- if (this.stamina <= this.automateThreshLow) {
- if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {
- this.action = this.automateActionLow;
- this.startAction(this.action);
- }
- } else if (this.stamina >= this.automateThreshHigh) {
- if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {
- this.action = this.automateActionHigh;
- this.startAction(this.action);
- }
- }
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
- this.updateContent();
- }
- }
-}
-
-Bladeburner.prototype.calculateMaxStamina = function() {
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * this.skillMultipliers.effAgi;
- var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);
- maxStamina *= this.skillMultipliers.stamina;
- maxStamina *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult;
- if (isNaN(maxStamina)) {throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()");}
- this.maxStamina = maxStamina;
-}
-
-Bladeburner.prototype.calculateStaminaGainPerSecond = function() {
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * this.skillMultipliers.effAgi;
- var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;
- var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);
- return gain * (this.skillMultipliers.stamina * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult);
-}
-
-Bladeburner.prototype.calculateStaminaPenalty = function() {
- return Math.min(1, this.stamina / (0.5 * this.maxStamina));
-}
-
-Bladeburner.prototype.changeRank = function(change) {
- if (isNaN(change)) {throw new Error("NaN passed into Bladeburner.changeRank()");}
- this.rank += change;
- if (this.rank < 0) {this.rank = 0;}
- this.maxRank = Math.max(this.rank, this.maxRank);
-
- var bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- if (bladeburnerFac.isMember) {
- var favorBonus = 1 + (bladeburnerFac.favor / 100);
- bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult * favorBonus);
- }
- }
-
- //Gain skill points. You get 1 every 4 ranks
- var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;
- if (this.maxRank >= rankNeededForSp) {
- //Calculate how many skill points to gain
- var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);
- this.skillPoints += gainedSkillPoints;
- this.totalSkillPoints += gainedSkillPoints;
- }
-}
-
-Bladeburner.prototype.getCurrentCity = function() {
- var city = this.cities[this.city];
- if (!(city instanceof City)) {
- throw new Error("Bladeburner.getCurrentCity() did not properly return a City object");
- }
- return city;
-}
-
-Bladeburner.prototype.resetSkillMultipliers = function() {
- this.skillMultipliers = {
- successChanceAll:1,
- successChanceStealth:1,
- successChanceKill:1,
- successChanceContract:1,
- successChanceOperation:1,
- successChanceEstimate:1,
- actionTime:1,
- effHack:1,
- effStr:1,
- effDef:1,
- effDex:1,
- effAgi:1,
- effCha:1,
- effInt:1,
- stamina:1,
- weaponAbility:1,
- gunAbility:1,
- };
-}
-
-Bladeburner.prototype.updateSkillMultipliers = function() {
- this.resetSkillMultipliers();
- for (var skillName in this.skills) {
- if (this.skills.hasOwnProperty(skillName)) {
- var skill = Skills[skillName];
- if (skill == null) {
- throw new Error("Could not find Skill Object for: " + skillName);
- }
- var level = this.skills[skillName];
- if (level == null || level <= 0) {continue;} //Not upgraded
-
- var multiplierNames = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multiplierNames.length; ++i) {
- var multiplierName = multiplierNames[i];
- if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {
- var value = skill[multiplierName] * level;
- var multiplierValue = 1 + (value / 100);
- if (multiplierName === "actionTime") {
- multiplierValue = 1 - (value / 100);
- }
- this.skillMultipliers[multiplierName] *= multiplierValue;
- }
- }
- }
- }
-}
-
-Bladeburner.prototype.upgradeSkill = function(skill) {
- //This does NOT handle deduction of skill points
- var skillName = skill.name;
- if (this.skills[skillName]) {
- ++this.skills[skillName];
- } else {
- this.skills[skillName] = 1;
- }
- if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {
- throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]);
- }
- this.updateSkillMultipliers();
-}
-
-Bladeburner.prototype.getActionObject = function(actionId) {
- //Given an ActionIdentifier object, returns the corresponding
- //Contract, Operation, or BlackOperation object
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- return this.contracts[actionId.name];
- break;
- case ActionTypes["Operation"]:
- return this.operations[actionId.name];
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return BlackOperations[actionId.name];
- break;
- default:
- return null;
- console.log("WARNING: Bladeburner.getActionObject() called with an unexpected " +
- "ActionIdentifier type: " + actionId.type);
- }
-}
-
-//Sets the player to the "IDLE" action
-Bladeburner.prototype.resetAction = function() {
- this.action = new ActionIdentifier({type:ActionTypes.Idle});
-}
-
-Bladeburner.prototype.startAction = function(actionId) {
- if (actionId == null) {return;}
- this.action = actionId;
- this.actionTimeCurrent = 0;
- switch (actionId.type) {
- case ActionTypes["Idle"]:
- this.actionTimeToComplete = 0;
- break;
- case ActionTypes["Contract"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get Contract Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Operation"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error ("Failed to get Operation Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get BlackOperation object for: " + actionId.name);
- }
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.actionTimeToComplete = 30;
- break;
- case ActionTypes["Recruitment"]:
- this.actionTimeToComplete = this.getRecruitmentTime();
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- this.actionTimeToComplete = 30;
- break;
- default:
- throw new Error("Invalid Action Type in Bladeburner.startAction(): " + actionId.type);
- break;
- }
-}
-
-Bladeburner.prototype.processAction = function(seconds) {
- if (this.action.type === ActionTypes["Idle"]) {return;}
- if (this.actionTimeToComplete <= 0) {
- console.log("action.type: " + this.action.type);
- throw new Error("Invalid actionTimeToComplete value: " + this.actionTimeToComplete);
- }
- if (!(this.action instanceof ActionIdentifier)) {
- throw new Error("Bladeburner.action is not an ActionIdentifier Object");
- }
-
- this.actionTimeCurrent += seconds;
- if (this.actionTimeCurrent >= this.actionTimeToComplete) {
- return this.completeAction();
- }
-}
-
-Bladeburner.prototype.completeAction = function() {
- switch (this.action.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- try {
- var isOperation = (this.action.type === ActionTypes["Operation"]);
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
- var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Process Contract/Operation success/failure
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- ++action.successes;
- --action.count;
-
- //Earn money for contracts
- var moneyGain = 0;
- if (!isOperation) {
- moneyGain = ContractBaseMoneyGain * rewardMultiplier;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainMoney(moneyGain);
- }
-
- if (isOperation) {
- action.setMaxLevel(OperationSuccessesPerLevel);
- } else {
- action.setMaxLevel(ContractSuccessesPerLevel);
- }
- if (action.rankGain) {
- var gain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankGain * rewardMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerRank, 10);
- this.changeRank(gain);
- if (isOperation && this.logging.ops) {
- this.log(action.name + " successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(gain, 3) + " rank");
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(gain, 3) + " rank and " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(moneyGain).format("$0.000a"));
- }
- }
- isOperation ? this.completeOperation(true) : this.completeContract(true);
- } else {
- this.gainActionStats(action, false);
- ++action.failures;
- var loss = 0, damage = 0;
- if (action.rankLoss) {
- loss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankLoss * rewardMultiplier, 10);
- this.changeRank(-1 * loss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(damage, 10));
- this.hpLost += damage;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].max_hp);
- }
- }
- var logLossText = "";
- if (loss > 0) {logLossText += "Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(loss, 3) + " rank.";}
- if (damage > 0) {logLossText += "Took " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(damage, 0) + " damage.";}
- if (isOperation && this.logging.ops) {
- this.log(action.name + " failed! " + logLossText);
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract failed! " + logLossText);
- }
- isOperation ? this.completeOperation(false) : this.completeContract(false);
- }
- if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel
- this.startAction(this.action); //Repeat action
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- var action = this.getActionObject(this.action);
- if (action == null || !(action instanceof BlackOperation)) {
- throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Team loss variables
- var teamCount = action.teamCount, teamLossMax;
-
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- action.count = 0;
- this.blackops[action.name] = true;
- var rankGain = 0;
- if (action.rankGain) {
- rankGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankGain * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerRank, 10);
- this.changeRank(rankGain);
- }
- teamLossMax = Math.ceil(teamCount/2);
-
- //Operation Daedalus
- if (action.name === "Operation Daedalus") {
- this.resetAction();
- return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN);
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
- this.createActionAndSkillsContent();
- }
-
- if (this.logging.blackops) {
- this.log(action.name + " successful! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(rankGain, 1) + " rank");
- }
- } else {
- this.gainActionStats(action, false);
- var rankLoss = 0, damage = 0;
- if (action.rankLoss) {
- rankLoss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankLoss, 10);
- this.changeRank(-1 * rankLoss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(damage, 10));
- if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].max_hp);
- }
- }
- teamLossMax = Math.floor(teamCount);
-
- if (this.logging.blackops) {
- this.log(action.name + " failed! Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(rankLoss, 1) + " rank and took" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(damage, 0) + " damage");
- }
- }
-
- this.resetAction(); //Stop regardless of success or fail
-
- //Calculate team lossses
- if (teamCount >= 1) {
- var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, teamLossMax);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.blackops) {
- this.log("You lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(losses, 0) + " team members during " + action.name);
- }
- }
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.stamina -= (0.5 * BaseStaminaLoss);
- var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult,
- defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult,
- dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult,
- agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult,
- staminaGain = 0.04 * this.skillMultipliers.stamina;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainStrengthExp(strExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDefenseExp(defExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDexterityExp(dexExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainAgilityExp(agiExpGain);
- this.staminaBonus += (staminaGain);
- if (this.logging.general) {
- this.log("Training completed. Gained: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(strExpGain, 1) + " str exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(defExpGain, 1) + " def exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(dexExpGain, 1) + " dex exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(agiExpGain, 1) + " agi exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(staminaGain, 3) + " max stamina");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- //Does not use stamina. Effectiveness depends on hacking, int, and cha
- var eff = 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_skill, 0.3) +
- 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].intelligence, 0.9) +
- 0.02 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma, 0.3);
- eff *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult;
- if (isNaN(eff) || eff < 0) {
- throw new Error("Field Analysis Effectiveness calculated to be NaN or negative");
- }
- var hackingExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult,
- charismaExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainHackingExp(hackingExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainIntelligenceExp(BaseIntGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(charismaExpGain);
- this.changeRank(0.1);
- console.log("DEBUG: Field Analysis effectiveness is " + (eff * this.skillMultipliers.successChanceEstimate));
- this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
- if (this.logging.general) {
- this.log("Field analysis completed. Gained 0.1 rank, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(hackingExpGain, 1) + " hacking exp, and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(charismaExpGain, 1) + " charisma exp");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["Recruitment"]:
- var successChance = this.getRecruitmentSuccessChance();
- console.log("Bladeburner recruitment success chance: " + successChance);
- if (Math.random() < successChance) {
- var expGain = 2 * BaseStatGain * this.actionTimeToComplete;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(expGain);
- ++this.teamSize;
- if (this.logging.general) {
- this.log("Successfully recruited a team member! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- } else {
- var expGain = BaseStatGain * this.actionTimeToComplete;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(expGain);
- if (this.logging.general) {
- this.log("Failed to recruit a team member. Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- }
- this.startAction(this.action); //Repeat action
- break;
- default:
- break;
- }
-}
-
-Bladeburner.prototype.completeContract = function(success) {
- if (this.action.type !== ActionTypes.Contract) {
- throw new Error("completeContract() called even though current action is not a Contract");
- }
- var city = this.getCurrentCity();
- if (success) {
- switch (this.action.name) {
- case "Tracking":
- //Increase estimate accuracy by a relatively small amount
- city.improvePopulationEstimateByCount(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(100, 1e3));
- break;
- case "Bounty Hunter":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.02);
- break;
- case "Retirement":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.04);
- break;
- default:
- throw new Error("Invalid Action name in completeContract: " + this.action.name);
- }
- }
-}
-
-Bladeburner.prototype.completeOperation = function(success) {
- if (this.action.type !== ActionTypes.Operation) {
- throw new Error("completeOperation() called even though current action is not an Operation");
- }
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
-
- //Calculate team losses
- var teamCount = action.teamCount, max;
- if (teamCount >= 1) {
- if (success) {
- max = Math.ceil(teamCount/2);
- } else {
- max = Math.floor(teamCount)
- }
- var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, max);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.ops && losses > 0) {
- this.log("Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(losses, 0) + " team members during this " + action.name);
- }
- }
-
- var city = this.getCurrentCity();
- if (this.logging.ops) {
- if (success) {
- this.log(action.name + " completed successfully! ")
- } else {
-
- }
- }
- switch (action.name) {
- case "Investigation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.1);
- }
- break;
- case "Undercover Operation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.15);
- }
- break;
- case "Sting Operation":
- if (success) {
- city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});
- }
- city.changeChaosByCount(0.1);
- break;
- case "Raid":
- if (success) {
- city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});
- --city.comms;
- --city.commsEst;
- } else {
- var change = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-3, -1);
- city.changePopulationByPercentage(change, {nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5));
- break;
- case "Stealth Retirement Operation":
- if (success) {
- city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-3, -1));
- break;
- case "Assassination":
- if (success) {
- city.changePopulationByCount(-1, {estChange:-1});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-5, 5));
- break;
- default:
- throw new Error("Invalid Action name in completeOperation: " + this.action.name);
- }
-}
-
-Bladeburner.prototype.getRecruitmentTime = function() {
- var effCharisma = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma * this.skillMultipliers.effCha;
- var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;
- return Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));
-}
-
-Bladeburner.prototype.getRecruitmentSuccessChance = function() {
- return Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma, 0.45) / (this.teamSize + 1);
-}
-
-//Process stat gains from Contracts, Operations, and Black Operations
-//@action(Action obj) - Derived action class
-//@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
- var difficultyMult = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
-
- var time = this.actionTimeToComplete;
- var successMult = success ? 1 : 0.5;
-
- var unweightedGain = time * BaseStatGain * successMult * difficultyMult;
- var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainHackingExp(unweightedGain * action.weights.hack * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainStrengthExp(unweightedGain * action.weights.str * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDefenseExp(unweightedGain * action.weights.def * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDexterityExp(unweightedGain * action.weights.dex * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainAgilityExp(unweightedGain * action.weights.agi * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(unweightedGain * action.weights.cha * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainIntelligenceExp(unweightedIntGain * action.weights.int);
-}
-
-Bladeburner.prototype.randomEvent = function() {
- var chance = Math.random();
-
- //Choose random source/destination city for events
- var sourceCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
- var sourceCity = this.cities[sourceCityName];
- if (!(sourceCity instanceof City)) {
- throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
- }
-
- var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
-
- if (!(sourceCity instanceof City) || !(destCity instanceof City)) {
- throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
- }
-
- if (chance <= 0.05) {
- //New Synthoid Community, 5%
- ++sourceCity.comms;
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else if (chance <= 0.1) {
- //Synthoid Community Migration, 5%
- if (sourceCity.comms <= 0) {
- //If no comms in source city, then instead trigger a new Synthoid community event
- ++sourceCity.comms;
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else {
- --sourceCity.comms;
- ++destCity.comms;
-
- //Change pop
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-
- if (this.logging.events) {
- this.log("Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city");
- }
- }
- } else if (chance <= 0.3) {
- //New Synthoids (non community), 20%
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(8, 24) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- } else if (chance <= 0.5) {
- //Synthoid migration (non community) 20%
- this.triggerMigration(sourceCityName);
- if (this.logging.events) {
- this.log("Intelligence indicates that a large number of Synthoids migrated from " + sourceCityName + " to some other city");
- }
- } else if (chance <= 0.7) {
- //Synthoid Riots (+chaos), 20%
- sourceCity.chaos += 1;
- sourceCity.chaos *= (1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(5, 10) / 100);
- if (this.logging.events) {
- this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
- }
- } else if (chance <= 0.9) {
- //Less Synthoids, 20%
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(5, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- }
- //20% chance of nothing happening
-}
-
-Bladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {
- if (chance == null || isNaN(chance)) {
- console.log("ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()");
- }
- if (chance > 1) {chance /= 100;}
- if (Math.random() < chance) {this.triggerMigration(sourceCityName);}
-}
-
-Bladeburner.prototype.triggerMigration = function(sourceCityName) {
- var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
- var sourceCity = this.cities[sourceCityName];
- if (destCity == null || sourceCity == null) {
- throw new Error("Failed to find City with name: " + destCityName);
- }
- var rand = Math.random(), percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(3, 15) / 100;
-
- if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration
- percentage *= Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(2, 4); //Migration increases population change
- --sourceCity.comms;
- ++destCity.comms;
- }
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-}
-
-var DomElems = {};
-
-Bladeburner.prototype.initializeDomElementRefs = function() {
- DomElems = {
- bladeburnerDiv: null,
-
- //Main Divs
- overviewConsoleParentDiv: null,
-
- overviewDiv: null, //Overview of stats that stays fixed on left
- actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)
- currentTab: null, //Contracts, Operations, Black Ops, Skills
-
- consoleDiv: null,
- consoleTable: null,
- consoleInputRow: null, //tr
- consoleInputCell: null, //td
- consoleInputHeader: null, //"> "
- consoleInput: null, //Actual input element
-
- //Overview Content
- overviewRank: null,
- overviewStamina: null,
- overviewStaminaHelpTip: null,
- overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city
- overviewEstPop: null,
- overviewEstPopHelpTip: null,
- overviewEstComms: null,
- overviewChaos: null,
- overviewSkillPoints: null,
- overviewAugSuccessMult: null,
- overviewAugMaxStaminaMult: null,
- overviewAugStaminaGainMult: null,
- overviewAugAnalysisMult: null,
-
- //Actions and Skills Content
- actionsAndSkillsDesc: null,
- actionsAndSkillsList: null, //ul element of all UI elements in this panel
- generalActions: {},
- contracts: {},
- operations: {},
- blackops: {},
- skills: {},
- skillPointsDisplay: null,
- };
-}
-
-Bladeburner.prototype.createContent = function() {
- DomElems.bladeburnerDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- id:"bladeburner-container", position:"fixed", class:"generic-menupage-container",
- });
-
- //Parent Div for Overview and Console
- DomElems.overviewConsoleParentDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- height:"60%", display:"block", position:"relative",
- });
-
- //Overview and Action/Skill pane
- DomElems.overviewDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- width:"30%", display:"inline-block", border:"1px solid white",
- });
-
- DomElems.actionAndSkillsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- height:"60%", width:"70%", display:"block",
- border:"1px solid white", margin:"6px", padding:"6px",
- });
-
- DomElems.currentTab = "general";
-
- this.createOverviewContent();
- this.createActionAndSkillsContent();
-
- //Console
- DomElems.consoleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-console-div",
- clickListener:()=>{
- if (DomElems.consoleInput instanceof Element) {
- DomElems.consoleInput.focus();
- }
- return false;
- }
- });
- DomElems.consoleTable = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("table", {class:"bladeburner-console-table"});
- DomElems.consoleInputRow = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("tr", {class:"bladeburner-console-input-row", id:"bladeubrner-console-input-row"});
- DomElems.consoleInputCell = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("td", {class:"bladeburner-console-input-cell"});
- DomElems.consoleInputHeader = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {innerText:"> "});
- DomElems.consoleInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
- type:"text", class:"bladeburner-console-input", tabIndex:1,
- onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}
- });
-
- DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);
- DomElems.consoleInputCell.appendChild(DomElems.consoleInput);
- DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);
- DomElems.consoleTable.appendChild(DomElems.consoleInputRow);
- DomElems.consoleDiv.appendChild(DomElems.consoleTable);
-
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);
-
- document.getElementById("entire-game-container").appendChild(DomElems.bladeburnerDiv);
-
- this.postToConsole("Bladeburner Console BETA");
- this.postToConsole("Type 'help' to see console commands");
- DomElems.consoleInput.focus();
-}
-
-Bladeburner.prototype.clearContent = function() {
- if (DomElems.bladeburnerDiv instanceof Element) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.bladeburnerDiv);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElement"])(DomElems.bladeburnerDiv);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems);
- this.initializeDomElementRefs();
-}
-
-Bladeburner.prototype.createOverviewContent = function() {
- if (DomElems.overviewDiv == null) {
- throw new Error("Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null");
- }
-
- DomElems.overviewRank = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"Rank: ",
- display:"inline-block",
- tooltip:"Your rank within the Bladeburner division",
- });
-
- DomElems.overviewStamina = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"inline-block",
- });
-
- DomElems.overviewStaminaHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- innerText:"?", class:"help-tip",
- clickListener:()=>{
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Performing actions will use up your stamina.
" +
- "Your max stamina is determined primarily by your agility stat.
" +
- "Your stamina gain rate is determined by both your agility and your " +
- "max stamina. Higher max stamina leads to a higher gain rate.
" +
- "Once your " +
- "stamina falls below 50% of its max value, it begins to negatively " +
- "affect the success rate of your contracts/operations. This penalty " +
- "is shown in the overview panel. If the penalty is 15%, then this means " +
- "your success rate would be multipled by 85% (100 - 15).
" +
- "Your max stamina and stamina gain rate can also be increased by " +
- "training, or through skills and Augmentation upgrades.");
- }
- });
-
- DomElems.overviewGen1 = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- });
-
- DomElems.overviewEstPop = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"Est. Synthoid Population: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner division's estimate of how many Synthoids exist " +
- "in your current city."
- });
-
- DomElems.overviewEstPopHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- innerText:"?", class:"help-tip",
- clickListener:()=>{
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("The success rate of your contracts/operations depends on " +
- "the population of Synthoids in your current city. " +
- "The success rate that is shown to you is only an estimate, " +
- "and it is based on your Synthoid population estimate.
" +
- "Therefore, it is important that this Synthoid population estimate " +
- "is accurate so that you have a better idea of your " +
- "success rate for contracts/operations. Certain " +
- "actions will increase the accuracy of your population " +
- "estimate.
" +
- "The Synthoid populations of cities can change due to your " +
- "actions or random events. If random events occur, they will " +
- "be logged in the Bladeburner Console.");
- }
- });
-
- DomElems.overviewEstComms = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"Est. Synthoid Communities: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner divison's estimate of how many Synthoid " +
- "communities exist in your current city.",
- });
-
- DomElems.overviewChaos = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"City Chaos: ",
- display:"inline-block",
- tooltip:"The city's chaos level due to tensions and conflicts between humans and Synthoids. " +
- "Having too high of a chaos level can make contracts and operations harder."
- });
-
- DomElems.overviewSkillPoints = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
-
- DomElems.overviewAugSuccessMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
- DomElems.overviewAugMaxStaminaMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
- DomElems.overviewAugStaminaGainMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
- DomElems.overviewAugAnalysisMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
-
-
- DomElems.overviewDiv.appendChild(DomElems.overviewRank);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewStamina);
- DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);
- DomElems.overviewDiv.appendChild(DomElems.overviewGen1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewChaos);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 2);
- DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);
-
- //Travel to new city button
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerHTML:"Travel", class:"a-link-button", display:"inline-block",
- clickListener:()=>{
- var popupId = "bladeburner-travel-popup-cancel-btn";
- var popupArguments = [];
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Cancel Button
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId); return false;
- }
- }))
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", { //Info Text
- innerText:"Travel to a different city for your Bladeburner " +
- "activities. This does not cost any money. The city you are " +
- "in for your Bladeburner duties does not affect " +
- "your location in the game otherwise",
- }));
- for (var i = 0; i < CityNames.length; ++i) {
- (function(inst, i) {
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- //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:()=>{
- inst.city = CityNames[i];
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
- inst.updateOverviewContent();
- return false;
- }
- }));
- })(this, i);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, popupArguments);
- }
- }));
-
- //Faction button
- const bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Faction", class:"a-link-button", display:"inline-block",
- tooltip:"Apply to the Bladeburner Faction, or go to the faction page if you are already a member",
- clickListener:()=>{
- if (bladeburnerFac.isMember) {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionContent();
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["displayFactionContent"])(bladeburnersFactionName);
- } else {
- if (this.rank >= RankNeededForFaction) {
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Congratulations! You were accepted into the Bladeburners faction");
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.overviewDiv);
- this.createOverviewContent();
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You need a rank of 25 to join the Bladeburners Faction!")
- }
- }
- return false;
- }
- }));
- }
-
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
-
- this.updateOverviewContent();
-}
-
-Bladeburner.prototype.createActionAndSkillsContent = function() {
- if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.actionAndSkillsDiv);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.generalActions);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.contracts);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.operations);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.blackops);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.skills);
-
- //Navigation buttons
- var currTab = DomElems.currentTab.toLowerCase();
- var buttons = ["General", "Contracts", "Operations", "BlackOps", "Skills"];
- for (var i = 0; i < buttons.length; ++i) {
- (function(buttons, i, inst, currTab) {
-
- DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:buttons[i],
- class:currTab === buttons[i].toLowerCase() ? "bladeburner-nav-button-inactive" : "bladeburner-nav-button",
- clickListener:()=>{
- DomElems.currentTab = buttons[i].toLowerCase();
- inst.createActionAndSkillsContent();
- return false;
- }
- }));
- }) (buttons, i, this, currTab);
- }
-
- //General info/description for each action
- DomElems.actionsAndSkillsDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block", margin:"4px", padding:"4px"
- });
-
- //List for actions/skills
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.actionsAndSkillsList);
- DomElems.actionsAndSkillsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("ul");
-
- switch(currTab) {
- case "general":
- this.createGeneralActionsContent();
- break;
- case "contracts":
- this.createContractsContent();
- break;
- case "operations":
- this.createOperationsContent();
- break;
- case "blackops":
- this.createBlackOpsContent();
- break;
- case "skills":
- this.createSkillsContent();
- break;
- default:
- throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
- }
- this.updateContent();
-
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);
-}
-
-Bladeburner.prototype.createGeneralActionsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createGeneralActionsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerText =
- "These are generic actions that will assist you in your Bladeburner " +
- "duties. They will not affect your Bladeburner rank in any way."
-
- for (var actionName in GeneralActions) {
- if (GeneralActions.hasOwnProperty(actionName)) {
- DomElems.generalActions[actionName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-action", name:actionName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);
- }
- }
-}
-
-Bladeburner.prototype.createContractsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createContractsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Complete contracts in order to increase your Bitburner rank and earn money. " +
- "Failing a contract will cause you to lose HP, which can lead to hospitalization.
" +
- "You can unlock higher-level contracts by successfully completing them. " +
- "Higher-level contracts are more difficult, but grant more rank, experience, and money.";
-
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- DomElems.contracts[contractName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-action", name:contractName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);
- }
- }
-}
-
-Bladeburner.prototype.createOperationsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createOperationsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Carry out operations for the Bladeburner division. " +
- "Failing an operation will reduce your Bladeburner rank. It will also " +
- "cause you to lose HP, which can lead to hospitalization. In general, " +
- "operations are harder and more punishing than contracts, " +
- "but are also more rewarding.
" +
- "Operations can affect the chaos level and Synthoid population of your " +
- "current city. The exact effects vary between different Operations.
" +
- "For operations, you can use a team. You must first recruit team members. " +
- "Having a larger team will improves your chances of success.
" +
- "You can unlock higher-level operations by successfully completing them. " +
- "Higher-level operations are more difficult, but grant more rank and experience.";
-
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- DomElems.operations[operationName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-action", name:operationName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);
- }
- }
-}
-
-Bladeburner.prototype.createBlackOpsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createBlackOpsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Black Operations (Black Ops) are special, one-time covert operations. " +
- "Each Black Op must be unlocked successively by completing " +
- "the one before it.
" +
- "Like normal operations, you may use a team for Black Ops. Failing " +
- "a black op will incur heavy HP and rank losses.";
-
- //Put Black Operations in sequence of required rank
- var blackops = [];
- for (var blackopName in BlackOperations) {
- if (BlackOperations.hasOwnProperty(blackopName)) {
- blackops.push(BlackOperations[blackopName]);
- }
- }
- blackops.sort(function(a, b) {
- return (a.reqdRank - b.reqdRank);
- });
-
- for (var i = 0; i < blackops.length; ++i) {
- DomElems.blackops[blackops[i].name] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-action", name:blackops[i].name
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);
- if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops
- }
-}
-
-Bladeburner.prototype.createSkillsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createSkillsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- //Display Current multipliers
- DomElems.actionsAndSkillsDesc.innerHTML =
- "You will gain one skill point every " + RanksPerSkillPoint + " ranks.
" +
- "Note that when upgrading a skill, the benefit for that skill is additive. " +
- "However, the effects of different skills with each other is multiplicative.
"
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- DomElems.actionsAndSkillsDesc.innerHTML += "Total Success Chance: x" + mult + "
";
- break;
- case "successChanceStealth":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stealth Success Chance: x" + mult + "
";
- break;
- case "successChanceKill":
- DomElems.actionsAndSkillsDesc.innerHTML += "Retirement Success Chance: x" + mult + "
";
- break;
- case "successChanceContract":
- DomElems.actionsAndSkillsDesc.innerHTML += "Contract Success Chance: x" + mult + "
";
- break;
- case "successChanceOperation":
- DomElems.actionsAndSkillsDesc.innerHTML += "Operation Success Chance: x" + mult + "
";
- break;
- case "successChanceEstimate":
- DomElems.actionsAndSkillsDesc.innerHTML += "Synthoid Data Estimate: x" + mult + "
";
- break;
- case "actionTime":
- DomElems.actionsAndSkillsDesc.innerHTML += "Action Time: x" + mult + "
";
- break;
- case "effHack":
- DomElems.actionsAndSkillsDesc.innerHTML += "Hacking Skill: x" + mult + "
";
- break;
- case "effStr":
- DomElems.actionsAndSkillsDesc.innerHTML += "Strength: x" + mult + "
";
- break;
- case "effDef":
- DomElems.actionsAndSkillsDesc.innerHTML += "Defense: x" + mult + "
";
- break;
- case "effDex":
- DomElems.actionsAndSkillsDesc.innerHTML += "Dexterity: x" + mult + "
";
- break;
- case "effAgi":
- DomElems.actionsAndSkillsDesc.innerHTML += "Agility: x" + mult + "
";
- break;
- case "effCha":
- DomElems.actionsAndSkillsDesc.innerHTML += "Charisma: x" + mult + "
";
- break;
- case "effInt":
- DomElems.actionsAndSkillsDesc.innerHTML += "Intelligence: x" + mult + "
";
- break;
- case "stamina":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stamina: x" + mult + "
";
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
-
- //Skill Points
- DomElems.skillPointsDisplay = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerHTML:"
Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0) + ""
- });
- DomElems.actionAndSkillsDiv.appendChild(DomElems.skillPointsDisplay);
-
- //UI Element for each skill
- for (var skillName in Skills) {
- if (Skills.hasOwnProperty(skillName)) {
- DomElems.skills[skillName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
- class:"bladeburner-action", name:skillName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);
- }
- }
-}
-
-Bladeburner.prototype.updateContent = function() {
- this.updateOverviewContent();
- this.updateActionAndSkillsContent();
-}
-
-Bladeburner.prototype.updateOverviewContent = function() {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {return;}
- DomElems.overviewRank.childNodes[0].nodeValue = "Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.rank, 2);
- DomElems.overviewStamina.innerText = "Stamina: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.stamina, 3) + " / " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.maxStamina, 3);
- DomElems.overviewGen1.innerHTML =
- "Stamina Penalty: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])((1-this.calculateStaminaPenalty())*100, 1) + "%
" +
- "Team Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.teamSize, 0) + "
" +
- "Team Members Lost: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.teamLost, 0) + "
" +
- "Num Times Hospitalized: " + this.numHosp + "
" +
- "Money Lost From Hospitalizations: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(this.moneyLost).format("$0.000a") + "
" +
- "Current City: " + this.city + "
";
-
- DomElems.overviewEstPop.childNodes[0].nodeValue = "Est. Synthoid Population: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(this.getCurrentCity().popEst).format("0.000a");
- DomElems.overviewEstComms.childNodes[0].nodeValue = "Est. Synthoid Communities: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.getCurrentCity().comms, 0);
- DomElems.overviewChaos.childNodes[0].nodeValue = "City Chaos: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.getCurrentCity().chaos);
- DomElems.overviewSkillPoints.innerText = "Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0);
- DomElems.overviewAugSuccessMult.innerText = "Aug. Success Chance Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult*100, 1) + "%";
- DomElems.overviewAugMaxStaminaMult.innerText = "Aug. Max Stamina Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult*100, 1) + "%";
- DomElems.overviewAugStaminaGainMult.innerText = "Aug. Stamina Gain Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult*100, 1) + "%";
- DomElems.overviewAugAnalysisMult.innerText = "Aug. Field Analysis Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult*100, 1) + "%";
-}
-
-Bladeburner.prototype.updateActionAndSkillsContent = function() {
- if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
- switch(DomElems.currentTab.toLowerCase()) {
- case "general":
- var actionElems = Object.keys(DomElems.generalActions);
- for (var i = 0; i < actionElems.length; ++i) {
- var actionElem = DomElems.generalActions[actionElems[i]];
- var name = actionElem.name;
- var actionObj = GeneralActions[name];
- if (actionObj == null) {
- throw new Error("Could not find Object " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- if (this.action.type === ActionTypes[name]) {
- actionElem.classList.add(ActiveActionCssClass);
- } else {
- actionElem.classList.remove(ActiveActionCssClass);
- }
- this.updateGeneralActionsUIElement(actionElem, actionObj);
- }
- break;
- case "contracts":
- var contractElems = Object.keys(DomElems.contracts);
- for (var i = 0; i < contractElems.length; ++i) {
- var contractElem = DomElems.contracts[contractElems[i]];
- var name = contractElem.name;
- if (this.action.type === ActionTypes["Contract"] && name === this.action.name) {
- contractElem.classList.add(ActiveActionCssClass);
- } else {
- contractElem.classList.remove(ActiveActionCssClass);
- }
- var contract = this.contracts[name];
- if (contract == null) {
- throw new Error("Could not find Contract " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateContractsUIElement(contractElem, contract);
- }
- break;
- case "operations":
- var operationElems = Object.keys(DomElems.operations);
- for (var i = 0; i < operationElems.length; ++i) {
- var operationElem = DomElems.operations[operationElems[i]];
- var name = operationElem.name;
- if (this.action.type === ActionTypes["Operation"] && name === this.action.name) {
- operationElem.classList.add(ActiveActionCssClass);
- } else {
- operationElem.classList.remove(ActiveActionCssClass);
- }
- var operation = this.operations[name];
- if (operation == null) {
- throw new Error("Could not find Operation " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateOperationsUIElement(operationElem, operation);
- }
- break;
- case "blackops":
- var blackopsElems = Object.keys(DomElems.blackops);
- for (var i = 0; i < blackopsElems.length; ++i) {
- var blackopElem = DomElems.blackops[blackopsElems[i]];
- var name = blackopElem.name;
- if (this.action.type === ActionTypes["BlackOperation"] && name === this.action.name) {
- blackopElem.classList.add(ActiveActionCssClass);
- } else {
- blackopElem.classList.remove(ActiveActionCssClass);
- }
- var blackop = BlackOperations[name];
- if (blackop == null) {
- throw new Error("Could not find BlackOperation " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateBlackOpsUIElement(blackopElem, blackop);
- }
- break;
- case "skills":
- DomElems.skillPointsDisplay.innerHTML = "
Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0) + "";
-
- var skillElems = Object.keys(DomElems.skills);
- for (var i = 0; i < skillElems.length; ++i) {
- var skillElem = DomElems.skills[skillElems[i]];
- var name = skillElem.name;
- var skill = Skills[name];
- if (skill == null) {
- throw new Error("Could not find Skill " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateSkillsUIElement(skillElem, skill);
- }
- break;
- default:
- throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
- }
-}
-
-Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block",
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
- }));
- } else {
- //Start button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes[action.name];
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- }
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", { //Info
- innerHTML:action.desc, display:"inline-block"
- }));
-
-
-}
-
-Bladeburner.prototype.updateContractsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block"
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
- }));
- } else { //Start button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- padding:"3px", margin:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes.Contract;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- }
-
- //Level and buttons to change level
- var maxLevel = (action.level >= action.maxLevel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
- display:"inline-block",
- innerText:"Level: " + action.level + " / " + action.maxLevel,
- tooltip:action.getSuccessesNeededForNextLevel(ContractSuccessesPerLevel) + " successes " +
- "needed for next level"
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
- display:"inline",
- clickListener:()=>{
- ++action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateContractsUIElement(el, action);
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
- display:"inline",
- clickListener:()=>{
- --action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateContractsUIElement(el, action);
- return false;
- }
- }));
-
- var actionTime = action.getActionTime(this);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", { //Info
- display:"inline-block",
- innerHTML:action.desc + "\n\n" +
- "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required (s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 0) + "\n" +
- "Contracts remaining: " + Math.floor(action.count) + "\n" +
- "Successes: " + action.successes + "\n" +
- "Failures: " + action.failures,
- }));
-
- //Autolevel Checkbox
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
- var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("label", {
- for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
- tooltip:"Automatically increase contract level when possible"
- }));
- var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
- type:"checkbox", id:autolevelCheckboxId, margin:"4px",
- checked:action.autoLevel,
- changeListener:()=>{
- action.autoLevel = autolevelCheckbox.checked;
- }
- });
- el.appendChild(autolevelCheckbox);
-}
-
-Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block"
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
- }));
- } else { //Start button and set Team Size button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes.Operation;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- var popupId = "bladeburner-operation-set-team-size-popup";
- var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"Enter the amount of team members you would like to take on these " +
- "operations. If you do not have the specified number of team members, " +
- "then as many as possible will be used. Note that team members may " +
- "be lost during operations."
-
- });
- var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
- type:"number", placeholder: "Team Members"
- });
- var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Confirm", class:"a-link-button",
- clickListener:()=>{
- var num = Math.round(parseFloat(input.value));
- if (isNaN(num)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
- } else {
- action.teamCount = num;
- this.updateOperationsUIElement(el, action);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
- return false;
- }
- });
- var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
- return false;
- }
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
- }
- }));
- }
-
- //Level and buttons to change level
- var maxLevel = (action.level >= action.maxLevel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
- display:"inline-block",
- innerText:"Level: " + action.level + " / " + action.maxLevel,
- tooltip:action.getSuccessesNeededForNextLevel(OperationSuccessesPerLevel) + " successes " +
- "needed for next level"
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
- display:"inline",
- clickListener:()=>{
- ++action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateOperationsUIElement(el, action);
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
- display:"inline",
- clickListener:()=>{
- --action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateOperationsUIElement(el, action);
- return false;
- }
- }));
-
- //General Info
- var difficulty = action.getDifficulty();
- var actionTime = action.getActionTime(this);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
- display:"inline-block",
- innerHTML:action.desc + "\n\n" +
- "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 1) + "\n" +
- "Operations remaining: " + Math.floor(action.count) + "\n" +
- "Successes: " + action.successes + "\n" +
- "Failures: " + action.failures,
- }));
-
- //Autolevel Checkbox
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
- var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("label", {
- for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
- tooltip:"Automatically increase operation level when possible"
- }));
- var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
- type:"checkbox", id:autolevelCheckboxId, margin:"4px",
- checked:action.autoLevel,
- changeListener:()=>{
- action.autoLevel = autolevelCheckbox.checked;
- }
- });
- el.appendChild(autolevelCheckbox);
-}
-
-Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var isCompleted = (this.blackops[action.name] != null);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
- var difficulty = action.getDifficulty();
- var actionTime = action.getActionTime(this);
- var hasReqdRank = this.rank >= action.reqdRank;
-
- //UI for Completed Black Op
- if (isCompleted) {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", {
- innerText:action.name + " (COMPLETED)", display:"block",
- }));
- return;
- }
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block",
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
- }));
- } else {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Start button
- innerText:"Start", margin:"3px", padding:"3px",
- class:hasReqdRank ? "a-link-button" : "a-link-button-inactive",
- clickListener:()=>{
- this.action.type = ActionTypes.BlackOperation;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Set Team Size Button
- innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- var popupId = "bladeburner-operation-set-team-size-popup";
- var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- innerText:"Enter the amount of team members you would like to take on this " +
- "BlackOp. If you do not have the specified number of team members, " +
- "then as many as possible will be used. Note that team members may " +
- "be lost during operations."
-
- });
- var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
- type:"number", placeholder: "Team Members"
- });
- var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Confirm", class:"a-link-button",
- clickListener:()=>{
- var num = Math.round(parseFloat(input.value));
- if (isNaN(num)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
- } else {
- action.teamCount = num;
- this.updateBlackOpsUIElement(el, action);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
- return false;
- }
- });
- var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
- return false;
- }
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
- }
- }));
- }
-
- //Info
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"inline-block",
- innerHTML:"
" + action.desc + "
",
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block", color:hasReqdRank ? "white" : "red",
- innerHTML:"Required Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.reqdRank, 0) + "
"
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"inline-block",
- innerHTML:"Estimated Success Chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 1),
- }))
-}
-
-Bladeburner.prototype.updateSkillsUIElement = function(el, skill) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
- var skillName = skill.name;
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var pointCost = skill.calculateCost(currentLevel);
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
- innerText:skill.name + " (Lvl " + currentLevel + ")", display:"inline-block"
- }));
-
- var canLevel = this.skillPoints >= pointCost;
- var maxLvl = skill.maxLvl ? currentLevel >= skill.maxLvl : false;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Level up button
- innerText:"Level", display:"inline-block",
- class: canLevel && !maxLvl ? "a-link-button" : "a-link-button-inactive",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- if (this.skillPoints < pointCost) {return;}
- this.skillPoints -= pointCost;
- this.upgradeSkill(skill);
- this.createActionAndSkillsContent();
- return false;
- }
- }));
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
- if (maxLvl) {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- color:"red", display:"block",
- innerText:"MAX LEVEL"
- }));
- } else {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
- display:"block",
- innerText:"Skill Points required: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(pointCost, 0),
- }));
- }
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", { //Info/Description
- innerHTML:skill.desc, display:"inline-block",
- }));
-}
-
-//Bladeburner Console Window
-Bladeburner.prototype.postToConsole = function(input) {
- if (input == null || DomElems.consoleDiv == null) {return;}
- $("#bladeubrner-console-input-row").before(' ');
- if (DomElems.consoleTable.childNodes.length > 200) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
- this.updateConsoleScroll();
-}
-
-Bladeburner.prototype.updateConsoleScroll = function() {
- DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;
-}
-
-Bladeburner.prototype.resetConsoleInput = function() {
- DomElems.consoleInput.value = "";
-}
-
-Bladeburner.prototype.clearConsole = function() {
- while (DomElems.consoleTable.childNodes.length > 1) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
-}
-
-Bladeburner.prototype.log = function(input) {
- //Adds a timestamp and then just calls postToConsole
- var d = new Date();
- var timestamp = d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes();
- this.postToConsole("[" + timestamp + "] " + input);
-}
-
-//Handles a potential series of commands (comm1; comm2; comm3;)
-Bladeburner.prototype.executeConsoleCommands = function(commands) {
- try {
- //Console History
- if (consoleHistory[consoleHistory.length-1] != commands) {
- consoleHistory.push(commands);
- if (consoleHistory.length > 50) {
- consoleHistory.splice(0, 1);
- }
- }
- consoleHistoryIndex = consoleHistory.length;
-
- var arrayOfCommands = commands.split(";");
- for (var i = 0; i < arrayOfCommands.length; ++i) {
- this.executeConsoleCommand(arrayOfCommands[i]);
- }
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
- }
-}
-
-//A single command
-Bladeburner.prototype.executeConsoleCommand = function(command) {
- command = command.trim();
- command = command.replace(/\s\s+/g, ' '); //Replace all whitespace w/ a single space
-
- var args = this.parseCommandArguments(command);
- if (args.length <= 0) {return;} //Log an error?
-
- switch(args[0].toLowerCase()) {
- case "automate":
- this.executeAutomateConsoleCommand(args);
- break;
- case "clear":
- case "cls":
- this.clearConsole();
- break;
- case "help":
- this.executeHelpConsoleCommand(args);
- break;
- case "log":
- this.executeLogConsoleCommand(args);
- break;
- case "skill":
- this.executeSkillConsoleCommand(args);
- break;
- case "start":
- this.executeStartConsoleCommand(args);
- break;
- case "stop":
- this.resetAction();
- break;
- default:
- this.postToConsole("Invalid console command");
- break;
- }
-}
-
-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
- var args = [];
- var start = 0, i = 0;
- while (i < command.length) {
- var c = command.charAt(i);
- if (c === '"') {
- var endQuote = command.indexOf('"', i+1);
- if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === " ")) {
- args.push(command.substr(i+1, (endQuote - i - 1)));
- if (endQuote === command.length-1) {
- start = i = endQuote+1;
- } else {
- start = i = endQuote+2; //Skip the space
- }
- continue;
- }
- } else if (c === " ") {
- args.push(command.substr(start, i-start));
- start = i+1;
- }
- ++i;
- }
- if (start !== i) {args.push(command.substr(start, i-start));}
- console.log("Bladeburner.parseCommandArguments returned: " + args);
- return args;
-}
-
-Bladeburner.prototype.executeAutomateConsoleCommand = function(args) {
- if (args.length !== 2 && args.length !== 4) {
- this.postToConsole("Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info");
- return;
- }
-
- //Enable/Disable
- if (args.length === 2) {
- var flag = args[1];
- if (flag.toLowerCase() === "status") {
- this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
- if (this.automateEnabled) {
- this.postToConsole("When your stamina drops to " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.automateThreshLow, 0) +
- ", you will automatically switch to " + this.automateActionLow.name +
- ". When your stamina recovers to " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.automateThreshHigh, 0) + ", you will automatically " +
- "switch to " + this.automateActionHigh.name + ".");
- }
-
- } else if (flag.toLowerCase().includes("en")) {
- if (!(this.automateActionLow instanceof ActionIdentifier) ||
- !(this.automateActionHigh instanceof ActionIdentifier)) {
- return this.log("Failed to enable automation. Actions were not set");
- }
- this.automateEnabled = true;
- this.log("Bladeburner automation enabled");
- } else if (flag.toLowerCase().includes("d")) {
- this.automateEnabled = false;
- this.log("Bladeburner automation disabled");
- } else {
- this.log("Invalid argument for 'automate' console command: " + args[1]);
- }
- return;
- }
-
- //Set variables
- if (args.length === 4) {
- var variable = args[1], val = args[2];
-
- var highLow = false; //True for high, false for low
- if (args[3].toLowerCase().includes("hi")) {highLow = true;}
-
- switch (variable) {
- case "general":
- case "gen":
- if (GeneralActions[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes[val], name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid action name specified: " + val);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Contract, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid contract name specified: " + val);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Operation, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid Operation name specified: " + val);
- }
- break;
- case "stamina":
- if (isNaN(val)) {
- this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val);
- } else {
- if (highLow) {
- this.automateThreshHigh = Number(val);
- } else {
- this.automateThreshLow = Number(val);
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val);
- }
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-Bladeburner.prototype.executeHelpConsoleCommand = function(args) {
- if (args.length === 1) {
- this.postToConsole(consoleHelpText.helpList);
- } else {
- for (var i = 1; i < args.length; ++i) {
- var commandText = consoleHelpText[args[i]];
- if (commandText != null) {
- this.postToConsole(commandText);
- this.postToConsole("' + input + '
");
- }
- }
- }
-}
-
-Bladeburner.prototype.executeLogConsoleCommand = function(args) {
- if (args.length < 3) {
- this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]");
- this.postToConsole("Use 'help log' for more details and examples");
- return;
- }
-
- var flag = true;
- if (args[1].toLowerCase().includes("d")) {flag = false;} //d for disable
-
- switch (args[2].toLowerCase()) {
- case "general":
- case "gen":
- this.logging.general = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions");
- break;
- case "contract":
- case "contracts":
- this.logging.contracts = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts");
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- this.logging.ops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations");
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- this.logging.blackops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps");
- break;
- case "event":
- case "events":
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for events");
- break;
- case "all":
- this.logging.general = flag;
- this.logging.contracts = flag;
- this.logging.ops = flag;
- this.logging.blackops = flag;
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything");
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[2]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]");
- break;
- }
-}
-
-Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
- switch (args.length) {
- case 1:
- //Display Skill Help Command
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- case 2:
- if (args[1].toLowerCase() === "list") {
- //List all skills and their level
- this.postToConsole("Skills: ");
- var skillNames = Object.keys(Skills);
- for(var i = 0; i < skillNames.length; ++i) {
- var skill = Skills[skillNames[i]];
- var level = 0;
- if (this.skills[skill.name] != null) {level = this.skills[skill.name];}
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(level, 0));
- }
- this.postToConsole(" ");
- this.postToConsole("Effects: ");
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- this.postToConsole("Total Success Chance: x" + mult);
- break;
- case "successChanceStealth":
- this.postToConsole("Stealth Success Chance: x" + mult);
- break;
- case "successChanceKill":
- this.postToConsole("Retirement Success Chance: x" + mult);
- break;
- case "successChanceContract":
- this.postToConsole("Contract Success Chance: x" + mult);
- break;
- case "successChanceOperation":
- this.postToConsole("Operation Success Chance: x" + mult);
- break;
- case "successChanceEstimate":
- this.postToConsole("Synthoid Data Estimate: x" + mult);
- break;
- case "actionTime":
- this.postToConsole("Action Time: x" + mult);
- break;
- case "effHack":
- this.postToConsole("Hacking Skill: x" + mult);
- break;
- case "effStr":
- this.postToConsole("Strength: x" + mult);
- break;
- case "effDef":
- this.postToConsole("Defense: x" + mult);
- break;
- case "effDex":
- this.postToConsole("Dexterity: x" + mult);
- break;
- case "effAgi":
- this.postToConsole("Agility: x" + mult);
- break;
- case "effCha":
- this.postToConsole("Charisma: x" + mult);
- break;
- case "effInt":
- this.postToConsole("Intelligence: x" + mult);
- break;
- case "stamina":
- this.postToConsole("Stamina: x" + mult);
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- case 3:
- var skillName = args[2];
- var skill = Skills[skillName];
- if (skill == null || !(skill instanceof Skill)) {
- return this.postToConsole("Invalid skill name (Note that this is case-sensitive): " + skillName);
- }
- if (args[1].toLowerCase() === "list") {
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skills[skill.name]), 0);
- } else if (args[1].toLowerCase() === "level") {
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var pointCost = skill.calculateCost(currentLevel);
- if (this.skillPoints >= pointCost) {
- this.skillPoints -= pointCost;
- this.upgradeSkill(skill);
- this.log(skill.name + " upgraded to Level " + this.skills[skillName]);
- this.createActionAndSkillsContent();
- } else {
- this.postToConsole("You do not have enough Skill Points to upgrade this. You need " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(pointCost, 0));
- }
-
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- default:
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- }
-}
-
-Bladeburner.prototype.executeStartConsoleCommand = function(args) {
- if (args.length !== 3) {
- this.postToConsole("Invalid usage of 'start' console command: start [type] [name]");
- this.postToConsole("Use 'help start' for more info");
- return;
- }
- var name = args[2];
- switch (args[1].toLowerCase()) {
- case "general":
- case "gen":
- if (GeneralActions[name] != null) {
- this.action.type = ActionTypes[name];
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid action name specified: " + args[2]);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[name] != null) {
- this.action.type = ActionTypes.Contract;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid contract name specified: " + args[2]);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[name] != null) {
- this.action.type = ActionTypes.Operation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid Operation name specified: " + args[2]);
- }
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- if (BlackOperations[name] != null) {
- this.action.type = ActionTypes.BlackOperation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid BlackOp name specified: " + args[2]);
- }
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[1]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]");
- break;
- }
-}
-
-Bladeburner.prototype.getActionIdFromTypeAndName = function(type="", name="") {
- if (type === "" || name === "") {return null;}
- var action = new ActionIdentifier();
- var convertedType = type.toLowerCase().trim();
- var convertedName = name.toLowerCase().trim();
- switch (convertedType) {
- case "contract":
- case "contracts":
- case "contr":
- action.type = ActionTypes["Contract"];
- if (this.contracts.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- case "operation":
- case "operations":
- case "op":
- case "ops":
- action.type = ActionTypes["Operation"];
- if (this.operations.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- case "blackoperation":
- case "black operation":
- case "black operations":
- case "black op":
- case "black ops":
- case "blackop":
- case "blackops":
- action.type = ActionTypes["BlackOp"];
- if (BlackOperations.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- case "general":
- case "general action":
- case "gen":
- break;
- default:
- return null;
- }
-
- if (convertedType.startsWith("gen")) {
- switch (convertedName) {
- case "training":
- action.type = ActionTypes["Training"];
- break;
- case "recruitment":
- case "recruit":
- action.type = ActionTypes["Recruitment"];
- break;
- case "field analysis":
- case "fieldanalysis":
- action.type = ActionTypes["Field Analysis"];
- break;
- default:
- return null;
- }
- return action;
- }
-}
-
-Bladeburner.prototype.getContractNamesNetscriptFn = function() {
- return Object.keys(this.contracts);
-}
-
-Bladeburner.prototype.getOperationNamesNetscriptFn = function() {
- return Object.keys(this.operations);
-}
-
-Bladeburner.prototype.getBlackOpNamesNetscriptFn = function() {
- return Object.keys(BlackOperations);
-}
-
-Bladeburner.prototype.getGeneralActionNamesNetscriptFn = function() {
- return Object.keys(GeneralActions);
-}
-
-Bladeburner.prototype.getSkillNamesNetscriptFn = function() {
- return Object.keys(Skills);
-}
-
-Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: Bladeburner.startAction() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return false;
- }
-
- try {
- this.startAction(actionId);
- if (workerScript.shouldLog("startAction")) {
- workerScript.scriptRef.log("Starting Bladeburner action with type " + type + " and name " + name);
- }
- return true;
- } catch(e) {
- this.resetAction();
- workerScript.scriptRef.log("ERROR: Bladeburner.startAction() failed to start action of type " + type + " due to invalid name: " + name +
- "Note that this name is case-sensitive and whitespace-sensitive");
- return false;
- }
-}
-
-Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: Bladeburner.getActionTime() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return actionObj.getActionTime(this);
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return 30;
- case ActionTypes["Recruitment"]:
- return this.getRecruitmentTime();
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: Bladeburner.getActionEstimatedSuccessChance() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return actionObj.getSuccessChance(this, {est:true});
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return 1;
- case ActionTypes["Recruitment"]:
- return this.getRecruitmentSuccessChance();
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: Bladeburner.getActionCountRemaining() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return actionObj.count;
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return Infinity;
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) {
- var errorLogText = "ERROR: Bladeburner.getSkillLevel() failed due to an invalid skill specified: " +
- skillName + ". Note that the name of the skill is case-sensitive";
-
- if (skillName === "") {
- //If skill name isn't specified, return an object with all of the player's skill levels
- let copy = Object.assign({}, this.Skills);
- return copy;
- }
-
- if (!Skills.hasOwnProperty(skillName)) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (this.skills[skillName] == null) {
- return 0;
- } else {
- return this.skills[skillName];
- }
-}
-
-Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) {
- var errorLogText = "ERROR: Bladeburner.upgradeSkill() failed due to an invalid skill specified: " +
- skillName + ". Note that the name of the skill is case-sensitive";
- if (!Skills.hasOwnProperty(skillName)) {
- workerScript.log(errorLogText);
- return false;
- }
-
- var skill = Skills[skillName];
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var cost = skill.calculateCost(currentLevel);
-
- if (this.skillPoints < cost) {
- if (workerScript.shouldLog("upgradeSkill")) {
- workerScript.log("Bladeburner.upgradeSkill() failed because you do not have enough " +
- "skill points to upgrade " + skillName + " (You have " +
- this.skillPoints + ", you need " + cost + ")");
- }
- return false;
- }
-
- this.skillPoints -= cost;
- this.upgradeSkill(skill);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner && DomElems.currentTab.toLowerCase() === "skills") {
- this.createActionAndSkillsContent();
- }
- if (workerScript.shouldLog("upgradeSkill")) {
- workerScript.log(skillName + " successfully upgraded to level " + this.skills[skillName]);
- }
- return true;
-}
-
-Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript) {
- if (type === "" && name === "") {
- return this.teamSize;
- }
-
- var errorLogText = "ERROR: Bladeburner.getTeamSize() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
-
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (actionId.type === ActionTypes["Operation"] ||
- actionId.type === ActionTypes["BlackOp"] ||
- actionId.type === ActionTypes["BlackOperation"]) {
- return actionObj.teamCount;
- } else {
- return 0;
- }
-}
-
-Bladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) {
- var errorLogText = "ERROR: Bladeburner.setTeamSize() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (actionId.type !== ActionTypes["Operation"] &&
- actionId.type !== ActionTypes["BlackOp"] &&
- actionId.type !== ActionTypes["BlackOperation"]) {
- workerScript.log("ERROR: Bladeburner.setTeamSize() failed. This function " +
- "only works for Operations and BlackOps");
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var sanitizedSize = Math.round(size);
- if (isNaN(sanitizedSize)) {
- workerScript.log("ERROR: Bladeburner.setTeamSize() failed due to an invalid 'size' argument: " + size);
- return -1;
- }
- if (this.teamSize < sanitizedSize) {sanitizedSize = this.teamSize;}
- actionObj.teamCount = sanitizedSize;
- if (workerScript.shouldLog("setTeamSize")) {
- workerScript.log("Team size for " + name + " set to " + sanitizedSize);
- }
- return sanitizedSize;
-}
-
-Bladeburner.prototype.getCityEstimatedPopulationNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: Bladeburner.getCityEstimatedPopulation() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].popEst;
-}
-
-Bladeburner.prototype.getCityEstimatedCommunitiesNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: Bladeburner.getCityEstimatedCommunities() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].commsEst;
-}
-
-Bladeburner.prototype.getCityChaosNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: Bladeburner.getCityChaos() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].chaos;
-}
-
-Bladeburner.prototype.switchCityNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: Bladeburner.switchCity() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return false;
- }
- this.city = cityName;
- return true;
-}
-
-Bladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) {
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"]["Bladeburners"];
- if (bladeburnerFac.isMember) {
- return true;
- } else if (this.rank >= RankNeededForFaction) {
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
- if (workerScript.shouldLog("joinBladeburnerFaction")) {
- workerScript.log("Joined Bladeburners Faction");
- }
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.overviewDiv);
- this.createOverviewContent();
- }
- return true;
- } else {
- if (workerScript.shouldLog("joinBladeburnerFaction")) {
- workerScript.log("Failed to join Bladeburners Faction because " +
- "you do not have the required " + RankNeededForFaction + " rank");
- }
- return false;
- }
-}
-
-Bladeburner.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Bladeburner", this);
-}
-Bladeburner.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Bladeburner, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["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
-function initBladeburner() {
- //Skills
- Skills[SkillNames.BladesIntuition] = new Skill({
- name:SkillNames.BladesIntuition,
- desc:"Each level of this skill increases your success chance " +
- "for all contracts and operations by 3%",
- baseCost:5, costInc:2,
- successChanceAll:3
- });
- Skills[SkillNames.Reaper] = new Skill({
- name:SkillNames.Reaper,
- desc:"Each level of this skill increases your " +
- "effective combat stats for Bladeburner actions by 3%",
- baseCost:3, costInc:2,
- effStr:3, effDef:3, effDex:3, effAgi:3
- });
- Skills[SkillNames.Cloak] = new Skill({
- name:SkillNames.Cloak,
- desc:"Each level of this skill increases your " +
- "success chance in stealth-related contracts and operations by 5.5%",
- baseCost:3, costInc:1,
- successChanceStealth:5.5
- });
-
- //TODO Marksman
- //TODO Weapon Proficiency
-
- Skills[SkillNames.Overclock] = new Skill({
- name:SkillNames.Overclock,
- desc:"Each level of this skill decreases the time it takes " +
- "to attempt a contract or operation by 1% (Max Level: 95)",
- baseCost:5, costInc:1, maxLvl:95,
- actionTime:1
- });
- Skills[SkillNames.EvasiveSystem] = new Skill({
- name:SkillNames.EvasiveSystem,
- desc:"Each level of this skill increases your effective " +
- "dexterity and agility for Bladeburner actions by 5%",
- baseCost:2, costInc: 1,
- effDex:5, effAgi:5
- });
- Skills[SkillNames.ShortCircuit] = new Skill({
- name:SkillNames.ShortCircuit,
- desc:"Each level of this skill increases your success chance " +
- "in contracts and operations that involve retirement by 5.5%",
- baseCost:3, costInc:2,
- successChanceKill:5.5
- });
- Skills[SkillNames.DigitalObserver] = new Skill({
- name:SkillNames.DigitalObserver,
- desc:"Each level of this skill increases your success chance in " +
- "all operations by 4%",
- baseCost:5, costInc:2,
- successChanceOperation:4
- });
- Skills[SkillNames.Datamancer] = new Skill({
- name:SkillNames.Datamancer,
- desc:"Each level of this skill increases your effectiveness in " +
- "synthoid population analysis and investigation by 5%. " +
- "This affects all actions that can potentially increase " +
- "the accuracy of your synthoid population/community estimates.",
- baseCost:3,costInc:1,
- successChanceEstimate:5
- });
- Skills[SkillNames.Tracer] = new Skill({
- name:SkillNames.Tracer,
- desc:"Each level of this skill increases your success chance in " +
- "all contracts by 4%",
- baseCost:3, costInc:2,
- successChanceContract:4
- });
- Skills[SkillNames.CybersEdge] = new Skill({
- name:SkillNames.CybersEdge,
- desc:"Each level of this skill increases your max " +
- "stamina by 2%",
- baseCost:1, costInc:3,
- stamina:2
- });
-
- //General Actions
- var actionName = "Training";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Improve your abilities at the Bladeburner unit's specialized training " +
- "center. Doing this gives experience for all combat stats and also " +
- "increases your max stamina."
- });
-
- var actionName = "Field Analysis";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Mine and analyze Synthoid-related data. This improve the " +
- "Bladeburner's unit intelligence on Synthoid locations and " +
- "activities. Completing this action will improve the accuracy " +
- "of your Synthoid population estimated in the current city.
" +
- "Does NOT require stamina."
- });
-
- var actionName = "Recruitment";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Attempt to recruit members for your Bladeburner team. These members " +
- "can help you conduct operations.
" +
- "Does NOT require stamina."
- });
-
- //Black Operations
- BlackOperations["Operation Typhoon"] = new BlackOperation({
- name:"Operation Typhoon",
- desc:"Obadiah Zenyatta is the leader of a RedWater PMC. It has long " +
- "been known among the intelligence community that Zenyatta, along " +
- "with the rest of the PMC, is a Synthoid.
" +
- "The goal of Operation Typhoon is to find and eliminate " +
- "Zenyatta and RedWater by any means necessary. After the task " +
- "is completed, the actions must be covered up from the general public.",
- baseDifficulty:2000, reqdRank:2.5e3,
- rankGain:50, rankLoss:10, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Zero"] = new BlackOperation({
- name:"Operation Zero",
- desc:"AeroCorp is one of the world's largest defense contractors. " +
- "It's leader, Steve Watataki, is thought to be a supporter of " +
- "Synthoid rights. He must be removed.
" +
- "The goal of Operation Zero is to covertly infiltrate AeroCorp and " +
- "uncover any incriminating evidence or " +
- "information against Watataki that will cause him to be removed " +
- "from his position at AeroCorp. Incriminating evidence can be " +
- "fabricated as a last resort. Be warned that AeroCorp has some of " +
- "the most advanced security measures in the world.",
- baseDifficulty:2500, reqdRank:5e3,
- rankGain:60, rankLoss:15, hpLoss:50,
- weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation X"] = new BlackOperation({
- name:"Operation X",
- desc:"We have recently discovered an underground publication " +
- "group called Samizdat. Even though most of their publications " +
- "are nonsensical conspiracy theories, the average human is " +
- "gullible enough to believe them. Many of their works discuss " +
- "Synthoids and pose a threat to society. The publications are spreading " +
- "rapidly in China and other Eastern countries.
" +
- "Samizdat has done a good job of keeping hidden and anonymous. " +
- "However, we've just received intelligence that their base of " +
- "operations is in Ishima's underground sewer systems. Your task is to " +
- "investigate the sewer systems, and eliminate Samizdat. They must " +
- "never publish anything again.",
- baseDifficulty:3000, reqdRank:7.5e3,
- rankGain:75, rankLoss:15, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Titan"] = new BlackOperation({
- name:"Operation Titan",
- desc:"Several months ago Titan Laboratories' Bioengineering department " +
- "was infiltrated by Synthoids. As far as we know, Titan Laboratories' " +
- "management has no knowledge about this. We don't know what the " +
- "Synthoids are up to, but the research that they could " +
- "be conducting using Titan Laboraties' vast resources is potentially " +
- "very dangerous.
" +
- "Your goal is to enter and destroy the Bioengineering department's " +
- "facility in Aevum. The task is not just to retire the Synthoids there, but " +
- "also to destroy any information or research at the facility that " +
- "is relevant to the Synthoids and their goals.",
- baseDifficulty:4000, reqdRank:10e3,
- rankGain:100, rankLoss:20, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ares"] = new BlackOperation({
- name:"Operation Ares",
- desc:"One of our undercover agents, Agent Carter, has informed us of a " +
- "massive weapons deal going down in Dubai between rogue Russian " +
- "militants and a radical Synthoid community. These weapons are next-gen " +
- "plasma and energy weapons. It is critical for the safety of humanity " +
- "that this deal does not happen.
" +
- "Your task is to intercept the deal. Leave no survivors.",
- baseDifficulty:5000, reqdRank:12.5e3,
- rankGain:125, rankLoss:20, hpLoss:200,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Archangel"] = new BlackOperation({
- name:"Operation Archangel",
- desc:"Our analysts have discovered that the popular Red Rabbit brothel in " +
- "Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence " +
- "suggests that the profit from this brothel is used to fund a large " +
- "black market arms trafficking operation.
" +
- "The goal of this operation is to take out the leaders that are running " +
- "the Red Rabbit brothel. Try to limit the number of other casualties, " +
- "but do what you must to complete the mission.",
- baseDifficulty:7500, reqdRank:15e3,
- rankGain:200, rankLoss:20, hpLoss:25,
- weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Juggernaut"] = new BlackOperation({
- name:"Operation Juggernaut",
- desc:"The CIA has just encountered a new security threat. A new " +
- "criminal group, lead by a shadowy operative who calls himself " +
- "Juggernaut, has been smuggling drugs and weapons (including " +
- "suspected bioweapons) into Sector-12. We also have reason " +
- "to believe the tried to break into one of Universal Energy's " +
- "facilities in order to cause a city-wide blackout. The CIA " +
- "suspects that Juggernaut is a heavily-augmented Synthoid, and " +
- "have thus enlisted our help.
" +
- "Your mission is to eradicate Juggernaut and his followers.",
- baseDifficulty:10e3, reqdRank:20e3,
- rankGain:300, rankLoss:40, hpLoss:300,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Red Dragon"] = new BlackOperation({
- name:"Operation Red Dragon",
- desc:"The Tetrads criminal organization is suspected of " +
- "reverse-engineering the MK-VI Synthoid design. We believe " +
- "they altered and possibly improved the design and began " +
- "manufacturing their own Synthoid models in order to bolster " +
- "their criminal activities.
" +
- "Your task is to infiltrate and destroy the Tetrads' base of operations " +
- "in Los Angeles. Intelligence tells us that their base houses " +
- "one of their Synthoid manufacturing units.",
- baseDifficulty:12.5e3, reqdRank:25e3,
- rankGain:500, rankLoss:50, hpLoss:500,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation K"] = new BlackOperation({
- name:"Operation K",
- desc:"CODE RED SITUATION. Our intelligence tells us that VitaLife " +
- "has discovered a new android cloning technology. This technology " +
- "is supposedly capable of cloning Synthoid, not only physically " +
- "but also their advanced AI modules. We do not believe that " +
- "VitaLife is trying to use this technology illegally or " +
- "maliciously, but if any Synthoids were able to infiltrate the " +
- "corporation and take advantage of this technology then the " +
- "results would be catastrophic.
" +
- "We do not have the power or jurisdiction to shutdown this down " +
- "through legal or political means, so we must resort to a covert " +
- "operation. Your goal is to destroy this technology and eliminate" +
- "anyone who was involved in its creation.",
- baseDifficulty:15e3, reqdRank:30e3,
- rankGain:750, rankLoss:60, hpLoss:1000,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Deckard"] = new BlackOperation({
- name:"Operation Deckard",
- desc:"Despite your success in eliminating VitaLife's new android-replicating " +
- "technology in Operation K, we've discovered that a small group of " +
- "MK-VI Synthoids were able to make off with the schematics and design " +
- "of the technology before the Operation. It is almost a certainty that " +
- "these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising." +
- "The goal of Operation Deckard is to hunt down these Synthoids and retire " +
- "them. I don't need to tell you how critical this mission is.",
- baseDifficulty:20e3, reqdRank:40e3,
- rankGain:1e3, rankLoss:75, hpLoss:200,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Tyrell"] = new BlackOperation({
- name:"Operation Tyrell",
- desc:"A week ago Blade Industries reported a small break-in at one " +
- "of their Aevum Augmentation storage facitilities. We figured out " +
- "that The Dark Army was behind the heist, and didn't think any more " +
- "of it. However, we've just discovered that several known MK-VI Synthoids " +
- "were part of that break-in group.
" +
- "We cannot have Synthoids upgrading their already-enhanced abilities " +
- "with Augmentations. Your task is to hunt down the associated Dark Army " +
- "members and eliminate them.",
- baseDifficulty:25e3, reqdRank:50e3,
- rankGain:1.5e3, rankLoss:100, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Wallace"] = new BlackOperation({
- name:"Operation Wallace",
- desc:"Based on information gathered from Operation Tyrell, we've discovered " +
- "that The Dark Army was well aware that there were Synthoids amongst " +
- "their ranks. Even worse, we believe that The Dark Army is working " +
- "together with other criminal organizations such as The Syndicate and " +
- "that they are planning some sort of large-scale takeover of multiple major " +
- "cities, most notably Aevum. We suspect that Synthoids have infiltrated " +
- "the ranks of these criminal factions and are trying to stage another " +
- "Synthoid uprising.
" +
- "The best way to deal with this is to prevent it before it even happens. " +
- "The goal of Operation Wallace is to destroy the Dark Army and " +
- "Syndicate factions in Aevum immediately. Leave no survivors.",
- baseDifficulty:30e3, reqdRank:75e3,
- rankGain:2e3, rankLoss:150, hpLoss:1500,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Shoulder of Orion"] = new BlackOperation({
- name:"Operation Shoulder of Orion",
- desc:"China's Solaris Space Systems is secretly launching the first " +
- "manned spacecraft in over a decade using Synthoids. We believe " +
- "China is trying to establish the first off-world colonies.
" +
- "The mission is to prevent this launch without instigating an " +
- "international conflict. When you accept this mission you will be " +
- "officially disavowed by the NSA and the national government until after you " +
- "successfully return. In the event of failure, all of the operation's " +
- "team members must not let themselves be captured alive.",
- baseDifficulty:35e3, reqdRank:100e3,
- rankGain:2.5e3, rankLoss:500, hpLoss:1500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Hyron"] = new BlackOperation({
- name:"Operation Hyron",
- desc:"Our intelligence tells us that Fulcrum Technologies is developing " +
- "a quantum supercomputer using human brains as core " +
- "processors. This supercomputer " +
- "is rumored to be able to store vast amounts of data and " +
- "perform computations unmatched by any other supercomputer on the " +
- "planet. But more importantly, the use of organic human brains " +
- "means that the supercomputer may be able to reason abstractly " +
- "and become self-aware.
" +
- "I do not need to remind you why sentient-level AIs pose a serious " +
- "thread to all of mankind.
" +
- "The research for this project is being conducted at one of Fulcrum " +
- "Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. " +
- "Infiltrate the compound, delete and destroy the work, and then find and kill the " +
- "project lead.",
- baseDifficulty:40e3, reqdRank:125e3,
- rankGain:3e3, rankLoss:1e3, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Morpheus"] = new BlackOperation({
- name:"Operation Morpheus",
- desc:"DreamSense Technologies is an advertising company that uses " +
- "special technology to transmit their ads into the peoples " +
- "dreams and subconcious. They do this using broadcast transmitter " +
- "towers. Based on information from our agents and informants in " +
- "Chonqging, we have reason to believe that one of the broadcast " +
- "towers there has been compromised by Synthoids and is being used " +
- "to spread pro-Synthoid propaganda.
" +
- "The mission is to destroy this broadcast tower. Speed and " +
- "stealth are of the upmost important for this.",
- baseDifficulty:45e3, reqdRank:150e3,
- rankGain:4e3, rankLoss:1e3, hpLoss:100,
- weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Ion Storm"] = new BlackOperation({
- name:"Operation Ion Storm",
- desc:"Our analysts have uncovered a gathering of MK-VI Synthoids " +
- "that have taken up residence in the Sector-12 Slums. We " +
- "don't know if they are rogue Synthoids from the Uprising, " +
- "but we do know that they have been stockpiling " +
- "weapons, money, and other resources. This makes them dangerous.
" +
- "This is a full-scale assault operation to find and retire all of these " +
- "Synthoids in the Sector-12 Slums.",
- baseDifficulty:50e3, reqdRank:175e3,
- rankGain:5e3, rankLoss:1e3, hpLoss:5000,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Annihilus"] = new BlackOperation({
- name:"Operation Annihilus",
- desc:"Our superiors have ordered us to eradicate everything and everyone " +
- "in an underground facility located in Aevum. They tell us " +
- "that the facility houses many dangerous Synthoids and " +
- "belongs to a terrorist organization called " +
- "'The Covenant'. We have no prior intelligence about this " +
- "organization, so you are going in blind.",
- baseDifficulty:55e3, reqdRank:200e3,
- rankGain:7.5e3, rankLoss:1e3, hpLoss:10e3,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ultron"] = new BlackOperation({
- name:"Operation Ultron",
- desc:"OmniTek Incorporated, the original designer and manufacturer of Synthoids, " +
- "has notified us of a malfunction in their AI design. This malfunction, " +
- "when triggered, causes MK-VI Synthoids to become radicalized and seek out " +
- "the destruction of humanity. They say that this bug affects all MK-VI Synthoids, " +
- "not just the rogue ones from the Uprising.
" +
- "OmniTek has also told us they they believe someone has triggered this " +
- "malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids " +
- "are now amassing in Volhaven to form a terrorist group called Ultron.
" +
- "Intelligence suggests Ultron is heavily armed and that their members are " +
- "augmented. We believe Ultron is making moves to take control of " +
- "and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
" +
- "Your task is to find and destroy Ultron.",
- baseDifficulty:60e3, reqdRank:250e3,
- rankGain:10e3, rankLoss:2e3, hpLoss:10e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Centurion"] = new BlackOperation({
- name:"Operation Centurion",
- desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
- "Throughout all of humanity's history, we have relied on " +
- "technology to survive, conquer, and progress. Its advancement became our primary goal. " +
- "And at the peak of human civilization technology turned into " +
- "power. Global, absolute power.
" +
- "It seems that the universe is not without a sense of irony.
" +
- "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
- baseDifficulty:70e3, reqdRank:300e3,
- rankGain:15e3, rankLoss:5e3, hpLoss:10e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
- BlackOperations["Operation Vindictus"] = new BlackOperation({
- name:"Operation Vindictus",
- desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
- "The bits are all around us. The daemons that hold the Node " +
- "together can manifest themselves in many different ways.
" +
- "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
- baseDifficulty:75e3, reqdRank:350e3,
- rankGain:20e3, rankLoss:20e3, hpLoss:20e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
- BlackOperations["Operation Daedalus"] = new BlackOperation({
- name:"Operation Daedalus",
- desc:"Yesterday we obeyed kings and bent our neck to emperors. " +
- "Today we kneel only to truth.",
- baseDifficulty:80e3, reqdRank:400e3,
- rankGain:40e3, rankLoss:10e3, hpLoss:100e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
-}
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
-
-/***/ }),
-/* 27 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeSuccess", function() { return determineCrimeSuccess; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findCrime", function() { return findCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Crimes", function() { return Crimes; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
-
-
-
-
-
-function Crime(name, type, time, money, difficulty, karma, params) {
- this.name = name;
- this.type = type;
- this.time = time;
- this.money = money;
- this.difficulty = difficulty;
- this.karma = karma;
-
- this.hacking_success_weight = params.hacking_success_weight ? params.hacking_success_weight : 0;
- this.strength_success_weight = params.strength_success_weight ? params.strength_success_weight : 0;
- this.defense_success_weight = params.defense_success_weight ? params.defense_success_weight : 0;
- this.dexterity_success_weight = params.dexterity_success_weight ? params.dexterity_success_weight : 0;
- this.agility_success_weight = params.agility_success_weight ? params.agility_success_weight : 0;
- this.charisma_success_weight = params.charisma_success_weight ? params.charisma_success_weight : 0;
-
- this.hacking_exp = params.hacking_exp ? params.hacking_exp : 0;
- this.strength_exp = params.strength_exp ? params.strength_exp : 0;
- this.defense_exp = params.defense_exp ? params.defense_exp : 0;
- this.dexterity_exp = params.dexterity_exp ? params.dexterity_exp : 0;
- this.agility_exp = params.agility_exp ? params.agility_exp : 0;
- this.charisma_exp = params.charisma_exp ? params.charisma_exp : 0;
- this.intelligence_exp = params.intelligence_exp ? params.intelligence_exp : 0;
-
- this.kills = params.kills ? params.kills : 0;
-}
-
-Crime.prototype.commit = function(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = this.type;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(
- this.hacking_exp/div,
- this.strength_exp/div,
- this.defense_exp/div,
- this.dexterity_exp/div,
- this.agility_exp/div,
- this.charisma_exp/div,
- this.money/div, this.time, singParams);
- return this.time;
-}
-
-Crime.prototype.successRate = function() {
- var chance = (this.hacking_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill +
- this.strength_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength +
- this.defense_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense +
- this.dexterity_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity +
- this.agility_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility +
- this.charisma_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma +
- _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeWeight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence);
- chance /= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
- chance /= this.difficulty;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-const Crimes = {
- Shoplift: new Crime("Shoplift", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift, 2e3, 15e3, 1/20, 0.1, {
- dexterity_success_weight: 1,
- agility_success_weight: 1,
-
- dexterity_exp: 2,
- agility_exp: 2,
- }),
-
- RobStore: new Crime("Rob Store", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore, 60e3, 400e3, 1/5, 0.5, {
- hacking_exp: 30,
- dexterity_exp: 45,
- agility_exp: 45,
-
- hacking_success_weight: 0.5 ,
- dexterity_success_weight: 2,
- agility_success_weight: 1,
-
- intelligence_exp: 0.25 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-
- Mug: new Crime("Mug", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug, 4e3, 36e3, 1/5, 0.25, {
- strength_exp: 3,
- defense_exp: 3,
- dexterity_exp: 3,
- agility_exp: 3,
-
- strength_success_weight: 1.5,
- defense_success_weight: 0.5,
- dexterity_success_weight: 1.5,
- agility_success_weight: 0.5,
- }),
-
- Larceny: new Crime("Larceny", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny, 90e3, 800e3, 1/3, 1.5, {
- hacking_exp: 45,
- dexterity_exp: 60,
- agility_exp: 60,
-
- hacking_skill_success_weight: 0.5,
- dexterity_success_weight: 1,
- agility_success_weight: 1,
-
- intelligence_exp: 0.5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-
- DealDrugs: new Crime("Deal Drugs", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs, 10e3, 120e3, 1, 0.5, {
- dexterity_exp: 5,
- agility_exp: 5,
- charisma_exp: 10,
-
- charisma_success_weight: 3,
- dexterity_success_weight: 2,
- agility_success_weight: 1,
- }),
-
- BondForgery: new Crime("Bond Forgery", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery, 300e3, 4.5e6, 1/2, 0.1, {
- hacking_exp: 100,
- dexterity_exp: 150,
- charisma_exp: 15,
-
- hacking_skill_success_weight: 0.05,
- dexterity_success_weight: 1.25,
-
- intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-
- TraffickArms: new Crime("Traffick Arms", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms, 40e3, 600e3, 2, 1, {
- strength_exp: 20,
- defense_exp: 20,
- dexterity_exp: 20,
- agility_exp: 20,
- charisma_exp: 40,
-
- charisma_success_weight: 1,
- strength_success_weight: 1,
- defense_success_weight: 1,
- dexterity_success_weight: 1,
- agility_success_weight: 1,
- }),
-
- Homicide: new Crime("Homicide", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide, 3e3, 45e3, 1, 3, {
- strength_exp: 2,
- defense_exp: 2,
- dexterity_exp: 2,
- agility_exp: 2,
-
- strength_success_weight: 2,
- defense_success_weight: 2,
- dexterity_success_weight: 0.5,
- agility_success_weight: 0.5,
-
- kills: 1,
- }),
-
- GrandTheftAuto: new Crime("Grand Theft Auto", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto, 80e3, 1.6e6, 8, 5, {
- strength_exp: 20,
- defense_exp: 20,
- dexterity_exp: 20,
- agility_exp: 80,
- charisma_exp: 40,
-
- hacking_skill_success_weight: 1,
- strength_success_weight: 1,
- dexterity_success_weight: 4,
- agility_success_weight: 2,
- charisma_success_weight: 2,
-
- intelligence_exp: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-
- Kidnap: new Crime("Kidnap", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap, 120e3, 3.6e6, 5, 6, {
- strength_exp: 80,
- defense_exp: 80,
- dexterity_exp: 80,
- agility_exp: 80,
- charisma_exp: 80,
-
- charisma_success_weight: 1,
- strength_success_weight: 1,
- dexterity_success_weight: 1,
- agility_success_weight: 1,
-
- intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-
- Assassination: new Crime("Assassination", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination, 300e3, 12e6, 8, 10, {
- strength_exp: 300,
- defense_exp: 300,
- dexterity_exp: 300,
- agility_exp: 300,
-
- strength_success_weight: 1,
- dexterity_success_weight: 2,
- agility_success_weight: 1,
-
- intelligence_exp: 5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
-
- kills: 1,
- }),
-
- Heist: new Crime("Heist", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist, 600e3, 120e6, 18, 15, {
- hacking_exp: 450,
- strength_exp: 450,
- defense_exp: 450,
- dexterity_exp: 450,
- agility_exp: 450,
- charisma_exp: 450,
-
- hacking_skill_success_weight: 1,
- strength_success_weight: 1,
- defense_success_weight: 1,
- dexterity_success_weight: 1,
- agility_success_weight: 1,
- charisma_success_weight: 1,
-
- intelligence_exp: 10 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
- }),
-};
-
-function determineCrimeSuccess(type, moneyGained) {
- var chance = 0;
- var found = false;
- for(const i in Crimes) {
- const crime = Crimes[i];
- if(crime.type == type) {
- chance = crime.successRate();
- found = true;
- break;
- }
- }
- if(!found) {
- console.log(crime);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
- return;
- }
-
- if (Math.random() <= chance) {
- //Success
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].gainMoney(moneyGained);
- return true;
- } else {
- //Failure
- return false;
- }
-}
-
-function findCrime(roughName) {
- if (roughName.includes("shoplift")) {
- return Crimes.Shoplift;
- } else if (roughName.includes("rob") && roughName.includes("store")) {
- return Crimes.RobStore;
- } else if (roughName.includes("mug")) {
- return Crimes.Mug;
- } else if (roughName.includes("larceny")) {
- return Crimes.Larceny;
- } else if (roughName.includes("drugs")) {
- return Crimes.DealDrugs;
- } else if (roughName.includes("bond") && roughName.includes("forge")) {
- return Crimes.BondForgery;
- } else if (roughName.includes("traffick") && roughName.includes("arms")) {
- return Crimes.TraffickArms;
- } else if (roughName.includes("homicide")) {
- return Crimes.Homicide;
- } else if (roughName.includes("grand") && roughName.includes("auto")) {
- return Crimes.GrandTheftAuto;
- } else if (roughName.includes("kidnap")) {
- return Crimes.Kidnap;
- } else if (roughName.includes("assassinate")) {
- return Crimes.Assassination;
- } else if (roughName.includes("heist")) {
- return Crimes.Heist;
- }
- return null;
-}
-
-
-
-
-/***/ }),
-/* 28 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Messages", function() { return Messages; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkForMessagesToSend", function() { return checkForMessagesToSend; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sendMessage", function() { return sendMessage; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "showMessage", function() { return showMessage; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadMessages", function() { return loadMessages; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initMessages", function() { return initMessages; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Message", function() { return Message; });
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
-/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(33);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(37);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(22);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(9);
-
-
-
-
-
-
-
-
-
-
-/* Message.js */
-function Message(filename="", msg="") {
- this.filename = filename;
- this.msg = msg;
- this.recvd = false;
-}
-
-Message.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Message", this);
-}
-
-
-Message.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Message, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Message = Message;
-
-//Sends message to player, including a pop up
-function sendMessage(msg, forced=false) {
- console.log("sending message: " + msg.filename);
- msg.recvd = true;
- if (forced || !_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].SuppressMessages) {
- showMessage(msg);
- }
- addMessageToServer(msg, "home");
-}
-
-function showMessage(msg) {
- var txt = "Message received from unknown sender:
" +
- "" + msg.msg + "
" +
- "This message was saved as " + msg.filename + " onto your home computer.";
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])(txt);
-}
-
-//Adds a message to a server
-function addMessageToServer(msg, serverHostname) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_5__["GetServerByHostname"])(serverHostname);
- if (server == null) {
- console.log("WARNING: Did not locate " + serverHostname);
- return;
- }
- for (var i = 0; i < server.messages.length; ++i) {
- if (server.messages[i].filename === msg.filename) {
- return; //Already exists
- }
- }
- server.messages.push(msg);
-}
-
-//Checks if any of the 'timed' messages should be sent
-function checkForMessagesToSend() {
- var jumper0 = Messages[MessageFilenames.Jumper0];
- var jumper1 = Messages[MessageFilenames.Jumper1];
- var jumper2 = Messages[MessageFilenames.Jumper2];
- var jumper3 = Messages[MessageFilenames.Jumper3];
- var jumper4 = Messages[MessageFilenames.Jumper4];
- var cybersecTest = Messages[MessageFilenames.CyberSecTest];
- var nitesecTest = Messages[MessageFilenames.NiteSecTest];
- var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
- var redpill = Messages[MessageFilenames.RedPill];
-
- var redpillOwned = false;
- if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].TheRedPill].owned) {
- redpillOwned = true;
- }
-
- if (redpill && redpillOwned && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].sourceFiles.length === 0 && !_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"]) {
- if (!_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
- sendMessage(redpill, true);
- }
- } else if (redpill && redpillOwned) {
- //If player has already destroyed a BitNode, message is not forced
- if (!_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"] && !_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
- sendMessage(redpill);
- }
- } else if (jumper0 && !jumper0.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 25) {
- sendMessage(jumper0);
- _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__["Programs"].Flight);
- } else if (jumper1 && !jumper1.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 40) {
- sendMessage(jumper1);
- } else if (cybersecTest && !cybersecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 50) {
- sendMessage(cybersecTest);
- } else if (jumper2 && !jumper2.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 175) {
- sendMessage(jumper2);
- } else if (nitesecTest && !nitesecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 200) {
- sendMessage(nitesecTest);
- } else if (jumper3 && !jumper3.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 350) {
- sendMessage(jumper3);
- } else if (jumper4 && !jumper4.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 490) {
- sendMessage(jumper4);
- } else if (bitrunnersTest && !bitrunnersTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 500) {
- sendMessage(bitrunnersTest);
- }
-}
-
-function AddToAllMessages(msg) {
- Messages[msg.filename] = msg;
-}
-
-let Messages = {}
-
-function loadMessages(saveString) {
- Messages = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
-}
-
-let MessageFilenames = {
- Jumper0: "j0.msg",
- Jumper1: "j1.msg",
- Jumper2: "j2.msg",
- Jumper3: "j3.msg",
- Jumper4: "j4.msg",
- CyberSecTest: "csec-test.msg",
- NiteSecTest: "nitesec-test.msg",
- BitRunnersTest: "19dfj3l1nd.msg",
- RedPill: "icarus.msg",
-}
-
-function initMessages() {
- //Reset
- Messages = {};
-
- //jump3R Messages
- AddToAllMessages(new Message(MessageFilenames.Jumper0,
- "I know you can sense it. I know you're searching for it. " +
- "It's why you spend night after " +
- "night at your computer.
It's real, I've seen it. And I can " +
- "help you find it. But not right now. You're not ready yet.
" +
- "Use this program to track your progress
" +
- "The fl1ght.exe program was added to your home computer
" +
- "-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper1,
- "Soon you will be contacted by a hacking group known as CyberSec. " +
- "They can help you with your search.
" +
- "You should join them, garner their favor, and " +
- "exploit them for their Augmentations. But do not trust them. " +
- "They are not what they seem. No one is.
" +
- "-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper2,
- "Do not try to save the world. There is no world to save. If " +
- "you want to find the truth, worry only about yourself. Ethics and " +
- "morals will get you killed.
Watch out for a hacking group known as NiteSec." +
- "
-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper3,
- "You must learn to walk before you can run. And you must " +
- "run before you can fly. Look for the black hand.
" +
- "I.I.I.I
-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper4,
- "To find what you are searching for, you must understand the bits. " +
- "The bits are all around us. The runners will help you.
" +
- "-jump3R"));
-
- //Messages from hacking factions
- AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
- "We've been watching you. Your skills are very impressive. But you're wasting " +
- "your talents. If you join us, you can put your skills to good use and change " +
- "the world for the better. If you join us, we can unlock your full potential.
" +
- "But first, you must pass our test. Find and hack our server using the Terminal.
" +
- "-CyberSec"));
- AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
- "People say that the corrupted governments and corporations rule the world. " +
- "Yes, maybe they do. But do you know who everyone really fears? People " +
- "like us. Because they can't hide from us. Because they can't fight shadows " +
- "and ideas with bullets.
" +
- "Join us, and people will fear you, too.
" +
- "Find and hack our hidden server using the Terminal. Then, we will contact you again." +
- "
-NiteSec"));
- AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
- "We know what you are doing. We know what drives you. We know " +
- "what you are looking for.
" +
- "We can help you find the answers.
" +
- "run4theh111z"));
-
- AddToAllMessages(new Message(MessageFilenames.RedPill,
- "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%
" +
- ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)
" +
- "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB
" +
- "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
-}
-
-
-
-
-/***/ }),
-/* 29 */
+/* 25 */
+/*!**********************!*\
+ !*** ./src/Alias.js ***!
+ \**********************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -30543,7 +23836,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; });
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 18);
let Aliases = {};
@@ -30660,7 +23953,10 @@ function substituteAliases(origCommand) {
/***/ }),
-/* 30 */
+/* 26 */
+/*!***********************************!*\
+ !*** ./src/NetscriptFunctions.js ***!
+ \***********************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -30674,43 +23970,44 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasCorporationSF", function() { return hasCorporationSF; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; });
-/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(41);
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(17);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(14);
-/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(27);
-/* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(26);
-/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(16);
-/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(50);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5);
-/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(34);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(11);
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(36);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(4);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(28);
-/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(33);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(0);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(25);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(8);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(22);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(18);
-/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(20);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(21);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(43);
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 23);
+/* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Bladeburner.js */ 35);
+/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Company.js */ 8);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./CreateProgram.js */ 20);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./DarkWeb.js */ 59);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Gang.js */ 33);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./HacknetNode.js */ 40);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Missions.js */ 41);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./StockMarket.js */ 29);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Terminal.js */ 18);
+/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./TextFile */ 58);
/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(_TextFile__WEBPACK_IMPORTED_MODULE_23__);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(19);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(6);
-/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(67);
-/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(44);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(23);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(1);
-/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(15);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(12);
-var sprintf = __webpack_require__(66).sprintf,
- vsprintf = __webpack_require__(66).vsprintf
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 82);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./NetscriptPort.js */ 65);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! decimal.js */ 19);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../utils/IPAddress.js */ 14);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+var sprintf = __webpack_require__(/*! sprintf-js */ 116).sprintf,
+ vsprintf = __webpack_require__(/*! sprintf-js */ 116).vsprintf
@@ -30949,7 +24246,7 @@ function NetscriptFunctions(workerScript) {
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].gainHackingExp(expGainedOnSuccess);
workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
+ workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
}
server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerFortifyAmount * threads);
return Promise.resolve(moneyGained);
@@ -30958,7 +24255,7 @@ function NetscriptFunctions(workerScript) {
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].gainHackingExp(expGainedOnFailure);
workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
+ workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
}
return Promise.resolve(0);
}
@@ -31000,7 +24297,7 @@ function NetscriptFunctions(workerScript) {
var growTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["scriptCalculateGrowTime"])(server);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
- workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(growTime/1000, 3) + " seconds (t=" + threads + ")");
+ workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(growTime/1000, 3) + " seconds (t=" + threads + ")");
}
return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["netscriptDelay"])(growTime, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
@@ -31015,8 +24312,8 @@ function NetscriptFunctions(workerScript) {
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])((moneyAfter/moneyBefore)*100 - 100, 6) + "%. Gained " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])((moneyAfter/moneyBefore)*100 - 100, 6) + "%. Gained " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
}
workerScript.scriptRef.onlineExpGained += expGain;
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].gainHackingExp(expGain);
@@ -31048,7 +24345,7 @@ function NetscriptFunctions(workerScript) {
var weakenTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["scriptCalculateWeakenTime"])(server);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
}
return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["netscriptDelay"])(weakenTime, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
@@ -31057,7 +24354,7 @@ function NetscriptFunctions(workerScript) {
var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["scriptCalculateExpGain"])(server) * threads;
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
- ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
+ ". Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
}
workerScript.scriptRef.onlineExpGained += expGain;
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].gainHackingExp(expGain);
@@ -31077,7 +24374,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
}
var x = args.toString();
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isHTML"])(x)) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isHTML"])(x)) {
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].takeDamage(1);
Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_29__["dialogBoxCreate"])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:
" +
"DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!
" +
@@ -31123,7 +24420,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram.name)) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the NUKE.exe virus!");
}
if (server.openPortCount < server.numOpenPortsRequired) {
@@ -31154,7 +24451,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.name)) {
workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the BruteSSH.exe program!");
}
@@ -31184,7 +24481,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.name)) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the FTPCrack.exe program!");
}
if (!server.ftpPortOpen) {
@@ -31213,7 +24510,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.name)) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the relaySMTP.exe program!");
}
if (!server.smtpPortOpen) {
@@ -31242,7 +24539,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.name)) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the HTTPWorm.exe program!");
}
if (!server.httpPortOpen) {
@@ -31271,7 +24568,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
}
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram)) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.name)) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "You do not have the SQLInject.exe program!");
}
if (!server.sqlPortOpen) {
@@ -31772,12 +25069,12 @@ function NetscriptFunctions(workerScript) {
if (server.hostname == "home") {
//Return player's money
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].money.toNumber(), 2));
+ workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].money.toNumber(), 2));
}
return _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].money.toNumber();
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
}
return server.moneyAvailable;
},
@@ -31792,7 +25089,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
- workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
}
return server.hackDifficulty;
},
@@ -31807,7 +25104,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
- workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
}
return server.baseDifficulty;
},
@@ -31822,7 +25119,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
- workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
}
return server.minDifficulty;
},
@@ -31837,7 +25134,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
- workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
}
return server.requiredHackingSkill;
},
@@ -31852,7 +25149,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
- workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
}
return server.moneyMax;
},
@@ -31867,7 +25164,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
- workerScript.scriptRef.log("getServerGrowth() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerGrowth() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
}
return server.serverGrowth;
},
@@ -31882,7 +25179,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
- workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
+ workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
}
return server.numOpenPortsRequired;
},
@@ -31897,7 +25194,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
- workerScript.scriptRef.log("getServerRam() returned [" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.ramUsed, 2) + "GB]");
+ workerScript.scriptRef.log("getServerRam() returned [" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(server.ramUsed, 2) + "GB]");
}
return [server.maxRam, server.ramUsed];
},
@@ -32026,9 +25323,9 @@ function NetscriptFunctions(workerScript) {
var totalPrice = stock.price * shares;
if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission)) {
- workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " +
+ workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " +
symbol + ". Need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission, 2).toString());
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission, 2).toString());
return 0;
}
@@ -32041,8 +25338,8 @@ function NetscriptFunctions(workerScript) {
Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_21__["updateStockPlayerPosition"])(stock);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
- workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(stock.price, 2) + " per share");
+ workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(stock.price, 2) + " per share");
}
return stock.price;
},
@@ -32082,9 +25379,9 @@ function NetscriptFunctions(workerScript) {
Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_21__["updateStockPlayerPosition"])(stock);
}
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
- workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(stock.price, 2) + " per share. Gained " +
- "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(gains, 2));
+ workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(stock.price, 2) + " per share. Gained " +
+ "$" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(gains, 2));
}
return stock.price;
},
@@ -32252,7 +25549,7 @@ function NetscriptFunctions(workerScript) {
var cost = ram * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamServer;
if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].money.lt(cost)) {
- workerScript.scriptRef.log("ERROR: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(cost, 2));
+ workerScript.scriptRef.log("ERROR: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(cost, 2));
return "";
}
var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_18__["Server"]({
@@ -32272,7 +25569,7 @@ function NetscriptFunctions(workerScript) {
newServ.serversOnNetwork.push(homeComputer.ip);
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].loseMoney(cost);
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
- workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(cost, 2));
+ workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["formatNumber"])(cost, 2));
}
return newServ.hostname;
},
@@ -32386,7 +25683,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
}
return port.write(data);
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Write to text file
+ } else if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Write to text file
var fn = port;
var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_18__["getServer"])(workerScript.serverIp);
if (server == null) {
@@ -32423,7 +25720,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
}
return port.read();
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Read from text file
+ } else if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Read from text file
var fn = port;
var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_18__["getServer"])(workerScript.serverIp);
if (server == null) {
@@ -32472,7 +25769,7 @@ function NetscriptFunctions(workerScript) {
throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_25__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
}
return port.clear();
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Clear text file
+ } else if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(port)) { //Clear text file
var fn = port;
var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_18__["getServer"])(workerScript.serverIp);
if (server == null) {
@@ -32539,7 +25836,7 @@ function NetscriptFunctions(workerScript) {
} else if (fn.endsWith(".lit")) {
for (var i = 0; i < s.messages.length; ++i) {
var f = s.messages[i];
- if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_14__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(f) && f === fn) {
+ if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_14__["Message"]) && Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(f) && f === fn) {
s.messages.splice(i, 1);
return true;
}
@@ -32720,7 +26017,7 @@ function NetscriptFunctions(workerScript) {
workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
return false;
}
- if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(txt)) {txt = String(txt);}
+ if (!Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(txt)) {txt = String(txt);}
var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_33__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_33__["yesNoBoxGetNoButton"])();
yesBtn.innerHTML = "Yes";
noBtn.innerHTML = "No";
@@ -33315,7 +26612,7 @@ function NetscriptFunctions(workerScript) {
return false;
}
//The Player object's applyForJob function can return string with special error messages
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(res)) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(res)) {
workerScript.scriptRef.log(res);
return false;
}
@@ -33593,78 +26890,34 @@ function NetscriptFunctions(workerScript) {
}
}
- switch(name.toLowerCase()) {
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram.toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 50) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 100) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 100);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 250) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 250);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 500) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer4Hours, 500);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 750) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer8Hours, 750);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 75) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 400) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 400);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 75) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 75);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hacking_skill < 25) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
- break;
- default:
- workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
- return false;
+ name = name.toLowerCase();
+
+ let p = null;
+ for (const key in _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"]) {
+ if(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"][key].name.toLowerCase() == name) {
+ p = _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"][key];
+ }
+ }
+
+ if (p == null) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].hasProgram(p.name)) {
+ workerScript.scriptRef.log('ERROR: createProgram() failed because you already have the ' + p.name + ' program');
+ return false;
+ }
+
+ if (!p.create.req()) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create " + p.name + " (level " + p.create.level + " req)");
+ return false
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].startCreateProgramWork(p.name, p.create.time, p.create.level);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
+ workerScript.scriptRef.log("Began creating program: " + name);
}
- workerScript.scriptRef.log("Began creating program: " + name);
return true;
},
commitCrime : function(crimeRoughName) {
@@ -33875,7 +27128,7 @@ function NetscriptFunctions(workerScript) {
var res = Object(_Faction_js__WEBPACK_IMPORTED_MODULE_11__["purchaseAugmentation"])(aug, fac, true);
workerScript.scriptRef.log(res);
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_32__["isString"])(res) && res.startsWith("You purchased")) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_32__["isString"])(res) && res.startsWith("You purchased")) {
_Player_js__WEBPACK_IMPORTED_MODULE_16__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
return true;
} else {
@@ -34206,17 +27459,238 @@ function NetscriptFunctions(workerScript) {
/***/ }),
-/* 31 */
+/* 27 */
+/*!************************!*\
+ !*** ./src/Message.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Messages", function() { return Messages; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkForMessagesToSend", function() { return checkForMessagesToSend; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sendMessage", function() { return sendMessage; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "showMessage", function() { return showMessage; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadMessages", function() { return loadMessages; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initMessages", function() { return initMessages; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Message", function() { return Message; });
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 15);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CreateProgram.js */ 20);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 41);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RedPill.js */ 34);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+
+
+
+
+
+
+
+
+
+
+/* Message.js */
+function Message(filename="", msg="") {
+ this.filename = filename;
+ this.msg = msg;
+ this.recvd = false;
+}
+
+Message.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Message", this);
+}
+
+
+Message.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Message, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Message = Message;
+
+//Sends message to player, including a pop up
+function sendMessage(msg, forced=false) {
+ console.log("sending message: " + msg.filename);
+ msg.recvd = true;
+ if (forced || !_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].SuppressMessages) {
+ showMessage(msg);
+ }
+ addMessageToServer(msg, "home");
+}
+
+function showMessage(msg) {
+ var txt = "Message received from unknown sender:
" +
+ "" + msg.msg + "
" +
+ "This message was saved as " + msg.filename + " onto your home computer.";
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])(txt);
+}
+
+//Adds a message to a server
+function addMessageToServer(msg, serverHostname) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_5__["GetServerByHostname"])(serverHostname);
+ if (server == null) {
+ console.log("WARNING: Did not locate " + serverHostname);
+ return;
+ }
+ for (var i = 0; i < server.messages.length; ++i) {
+ if (server.messages[i].filename === msg.filename) {
+ return; //Already exists
+ }
+ }
+ server.messages.push(msg);
+}
+
+//Checks if any of the 'timed' messages should be sent
+function checkForMessagesToSend() {
+ var jumper0 = Messages[MessageFilenames.Jumper0];
+ var jumper1 = Messages[MessageFilenames.Jumper1];
+ var jumper2 = Messages[MessageFilenames.Jumper2];
+ var jumper3 = Messages[MessageFilenames.Jumper3];
+ var jumper4 = Messages[MessageFilenames.Jumper4];
+ var cybersecTest = Messages[MessageFilenames.CyberSecTest];
+ var nitesecTest = Messages[MessageFilenames.NiteSecTest];
+ var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
+ var redpill = Messages[MessageFilenames.RedPill];
+
+ var redpillOwned = false;
+ if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].TheRedPill].owned) {
+ redpillOwned = true;
+ }
+
+ if (redpill && redpillOwned && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].sourceFiles.length === 0 && !_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"]) {
+ if (!_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
+ sendMessage(redpill, true);
+ }
+ } else if (redpill && redpillOwned) {
+ //If player has already destroyed a BitNode, message is not forced
+ if (!_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"] && !_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
+ sendMessage(redpill);
+ }
+ } else if (jumper0 && !jumper0.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 25) {
+ sendMessage(jumper0);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__["Programs"].Flight.name);
+ } else if (jumper1 && !jumper1.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 40) {
+ sendMessage(jumper1);
+ } else if (cybersecTest && !cybersecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 50) {
+ sendMessage(cybersecTest);
+ } else if (jumper2 && !jumper2.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 175) {
+ sendMessage(jumper2);
+ } else if (nitesecTest && !nitesecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 200) {
+ sendMessage(nitesecTest);
+ } else if (jumper3 && !jumper3.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 350) {
+ sendMessage(jumper3);
+ } else if (jumper4 && !jumper4.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 490) {
+ sendMessage(jumper4);
+ } else if (bitrunnersTest && !bitrunnersTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 500) {
+ sendMessage(bitrunnersTest);
+ }
+}
+
+function AddToAllMessages(msg) {
+ Messages[msg.filename] = msg;
+}
+
+let Messages = {}
+
+function loadMessages(saveString) {
+ Messages = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
+}
+
+let MessageFilenames = {
+ Jumper0: "j0.msg",
+ Jumper1: "j1.msg",
+ Jumper2: "j2.msg",
+ Jumper3: "j3.msg",
+ Jumper4: "j4.msg",
+ CyberSecTest: "csec-test.msg",
+ NiteSecTest: "nitesec-test.msg",
+ BitRunnersTest: "19dfj3l1nd.msg",
+ RedPill: "icarus.msg",
+}
+
+function initMessages() {
+ //Reset
+ Messages = {};
+
+ //jump3R Messages
+ AddToAllMessages(new Message(MessageFilenames.Jumper0,
+ "I know you can sense it. I know you're searching for it. " +
+ "It's why you spend night after " +
+ "night at your computer.
It's real, I've seen it. And I can " +
+ "help you find it. But not right now. You're not ready yet.
" +
+ "Use this program to track your progress
" +
+ "The fl1ght.exe program was added to your home computer
" +
+ "-jump3R"));
+ AddToAllMessages(new Message(MessageFilenames.Jumper1,
+ "Soon you will be contacted by a hacking group known as CyberSec. " +
+ "They can help you with your search.
" +
+ "You should join them, garner their favor, and " +
+ "exploit them for their Augmentations. But do not trust them. " +
+ "They are not what they seem. No one is.
" +
+ "-jump3R"));
+ AddToAllMessages(new Message(MessageFilenames.Jumper2,
+ "Do not try to save the world. There is no world to save. If " +
+ "you want to find the truth, worry only about yourself. Ethics and " +
+ "morals will get you killed.
Watch out for a hacking group known as NiteSec." +
+ "
-jump3R"));
+ AddToAllMessages(new Message(MessageFilenames.Jumper3,
+ "You must learn to walk before you can run. And you must " +
+ "run before you can fly. Look for the black hand.
" +
+ "I.I.I.I
-jump3R"));
+ AddToAllMessages(new Message(MessageFilenames.Jumper4,
+ "To find what you are searching for, you must understand the bits. " +
+ "The bits are all around us. The runners will help you.
" +
+ "-jump3R"));
+
+ //Messages from hacking factions
+ AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
+ "We've been watching you. Your skills are very impressive. But you're wasting " +
+ "your talents. If you join us, you can put your skills to good use and change " +
+ "the world for the better. If you join us, we can unlock your full potential.
" +
+ "But first, you must pass our test. Find and hack our server using the Terminal.
" +
+ "-CyberSec"));
+ AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
+ "People say that the corrupted governments and corporations rule the world. " +
+ "Yes, maybe they do. But do you know who everyone really fears? People " +
+ "like us. Because they can't hide from us. Because they can't fight shadows " +
+ "and ideas with bullets.
" +
+ "Join us, and people will fear you, too.
" +
+ "Find and hack our hidden server using the Terminal. Then, we will contact you again." +
+ "
-NiteSec"));
+ AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
+ "We know what you are doing. We know what drives you. We know " +
+ "what you are looking for.
" +
+ "We can help you find the answers.
" +
+ "run4theh111z"));
+
+ AddToAllMessages(new Message(MessageFilenames.RedPill,
+ "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%
" +
+ ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)
" +
+ "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB
" +
+ "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
+}
+
+
+
+
+/***/ }),
+/* 28 */
+/*!*****************************************!*\
+ !*** ./node_modules/jszip/lib/utils.js ***!
+ \*****************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-var support = __webpack_require__(48);
-var base64 = __webpack_require__(107);
-var nodejsUtils = __webpack_require__(63);
-var setImmediate = __webpack_require__(169);
-var external = __webpack_require__(57);
+var support = __webpack_require__(/*! ./support */ 46);
+var base64 = __webpack_require__(/*! ./base64 */ 106);
+var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ 62);
+var setImmediate = __webpack_require__(/*! core-js/library/fn/set-immediate */ 168);
+var external = __webpack_require__(/*! ./external */ 54);
/**
@@ -34689,7 +28163,1397 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt
/***/ }),
-/* 32 */
+/* 29 */
+/*!****************************!*\
+ !*** ./src/StockMarket.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockMarket", function() { return StockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockSymbols", function() { return StockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolToStockMap", function() { return SymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockSymbols", function() { return initStockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockMarket", function() { return initStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSymbolToStockMap", function() { return initSymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stockMarketCycle", function() { return stockMarketCycle; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyStock", function() { return buyStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellStock", function() { return sellStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shortStock", function() { return shortStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellShort", function() { return sellShort; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPrices", function() { return updateStockPrices; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayStockMarketContent", function() { return displayStockMarketContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockTicker", function() { return updateStockTicker; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPlayerPosition", function() { return updateStockPlayerPosition; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadStockMarket", function() { return loadStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setStockMarketContentCreated", function() { return setStockMarketContentCreated; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placeOrder", function() { return placeOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOrder", function() { return cancelOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Order", function() { return Order; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OrderTypes", function() { return OrderTypes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionTypes", function() { return PositionTypes; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 26);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+let StockPriceCap = 1e9; //Put a limit on how high a price can go
+
+function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
+ this.symbol = symbol;
+ this.name = name;
+ this.price = initPrice;
+
+ this.playerShares = 0;
+ this.playerAvgPx = 0;
+ this.playerShortShares = 0;
+ this.playerAvgShortPx = 0;
+ this.mv = mv;
+ this.b = b;
+ this.otlkMag = otlkMag;
+
+ this.posTxtEl = null;
+}
+
+Stock.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Stock", this);
+}
+
+Stock.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Stock, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Stock = Stock;
+
+var OrderTypes = {
+ LimitBuy: "Limit Buy Order",
+ LimitSell: "Limit Sell Order",
+ StopBuy: "Stop Buy Order",
+ StopSell: "Stop Sell Order"
+}
+
+var PositionTypes = {
+ Long: "L",
+ Short: "S"
+}
+
+function placeOrder(stock, shares, price, type, position, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ var order = new Order(stock, shares, price, type, position);
+ if (isNaN(shares) || isNaN(price)) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
+ }
+ return false;
+ }
+ if (StockMarket["Orders"] == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ }
+ StockMarket["Orders"][stock.symbol].push(order);
+ //Process to see if it should be executed immediately
+ processOrders(order.stock, order.type, order.pos);
+ updateStockOrderList(order.stock);
+ return true;
+}
+
+//Returns true if successfully cancels an order, false otherwise
+function cancelOrder(params, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (StockMarket["Orders"] == null) {return false;}
+ if (params.order && params.order instanceof Order) {
+ var order = params.order;
+ //An 'Order' object is passed in
+ var stockOrders = StockMarket["Orders"][order.stock.symbol];
+ for (var i = 0; i < stockOrders.length; ++i) {
+ if (order == stockOrders[i]) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ return true;
+ }
+ }
+ return false;
+ } else if (params.stock && params.shares && params.price && params.type &&
+ params.pos && params.stock instanceof Stock) {
+ //Order properties are passed in. Need to look for the order
+ var stockOrders = StockMarket["Orders"][params.stock.symbol];
+ var orderTxt = params.stock.symbol + " - " + params.shares + " @ " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(params.price).format('$0.000a');
+ for (var i = 0; i < stockOrders.length; ++i) {
+ var order = stockOrders[i];
+ if (params.shares === order.shares &&
+ params.price === order.price &&
+ params.type === order.type &&
+ params.pos === order.pos) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ if (tixApi) {
+ workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt);
+ }
+ return true;
+ }
+ }
+ if (tixApi) {
+ workerScript.scriptRef.log("Failed to cancel order: " + orderTxt);
+ }
+ return false;
+ }
+ return false;
+}
+
+function executeOrder(order) {
+ var stock = order.stock;
+ var orderBook = StockMarket["Orders"];
+ var stockOrders = orderBook[stock.symbol];
+ var res = true;
+ console.log("Executing the following order:");
+ console.log(order);
+ switch (order.type) {
+ case OrderTypes.LimitBuy:
+ case OrderTypes.StopBuy:
+ if (order.pos === PositionTypes.Long) {
+ res = buyStock(order.stock, order.shares) && res;
+ } else if (order.pos === PositionTypes.Short) {
+ res = shortStock(order.stock, order.shares) && res;
+ }
+ break;
+ case OrderTypes.LimitSell:
+ case OrderTypes.StopSell:
+ if (order.pos === PositionTypes.Long) {
+ res = sellStock(order.stock, order.shares) && res;
+ } else if (order.pos === PositionTypes.Short) {
+ res = sellShort(order.stock, order.shares) && res;
+ }
+ break;
+ }
+ if (res) {
+ //Remove order from order book
+ for (var i = 0; i < stockOrders.length; ++i) {
+ if (order == stockOrders[i]) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ return;
+ }
+ }
+ console.log("ERROR: Could not find the following Order in Order Book: ");
+ console.log(order);
+ } else {
+ console.log("Order failed to execute");
+ }
+}
+
+function Order(stock, shares, price, type, position) {
+ this.stock = stock;
+ this.shares = shares;
+ this.price = price;
+ this.type = type;
+ this.pos = position;
+}
+
+Order.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Order", this);
+}
+
+Order.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Order, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Order = Order;
+
+let StockMarket = {} //Full name to stock object
+let StockSymbols = {} //Full name to symbol
+let SymbolToStockMap = {}; //Symbol to Stock object
+
+function loadStockMarket(saveString) {
+ if (saveString === "") {
+ StockMarket = {};
+ } else {
+ StockMarket = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
+ }
+}
+
+function initStockSymbols() {
+ //Stocks for companies at which you can work
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff] = "FNS";
+
+ //Stocks for other companies
+ StockSymbols["Sigma Cosmetics"] = "SGC";
+ StockSymbols["Joes Guns"] = "JGN";
+ StockSymbols["Catalyst Ventures"] = "CTYS";
+ StockSymbols["Microdyne Technologies"] = "MDYN";
+ StockSymbols["Titan Laboratories"] = "TITN";
+}
+
+function initStockMarket() {
+ for (var stk in StockMarket) {
+ if (StockMarket.hasOwnProperty(stk)) {
+ delete StockMarket[stk];
+ }
+ }
+
+ var ecorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
+ var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[ecorp] = ecorpStk;
+
+ var megacorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
+ var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(25000, 33000));
+ StockMarket[megacorp] = megacorpStk;
+
+ var blade = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
+ var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 22000));
+ StockMarket[blade] = bladeStk;
+
+ var clarke = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
+ var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[clarke] = clarkeStk;
+
+ var omnitek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
+ var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(35000, 40000));
+ StockMarket[omnitek] = omnitekStk;
+
+ var foursigma = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
+ var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(60000, 70000));
+ StockMarket[foursigma] = foursigmaStk;
+
+ var kuaigong = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
+ var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 24000));
+ StockMarket[kuaigong] = kuaigongStk;
+
+ var fulcrum = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
+ var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(30000, 35000));
+ StockMarket[fulcrum] = fulcrumStk;
+
+ var storm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
+ var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(21000, 24000));
+ StockMarket[storm] = stormStk;
+
+ var defcomm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
+ var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[defcomm] = defcommStk;
+
+ var helios = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
+ var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(12000, 16000));
+ StockMarket[helios] = heliosStk;
+
+ var vitalife = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
+ var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 12000));
+ StockMarket[vitalife] = vitalifeStk;
+
+ var icarus = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
+ var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(16000, 20000));
+ StockMarket[icarus] = icarusStk;
+
+ var universalenergy = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
+ var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[universalenergy] = universalenergyStk;
+
+ var aerocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
+ var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[aerocorp] = aerocorpStk;
+
+ var omnia = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
+ var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(9000, 12000));
+ StockMarket[omnia] = omniaStk;
+
+ var solaris = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
+ var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[solaris] = solarisStk;
+
+ var globalpharm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
+ var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[globalpharm] = globalpharmStk;
+
+ var nova = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
+ var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[nova] = novaStk;
+
+ var watchdog = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
+ var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[watchdog] = watchdogStk;
+
+ var lexocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
+ var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[lexocorp] = lexocorpStk;
+
+ var rho = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
+ var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[rho] = rhoStk;
+
+ var alpha = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
+ var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[alpha] = alphaStk;
+
+ var syscore = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
+ var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(4000, 7000))
+ StockMarket[syscore] = syscoreStk;
+
+ var computek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
+ var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 5000));
+ StockMarket[computek] = computekStk;
+
+ var netlink = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
+ var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 4000));
+ StockMarket[netlink] = netlinkStk;
+
+ var omega = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
+ var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[omega] = omegaStk;
+
+ var fns = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
+ var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(1000, 4000));
+ StockMarket[fns] = fnsStk;
+
+ var sigmacosm = "Sigma Cosmetics";
+ var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 3000));
+ StockMarket[sigmacosm] = sigmacosmStk;
+
+ var joesguns = "Joes Guns";
+ var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[joesguns] = joesgunsStk;
+
+ var catalyst = "Catalyst Ventures";
+ var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[catalyst] = catalystStk;
+
+ var microdyne = "Microdyne Technologies";
+ var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[microdyne] = microdyneStk;
+
+ var titanlabs = "Titan Laboratories";
+ var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[titanlabs] = titanlabsStk;
+
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+}
+
+function initSymbolToStockMap() {
+ for (var name in StockSymbols) {
+ if (StockSymbols.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (stock == null) {
+ console.log("ERROR finding stock");
+ continue;
+ }
+ var symbol = StockSymbols[name];
+ SymbolToStockMap[symbol] = stock;
+ }
+ }
+}
+
+function stockMarketCycle() {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ var thresh = 0.6;
+ if (stock.b) {thresh = 0.4;}
+ if (Math.random() < thresh) {
+ stock.b = !stock.b;
+ }
+ }
+ }
+}
+
+//Returns true if successful, false otherwise
+function buyStock(stock, shares) {
+ if (stock == null || shares < 0 || isNaN(shares)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares == 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this. You need $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2).toString() + ".");
+ return false;
+ }
+
+ var origTotal = stock.playerShares * stock.playerAvgPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShares += shares;
+ stock.playerAvgPx = newTotal / stock.playerShares;
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function sellStock(stock, shares) {
+ if (shares == 0) {return false;}
+ if (stock == null || shares < 0 || isNaN(shares)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell stock. This may be a bug, contact developer");
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares > stock.playerShares) {shares = stock.playerShares;}
+ if (shares === 0) {return false;}
+ var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(gains);
+ stock.playerShares -= shares;
+ if (stock.playerShares == 0) {
+ stock.playerAvgPx = 0;
+ }
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(gains, 2));
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function shortStock(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to initiate a short position in a stock. This is probably " +
+ "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
+ }
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares === 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " +
+ "money to purchase this short position. You need " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)'));
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + ".");
+ }
+
+ return false;
+ }
+
+ var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShortShares += shares;
+ stock.playerAvgShortPx = newTotal / stock.playerShortShares;
+ updateStockPlayerPosition(stock);
+ if (tixApi) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
+ workerScript.scriptRef.log("Bought a short position of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. Paid " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)') + " in commission fees.");
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought a short position of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
+ }
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function sellShort(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell a short position in a stock. This is probably " +
+ "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
+ }
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}
+ if (shares === 0) {return false;}
+
+ var origCost = shares * stock.playerAvgShortPx;
+ var profit = ((stock.playerAvgShortPx - stock.price) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ if (isNaN(profit)) {profit = 0;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(origCost + profit);
+ if (tixApi) {
+ workerScript.scriptRef.onlineMoneyMade += profit;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].scriptProdSinceLastAug += profit;
+ }
+
+ stock.playerShortShares -= shares;
+ if (stock.playerShortShares === 0) {
+ stock.playerAvgShortPx = 0;
+ }
+ updateStockPlayerPosition(stock);
+ if (tixApi) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
+ workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
+ "a total of " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(origCost + profit).format('($0.000a)'));
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold your short position of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(origCost + profit, 2));
+ }
+
+ return true;
+}
+
+function updateStockPrices() {
+ var v = Math.random();
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ var av = (v * stock.mv) / 100;
+ if (isNaN(av)) {av = .02;}
+
+ var chc = 50;
+ if (stock.b) {
+ chc = (chc + stock.otlkMag)/100;
+ if (isNaN(chc)) {chc = 0.5;}
+ } else {
+ chc = (chc - stock.otlkMag)/100;
+ if (isNaN(chc)) {chc = 0.5;}
+ }
+ if (stock.price >= StockPriceCap) {
+ chc = -1; //Limit on stock price
+ stock.b = false;
+ }
+
+ var c = Math.random();
+ if (c < chc) {
+ stock.price *= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
+ updateStockTicker(stock, true);
+ }
+ } else {
+ stock.price /= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
+ updateStockTicker(stock, false);
+ }
+ }
+
+ var otlkMagChange = stock.otlkMag * av;
+ if (stock.otlkMag <= 0.1) {
+ otlkMagChange = 1;
+ }
+ if (c < 0.5) {
+ stock.otlkMag += otlkMagChange;
+ } else {
+ stock.otlkMag -= otlkMagChange;
+ }
+ if (stock.otlkMag < 0) {
+ stock.otlkMag *= -1;
+ stock.b = !stock.b;
+ }
+
+ }
+ }
+}
+
+//Checks and triggers any orders for the specified stock
+function processOrders(stock, orderType, posType) {
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ return; //Newly created, so no orders to process
+ }
+ var stockOrders = orderBook[stock.symbol];
+ if (stockOrders == null || !(stockOrders.constructor === Array)) {
+ console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()");
+ stockOrders = [];
+ return;
+ }
+ for (var i = 0; i < stockOrders.length; ++i) {
+ var order = stockOrders[i];
+ if (order.type === orderType && order.pos === posType) {
+ switch(order.type) {
+ case OrderTypes.LimitBuy:
+ if (order.pos === PositionTypes.Long && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.LimitSell:
+ if (order.pos === PositionTypes.Long && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.StopBuy:
+ if (order.pos === PositionTypes.Long && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.StopSell:
+ if (order.pos === PositionTypes.Long && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ default:
+ console.log("Invalid order type: " + order.type);
+ return;
+ }
+ }
+ }
+}
+
+function setStockMarketContentCreated(b) {
+ stockMarketContentCreated = b;
+}
+
+var stockMarketContentCreated = false;
+var stockMarketPortfolioMode = false;
+var COMM = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+function displayStockMarketContent() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = false;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = false;}
+
+ //Purchase WSE Account button
+ var wseAccountButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-account");
+ wseAccountButton.innerText = "Buy WSE Account - $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost)) {
+ wseAccountButton.setAttribute("class", "a-link-button");
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount){
+ wseAccountButton.innerText = "WSE Account - Purchased";
+ wseAccountButton.setAttribute("class", "a-link-button-bought");
+ } else {
+ wseAccountButton.setAttribute("class", "a-link-button-inactive");
+ }
+ wseAccountButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = true;
+ initStockMarket();
+ initSymbolToStockMap();
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ //Purchase TIX API Access account
+ var tixApiAccessButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-tix-api");
+ tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost)) {
+ tixApiAccessButton.setAttribute("class", "a-link-button");
+ } else if(_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess) {
+ tixApiAccessButton.innerText = "Trade Information eXchange (TIX) API Access - Purchased"
+ tixApiAccessButton.setAttribute("class", "a-link-button-bought");
+ } else {
+ tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
+ }
+ tixApiAccessButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ stockMarketContentCreated = false;
+ while (stockList.firstChild) {
+ stockList.removeChild(stockList.firstChild);
+ }
+ return;
+ }
+
+ //Create stock market content if you have an account
+ if (!stockMarketContentCreated && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ console.log("Creating Stock Market UI");
+ document.getElementById("stock-market-commission").innerHTML =
+ "Commission Fees: Every transaction you make has a $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " commission fee.
" +
+ "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
+ "This means all your positions are lost, so make sure to sell your stocks before installing " +
+ "Augmentations!";
+
+ var investopediaButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-investopedia");
+ investopediaButton.addEventListener("click", function() {
+ var txt = "When making a transaction on the stock market, there are two " +
+ "types of positions: Long and Short. A Long position is the typical " +
+ "scenario where you buy a stock and earn a profit if the price of that " +
+ "stock increases. Meanwhile, a Short position is the exact opposite. " +
+ "In a Short position you purchase shares of a stock and earn a profit " +
+ "if the price of that stock decreases. This is also called 'shorting' a stock.
" +
+ "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.
" +
+ "There are three different types of orders you can make to buy or sell " +
+ "stocks on the exchange: Market Order, Limit Order, and Stop Order. " +
+ "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " +
+ "later on in the game.
" +
+ "When you place a Market Order to buy or sell a stock, the order executes " +
+ "immediately at whatever the current price of the stock is. For example " +
+ "if you choose to short a stock with 5000 shares using a Market Order, " +
+ "you immediately purchase those 5000 shares in a Short position at whatever " +
+ "the current market price is for that stock.
" +
+ "A Limit Order is an order that only executes under certain conditions. " +
+ "A Limit Order is used to buy or sell a stock at a specified price or better. " +
+ "For example, lets say you purchased a Long position of 100 shares of some stock " +
+ "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " +
+ "at $50 or better. The Limit Order will execute when the price of the stock reaches a " +
+ "value of $50 or higher.
" +
+ "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " +
+ "at a specified price (before the price gets 'worse'). For example, lets say you purchased " +
+ "a Short position of 100 shares of some stock at a price of $100 per share. " +
+ "The current price of the stock is $80 (a profit of $20 per share). You can place a " +
+ "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " +
+ "This can be used to lock in your profits and limit any losses.
" +
+ "Here is a summary of how each order works and when they execute:
" +
+ "In a LONG Position:
" +
+ "A Limit Order to buy will execute if the stock's price <= order's price
" +
+ "A Limit Order to sell will execute if the stock's price >= order's price
" +
+ "A Stop Order to buy will execute if the stock's price >= order's price
" +
+ "A Stop Order to sell will execute if the stock's price <= order's price
" +
+ "In a SHORT Position:
" +
+ "A Limit Order to buy will execute if the stock's price >= order's price
" +
+ "A Limit Order to sell will execute if the stock's price <= order's price
" +
+ "A Stop Order to buy will execute if the stock's price <= order's price
" +
+ "A Stop Order to sell will execute if the stock's price >= order's price.";
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])(txt);
+ return false;
+ });
+
+ //Switch to Portfolio Mode Button
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
+ "Displays only the stocks for which you have shares or orders";
+ modeBtn.addEventListener("click", switchToPortfolioMode);
+ }
+
+ //Expand/Collapse tickers buttons
+ var expandBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-expand-tickers"),
+ collapseBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-collapse-tickers"),
+ stockList = document.getElementById("stock-market-list");
+ if (expandBtn) {
+ expandBtn.addEventListener("click", ()=>{
+ var tickerHdrs = stockList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < tickerHdrs.length; ++i) {
+ if (!tickerHdrs[i].classList.contains("active")) {
+ tickerHdrs[i].click();
+ }
+ }
+ });
+ }
+ if (collapseBtn) {
+ collapseBtn.addEventListener("click",()=>{
+ var tickerHdrs = stockList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < tickerHdrs.length; ++i) {
+ if (tickerHdrs[i].classList.contains("active")) {
+ tickerHdrs[i].click();
+ }
+ }
+ });
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers(); //Clicking headers opens/closes panels
+ stockMarketContentCreated = true;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ updateStockTicker(stock, null);
+ updateStockOrderList(stock);
+ }
+ }
+ }
+}
+
+//Displays only stocks you have position/order in
+function switchToPortfolioMode() {
+ stockMarketPortfolioMode = true;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
+ "Displays all stocks on the WSE";
+ modeBtn.addEventListener("click", switchToDisplayAllMode);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+
+ //Get Order book (create it if it hasn't been created)
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ var stockOrders = orderBook[stock.symbol];
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ stockOrders.length === 0) {continue;}
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+//Displays all stocks
+function switchToDisplayAllMode() {
+ stockMarketPortfolioMode = false;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
+ "Displays only the stocks for which you have shares or orders";
+ modeBtn.addEventListener("click", switchToPortfolioMode);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+function createStockTicker(stock) {
+ if (!(stock instanceof Stock)) {
+ console.log("Invalid stock in createStockSticker()");
+ return;
+ }
+ var tickerId = "stock-market-ticker-" + stock.symbol;
+ var li = document.createElement("li"), hdr = document.createElement("button");
+ hdr.classList.add("accordion-header");
+ hdr.setAttribute("id", tickerId + "-hdr");
+ hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price;
+
+ //Div for entire panel
+ var stockDiv = document.createElement("div");
+ stockDiv.classList.add("accordion-panel");
+ stockDiv.setAttribute("id", tickerId + "-panel");
+
+ /* Create panel DOM */
+ var qtyInput = document.createElement("input"),
+ longShortSelect = document.createElement("select"),
+ orderTypeSelect = document.createElement("select"),
+ buyButton = document.createElement("span"),
+ sellButton = document.createElement("span"),
+ buyMaxButton = document.createElement("span"),
+ sellAllButton = document.createElement("span"),
+ positionTxt = document.createElement("p"),
+ orderList = document.createElement("ul");
+
+ qtyInput.classList.add("stock-market-input");
+ qtyInput.placeholder = "Quantity (Shares)";
+ qtyInput.setAttribute("id", tickerId + "-qty-input");
+ qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " +
+ " || (47Long Position: " +
+ "Shares in the long position will increase " +
+ "in value if the price of the corresponding stock increases
" +
+ "
Shares: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShares, 0) +
+ "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgPx).format('$0.000a') +
+ " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalCost).format('$0.000a') + ")" +
+ "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(gains).format('$0.000a') +
+ " (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(percentageGains*100, 2) + "%)
";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 2)) {
+ stock.posTxtEl.innerHTML +=
+ "Short Position: " +
+ "Shares in short position will increase " +
+ "in value if the price of the corresponding stock decreases
" +
+ "
Shares: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShortShares, 0) +
+ "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgShortPx).format('$0.000a') +
+ " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortTotalCost).format('$0.000a') + ")" +
+ "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortGains).format('$0.000a') +
+ " (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shortPercentageGains*100, 2) + "%)" +
+ "Orders:
";
+ }
+
+}
+
+function updateStockOrderList(stock) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
+ var tickerId = "stock-market-ticker-" + stock.symbol;
+ var orderList = document.getElementById(tickerId + "-order-list");
+ if (orderList == null) {
+ if (!stockMarketPortfolioMode) {console.log("ERROR: Could not find order list for " + stock.symbol);}
+ return;
+ }
+
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ console.log("ERROR: Could not find order book in stock market");
+ return;
+ }
+ var stockOrders = orderBook[stock.symbol];
+ if (stockOrders == null) {
+ console.log("ERROR: Could not find orders for: " + stock.symbol);
+ return;
+ }
+
+ if (stockMarketPortfolioMode) {
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
+ StockMarket["Orders"][stock.symbol].length === 0) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-panel");
+ return;
+ } else {
+ //If the ticker hasn't been created, create it (handles updating)
+ //If it has been created, continue normally
+ if (document.getElementById(tickerId + "-hdr") == null) {
+ createStockTicker(stock);
+ setStockTickerClickHandlers();
+ return;
+ }
+ }
+ }
+
+ //Remove everything from list
+ while (orderList.firstChild) {
+ orderList.removeChild(orderList.firstChild);
+ }
+
+ for (var i = 0; i < stockOrders.length; ++i) {
+ (function() {
+ var order = stockOrders[i];
+ var li = document.createElement("li");
+ li.style.padding = "4px";
+ var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position");
+ li.style.color = "white";
+ li.innerText = order.type + " - " + posText + " - " +
+ order.shares + " @ $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(order.price, 2);
+
+ var cancelButton = document.createElement("span");
+ cancelButton.classList.add("stock-market-order-cancel-btn");
+ cancelButton.classList.add("a-link-button");
+ cancelButton.innerHTML = "Cancel Order";
+ cancelButton.addEventListener("click", function() {
+ cancelOrder({order: order}, null);
+ return false;
+ });
+ li.appendChild(cancelButton);
+ orderList.appendChild(li);
+ }());
+
+ }
+}
+
+
+
+
+/***/ }),
+/* 30 */
+/*!**********************!*\
+ !*** ./src/Fconf.js ***!
+ \**********************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -34698,7 +29562,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; });
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(35);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__);
@@ -34830,24 +29694,41 @@ function loadFconf(saveString) {
/***/ }),
-/* 33 */
+/* 31 */
+/*!***********************************!*\
+ !*** ./src/NetscriptEvaluator.js ***!
+ \***********************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HackingMission", function() { return HackingMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inMission", function() { return inMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setInMission", function() { return setInMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currMission", function() { return currMission; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2);
-/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(201);
-/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(jsplumb__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeRuntimeRejectMsg", function() { return makeRuntimeRejectMsg; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "netscriptDelay", function() { return netscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptFromScript", function() { return runScriptFromScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingChance", function() { return scriptCalculateHackingChance; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingTime", function() { return scriptCalculateHackingTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateExpGain", function() { return scriptCalculateExpGain; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculatePercentMoneyHacked", function() { return scriptCalculatePercentMoneyHacked; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateGrowTime", function() { return scriptCalculateGrowTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateWeakenTime", function() { return scriptCalculateWeakenTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluate", function() { return evaluate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptErrorMessage", function() { return isScriptErrorMessage; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killNetscriptDelay", function() { return killNetscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluateImport", function() { return evaluateImport; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 82);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/IPAddress.js */ 14);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__);
@@ -34857,3022 +29738,970 @@ __webpack_require__.r(__webpack_exports__);
-let inMission = false; //Flag to denote whether a mission is running
-let currMission = null;
-function setInMission(bool, mission) {
- inMission = bool;
- if (bool) {
- currMission = mission;
- } else {
- currMission = null;
- }
-}
-//Keyboard shortcuts
-$(document).keydown(function(e) {
- if (inMission && currMission && currMission.selectedNode.length != 0) {
- switch (e.keyCode) {
- case 65: //a for Attack
- currMission.actionButtons[0].click();
- break;
- case 83: //s for Scan
- currMission.actionButtons[1].click();
- break;
- case 87: //w for Weaken
- currMission.actionButtons[2].click();
- break;
- case 70: //f for Fortify
- currMission.actionButtons[3].click();
- break;
- case 82: //r for Overflow
- currMission.actionButtons[4].click();
- break;
- case 68: //d for Detach connection
- currMission.actionButtons[5].click();
- break;
- default:
- break;
- }
- }
+
+
+
+
+var Promise = __webpack_require__(/*! bluebird */ 183);
+
+Promise.config({
+ warnings: false,
+ longStackTraces: false,
+ cancellation: true,
+ monitoring: false
});
-
-let NodeTypes = {
- Core: "CPU Core Node", //All actions available
- Firewall: "Firewall Node", //No actions available
- Database: "Database Node", //No actions available
- Spam: "Spam Node", //No actions Available
- Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow
- Shield: "Shield Node" //Can Fortify
-}
-
-let NodeActions = {
- Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def
- Scan: "Scanning", //-Def for target, affected by attack and hacking level
- Weaken: "Weakening", //-Attack for target, affected by attack and hacking level
- Fortify: "Fortifying", //+Defense for Node, affected by hacking level
- Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level
-}
-
-function Node(type, stats) {
- this.type = type;
- this.atk = stats.atk ? stats.atk : 0;
- this.def = stats.def ? stats.def : 0;
- this.hp = stats.hp ? stats.hp : 0;
- this.maxhp = this.hp;
- this.plyrCtrl = false;
- this.enmyCtrl = false;
- this.pos = [0, 0]; //x, y
- this.el = null; //Holds the Node's DOM element
- 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)
- this.conn = null;
-}
-
-Node.prototype.setPosition = function(x, y) {
- this.pos = [x, y];
-}
-
-Node.prototype.setControlledByPlayer = function() {
- this.plyrCtrl = true;
- this.enmyCtrl = false;
- if (this.el) {
- this.el.classList.remove("hack-mission-enemy-node");
- this.el.classList.add("hack-mission-player-node");
- }
-}
-
-Node.prototype.setControlledByEnemy = function() {
- this.plyrCtrl = false;
- this.enmyCtrl = true;
- if (this.el) {
- this.el.classList.remove("hack-mission-player-node");
- this.el.classList.add("hack-mission-enemy-node");
- }
-}
-
-//Sets this node to be the active node
-Node.prototype.select = function(actionButtons) {
- if (this.enmyCtrl) {return;}
- this.el.classList.add("hack-mission-player-node-active");
-
- //Make all buttons inactive
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button");
- actionButtons[i].classList.add("a-link-button-inactive");
- }
-
- switch(this.type) {
- case NodeTypes.Core:
- //All buttons active
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button-inactive");
- actionButtons[i].classList.add("a-link-button");
- }
- break;
- case NodeTypes.Transfer:
- actionButtons[1].classList.remove("a-link-button-inactive");
- actionButtons[1].classList.add("a-link-button");
- actionButtons[2].classList.remove("a-link-button-inactive");
- actionButtons[2].classList.add("a-link-button");
- actionButtons[3].classList.remove("a-link-button-inactive");
- actionButtons[3].classList.add("a-link-button");
- actionButtons[4].classList.remove("a-link-button-inactive");
- actionButtons[4].classList.add("a-link-button");
- actionButtons[5].classList.remove("a-link-button-inactive");
- actionButtons[5].classList.add("a-link-button");
- break;
- case NodeTypes.Shield:
- case NodeTypes.Firewall:
- actionButtons[3].classList.remove("a-link-button-inactive");
- actionButtons[3].classList.add("a-link-button");
- break;
- default:
- break;
- }
-}
-
-Node.prototype.deselect = function(actionButtons) {
- this.el.classList.remove("hack-mission-player-node-active");
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button");
- actionButtons[i].classList.add("a-link-button-inactive");
- }
-}
-
-
-Node.prototype.untarget = function() {
- if (this.targetedCount === 0) {
- console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count");
- return;
- }
- --this.targetedCount;
-}
-
-//Hacking mission instance
-//Takes in the reputation of the Faction for which the mission is
-//being conducted
-function HackingMission(rep, fac) {
- this.faction = fac;
-
- this.started = false;
- this.time = 180000; //5 minutes to start, milliseconds
-
- this.playerCores = [];
- this.playerNodes = []; //Non-core nodes
- this.playerAtk = 0;
- this.playerDef = 0;
-
- this.enemyCores = [];
- this.enemyDatabases = [];
- this.enemyNodes = []; //Non-core nodes
- this.enemyAtk = 0;
- this.enemyDef = 0;
-
- this.miscNodes = [];
-
- this.selectedNode = []; //Which of the player's nodes are currently selected
-
- this.actionButtons = []; //DOM buttons for actions
-
- this.availablePositions = [];
- for (var r = 0; r < 8; ++r) {
- for (var c = 0; c < 8; ++c) {
- this.availablePositions.push([r, c]);
- }
- }
-
- this.map = [];
- for (var i = 0; i < 8; ++i) {
- this.map.push([null, null, null, null, null, null, null, null]);
- }
-
- this.jsplumbinstance = null;
-
- this.difficulty = rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToDiffConversion + 1;
- console.log("difficulty: " + this.difficulty);
- this.reward = 250 + (rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToRewardConversion);
-}
-
-HackingMission.prototype.init = function() {
- //Create Header DOM
- this.createPageDom();
-
- //Create player starting nodes
- var home = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer()
- for (var i = 0; i < home.cpuCores; ++i) {
- var stats = {
- atk: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 7.5) + 30,
- def: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 20),
- hp: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 4),
- };
- this.playerCores.push(new Node(NodeTypes.Core, stats));
- this.playerCores[i].setControlledByPlayer();
- this.setNodePosition(this.playerCores[i], i, 0);
- this.removeAvailablePosition(i, 0);
- }
-
- //Randomly generate enemy nodes (CPU and Firewall) based on difficulty
- var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4)));
- var numFirewalls = Math.min(20,
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1));
- var numDatabases = Math.min(10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(1, Math.round(this.difficulty / 3) + 1));
- var totalNodes = numNodes + numFirewalls + numDatabases;
- var xlimit = 7 - Math.floor(totalNodes / 8);
- var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.8 + (this.difficulty / 5), 10);
- for (var i = 0; i < numNodes; ++i) {
- var stats = {
- atk: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(80, 86),
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(5, 10),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 230)
- }
- this.enemyCores.push(new Node(NodeTypes.Core, stats));
- this.enemyCores[i].setControlledByEnemy();
- this.setNodeRandomPosition(this.enemyCores[i], xlimit);
- }
- for (var i = 0; i < numFirewalls; ++i) {
- var stats = {
- atk: 0,
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(10, 20),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(275, 300)
- }
- this.enemyNodes.push(new Node(NodeTypes.Firewall, stats));
- this.enemyNodes[i].setControlledByEnemy();
- this.setNodeRandomPosition(this.enemyNodes[i], xlimit);
- }
- for (var i = 0; i < numDatabases; ++i) {
- var stats = {
- atk: 0,
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 55),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 275)
- }
- var node = new Node(NodeTypes.Database, stats);
- node.setControlledByEnemy();
- this.setNodeRandomPosition(node, xlimit);
- this.enemyDatabases.push(node);
- }
- this.calculateDefenses();
- this.calculateAttacks();
- this.createMap();
-}
-
-HackingMission.prototype.createPageDom = function() {
- var container = document.getElementById("mission-container");
-
- var favorMult = 1 + (this.faction.favor / 100);
- var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
- var headerText = document.createElement("p");
- headerText.innerHTML = "You are about to start a hacking mission! You will gain " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " faction reputation with " + this.faction.name +
- " if you win. For more information " +
- "about how hacking missions work, click one of the guide links " +
- "below (one opens up an in-game guide and the other opens up " +
- "the guide from the wiki). Click the 'Start' button to begin.";
- headerText.style.display = "block";
- headerText.classList.add("hack-mission-header-element");
- headerText.style.width = "80%";
-
- var inGameGuideBtn = document.createElement("a");
- inGameGuideBtn.innerText = "How to Play";
- inGameGuideBtn.classList.add("a-link-button");
- inGameGuideBtn.style.display = "inline-block";
- inGameGuideBtn.classList.add("hack-mission-header-element");
- inGameGuideBtn.addEventListener("click", function() {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionHowToPlay);
- return false;
- });
-
- var wikiGuideBtn = document.createElement("a");
- wikiGuideBtn.innerText = "Wiki Guide";
- wikiGuideBtn.classList.add("a-link-button");
- wikiGuideBtn.style.display = "inline-block";
- wikiGuideBtn.classList.add("hack-mission-header-element");
- wikiGuideBtn.target = "_blank";
- //TODO Add link to wiki page wikiGuideBtn.href =
-
-
- //Start button will get replaced with forfeit when game is started
- var startBtn = document.createElement("a");
- startBtn.innerHTML = "Start";
- startBtn.setAttribute("id", "hack-mission-start-btn");
- startBtn.classList.add("a-link-button");
- startBtn.classList.add("hack-mission-header-element");
- startBtn.style.display = "inline-block";
- startBtn.addEventListener("click", ()=>{
- this.start();
- return false;
- });
-
- var forfeitMission = document.createElement("a");
- forfeitMission.innerHTML = "Forfeit Mission (Exit)";
- forfeitMission.classList.add("a-link-button");
- forfeitMission.classList.add("hack-mission-header-element");
- forfeitMission.style.display = "inline-block";
- forfeitMission.addEventListener("click", ()=> {
- this.finishMission(false);
- return false;
- });
-
- var timer = document.createElement("p");
- timer.setAttribute("id", "hacking-mission-timer");
- timer.style.display = "inline-block";
- timer.style.margin = "6px";
-
- //Create Action Buttons (Attack/Scan/Weaken/ etc...)
- var actionsContainer = document.createElement("span");
- actionsContainer.style.display = "block";
- actionsContainer.classList.add("hack-mission-action-buttons-container");
- for (var i = 0; i < 6; ++i) {
- this.actionButtons.push(document.createElement("a"));
- this.actionButtons[i].style.display = "inline-block";
- this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start
- this.actionButtons[i].classList.add("tooltip"); //Disabled at start
- this.actionButtons[i].classList.add("hack-mission-header-element");
- actionsContainer.appendChild(this.actionButtons[i]);
- }
- this.actionButtons[0].innerText = "Attack(a)";
- var atkTooltip = document.createElement("span");
- atkTooltip.classList.add("tooltiptexthigh");
- atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[0].appendChild(atkTooltip);
- this.actionButtons[1].innerText = "Scan(s)";
- var scanTooltip = document.createElement("span");
- scanTooltip.classList.add("tooltiptexthigh");
- scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[1].appendChild(scanTooltip);
- this.actionButtons[2].innerText = "Weaken(w)";
- var WeakenTooltip = document.createElement("span");
- WeakenTooltip.classList.add("tooltiptexthigh");
- WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[2].appendChild(WeakenTooltip);
- this.actionButtons[3].innerText = "Fortify(f)";
- var fortifyTooltip = document.createElement("span");
- fortifyTooltip.classList.add("tooltiptexthigh");
- fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " +
- "your hacking level";
- this.actionButtons[3].appendChild(fortifyTooltip);
- this.actionButtons[4].innerText = "Overflow(r)";
- var overflowTooltip = document.createElement("span");
- overflowTooltip.classList.add("tooltiptexthigh");
- overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " +
- "of this depends on your hacking level.";
- this.actionButtons[4].appendChild(overflowTooltip);
- this.actionButtons[5].innerText = "Drop Connection(d)";
- var dropconnTooltip = document.createElement("span");
- dropconnTooltip.classList.add("tooltiptexthigh");
- dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " +
- "also be done by simply clicking the white connection line.";
- this.actionButtons[5].appendChild(dropconnTooltip);
-
- //Player/enemy defense displays will be in action container
- var playerStats = document.createElement("p");
- var enemyStats = document.createElement("p");
- playerStats.style.display = "inline-block";
- enemyStats.style.display = "inline-block";
- playerStats.style.color = "#00ccff";
- enemyStats.style.color = "red";
- playerStats.style.margin = "4px";
- enemyStats.style.margin = "4px";
- playerStats.setAttribute("id", "hacking-mission-player-stats");
- enemyStats.setAttribute("id", "hacking-mission-enemy-stats");
- actionsContainer.appendChild(playerStats);
- actionsContainer.appendChild(enemyStats);
-
- //Set Action Button event listeners
- this.actionButtons[0].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- if (this.selectedNode[0].type !== NodeTypes.Core) {return;}
- this.setActionButtonsActive(this.selectedNode[0].type);
- this.setActionButton(NodeActions.Attack, false); //Set attack button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Attack;
- });
- });
-
- this.actionButtons[1].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Scan, false); //Set scan button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Scan;
- });
- });
-
- this.actionButtons[2].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Weaken;
- });
- });
-
- this.actionButtons[3].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- this.setActionButtonsActive(this.selectedNode[0].type);
- this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Fortify;
- });
- });
-
- this.actionButtons[4].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type;
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Overflow;
- });
- });
-
- this.actionButtons[5].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- this.selectedNode.forEach(function(node){
- if (node.conn) {
- var endpoints = node.conn.endpoints;
- endpoints[0].detachFrom(endpoints[1]);
- }
- node.action = NodeActions.Fortify;
- });
- // if (this.selectedNode.conn) {
- // var endpoints = this.selectedNode.conn.endpoints;
- // endpoints[0].detachFrom(endpoints[1]);
- // }
- })
-
- var timeDisplay = document.createElement("p");
-
- container.appendChild(headerText);
- container.appendChild(inGameGuideBtn);
- container.appendChild(wikiGuideBtn);
- container.appendChild(startBtn);
- container.appendChild(forfeitMission);
- container.appendChild(timer);
- container.appendChild(actionsContainer);
- container.appendChild(timeDisplay);
-}
-
-HackingMission.prototype.setActionButtonsInactive = function() {
- for (var i = 0; i < this.actionButtons.length; ++i) {
- this.actionButtons[i].classList.remove("a-link-button");
- this.actionButtons[i].classList.add("a-link-button-inactive");
- }
-}
-
-HackingMission.prototype.setActionButtonsActive = function(nodeType=null) {
- for (var i = 0; i < this.actionButtons.length; ++i) {
- this.actionButtons[i].classList.add("a-link-button");
- 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
- if (nodeType) {
- switch (nodeType) {
- case NodeTypes.Firewall:
- case NodeTypes.Shield:
- this.actionButtons[0].classList.remove("a-link-button");
- this.actionButtons[0].classList.add("a-link-button-inactive");
- this.actionButtons[1].classList.remove("a-link-button");
- this.actionButtons[1].classList.add("a-link-button-inactive");
- this.actionButtons[2].classList.remove("a-link-button");
- this.actionButtons[2].classList.add("a-link-button-inactive");
- this.actionButtons[4].classList.remove("a-link-button");
- this.actionButtons[4].classList.add("a-link-button-inactive");
- this.actionButtons[5].classList.remove("a-link-button");
- this.actionButtons[5].classList.add("a-link-button-inactive");
- break;
- case NodeTypes.Transfer:
- this.actionButtons[0].classList.remove("a-link-button");
- this.actionButtons[0].classList.add("a-link-button-inactive");
- break;
- default:
- break;
- }
- }
-}
-
-//True for active, false for inactive
-HackingMission.prototype.setActionButton = function(i, active=true) {
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(i)) {
- switch (i) {
- case NodeActions.Attack:
- i = 0;
- break;
- case NodeActions.Scan:
- i = 1;
- break;
- case NodeActions.Weaken:
- i = 2;
- break;
- case NodeActions.Fortify:
- i = 3;
- break;
- case NodeActions.Overflow:
- default:
- i = 4;
- break;
- }
- }
- if (active) {
- this.actionButtons[i].classList.remove("a-link-button-inactive");
- this.actionButtons[i].classList.add("a-link-button");
- } else {
- this.actionButtons[i].classList.remove("a-link-button");
- this.actionButtons[i].classList.add("a-link-button-inactive");
- }
-
-}
-
-HackingMission.prototype.calculateAttacks = function() {
- var total = 0;
- for (var i = 0; i < this.playerCores.length; ++i) {
- total += this.playerCores[i].atk;
- }
- for (var i = 0; i < this.playerNodes.length; ++i) {
- total += this.playerNodes[i].atk;
- }
- this.playerAtk = total;
- document.getElementById("hacking-mission-player-stats").innerHTML =
- "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
- "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
- total = 0;
- for (var i = 0; i < this.enemyCores.length; ++i) {
- total += this.enemyCores[i].atk;
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- total += this.enemyDatabases[i].atk;
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- total += this.enemyNodes[i].atk;
- }
- this.enemyAtk = total;
- document.getElementById("hacking-mission-enemy-stats").innerHTML =
- "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
- "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
-}
-
-HackingMission.prototype.calculateDefenses = function() {
- var total = 0;
- for (var i = 0; i < this.playerCores.length; ++i) {
- total += this.playerCores[i].def;
- }
- for (var i = 0; i < this.playerNodes.length; ++i) {
- total += this.playerNodes[i].def;
- }
- this.playerDef = total;
- document.getElementById("hacking-mission-player-stats").innerHTML =
- "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
- "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
- total = 0;
- for (var i = 0; i < this.enemyCores.length; ++i) {
- total += this.enemyCores[i].def;
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- total += this.enemyDatabases[i].def;
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- total += this.enemyNodes[i].def;
- }
- this.enemyDef = total;
- document.getElementById("hacking-mission-enemy-stats").innerHTML =
- "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
- "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
-}
-
-HackingMission.prototype.removeAvailablePosition = function(x, y) {
- for (var i = 0; i < this.availablePositions.length; ++i) {
- if (this.availablePositions[i][0] === x &&
- this.availablePositions[i][1] === y) {
- this.availablePositions.splice(i, 1);
- return;
- }
- }
- console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y);
-}
-
-HackingMission.prototype.setNodePosition = function(nodeObj, x, y) {
- if (!(nodeObj instanceof Node)) {
- console.log("WARNING: Non-Node object passed into setNodePOsition");
- return;
- }
- if (isNaN(x) || isNaN(y)) {
- console.log("ERR: Invalid values passed as x and y for setNodePosition");
- console.log(x);
- console.log(y);
- return;
- }
- nodeObj.pos = [x, y];
- this.map[x][y] = nodeObj;
-}
-
-HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {
- var i = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.availablePositions.length - 1);
- if (this.availablePositions[i][1] < xlimit) {
- //Recurse if not within limit
- return this.setNodeRandomPosition(nodeObj, xlimit);
- }
- var pos = this.availablePositions.splice(i, 1);
- pos = pos[0];
- this.setNodePosition(nodeObj, pos[0], pos[1]);
-}
-
-HackingMission.prototype.createMap = function() {
- //Use a grid
- var map = document.createElement("div");
- map.classList.add("hack-mission-grid");
- map.setAttribute("id", "hacking-mission-map");
- document.getElementById("mission-container").appendChild(map);
-
- //Create random Nodes for every space in the map that
- //hasn't been filled yet. The stats of each Node will be based on
- //the player/enemy attack
- var averageAttack = (this.playerAtk + this.enemyAtk) / 2;
- for (var x = 0; x < 8; ++x) {
- for (var y = 0; y < 8; ++y) {
- if (!(this.map[x][y] instanceof Node)) {
- var node, type = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, 2);
- var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.85 + (this.difficulty / 2), 15);
- switch (type) {
- case 0: //Spam
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(200, 225)
- }
- node = new Node(NodeTypes.Spam, stats);
- break;
- case 1: //Transfer
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(250, 275)
- }
- node = new Node(NodeTypes.Transfer, stats);
- break;
- case 2: //Shield
- default:
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 70),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(300, 320)
- }
- node = new Node(NodeTypes.Shield, stats);
- break;
- }
- this.setNodePosition(node, x, y);
- this.removeAvailablePosition(x, y);
- this.miscNodes.push(node);
- }
- }
- }
-
- //Create DOM elements in order
- for (var r = 0; r < 8; ++r) {
- for (var c = 0; c < 8; ++c) {
- this.createNodeDomElement(this.map[r][c]);
- }
- }
-
- //Configure all Player CPUS
- for (var i = 0; i < this.playerCores.length; ++i) {
- console.log("Configuring Player Node: " + this.playerCores[i].el.id);
- this.configurePlayerNodeElement(this.playerCores[i].el);
- }
-}
-
-HackingMission.prototype.createNodeDomElement = function(nodeObj) {
- var nodeDiv = document.createElement("a"), txtEl = document.createElement('p');
- nodeObj.el = nodeDiv;
-
- //Set the node element's id based on its coordinates
- var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
- nodeDiv.setAttribute("id", id);
- txtEl.setAttribute("id", id + "-txt");
-
- //Set node classes for owner
- nodeDiv.classList.add("hack-mission-node");
- if (nodeObj.plyrCtrl) {
- nodeDiv.classList.add("hack-mission-player-node");
- } else if (nodeObj.enmyCtrl) {
- nodeDiv.classList.add("hack-mission-enemy-node");
- }
-
- //Set node classes based on type
- var txt;
- switch (nodeObj.type) {
- case NodeTypes.Core:
- txt = "CPU Core
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-cpu-node");
- break;
- case NodeTypes.Firewall:
- txt = "Firewall
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-firewall-node");
- break;
- case NodeTypes.Database:
- txt = "Database
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-database-node");
- break;
- case NodeTypes.Spam:
- txt = "Spam
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-spam-node");
- break;
- case NodeTypes.Transfer:
- txt = "Transfer
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-transfer-node");
- break;
- case NodeTypes.Shield:
- default:
- txt = "Shield
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-shield-node");
- break;
- }
-
- txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
- "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
- txtEl.innerHTML = txt;
-
- nodeDiv.appendChild(txtEl);
- document.getElementById("hacking-mission-map").appendChild(nodeDiv);
-}
-
-HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
- if (nodeObj.el == null) {
- console.log("ERR: Calling updateNodeDomElement on a Node without an element");
- return;
- }
-
- var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
- var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt");
-
- //Set node classes based on type
- var txt;
- switch (nodeObj.type) {
- case NodeTypes.Core:
- txt = "CPU Core
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Firewall:
- txt = "Firewall
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Database:
- txt = "Database
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Spam:
- txt = "Spam
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Transfer:
- txt = "Transfer
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Shield:
- default:
- txt = "Shield
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- }
-
- txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
- "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
- if (nodeObj.action) {
- txt += "
" + nodeObj.action;
- }
- 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
-HackingMission.prototype.getNodeFromElement = function(el) {
- var id;
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(el)) {
- id = el;
- } else {
- id = el.id;
- }
- id = id.replace("hacking-mission-node-", "");
- var res = id.split('-');
- if (res.length != 2) {
- console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates");
- return null;
- }
- var x = res[0], y = res[1];
- if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {
- console.log("ERROR: Unexpected values for x and y: " + x + ", " + y);
- return null;
- }
- return this.map[x][y];
-}
-
-function selectNode(hackMissionInst, el) {
- var nodeObj = hackMissionInst.getNodeFromElement(el);
- if (nodeObj == null) {console.log("Error getting Node object");}
- if (!nodeObj.plyrCtrl) {return;}
-
- clearAllSelectedNodes(hackMissionInst);
- nodeObj.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(nodeObj);
-}
-
-function multiselectNode(hackMissionInst, el) {
- var nodeObj = hackMissionInst.getNodeFromElement(el);
- if (nodeObj == null) {console.log("ERROR: Getting Node Object in multiselectNode()");}
- if (!nodeObj.plyrCtrl) {return;}
-
- clearAllSelectedNodes(hackMissionInst);
- var type = nodeObj.type;
- if (type === NodeTypes.Core) {
- hackMissionInst.playerCores.forEach(function(node) {
- node.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(node);
- });
- } else {
- hackMissionInst.playerNodes.forEach(function(node) {
- if (node.type === type) {
- node.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(node);
- }
- });
- }
-}
-
-function clearAllSelectedNodes(hackMissionInst) {
- if (hackMissionInst.selectedNode.length > 0) {
- hackMissionInst.selectedNode.forEach(function(node){
- node.deselect(hackMissionInst.actionButtons);
- });
- hackMissionInst.selectedNode.length = 0;
- }
-}
-
-//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");}
-
- //Add event listener
- var self = this;
- function selectNodeWrapper() {
- selectNode(self, el);
- }
- el.addEventListener("click", selectNodeWrapper);
-
- function multiselectNodeWrapper() {
- multiselectNode(self, el);
- }
- el.addEventListener("dblclick", multiselectNodeWrapper);
-
-
- if (el.firstChild) {
- el.firstChild.addEventListener("click", selectNodeWrapper);
- }
-}
-
-//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);
- for (var i = 0; i < this.selectedNode.length; ++i) {
- if (this.selectedNode[i] == nodeObj) {
- nodeObj.deselect(this.actionButtons);
- this.selectedNode.splice(i, 1);
- break;
- }
- }
-}
-
-//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;}
- if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}
- if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}
- if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}
- return false;
-}
-
-HackingMission.prototype.nodeReachableByEnemy = function(node) {
- if (node == null) {return false;}
- var x = node.pos[0], y = node.pos[1];
- if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
- if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
- if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}
- if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}
- return false;
-}
-
-HackingMission.prototype.start = function() {
- this.started = true;
- this.initJsPlumb();
- var startBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("hack-mission-start-btn");
- startBtn.classList.remove("a-link-button");
- startBtn.classList.add("a-link-button-inactive");
-}
-
-HackingMission.prototype.initJsPlumb = function() {
- var instance = jsPlumb.getInstance({
- DragOptions:{cursor:"pointer", zIndex:2000},
- PaintStyle: {
- gradient: { stops: [
- [ 0, "#FFFFFF" ],
- [ 1, "#FFFFFF" ]
- ] },
- stroke: "#FFFFFF",
- strokeWidth: 8
- },
- });
-
- this.jsplumbinstance = instance;
-
- //All player cores are sources
- for (var i = 0; i < this.playerCores.length; ++i) {
- instance.makeSource(this.playerCores[i].el, {
- deleteEndpointsOnEmpty:true,
- maxConnections:1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
-
- //Everything else is a target
- for (var i = 0; i < this.enemyCores.length; ++i) {
- instance.makeTarget(this.enemyCores[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- instance.makeTarget(this.enemyDatabases[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:["Flowchart"]
- });
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- instance.makeTarget(this.enemyNodes[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
- for (var i = 0; i < this.miscNodes.length; ++i) {
- instance.makeTarget(this.miscNodes[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
-
- //Clicking a connection drops it
- instance.bind("click", function(conn, originalEvent) {
- var endpoints = conn.endpoints;
- endpoints[0].detachFrom(endpoints[1]);
- });
-
- //Connection events
- instance.bind("connection", (info)=>{
- var targetNode = this.getNodeFromElement(info.target);
-
- //Do not detach for enemy nodes
- var thisNode = this.getNodeFromElement(info.source);
- if (thisNode.enmyCtrl) {return;}
-
- //If the node is not reachable, drop the connection
- if (!this.nodeReachable(targetNode)) {
- info.sourceEndpoint.detachFrom(info.targetEndpoint);
- return;
- }
-
- var sourceNode = this.getNodeFromElement(info.source);
- sourceNode.conn = info.connection;
- var targetNode = this.getNodeFromElement(info.target);
- ++targetNode.targetedCount;
- });
-
- //Detach Connection events
- instance.bind("connectionDetached", (info, originalEvent)=>{
- var sourceNode = this.getNodeFromElement(info.source);
- sourceNode.conn = null;
- var targetNode = this.getNodeFromElement(info.target);
- targetNode.untarget();
- });
-
-}
-
-//Drops all connections where the specified node is the source
-HackingMission.prototype.dropAllConnectionsFromNode = function(node) {
- var allConns = this.jsplumbinstance.getAllConnections();
- for (var i = allConns.length-1; i >= 0; --i) {
- if (allConns[i].source == node.el) {
- allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
- }
- }
-}
-
-//Drops all connections where the specified node is the target
-HackingMission.prototype.dropAllConnectionsToNode = function(node) {
- var allConns = this.jsplumbinstance.getAllConnections();
- for (var i = allConns.length-1; i >= 0; --i) {
- if (allConns[i].target == node.el) {
- allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
- }
- }
- node.beingTargeted = false;
-}
-
-var storedCycles = 0;
-HackingMission.prototype.process = function(numCycles=1) {
- if (!this.started) {return;}
- storedCycles += numCycles;
- if (storedCycles < 2) {return;} //Only process every 3 cycles minimum
-
- var res = false;
- //Process actions of all player nodes
- this.playerCores.forEach((node)=>{
- res |= this.processNode(node, storedCycles);
- });
-
- this.playerNodes.forEach((node)=>{
- if (node.type === NodeTypes.Transfer ||
- node.type === NodeTypes.Shield ||
- node.type === NodeTypes.Firewall) {
- res |= this.processNode(node, storedCycles);
- }
- });
-
- //Process actions of all enemy nodes
- this.enemyCores.forEach((node)=>{
- this.enemyAISelectAction(node);
- res |= this.processNode(node, storedCycles);
- });
-
- this.enemyNodes.forEach((node)=>{
- if (node.type === NodeTypes.Transfer ||
- node.type === NodeTypes.Shield ||
- node.type === NodeTypes.Firewall) {
- this.enemyAISelectAction(node);
- res |= this.processNode(node, storedCycles);
- }
- });
-
- //The hp of enemy databases increases slowly
- this.enemyDatabases.forEach((node)=>{
- node.maxhp += (0.1 * storedCycles);
- node.hp += (0.1 * storedCycles);
- });
-
- if (res) {
- this.calculateAttacks();
- this.calculateDefenses();
- }
-
- //Win if all enemy databases are conquered
- if (this.enemyDatabases.length === 0) {
- this.finishMission(true);
- return;
- }
-
- //Lose if all your cores are gone
- if (this.playerCores.length === 0) {
- this.finishMission(false);
- return;
- }
-
- //Defense/hp of misc nodes increases slowly over time
- this.miscNodes.forEach((node)=>{
- node.def += (0.1 * storedCycles);
- node.maxhp += (0.05 * storedCycles);
- node.hp += (0.1 * storedCycles);
- if (node.hp > node.maxhp) {node.hp = node.maxhp;}
- this.updateNodeDomElement(node);
- });
-
- //Update timer and check if player lost
- this.time -= (storedCycles * _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"]._idleSpeed);
- if (this.time <= 0) {
- this.finishMission(false);
- return;
- }
- this.updateTimer();
-
- storedCycles = 0;
-}
-
-//Returns a bool representing whether defenses need to be re-calculated
-HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
- if (nodeObj.action == null) {
- return;
- }
-
- var targetNode = null, def, atk;
- if (nodeObj.conn) {
- if (nodeObj.conn.target != null) {
- targetNode = this.getNodeFromElement(nodeObj.conn.target);
- } else {
- targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
- }
-
- if (targetNode == null) {
- //Player is in the middle of dragging the connection,
- //so the target node is null. Do nothing here
- } else if (targetNode.plyrCtrl) {
- def = this.playerDef;
- atk = this.enemyAtk;
- } else if (targetNode.enmyCtrl) {
- def = this.enemyDef;
- atk = this.playerAtk;
- } else { //Misc Node
- def = targetNode.def;
- nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;
- }
- }
-
- //Calculations are per second, so divide everything by 5
- var calcStats = false, plyr = nodeObj.plyrCtrl;
- var enmyHacking = this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionDifficultyToHacking;
- switch(nodeObj.action) {
- case NodeActions.Attack:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var dmg = this.calculateAttackDamage(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.hp -= (dmg/5 * numCycles);
- break;
- case NodeActions.Scan:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var eff = this.calculateScanEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.def -= (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Weaken:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var eff = this.calculateWeakenEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.atk -= (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Fortify:
- var eff = this.calculateFortifyEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
- nodeObj.def += (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Overflow:
- var eff = this.calculateOverflowEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
- if (nodeObj.def < eff) {break;}
- nodeObj.def -= (eff/5 * numCycles);
- nodeObj.atk += (eff/5 * numCycles);
- calcStats = true;
- break;
- default:
- console.log("ERR: Invalid Node Action: " + nodeObj.action);
- break;
- }
-
- //Stats can't go below 0
- if (nodeObj.atk < 0) {nodeObj.atk = 0;}
- if (nodeObj.def < 0) {nodeObj.def = 0;}
- if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}
- if (targetNode && targetNode.def < 0) {targetNode.def = 0;}
-
- //Conquering a node
- if (targetNode && targetNode.hp <= 0) {
- var conqueredByPlayer = nodeObj.plyrCtrl;
- targetNode.hp = targetNode.maxhp;
- targetNode.action = null;
- targetNode.conn = null;
- if (this.selectedNode == targetNode) {
- targetNode.deselect(this.actionButtons);
- }
-
- //The conquered node has its stats reduced
- targetNode.atk /= 2;
- targetNode.def /= 3.5;
-
- //Flag for whether the target node was a misc node
- var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;
-
- //Remove all connections from Node
- this.dropAllConnectionsToNode(targetNode);
- this.dropAllConnectionsFromNode(targetNode);
-
- //Changes the css class and turn the node into a JsPlumb Source/Target
- if (conqueredByPlayer) {
- targetNode.setControlledByPlayer();
- this.jsplumbinstance.unmakeTarget(targetNode.el);
- this.jsplumbinstance.makeSource(targetNode.el, {
- deleteEndpointsOnEmpty:true,
- maxConnections:1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- } else {
- targetNode.setControlledByEnemy();
- nodeObj.conn = null; //Clear connection
- this.jsplumbinstance.unmakeSource(targetNode.el);
- this.jsplumbinstance.makeTarget(targetNode.el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:["Flowchart"]
- });
- }
-
- calcStats = true;
-
- //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays
- function swapNodes(orig, dest, targetNode) {
- for (var i = 0; i < orig.length; ++i) {
- if (orig[i] == targetNode) {
- var node = orig.splice(i, 1);
- node = node[0];
- dest.push(node);
- break;
- }
- }
- }
-
- switch(targetNode.type) {
- case NodeTypes.Core:
- if (conqueredByPlayer) {
- swapNodes(this.enemyCores, this.playerCores, targetNode);
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(this.playerCores, this.enemyCores, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Firewall:
- if (conqueredByPlayer) {
- swapNodes(this.enemyNodes, this.playerNodes, targetNode);
- } else {
- swapNodes(this.playerNodes, this.enemyNodes, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Database:
- if (conqueredByPlayer) {
- swapNodes(this.enemyDatabases, this.playerNodes, targetNode);
- } else {
- swapNodes(this.playerNodes, this.enemyDatabases, targetNode);
- }
- break;
- case NodeTypes.Spam:
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- //Conquering spam node increases time limit
- this.time += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionSpamTimeIncrease;
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- }
-
- break;
- case NodeTypes.Transfer:
- //Conquering a Transfer node increases the attack of all cores by some percentages
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- this.playerCores.forEach(function(node) {
- node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
- });
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- this.enemyCores.forEach(function(node) {
- node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
- });
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Shield:
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- }
-
- //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount
- if (isMiscNode) { //&& conqueredByPlayer) {
- this.miscNodes.forEach((node)=>{
- if (node.targetedCount === 0) {
- node.def *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionMiscDefenseIncrease;
- }
- });
- }
- }
-
- //Update node DOMs
- this.updateNodeDomElement(nodeObj);
- if (targetNode) {this.updateNodeDomElement(targetNode);}
- return calcStats;
-}
-
-//Enemy "AI" for CPU Core and Transfer Nodes
-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
- if (nodeObj.conn == null) {
- if (this.miscNodes.length === 0) {
- //Randomly pick a player node and attack it if its reachable
- var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerNodes.length-1);
- var node;
- if (this.playerNodes.length === 0) {
- node = null;
- } else {
- node = this.playerNodes[rand];
- }
- if (this.nodeReachableByEnemy(node)) {
- //Create connection
- nodeObj.conn = this.jsplumbinstance.connect({
- source:nodeObj.el,
- target:node.el
- });
- ++node.targetedCount;
- } else {
- //Randomly pick a player core and attack it if its reachable
- rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerCores.length-1);
- if (this.playerCores.length === 0) {
- return; //No Misc Nodes, no player Nodes, no Player cores. Player lost
- } else {
- node = this.playerCores[rand];
- }
-
- if (this.nodeReachableByEnemy(node)) {
- //Create connection
- nodeObj.conn = this.jsplumbinstance.connect({
- source:nodeObj.el,
- target:node.el
- });
- ++node.targetedCount;
- }
- }
- } else {
- //Randomly pick a misc node and attack it if its reachable
- var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.miscNodes.length-1);
- var node = this.miscNodes[rand];
- if (this.nodeReachableByEnemy(node)) {
- nodeObj.conn = this.jsplumbinstance.connect({
- source:nodeObj.el,
- target:node.el,
- });
- ++node.targetedCount;
- }
- }
-
- //If no connection was made, set the Core to Fortify
- nodeObj.action = NodeActions.Fortify;
- } else {
- //If this node has a selected target
- var targetNode;
- if (nodeObj.conn.target) {
- targetNode = this.getNodeFromElement(nodeObj.conn.target);
- } else {
- targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
- }
- if (targetNode == null) {
- console.log("Error getting Target node Object in enemyAISelectAction()");
- }
-
- if (targetNode.def > this.enemyAtk + 15) {
- if (nodeObj.def < 50) {
- nodeObj.action = NodeActions.Fortify;
- } else {
- nodeObj.action = NodeActions.Overflow;
- }
- } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) {
- nodeObj.action = NodeActions.Scan;
- } else {
- nodeObj.action = NodeActions.Attack;
- }
- }
- break;
- case NodeTypes.Transfer:
- //Switch between fortifying and overflowing as necessary
- if (nodeObj.def < 125) {
- nodeObj.action = NodeActions.Fortify;
- } else {
- nodeObj.action = NodeActions.Overflow;
- }
- break;
- case NodeTypes.Firewall:
- case NodeTypes.Shield:
- nodeObj.action = NodeActions.Fortify;
- break;
- default:
- break;
- }
-}
-
-var hackEffWeightSelf = 130; //Weight for Node actions on self
-var hackEffWeightTarget = 25; //Weight for Node Actions against Target
-var hackEffWeightAttack = 80; //Weight for Attack action
-
-//Returns damage per cycle based on stats
-HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) {
- return Math.max(0.55 * (atk + (hacking / hackEffWeightAttack) - def), 1);
-}
-
-HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) {
- return Math.max(0.6 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2);
-}
-
-HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) {
- return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2);
-}
-
-HackingMission.prototype.calculateFortifyEffect = function(hacking=0) {
- return 0.9 * hacking / hackEffWeightSelf;
-}
-
-HackingMission.prototype.calculateOverflowEffect = function(hacking=0) {
- return 0.95 * hacking / hackEffWeightSelf;
-}
-
-//Updates timer display
-HackingMission.prototype.updateTimer = function() {
- var timer = document.getElementById("hacking-mission-timer");
-
- //Convert time remaining to a string of the form mm:ss
- var seconds = Math.round(this.time / 1000);
- var minutes = Math.trunc(seconds / 60);
- seconds %= 60;
- var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2);
- timer.innerText = "Time left: " + str;
-}
-
-//The 'win' argument is a bool for whether or not the player won
-HackingMission.prototype.finishMission = function(win) {
- inMission = false;
- currMission = null;
-
- if (win) {
- var favorMult = 1 + (this.faction.favor / 100);
- console.log("Hacking mission base reward: " + this.reward);
- console.log("favorMult: " + favorMult);
- console.log("rep mult: " + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult);
- var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission won! You earned " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " reputation with " + this.faction.name);
- _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainIntelligenceExp(this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceHackingMissionBaseExpGain);
- this.faction.playerReputation += gain;
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission lost/forfeited! You did not gain any faction reputation.");
- }
-
- //Clear mission container
- var container = document.getElementById("mission-container");
- while(container.firstChild) {
- container.removeChild(container.firstChild);
- }
-
- //Return to Faction page
- document.getElementById("mainmenu-container").style.visibility = "visible";
- document.getElementById("character-overview-wrapper").style.visibility = "visible";
- _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(this.faction.name);
-}
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
-
-/***/ }),
-/* 34 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gang", function() { return Gang; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayGangContent", function() { return displayGangContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateGangContent", function() { return updateGangContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAllGangs", function() { return loadAllGangs; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllGangs", function() { return AllGangs; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resetGangs", function() { return resetGangs; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteGangDisplayContent", function() { return deleteGangDisplayContent; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(12);
-
-
-
-
-
-
-
-
-
-
-
-/* Gang.js */
-//Switch between territory and management screen with 1 and 2
-$(document).keydown(function(event) {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Gang && !_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoBoxOpen"]) {
- if (gangMemberFilter != null && gangMemberFilter === document.activeElement) {return;}
- if (event.keyCode === 49) {
- if(gangTerritorySubpage.style.display === "block") {
- managementButton.click();
- }
- } else if (event.keyCode === 50) {
- if (gangManagementSubpage.style.display === "block") {
- territoryButton.click();
- }
- }
- }
-});
-
-//Delete upgrade box when clicking outside
-$(document).mousedown(function(event) {
- var boxId = "gang-member-upgrade-popup-box";
- var contentId = "gang-member-upgrade-popup-box-content";
- if (gangMemberUpgradeBoxOpened) {
- if ( $(event.target).closest("#" + contentId).get(0) == null ) {
- //Delete the box
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBox);
- gangMemberUpgradeBox = null;
- gangMemberUpgradeBoxContent = null;
- gangMemberUpgradeBoxOpened = false;
- gangMemberUpgradeBoxElements = null;
- }
- }
-});
-
-let GangNames = ["Slum Snakes", "Tetrads", "The Syndicate", "The Dark Army", "Speakers for the Dead",
- "NiteSec", "The Black Hand"];
-let AllGangs = {
- "Slum Snakes" : {
- power: 1,
- territory: 1/7,
- },
- "Tetrads" : {
- power: 1,
- territory: 1/7,
- },
- "The Syndicate" : {
- power: 1,
- territory: 1/7,
- },
- "The Dark Army" : {
- power: 1,
- territory: 1/7,
- },
- "Speakers for the Dead" : {
- power: 1,
- territory: 1/7,
- },
- "NiteSec" : {
- power: 1,
- territory: 1/7,
- },
- "The Black Hand" : {
- power: 1,
- territory: 1/7,
- },
-}
-
-function resetGangs() {
- AllGangs = {
- "Slum Snakes" : {
- power: 1,
- territory: 1/7,
- },
- "Tetrads" : {
- power: 1,
- territory: 1/7,
- },
- "The Syndicate" : {
- power: 1,
- territory: 1/7,
- },
- "The Dark Army" : {
- power: 1,
- territory: 1/7,
- },
- "Speakers for the Dead" : {
- power: 1,
- territory: 1/7,
- },
- "NiteSec" : {
- power: 1,
- territory: 1/7,
- },
- "The Black Hand" : {
- power: 1,
- territory: 1/7,
- },
- }
-}
-
-function loadAllGangs(saveString) {
- AllGangs = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"]);
-}
-
-//Power is an estimate of a gang's ability to gain/defend territory
-let gangStoredPowerCycles = 0;
-function processAllGangPowerGains(numCycles=1) {
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
- gangStoredPowerCycles += numCycles;
- if (gangStoredPowerCycles < 150) {return;}
- var playerGangName = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName;
- for (var name in AllGangs) {
- if (AllGangs.hasOwnProperty(name)) {
- if (name == playerGangName) {
- AllGangs[name].power += _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.calculatePower();
- } else {
- var gain = Math.random() * 0.02; //TODO Adjust as necessary
- AllGangs[name].power += (gain);
- }
- }
- }
-
- gangStoredPowerCycles -= 150;
-}
-
-let gangStoredTerritoryCycles = 0;
-function processAllGangTerritory(numCycles=1) {
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
- gangStoredTerritoryCycles += numCycles;
- if (gangStoredTerritoryCycles < _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer) {return;}
-
- for (var i = 0; i < GangNames.length; ++i) {
- var other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
- while(other == i) {
- other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
- }
- var thisPwr = AllGangs[GangNames[i]].power;
- var otherPwr = AllGangs[GangNames[other]].power;
- var thisChance = thisPwr / (thisPwr + otherPwr);
-
- if (Math.random() < thisChance) {
- if (AllGangs[GangNames[other]].territory <= 0) {
- return;
- }
- AllGangs[GangNames[i]].territory += 0.0001;
- AllGangs[GangNames[other]].territory -= 0.0001;
- } else {
- if (AllGangs[GangNames[i]].territory <= 0) {
- return;
- }
- AllGangs[GangNames[i]].territory -= 0.0001;
- AllGangs[GangNames[other]].territory += 0.0001;
- }
- }
-
- gangStoredTerritoryCycles -= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer;
-}
-
-/* faction - Name of corresponding faction
- hacking - Boolean indicating whether its a hacking gang or not
+/* Evaluator
+ * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser
+ *
+ * Returns a promise
*/
-function Gang(facName, hacking=false) {
- this.facName = facName;
- this.members = []; //Array of GangMembers
- this.wanted = 1;
- this.respect = 1;
- this.power = 0;
-
- this.isHackingGang = hacking;
-
- this.respectGainRate = 0;
- this.wantedGainRate = 0;
- this.moneyGainRate = 0;
-
- //When processing gains, this stores the number of cycles until some
- //limit is reached, and then calculates and applies the gains only at that limit
- this.storedCycles = 0;
-}
-
-Gang.prototype.process = function(numCycles=1) {
- this.processGains(numCycles);
- this.processExperienceGains(numCycles);
- processAllGangPowerGains(numCycles);
- processAllGangTerritory(numCycles);
-}
-
-Gang.prototype.processGains = function(numCycles=1) {
- this.storedCycles += numCycles;
- if (isNaN(this.storedCycles)) {
- console.log("ERROR: Gang's storedCylces is NaN");
- this.storedCycles = 0;
- }
- if (this.storedCycles < 25) {return;} //Only process every 5 seconds at least
-
- //Get gains per cycle
- var moneyGains = 0, respectGains = 0, wantedLevelGains = 0;
- for (var i = 0; i < this.members.length; ++i) {
- respectGains += (this.members[i].calculateRespectGain());
- wantedLevelGains += (this.members[i].calculateWantedLevelGain());
- moneyGains += (this.members[i].calculateMoneyGain());
- }
- this.respectGainRate = respectGains;
- this.wantedGainRate = wantedLevelGains;
- this.moneyGainRate = moneyGains;
-
- if (!isNaN(respectGains)) {
- var gain = respectGains * this.storedCycles;
- this.respect += (gain);
- //Faction reputation gains is respect gain divided by some constant
- var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][this.facName];
- if (!(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("ERROR: Could not get Faction associates with your gang. This is a bug, please report to game dev");
- } else {
- var favorMult = 1 + (fac.favor / 100);
- fac.playerReputation += ((_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * gain * favorMult) / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangRespectToReputationRatio);
+function evaluate(exp, workerScript) {
+ return Promise.delay(_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].CodeInstructionRunTime).then(function() {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ if (exp == null) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error: NULL expression", exp));
}
-
- } else {
- console.log("ERROR: respectGains is NaN");
- }
- if (!isNaN(wantedLevelGains)) {
- if (this.wanted === 1 && wantedLevelGains < 0) {
- //Do nothing
- } else {
- this.wanted += (wantedLevelGains * this.storedCycles);
- if (this.wanted < 1) {this.wanted = 1;}
- }
- } else {
- console.log("ERROR: wantedLevelGains is NaN");
- }
- if (!isNaN(moneyGains)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainMoney(moneyGains * this.storedCycles);
- } else {
- console.log("ERROR: respectGains is NaN");
- }
-
- this.storedCycles = 0;
-}
-
-Gang.prototype.processExperienceGains = function(numCycles=1) {
- for (var i = 0; i < this.members.length; ++i) {
- this.members[i].gainExperience(numCycles);
- this.members[i].updateSkillLevels();
- }
-}
-
-//Calculates power GAIN, which is added onto the Gang's existing power
-Gang.prototype.calculatePower = function() {
- var memberTotal = 0;
- for (var i = 0; i < this.members.length; ++i) {
- if (this.members[i].task instanceof GangMemberTask &&
- this.members[i].task.name == "Territory Warfare") {
- memberTotal += this.members[i].calculatePower();
- }
- }
- return (0.0005 * memberTotal);
-}
-
-Gang.prototype.autoAssignMemberToTask = function(taskName) {
- for (var i = 0; i < this.members.length; ++i) {
- if (this.members[i].task.name === taskName) {
- this.members[i].assignToTask(taskName);
- return true;
- }
- }
- return false;
-}
-
-Gang.prototype.autoUnassignMemberFromTask = function(taskName) {
- for (var i = 0; i < this.members.length; ++i) {
- if (this.members[i].task.name === taskName) {
- this.members[i].unassignFromTask();
- return true;
- }
- }
- return false;
-}
-
-Gang.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("Gang", this);
-}
-
-Gang.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(Gang, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.Gang = Gang;
-
-/*** Gang Member object ***/
-function GangMember(name) {
- this.name = name;
- this.task = GangMemberTasks["Unassigned"]; //GangMemberTask object
- this.city = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].city;
-
- this.hack = 1;
- this.str = 1;
- this.def = 1;
- this.dex = 1;
- this.agi = 1;
- this.cha = 1;
-
- this.hack_exp = 0;
- this.str_exp = 0;
- this.def_exp = 0;
- this.dex_exp = 0;
- this.agi_exp = 0;
- this.cha_exp = 0;
-
- this.hack_mult = 1;
- this.str_mult = 1;
- this.def_mult = 1;
- this.dex_mult = 1;
- this.agi_mult = 1;
- this.cha_mult = 1;
-
- this.upgrades = []; //Names of upgrades
-}
-
-//Same formula for Player
-GangMember.prototype.calculateSkill = function(exp, mult=1) {
- return Math.max(Math.floor(mult*(32 * Math.log(exp + 534.5) - 200)), 1);
-}
-
-GangMember.prototype.updateSkillLevels = function() {
- this.hack = this.calculateSkill(this.hack_exp, this.hack_mult);
- this.str = this.calculateSkill(this.str_exp, this.str_mult);
- this.def = this.calculateSkill(this.def_exp, this.def_mult);
- this.dex = this.calculateSkill(this.dex_exp, this.dex_mult);
- this.agi = this.calculateSkill(this.agi_exp, this.agi_mult);
- this.cha = this.calculateSkill(this.cha_exp, this.cha_mult);
-}
-
-GangMember.prototype.calculatePower = function() {
- return (this.hack + this.str + this.def +
- this.dex + this.agi + this.cha) / 100;
-}
-
-GangMember.prototype.assignToTask = function(taskName) {
- if (GangMemberTasks.hasOwnProperty(taskName)) {
- this.task = GangMemberTasks[taskName];
- } else {
- this.task = GangMemberTasks["Unassigned"];
- }
-}
-
-GangMember.prototype.unassignFromTask = function() {
- if (GangMemberTasks.hasOwnProperty("Unassigned")) {
- this.task = GangMemberTasks["Unassigned"];
- } else {
- console.log("ERROR: Can't find Unassigned Gang member task");
- this.task = null;
- }
-}
-
-//Gains are per cycle
-GangMember.prototype.calculateRespectGain = function() {
- var task = this.task;
- if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
- var statWeight = (task.hackWeight/100) * this.hack +
- (task.strWeight/100) * this.str +
- (task.defWeight/100) * this.def +
- (task.dexWeight/100) * this.dex +
- (task.agiWeight/100) * this.agi +
- (task.chaWeight/100) * this.cha;
- statWeight -= (3.5 * task.difficulty);
- if (statWeight <= 0) {return 0;}
- var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
- if (territoryMult <= 0) {return 0;}
- var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
- return 12 * task.baseRespect * statWeight * territoryMult * respectMult;
-}
-
-GangMember.prototype.calculateWantedLevelGain = function() {
- var task = this.task;
- if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) {return 0;}
- var statWeight = (task.hackWeight/100) * this.hack +
- (task.strWeight/100) * this.str +
- (task.defWeight/100) * this.def +
- (task.dexWeight/100) * this.dex +
- (task.agiWeight/100) * this.agi +
- (task.chaWeight/100) * this.cha;
- statWeight -= (3.5 * task.difficulty);
- if (statWeight <= 0) {return 0;}
- var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
- if (territoryMult <= 0) {return 0;}
- if (task.baseWanted < 0) {
- return task.baseWanted * statWeight * territoryMult;
- } else {
- return 6 * task.baseWanted / (3 * statWeight * territoryMult);
- }
-}
-
-GangMember.prototype.calculateMoneyGain = function() {
- var task = this.task;
- if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
- var statWeight = (task.hackWeight/100) * this.hack +
- (task.strWeight/100) * this.str +
- (task.defWeight/100) * this.def +
- (task.dexWeight/100) * this.dex +
- (task.agiWeight/100) * this.agi +
- (task.chaWeight/100) * this.cha;
- statWeight -= (3.5 * task.difficulty);
- if (statWeight <= 0) {return 0;}
- var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
- if (territoryMult <= 0) {return 0;}
- var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
- return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
-}
-
-GangMember.prototype.gainExperience = function(numCycles=1) {
- var task = this.task;
- if (task == null || !(task instanceof GangMemberTask)) {return;}
- this.hack_exp += (task.hackWeight / 1500) * task.difficulty * numCycles;
- this.str_exp += (task.strWeight / 1500) * task.difficulty * numCycles;
- this.def_exp += (task.defWeight / 1500) * task.difficulty * numCycles;
- this.dex_exp += (task.dexWeight / 1500) * task.difficulty * numCycles;
- this.agi_exp += (task.agiWeight / 1500) * task.difficulty * numCycles;
- this.cha_exp += (task.chaWeight / 1500) * task.difficulty * numCycles;
-}
-
-GangMember.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMember", this);
-}
-
-GangMember.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMember, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMember = GangMember;
-
-//Defines tasks that Gang Members can work on
-function GangMemberTask(name="", desc="",
- params={baseRespect: 0, baseWanted: 0, baseMoney: 0,
- hackWeight: 0, strWeight: 0, defWeight: 0,
- dexWeight: 0, agiWeight: 0, chaWeight: 0,
- difficulty: 0}) {
- this.name = name;
- this.desc = desc;
-
- this.baseRespect = params.baseRespect ? params.baseRespect : 0;
- this.baseWanted = params.baseWanted ? params.baseWanted : 0;
- this.baseMoney = params.baseMoney ? params.baseMoney : 0;
-
- //Weights must add up to 100
- this.hackWeight = params.hackWeight ? params.hackWeight : 0;
- this.strWeight = params.strWeight ? params.strWeight : 0;
- this.defWeight = params.defWeight ? params.defWeight : 0;
- this.dexWeight = params.dexWeight ? params.dexWeight : 0;
- this.agiWeight = params.agiWeight ? params.agiWeight : 0;
- this.chaWeight = params.chaWeight ? params.chaWeight : 0;
-
- //1 - 100
- this.difficulty = params.difficulty ? params.difficulty : 1;
-}
-
-GangMemberTask.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberTask", this);
-}
-
-GangMemberTask.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberTask, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberTask = GangMemberTask;
-
-//TODO Human trafficking and an equivalent hacking crime
-let GangMemberTasks = {
- "Unassigned" : new GangMemberTask(
- "Unassigned",
- "This gang member is currently idle"),
- "Ransomware" : new GangMemberTask(
- "Ransomware",
- "Assign this gang member to create and distribute ransomware
" +
- "Earns money - Slightly increases respect - Slightly increases wanted level",
- {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
- hackWeight: 100, difficulty: 1}),
- "Phishing" : new GangMemberTask(
- "Phishing",
- "Assign this gang member to attempt phishing scams and attacks
" +
- "Earns money - Slightly increases respect - Slightly increases wanted level",
- {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 2.5,
- hackWeight: 85, chaWeight: 15, difficulty: 3}),
- "Identity Theft" : new GangMemberTask(
- "Identity Theft",
- "Assign this gang member to attempt identity theft
" +
- "Earns money - Increases respect - Increases wanted level",
- {baseRespect: 0.0001, baseWanted: 0.01, baseMoney: 6,
- hackWeight: 80, chaWeight: 20, difficulty: 4}),
- "DDoS Attacks" : new GangMemberTask(
- "DDoS Attacks",
- "Assign this gang member to carry out DDoS attacks
" +
- "Increases respect - Increases wanted level",
- {baseRespect: 0.0004, baseWanted: 0.05,
- hackWeight: 100, difficulty: 7}),
- "Plant Virus" : new GangMemberTask(
- "Plant Virus",
- "Assign this gang member to create and distribute malicious viruses
" +
- "Increases respect - Increases wanted level",
- {baseRespect: 0.0006, baseWanted: 0.05,
- hackWeight: 100, difficulty: 10}),
- "Fraud & Counterfeiting" : new GangMemberTask(
- "Fraud & Counterfeiting",
- "Assign this gang member to commit financial fraud and digital counterfeiting
" +
- "Earns money - Slightly increases respect - Slightly increases wanted level",
- {baseRespect: 0.0005, baseWanted: 0.1, baseMoney: 15,
- hackWeight: 80, chaWeight: 20, difficulty: 17}),
- "Money Laundering" : new GangMemberTask(
- "Money Laundering",
- "Assign this gang member to launder money
" +
- "Earns money - Increases respect - Increases wanted level",
- {baseRespect: 0.0006, baseWanted:0.2, baseMoney: 40,
- hackWeight: 75, chaWeight: 25, difficulty: 20}),
- "Cyberterrorism" : new GangMemberTask(
- "Cyberterrorism",
- "Assign this gang member to commit acts of cyberterrorism
" +
- "Greatly increases respect - Greatly increases wanted level",
- {baseRespect: 0.001, baseWanted: 0.5,
- hackWeight: 80, chaWeight: 20, difficulty: 33}),
- "Ethical Hacking" : new GangMemberTask(
- "Ethical Hacking",
- "Assign this gang member to be an ethical hacker for corporations
" +
- "Earns money - Lowers wanted level",
- {baseWanted: -0.001, baseMoney: 1,
- hackWeight: 90, chaWeight: 10, difficulty: 1}),
- "Mug People" : new GangMemberTask(
- "Mug People",
- "Assign this gang member to mug random people on the streets
" +
- "Earns money - Slightly increases respect - Very slightly increases wanted level",
- {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
- strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 10, chaWeight: 15, difficulty: 1}),
- "Deal Drugs" : new GangMemberTask(
- "Deal Drugs",
- "Assign this gang member to sell drugs.
" +
- "Earns money - Slightly increases respect - Slightly increases wanted level",
- {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 4,
- agiWeight: 20, dexWeight: 20, chaWeight: 60, difficulty: 3}),
- "Run a Con" : new GangMemberTask(
- "Run a Con",
- "Assign this gang member to run cons
" +
- "Earns money - Increases respect - Increases wanted level",
- {baseRespect: 0.00015, baseWanted: 0.01, baseMoney: 10,
- strWeight: 5, defWeight: 5, agiWeight: 25, dexWeight: 25, chaWeight: 40, difficulty: 10}),
- "Armed Robbery" : new GangMemberTask(
- "Armed Robbery",
- "Assign this gang member to commit armed robbery on stores, banks and armored cars
" +
- "Earns money - Increases respect - Increases wanted level",
- {baseRespect: 0.00015, baseWanted: 0.05, baseMoney: 25,
- hackWeight: 20, strWeight: 15, defWeight: 15, agiWeight: 10, dexWeight: 20, chaWeight: 20,
- difficulty: 17}),
- "Traffick Illegal Arms" : new GangMemberTask(
- "Traffick Illegal Arms",
- "Assign this gang member to traffick illegal arms
" +
- "Earns money - Increases respect - Increases wanted level",
- {baseRespect: 0.0003, baseWanted: 0.1, baseMoney: 40,
- hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, chaWeight: 75,
- difficulty: 25}),
- "Threaten & Blackmail" : new GangMemberTask(
- "Threaten & Blackmail",
- "Assign this gang member to threaten and black mail high-profile targets
" +
- "Earns money - Slightly increases respect - Slightly increases wanted level",
- {baseRespect: 0.0002, baseWanted: 0.05, baseMoney: 15,
- hackWeight: 25, strWeight: 25, dexWeight: 25, chaWeight: 25, difficulty: 28}),
- "Terrorism" : new GangMemberTask(
- "Terrorism",
- "Assign this gang member to commit acts of terrorism
" +
- "Greatly increases respect - Greatly increases wanted level",
- {baseRespect: 0.001, baseWanted: 1,
- hackWeight: 20, strWeight: 20, defWeight: 20,dexWeight: 20, chaWeight: 20,
- difficulty: 33}),
- "Vigilante Justice" : new GangMemberTask(
- "Vigilante Justice",
- "Assign this gang member to be a vigilante and protect the city from criminals
" +
- "Decreases wanted level",
- {baseWanted: -0.001,
- hackWeight: 20, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight:20,
- difficulty: 1}),
- "Train Combat" : new GangMemberTask(
- "Train Combat",
- "Assign this gang member to increase their combat stats (str, def, dex, agi)",
- {strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 25, difficulty: 5}),
- "Train Hacking" : new GangMemberTask(
- "Train Hacking",
- "Assign this gang member to train their hacking skills",
- {hackWeight: 100, difficulty: 8}),
- "Territory Warfare" : new GangMemberTask(
- "Territory Warfare",
- "Assign this gang member to engage in territorial warfare with other gangs. " +
- "Members assigned to this task will help increase your gang's territory " +
- "and will defend your territory from being taken.",
- {hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight: 20,
- chaWeight: 5, difficulty: 3}),
-}
-
-
-function GangMemberUpgrade(name="", desc="", cost=0, type="w") {
- this.name = name;
- this.desc = desc;
- this.cost = cost;
- this.type = type; //w, a, v, r
-}
-
-//Passes in a GangMember object
-GangMemberUpgrade.prototype.apply = function(member) {
- switch(this.name) {
- case "Baseball Bat":
- member.str_mult *= 1.05;
- member.def_mult *= 1.05;
- break;
- case "Katana":
- member.str_mult *= 1.1;
- member.def_mult *= 1.1;
- member.dex_mult *= 1.1;
- break;
- case "Glock 18C":
- member.str_mult *= 1.15;
- member.def_mult *= 1.15;
- member.dex_mult *= 1.15;
- member.agi_mult *= 1.15;
- break;
- case "P90C":
- member.str_mult *= 1.2;
- member.def_mult *= 1.2;
- member.agi_mult *= 1.1;
- break;
- case "Steyr AUG":
- member.str_mult *= 1.25;
- member.def_mult *= 1.25;
- break;
- case "AK-47":
- member.str_mult *= 1.5;
- member.def_mult *= 1.5;
- break;
- case "M15A10 Assault Rifle":
- member.str_mult *= 1.6;
- member.def_mult *= 1.6;
- break;
- case "AWM Sniper Rifle":
- member.str_mult *= 1.5;
- member.dex_mult *= 1.5;
- member.agi_mult *= 1.5;
- break;
- case "Bulletproof Vest":
- member.def_mult *= 1.05;
- break;
- case "Full Body Armor":
- member.def_mult *= 1.1;
- break;
- case "Liquid Body Armor":
- member.def_mult *= 1.25;
- member.agi_mult *= 1.25;
- break;
- case "Graphene Plating Armor":
- member.def_mult *= 1.5;
- break;
- case "Ford Flex V20":
- member.agi_mult *= 1.1;
- member.cha_mult *= 1.1;
- break;
- case "ATX1070 Superbike":
- member.agi_mult *= 1.15;
- member.cha_mult *= 1.15;
- break;
- case "Mercedes-Benz S9001":
- member.agi_mult *= 1.2;
- member.cha_mult *= 1.2;
- break;
- case "White Ferrari":
- member.agi_mult *= 1.25;
- member.cha_mult *= 1.25;
- break;
- case "NUKE Rootkit":
- member.hack_mult *= 1.1;
- break;
- case "Soulstealer Rootkit":
- member.hack_mult *= 1.2;
- break;
- case "Demon Rootkit":
- member.hack_mult *= 1.3;
- break;
- default:
- console.log("ERROR: Could not find this upgrade: " + this.name);
- break;
- }
-}
-
-GangMemberUpgrade.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberUpgrade", this);
-}
-
-GangMemberUpgrade.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberUpgrade, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberUpgrade = GangMemberUpgrade;
-
-let GangMemberUpgrades = {
- "Baseball Bat" : new GangMemberUpgrade("Baseball Bat",
- "Increases strength and defense by 5%", 1e6, "w"),
- "Katana" : new GangMemberUpgrade("Katana",
- "Increases strength, defense, and dexterity by 10%", 12e6, "w"),
- "Glock 18C" : new GangMemberUpgrade("Glock 18C",
- "Increases strength, defense, dexterity, and agility by 15%", 25e6, "w"),
- "P90C" : new GangMemberUpgrade("P90C",
- "Increases strength and defense by 20%. Increases agility by 10%", 50e6, "w"),
- "Steyr AUG" : new GangMemberUpgrade("Steyr AUG",
- "Increases strength and defense by 25%", 60e6, "w"),
- "AK-47" : new GangMemberUpgrade("AK-47",
- "Increases strength and defense by 50%", 100e6, "w"),
- "M15A10 Assault Rifle" : new GangMemberUpgrade("M15A10 Assault Rifle",
- "Increases strength and defense by 60%", 150e6, "w"),
- "AWM Sniper Rifle" : new GangMemberUpgrade("AWM Sniper Rifle",
- "Increases strength, dexterity, and agility by 50%", 225e6, "w"),
- "Bulletproof Vest" : new GangMemberUpgrade("Bulletproof Vest",
- "Increases defense by 5%", 2e6, "a"),
- "Full Body Armor" : new GangMemberUpgrade("Full Body Armor",
- "Increases defense by 10%", 5e6, "a"),
- "Liquid Body Armor" : new GangMemberUpgrade("Liquid Body Armor",
- "Increases defense and agility by 25%", 25e6, "a"),
- "Graphene Plating Armor" : new GangMemberUpgrade("Graphene Plating Armor",
- "Increases defense by 50%", 40e6, "a"),
- "Ford Flex V20" : new GangMemberUpgrade("Ford Flex V20",
- "Increases agility and charisma by 10%", 3e6, "v"),
- "ATX1070 Superbike" : new GangMemberUpgrade("ATX1070 Superbike",
- "Increases agility and charisma by 15%", 9e6, "v"),
- "Mercedes-Benz S9001" : new GangMemberUpgrade("Mercedes-Benz S9001",
- "Increases agility and charisma by 20%", 18e6, "v"),
- "White Ferrari" : new GangMemberUpgrade("White Ferrari",
- "Increases agility and charisma by 25%", 30e6, "v"),
- "NUKE Rootkit" : new GangMemberUpgrade("NUKE Rootkit",
- "Increases hacking by 10%", 5e6, "r"),
- "Soulstealer Rootkit" : new GangMemberUpgrade("Soulstealer Rootkit",
- "Increases hacking by 20%", 15e6, "r"),
- "Demon Rootkit" : new GangMemberUpgrade("Demon Rootkit",
- "Increases hacking by 30%", 50e6, "r"),
-}
-
-//Create a pop-up box that lets player purchase upgrades
-let gangMemberUpgradeBoxOpened = false;
-function createGangMemberUpgradeBox(initialFilter="") {
- var boxId = "gang-member-upgrade-popup-box";
- if (gangMemberUpgradeBoxOpened) {
- //Already opened, refreshing
- if (gangMemberUpgradeBoxElements == null || gangMemberUpgradeBox == null || gangMemberUpgradeBoxContent == null) {
- console.log("ERROR: Refreshing Gang member upgrade box throws error because required elements are null");
- return;
- }
-
- for (var i = 1; i < gangMemberUpgradeBoxElements.length; ++i) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBoxElements[i]);
- }
- gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter];
-
- var filter = gangMemberUpgradeBoxFilter.value.toString();
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name.indexOf(filter) > -1 || _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].task.name.indexOf(filter) > -1) {
- var newPanel = createGangMemberUpgradePanel(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]);
- gangMemberUpgradeBoxContent.appendChild(newPanel);
- gangMemberUpgradeBoxElements.push(newPanel);
- }
- }
- } else {
- //New popup
- gangMemberUpgradeBoxFilter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("input", {
- type:"text", placeholder:"Filter gang members",
- value:initialFilter,
- onkeyup:()=>{
- var filterValue = gangMemberUpgradeBoxFilter.value.toString();
- createGangMemberUpgradeBox(filterValue);
- }
- });
-
- gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter];
-
- var filter = gangMemberUpgradeBoxFilter.value.toString();
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name.indexOf(filter) > -1 || _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].task.name.indexOf(filter) > -1) {
- gangMemberUpgradeBoxElements.push(createGangMemberUpgradePanel(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]));
- }
- }
-
- gangMemberUpgradeBox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createPopup"])(boxId, gangMemberUpgradeBoxElements);
- gangMemberUpgradeBoxContent = document.getElementById(boxId + "-content");
- gangMemberUpgradeBoxOpened = true;
- }
-}
-
-//Create upgrade panels for each individual Gang Member
-function createGangMemberUpgradePanel(memberObj) {
- var container = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- border:"1px solid white",
- });
-
- var header = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("h1", {
- innerText:memberObj.name + " (" + memberObj.task.name + ")"
- });
- container.appendChild(header);
-
- var text = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("pre", {
- fontSize:"14px", display: "inline-block", width:"20%",
- innerText:
- "Hack: " + memberObj.hack + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.hack_mult, 2) + ")\n" +
- "Str: " + memberObj.str + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.str_mult, 2) + ")\n" +
- "Def: " + memberObj.def + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.def_mult, 2) + ")\n" +
- "Dex: " + memberObj.dex + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.dex_mult, 2) + ")\n" +
- "Agi: " + memberObj.agi + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.agi_mult, 2) + ")\n" +
- "Cha: " + memberObj.cha + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.cha_mult, 2) + ")\n",
- });
-
- //Already purchased upgrades
- var ownedUpgradesElements = [];
- for (var i = 0; i < memberObj.upgrades.length; ++i) {
- var upg = GangMemberUpgrades[memberObj.upgrades[i]];
- if (upg == null) {
- console.log("ERR: Could not find this upgrade: " + memberObj.upgrades[i]);
- continue;
- }
- var e = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- border:"1px solid white", innerText:memberObj.upgrades[i],
- margin:"1px", padding:"1px", tooltip:upg.desc, fontSize:"12px",
- });
- ownedUpgradesElements.push(e);
- }
- var ownedUpgrades = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- display:"inline-block", marginLeft:"6px", width:"75%", innerText:"Purchased Upgrades:",
- });
- for (var i = 0; i < ownedUpgradesElements.length; ++i) {
- ownedUpgrades.appendChild(ownedUpgradesElements[i]);
- }
- container.appendChild(text);
- container.appendChild(ownedUpgrades);
- container.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- //Upgrade buttons. Only show upgrades that can be afforded
- var weaponUpgrades = [], armorUpgrades = [], vehicleUpgrades = [], rootkitUpgrades = [];
- for (var upgName in GangMemberUpgrades) {
- if (GangMemberUpgrades.hasOwnProperty(upgName)) {
- var upg = GangMemberUpgrades[upgName];
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].money.lt(upg.cost) || memberObj.upgrades.includes(upgName)) {continue;}
- switch (upg.type) {
- case "w":
- weaponUpgrades.push(upg);
- break;
- case "a":
- armorUpgrades.push(upg);
- break;
- case "v":
- vehicleUpgrades.push(upg);
- break;
- case "r":
- rootkitUpgrades.push(upg);
- break;
- default:
- console.log("ERROR: Invalid Gang Member Upgrade Type: " + upg.type);
- }
- }
- }
-
- var weaponDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
- var armorDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
- var vehicleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
- var rootkitDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
- var upgrades = [weaponUpgrades, armorUpgrades, vehicleUpgrades, rootkitUpgrades];
- var divs = [weaponDiv, armorDiv, vehicleDiv, rootkitDiv];
-
- for (var i = 0; i < upgrades.length; ++i) {
- var upgradeArray = upgrades[i];
- var div = divs[i];
- for (var j = 0; j < upgradeArray.length; ++j) {
- var upg = upgradeArray[j];
- (function (upg, div, memberObj) {
- div.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- innerText:upg.name + " - " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(upg.cost).format("$0.000a"),
- class:"a-link-button", margin:"2px", padding:"2px", display:"block",
- fontSize:"12px",
- tooltip:upg.desc,
- clickListener:()=>{
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].money.lt(upg.cost)) {return false;}
- _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].loseMoney(upg.cost);
- memberObj.upgrades.push(upg.name);
- upg.apply(memberObj);
- var initFilterValue = gangMemberUpgradeBoxFilter.value.toString();
- createGangMemberUpgradeBox(initFilterValue);
- return false;
- }
- }));
- })(upg, div, memberObj);
- }
- }
-
- container.appendChild(weaponDiv);
- container.appendChild(armorDiv);
- container.appendChild(vehicleDiv);
- container.appendChild(rootkitDiv);
- return container;
-}
-
-//Gang DOM elements
-let gangContentCreated = false,
- gangContainer = null, managementButton = null, territoryButton = null;
-
-//Subpages
-let gangManagementSubpage = null, gangTerritorySubpage = null;
-
-//Gang Management Elements
-let gangDesc = null, gangInfo = null,
- gangRecruitMemberButton = null, gangRecruitRequirementText = null,
- gangExpandAllButton = null, gangCollapseAllButton, gangMemberFilter = null,
- gangManageEquipmentButton = null,
- gangMemberList = null;
-
-//Gang Equipment Upgrade Elements
-let gangMemberUpgradeBox = null, gangMemberUpgradeBoxContent = null,
- gangMemberUpgradeBoxFilter = null, gangMemberUpgradeBoxElements = null;
-
-
-//Gang Territory Elements
-let gangTerritoryDescText = null, gangTerritoryInfoText = null;
-
-function displayGangContent() {
- if (!gangContentCreated || gangContainer == null) {
- gangContentCreated = true;
-
- //Create gang container
- gangContainer = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- id:"gang-container", class:"generic-menupage-container",
- });
-
- //Get variables
- var facName = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName,
- members = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members,
- wanted = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted,
- respect = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect;
-
- //Back button
- gangContainer.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- class:"a-link-button", display:"inline-block", innerText:"Back",
- clickListener:()=>{
- _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(facName);
- return false;
- }
- }));
-
- //Buttons to switch between panels
- managementButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- id:"gang-management-subpage-button", class:"a-link-button-inactive",
- display:"inline-block", innerHTML: "Gang Management (1)",
- clickListener:()=>{
- gangManagementSubpage.style.display = "block";
- gangTerritorySubpage.style.display = "none";
- managementButton.classList.toggle("a-link-button-inactive");
- managementButton.classList.toggle("a-link-button");
- territoryButton.classList.toggle("a-link-button-inactive");
- territoryButton.classList.toggle("a-link-button");
- updateGangContent();
- return false;
- }
- })
- territoryButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- id:"gang-territory-subpage-button", class:"a-link-button",
- display:"inline-block", innerHTML:"Gang Territory (2)",
- clickListener:()=>{
- gangManagementSubpage.style.display = "none";
- gangTerritorySubpage.style.display = "block";
- managementButton.classList.toggle("a-link-button-inactive");
- managementButton.classList.toggle("a-link-button");
- territoryButton.classList.toggle("a-link-button-inactive");
- territoryButton.classList.toggle("a-link-button");
- updateGangContent();
- return false;
- }
- });
- gangContainer.appendChild(managementButton);
- gangContainer.appendChild(territoryButton);
-
- //Subpage for managing gang members
- gangManagementSubpage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- display:"block", id:"gang-management-subpage",
- });
-
- var lowerWantedTask = "";
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.isHackingGang) {
- lowerWantedTask = "Ethical Hacking";
- } else {
- lowerWantedTask = "Vigilante Justice";
- }
- gangDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {width:"70%",
- innerHTML:
- "This page is used to manage your gang members and get an overview of your " +
- "gang's stats.
" +
- "If a gang member is not earning much money or respect, the task that you " +
- "have assigned to that member might be too difficult. Consider training that " +
- "member's stats or choosing an easier task. The tasks closer to the " +
- "top of the dropdown list are generally easier. Alternatively, the gang member's " +
- "low production might be due to the fact that your wanted level is too high. " +
- "Consider assigning a few members to the '" + lowerWantedTask + "' " +
- "task to lower your wanted level.
" +
- "Installing Augmentations does NOT reset your progress with your Gang. " +
- "Furthermore, after installing Augmentations, you will " +
- "automatically be a member of whatever Faction you created your gang with.
"
- });
- gangManagementSubpage.appendChild(gangDesc);
-
- gangInfo = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-info", width:"70%"});
- gangManagementSubpage.appendChild(gangInfo);
-
- gangRecruitMemberButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- id:"gang-management-recruit-member-btn", class:"a-link-button-inactive",
- innerHTML:"Recruit Gang Member", display:"inline-block", margin:"10px",
- clickListener:()=>{
- var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetNoButton"])();
- yesBtn.innerHTML = "Recruit Gang Member";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", ()=>{
- var name = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetInput"])();
- if (name === "") {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You must enter a name for your Gang member!");
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ switch (exp.type) {
+ case "BlockStatement":
+ case "Program":
+ var evaluateProgPromise = evaluateProg(exp, workerScript, 0); //TODO: make every block/program use individual enviroment
+ return evaluateProgPromise.then(function(w) {
+ return Promise.resolve(workerScript);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ return Promise.reject(e);
+ } else if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ workerScript.errorMessage = e;
+ return Promise.reject(workerScript);
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ return Promise.reject(e);
} else {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
- if (name == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You already have a gang member with this name!");
- return false;
+ return Promise.reject(workerScript);
+ }
+ });
+ break;
+ case "Literal":
+ return Promise.resolve(exp.value);
+ break;
+ case "Identifier":
+ //Javascript constructor() method can be used as an exploit to run arbitrary code
+ if (exp.name == "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
+
+ if (!(exp.name in env.vars)){
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.name + " not defined", exp));
+ }
+ return Promise.resolve(env.get(exp.name))
+ break;
+ case "ExpressionStatement":
+ return evaluate(exp.expression, workerScript);
+ break;
+ case "ArrayExpression":
+ var argPromises = exp.elements.map(function(arg) {
+ return evaluate(arg, workerScript);
+ });
+ return Promise.all(argPromises).then(function(array) {
+ return Promise.resolve(array)
+ });
+ break;
+ case "CallExpression":
+ return evaluate(exp.callee, workerScript).then(function(func) {
+ return Promise.map(exp.arguments, function(arg) {
+ return evaluate(arg, workerScript);
+ }).then(function(args) {
+ if (func instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) { //Player-defined function
+ //Create new Environment for the function
+ //Should be automatically garbage collected...
+ var funcEnv = env.extend();
+
+ //Define function arguments in this new environment
+ for (var i = 0; i < func.params.length; ++i) {
+ var arg;
+ if (i >= args.length) {
+ arg = null;
+ } else {
+ arg = args[i];
+ }
+ funcEnv.def(func.params[i].name, arg);
+ }
+
+ //Create a new WorkerScript for this function evaluation
+ var funcWorkerScript = new _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"](workerScript.scriptRef);
+ funcWorkerScript.serverIp = workerScript.serverIp;
+ funcWorkerScript.env = funcEnv;
+ workerScript.fnWorker = funcWorkerScript;
+
+ return evaluate(func.body, funcWorkerScript).then(function(res) {
+ //If the function finished successfuly, that means there
+ //was no return statement since a return statement rejects. So resolve to null
+ workerScript.fnWorker = null;
+ return Promise.resolve(null);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ //Return statement from function
+ return Promise.resolve(e[1]);
+ workerScript.fnWorker = null;
+ } else if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e));
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ //Parse out the err message from the WorkerScript and re-reject
+ var errorMsg = e.errorMessage;
+ var errorTextArray = errorMsg.split("|");
+ if (errorTextArray.length === 4) {
+ errorMsg = errorTextArray[3];
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, errorMsg));
+ } else {
+ if (env.stopFlag) {
+ return Promise.reject(workerScript);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error in one of your functions. Could not identify which function"));
+ }
+ }
+ } else if (e instanceof Error) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e.toString()));
+ }
+ });
+ } else if (exp.callee.type === "MemberExpression"){
+ return evaluate(exp.callee.object, workerScript).then(function(object) {
+ try {
+ if (func === "NETSCRIPTFOREACH") {
+ return evaluateForeach(object, args, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ }
+ var res = func.apply(object,args);
+ return Promise.resolve(res);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
+ });
+ } else {
+ try {
+ var out = func.apply(null,args);
+ if (out instanceof Promise){
+ return out.then(function(res) {
+ return Promise.resolve(res)
+ }).catch(function(e) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.resolve(out);
+ }
+ } catch (e) {
+ if (isScriptErrorMessage(e)) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
}
}
- var member = new GangMember(name);
- _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.push(member);
- createGangMemberDisplayElement(member);
- updateGangContent();
- }
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
+ });
});
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
- });
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxCreate"])("Please enter a name for your new Gang member:");
- return false;
- }
- });
- gangManagementSubpage.appendChild(gangRecruitMemberButton);
-
- //Text for how much reputation is required for recruiting next memberList
- gangRecruitRequirementText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {color:"red", id:"gang-recruit-requirement-text"});
- gangManagementSubpage.appendChild(gangRecruitRequirementText);
-
- //Gang Member List management buttons (Expand/Collapse All, select a single member)
- gangManagementSubpage.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
- gangExpandAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- class:"a-link-button", display:"inline-block",
- innerHTML:"Expand All",
- clickListener:()=>{
- var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
- for (var i = 0; i < allHeaders.length; ++i) {
- var hdr = allHeaders[i];
- if (!hdr.classList.contains("active")) {
- hdr.click();
- }
- }
- return false;
- }
- });
- gangCollapseAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- class:"a-link-button", display:"inline-block",
- innerHTML:"Collapse All",
- clickListener:()=>{
- var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
- for (var i = 0; i < allHeaders.length; ++i) {
- var hdr = allHeaders[i];
- if (hdr.classList.contains("active")) {
- hdr.click();
- }
- }
- return false;
- }
- });
- gangMemberFilter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("input", {
- type:"text", placeholder:"Filter gang members", margin:"5px", padding:"5px",
- onkeyup:()=>{
- displayGangMemberList();
- }
- });
- gangManageEquipmentButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- class:"a-link-button", display:"inline-block",
- innerHTML:"Manage Equipment",
- clickListener:()=>{
- createGangMemberUpgradeBox();
- }
- });
- gangManagementSubpage.appendChild(gangExpandAllButton);
- gangManagementSubpage.appendChild(gangCollapseAllButton);
- gangManagementSubpage.appendChild(gangMemberFilter);
- gangManagementSubpage.appendChild(gangManageEquipmentButton);
-
- //Gang Member list
- gangMemberList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("ul", {id:"gang-member-list"});
- displayGangMemberList();
- gangManagementSubpage.appendChild(gangMemberList);
-
- //Subpage for seeing gang territory information
- gangTerritorySubpage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- id:"gang-territory-subpage", display:"none"
- });
-
- //Info text for territory page
- gangTerritoryDescText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
- width:"70%",
- innerHTML:"This page shows how much territory your Gang controls. This statistic is listed as a percentage, " +
- "which represents how much of the total territory you control.
" +
- "Territory gain and loss is processed automatically and is updated every ~30 seconds. Your chances " +
- "to gain and lose territory depend on your Gang's power, which is listed in the display below. " +
- "Your gang's power is determined by the stats of all Gang members you have assigned to the " +
- "'Territory Warfare' task. Gang members that are not assigned to this task do not contribute to " +
- "your Gang's power.
" +
- "The amount of territory you have affects all aspects of your Gang members' production, including " +
- "money, respect, and wanted level. It is very beneficial to have high territory control.
"
- });
- gangTerritorySubpage.appendChild(gangTerritoryDescText);
-
- var territoryBorder = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("fieldset", {width:"50%", display:"inline-block"});
-
- gangTerritoryInfoText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-territory-info"});
-
- territoryBorder.appendChild(gangTerritoryInfoText);
- gangTerritorySubpage.appendChild(territoryBorder);
-
- gangContainer.appendChild(gangTerritorySubpage);
- gangContainer.appendChild(gangManagementSubpage);
- document.getElementById("entire-game-container").appendChild(gangContainer);
- }
- gangContainer.style.display = "block";
- updateGangContent();
-}
-
-function displayGangMemberList() {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeChildrenFromElement"])(gangMemberList);
- var members = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members;
- var filter = gangMemberFilter.value.toString();
- for (var i = 0; i < members.length; ++i) {
- if (members[i].name.indexOf(filter) > -1 || members[i].task.name.indexOf(filter) > -1) {
- createGangMemberDisplayElement(members[i]);
- }
- }
- //setGangMemberClickHandlers(); //Set buttons to toggle the gang member info panels
-}
-
-function updateGangContent() {
- if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
-
- if(gangTerritorySubpage.style.display === "block") {
- //Update territory information
- gangTerritoryInfoText.innerHTML = "";
- for (var gangname in AllGangs) {
- if (AllGangs.hasOwnProperty(gangname)) {
- var gangTerritoryInfo = AllGangs[gangname];
- let territory = gangTerritoryInfo.territory*100;
-
- //Fix some rounding issues graphically
- let displayNumber;
- if (territory <= 0) {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2);
- } else if (territory >= 100) {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2);
- } else {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territory, 2);
- }
-
- if (gangname == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName) {
- gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " +
- displayNumber + "%
");
- } else {
- gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " +
- displayNumber + "%
");
- }
- }
- }
- } else {
- //Update information for overall gang
- if (gangInfo instanceof Element) {
- var faction = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName];
- var rep;
- if (!(faction instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
- rep = "ERROR";
- } else {
- rep = faction.playerReputation;
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeChildrenFromElement"])(gangInfo);
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Respect
- display:"inline-block",
- innerText:"Respect: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect, 6) +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respectGainRate, 6) + " / sec)",
- tooltip:"Represents the amount of respect your gang has from other gangs and criminal " +
- "organizations. Your respect affects the amount of money " +
- "your gang members will earn, and also determines how much " +
- "reputation you are earning with your gang's corresponding Faction."
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Wanted level
- display:"inline-block",
- innerText:"Wanted Level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted, 6) +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wantedGainRate, 6) + " / sec)",
- tooltip:"Represents how much the gang is wanted by law enforcement. The higher " +
- "your gang's wanted level, the harder it will be for your gang members " +
- "to make money and earn respect. Note that the minimum wanted level is 1."
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- var wantedPenalty = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
- wantedPenalty = (1 - wantedPenalty) * 100;
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Wanted Level multiplier
- display:"inline-block",
- innerText:"Wanted Level Penalty: -" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(wantedPenalty, 2) + "%",
- tooltip:"Penalty for respect and money gain rates due to Wanted Level"
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Money gain rate
- display:"inline-block",
- innerText:"Money gain rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.moneyGainRate, 2) +
- " / sec",
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- //Fix some rounding issues graphically
- var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory * 100;
- let displayNumber;
- if (territoryMult <= 0) {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2);
- } else if (territoryMult >= 100) {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2);
- } else {
- displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult, 2);
- }
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Territory multiplier
- display:"inline-block",
- innerText:"Territory: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(displayNumber, 3) + "%",
- tooltip:"The percentage of total territory your Gang controls"
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
-
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Faction reputation
- display:"inline-block",
- innerText:"Faction reputation: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(rep, 3)
- }));
- gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
- } else {
- console.log("ERROR: gang-info DOM element DNE");
- }
-
- //Toggle the 'Recruit member button' if valid
- var numMembers = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length;
- var repCost = 0;
- if (numMembers > 0) {
- var repCost = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangRecruitCostMultiplier, numMembers);
- }
- var faction = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName];
- if (faction == null) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Could not find your gang's faction. This is probably a bug please report to dev");
- return;
- }
- var btn = gangRecruitMemberButton;
- if (numMembers >= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaximumGangMembers) {
- btn.className = "a-link-button-inactive";
- gangRecruitRequirementText.style.display = "block";
- gangRecruitRequirementText.innerHTML =
- "You have reached the maximum amount of gang members";
- } else if (faction.playerReputation >= repCost) {
- btn.className = "a-link-button";
- gangRecruitRequirementText.style.display = "none";
- } else {
- btn.className = "a-link-button-inactive";
- gangRecruitRequirementText.style.display = "block";
- gangRecruitRequirementText.innerHTML =
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(repCost, 2) + " Faction reputation needed to recruit next member";
- }
-
- //Update information for each gang member
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
- updateGangMemberDisplayElement(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]);
- }
- }
-}
-
-//Takes in a GangMember object
-function createGangMemberDisplayElement(memberObj) {
- if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
- var name = memberObj.name;
-
- var accordion = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createAccordionElement"])({
- id:name + "gang-member",
- hdrText:name,
- });
- var li = accordion[0];
- var hdr = accordion[1];
- var gangMemberDiv = accordion[2];
-
- //Gang member content divided into 3 panels:
- //Stats Panel
- var statsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- id: name + "gang-member-stats", class: "gang-member-info-div",
- width:"30%", display:"inline"
- });
- var statsP = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
- id:name + "gang-member-stats-text", display:"inline"
- });
-
- statsDiv.appendChild(statsP);
- //statsDiv.appendChild(upgradeButton);
-
- //Panel for Selecting task and show respect/wanted gain
- var taskDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- id: name + "gang-member-task", class:"gang-member-info-div",
- width:"30%", display:"inline"
- });
- var taskSelector = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("select", {
- color:"white", backgroundColor:"black",
- id:name + "gang-member-task-selector"
- });
-
- var tasks = null;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.isHackingGang) {
- tasks = ["---", "Ransomware", "Phishing", "Identity Theft", "DDoS Attacks",
- "Plant Virus", "Fraud & Counterfeiting","Money Laundering",
- "Cyberterrorism", "Ethical Hacking", "Train Combat",
- "Train Hacking", "Territory Warfare"];
- } else {
- tasks = ["---", "Mug People", "Deal Drugs", "Run a Con", "Armed Robbery",
- "Traffick Illegal Arms", "Threaten & Blackmail",
- "Terrorism", "Vigilante Justice", "Train Combat",
- "Train Hacking", "Territory Warfare"];
- }
- for (var i = 0; i < tasks.length; ++i) {
- var option = document.createElement("option");
- option.text = tasks[i];
- taskSelector.add(option);
- }
- taskSelector.addEventListener("change", function() {
- var task = taskSelector.options[taskSelector.selectedIndex].text;
- memberObj.assignToTask(task);
- setGangMemberTaskDescription(memberObj, task);
- updateGangContent();
- });
- //Set initial task in selector element
- if (memberObj.task instanceof GangMemberTask) {
- var taskName = memberObj.task.name;
- var taskIndex = 0;
- for (let i = 0; i < tasks.length; ++i) {
- if (taskName == tasks[i]) {
- taskIndex = i;
break;
+ case "MemberExpression":
+ return evaluate(exp.object, workerScript).then(function(object) {
+ if (exp.computed){
+ return evaluate(exp.property, workerScript).then(function(index) {
+ if (index >= object.length) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays", exp));
+ }
+ return Promise.resolve(object[index]);
+ }).catch(function(e) {
+ if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] || isScriptErrorMessage(e)) {
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression", exp));
+ }
+ });
+ } else {
+ if (exp.property.name === "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
+ if (object != null && object instanceof Array && exp.property.name === "forEach") {
+ return "NETSCRIPTFOREACH";
+ }
+ try {
+ return Promise.resolve(object[exp.property.name])
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to get property: " + e.toString(), exp));
+ }
+ }
+ });
+ break;
+ case "LogicalExpression":
+ case "BinaryExpression":
+ return evalBinary(exp, workerScript);
+ break;
+ case "UnaryExpression":
+ return evalUnary(exp, workerScript);
+ break;
+ case "AssignmentExpression":
+ return evalAssignment(exp, workerScript);
+ break;
+ case "VariableDeclaration":
+ return evalVariableDeclaration(exp, workerScript);
+ break;
+ case "UpdateExpression":
+ if (exp.argument.type==="Identifier"){
+ if (exp.argument.name in env.vars){
+ if (exp.operator === "++" || exp.operator === "--") {
+ switch (exp.operator) {
+ case "++":
+ env.set(exp.argument.name,env.get(exp.argument.name)+1);
+ break;
+ case "--":
+ env.set(exp.argument.name,env.get(exp.argument.name)-1);
+ break;
+ default: break;
+ }
+ return Promise.resolve(env.get(exp.argument.name));
+ }
+ //Not sure what prefix UpdateExpressions there would be besides ++/--
+ if (exp.prefix){
+ return Promise.resolve(env.get(exp.argument.name))
+ }
+ switch (exp.operator){
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". You are trying to use code that is currently unsupported", exp));
+ }
+ return Promise.resolve(env.get(exp.argument.name))
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.argument.name + " not defined", exp));
+ }
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier", exp));
+ }
+ break;
+ case "EmptyStatement":
+ return Promise.resolve(false);
+ break;
+ case "ReturnStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(["RETURNSTATEMENT", res]);
+ });
+ break;
+ case "BreakStatement":
+ return Promise.reject("BREAKSTATEMENT");
+ break;
+ case "ContinueStatement":
+ return Promise.reject("CONTINUESTATEMENT");
+ break;
+ case "IfStatement":
+ return evaluateIf(exp, workerScript);
+ break;
+ case "SwitchStatement":
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Switch statements are not yet implemented in Netscript", exp));
+ break;
+ case "WhileStatement":
+ return evaluateWhile(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("whileLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "ForStatement":
+ return evaluate(exp.init, workerScript).then(function(expInit) {
+ return evaluateFor(exp, workerScript);
+ }).then(function(forLoopRes) {
+ return Promise.resolve("forLoopDone");
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("forLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "FunctionDeclaration":
+ if (exp.id && exp.id.name) {
+ env.set(exp.id.name, exp);
+ return Promise.resolve(true);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration", exp));
+ }
+ break;
+ case "ImportDeclaration":
+ return evaluateImport(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ break;
+ case "ThrowStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, res));
+ });
+ break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". This is currently unsupported in Netscript", exp));
+ break;
+ } //End switch
+ }).catch(function(e) {
+ return Promise.reject(e);
+ }); // End Promise
+}
+
+function evalBinary(exp, workerScript){
+ return evaluate(exp.left, workerScript).then(function(expLeft) {
+ //Short circuiting
+ if (expLeft && exp.operator === "||") {
+ return Promise.resolve(expLeft);
+ }
+ if (!expLeft && exp.operator === "&&") {
+ return Promise.resolve(expLeft);
+ }
+ return evaluate(exp.right, workerScript).then(function(expRight) {
+ switch (exp.operator){
+ case "===":
+ case "==":
+ return Promise.resolve(expLeft===expRight);
+ break;
+ case "!==":
+ case "!=":
+ return Promise.resolve(expLeft!==expRight);
+ break;
+ case "<":
+ return Promise.resolve(expLeft
" +
- "Strength: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.str, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.str_exp).format('(0.00a)') + " exp)
" +
- "Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.def, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.def_exp).format('(0.00a)') + " exp)
" +
- "Dexterity: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.dex, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.dex_exp).format('(0.00a)') + " exp)
" +
- "Agility: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.agi, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.agi_exp).format('(0.00a)') + " exp)
" +
- "Charisma: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.cha, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.cha_exp).format('(0.00a)') + " exp)
";
+ if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left)));
}
- var gainInfo = document.getElementById(name + "gang-member-gain-info");
- if (gainInfo) {
- gainInfo.innerHTML =
- "Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateMoneyGain(), 2) + " / sec
" +
- "Respect: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateRespectGain(), 6) + " / sec
" +
- "Wanted Level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateWantedLevelGain(), 6) + " / sec
";
+ if (exp.operator !== "=" && !(exp.left.name in env.vars)){
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.left.name + " not defined"));
+ }
+
+ return evaluate(exp.right, workerScript).then(function(expRight) {
+ if (exp.left.type == "MemberExpression") {
+ if (!exp.left.computed) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to an object's property. This is currently unsupported in Netscript", exp));
+ }
+ //Assign to array element
+ //Array object designed by exp.left.object.name
+ //Index designated by exp.left.property
+ return getArrayElement(exp.left, workerScript).then(function(res) {
+ if (!(res instanceof Array) || res.length < 2) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error evaluating array assignment. This is (probably) a bug please report to game dev"));
+ }
+
+ //The array name is the second value
+ var arrName = res.splice(1, 1);
+ arrName = arrName[0];
+
+ var res;
+ try {
+ res = env.setArrayElement(arrName, res, expRight);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e));
+ }
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ //Other assignments
+ try {
+ var assign;
+ switch (exp.operator) {
+ case "=":
+ assign = expRight; break;
+ case "+=":
+ assign = env.get(exp.left.name) + expRight; break;
+ case "-=":
+ assign = env.get(exp.left.name) - expRight; break;
+ case "*=":
+ assign = env.get(exp.left.name) * expRight; break;
+ case "/=":
+ assign = env.get(exp.left.name) / expRight; break;
+ case "%=":
+ assign = env.get(exp.left.name) % expRight; break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Bitwise assignment is not implemented"));
+ }
+ env.set(exp.left.name, assign);
+ return Promise.resolve(assign);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to set environment variable: " + e.toString()));
+ }
+ }
+ });
+}
+
+function evalVariableDeclaration(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+
+ if (!(exp.declarations instanceof Array)) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Variable declarations parsed incorrectly. This may be a syntax error"));
+ }
+
+ if (exp.kind !== "var") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Only 'var' declarations are currently allowed (let, const, etc. are not allowed)"));
+ }
+
+ return Promise.all(exp.declarations.map((decl)=>{
+ evalVariableDeclarator(decl, workerScript);
+ })).then(function(res) {
+ return Promise.resolve(res);
+ });
+}
+
+//A Variable Declaration contains an array of Variable Declarators
+function evalVariableDeclarator(exp, workerScript) {
+ var env = workerScript.env;
+ if (exp.type !== "VariableDeclarator") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid AST Node passed into evalVariableDeclarator: " + exp.type));
+ }
+ if (exp.init == null) {
+ env.set(exp.id.name, null);
+ return Promise.resolve(null);
+ } else {
+ return evaluate(exp.init, workerScript).then(function(initValue) {
+ env.set(exp.id.name, initValue);
+ });
}
}
-function setGangMemberTaskDescription(memberObj, taskName) {
- var name = memberObj.name;
- var taskDesc = document.getElementById(name + "gang-member-task-description");
- if (taskDesc) {
- var task = GangMemberTasks[taskName];
- if (task == null) {return;}
- var desc = task.desc;
- taskDesc.innerHTML = desc;
+function evaluateIf(exp, workerScript, i) {
+ var env = workerScript.env;
+ return evaluate(exp.test, workerScript).then(function(condRes) {
+ if (condRes) {
+ return evaluate(exp.consequent, workerScript).then(function(res) {
+ return Promise.resolve(true);
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else if (exp.alternate) {
+ return evaluate(exp.alternate, workerScript).then(function(res) {
+ return Promise.resolve(true);
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.resolve("endIf");
+ }
+ });
+}
+
+//Evaluate the looping part of a for loop (Initialization block is NOT done in here)
+function evaluateFor(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ return new Promise(function(resolve, reject) {
+ function recurse() {
+ //Don't return a promise so the promise chain is broken on each recursion (saving memory)
+ evaluate(exp.test, workerScript).then(function(resCond) {
+ if (resCond) {
+ return evaluate(exp.body, workerScript).then(function(res) {
+ return evaluate(exp.update, workerScript);
+ }).catch(function(e) {
+ if (e == "CONTINUESTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "CONTINUESTATEMENT")) {
+ //Continue statement, recurse to next iteration
+ return evaluate(exp.update, workerScript).then(function(resPostloop) {
+ return evaluateFor(exp, workerScript);
+ }).then(function(foo) {
+ return Promise.resolve("endForLoop");
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.reject(e);
+ }
+ }).then(recurse, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ resolve();
+ }
+ }).catch(function(e) {
+ reject(e);
+ });
+ }
+ recurse();
+ });
+}
+
+function evaluateForeach(arr, args, workerScript) {
+ console.log("evaluateForeach called");
+ if (!(arr instanceof Array)) {
+ return Promise.reject("Invalid array passed into forEach");
+ }
+ if (!(args instanceof Array) && args.length != 1) {
+ return Promise.reject("Invalid argument passed into forEach");
+ }
+ var func = args[0];
+ if (typeof func !== "function") {
+ return Promise.reject("Invalid function passed into forEach");
+ }
+ console.log(func);
+ return new Promise(function(resolve, reject) {
+ //Don't return a promise so the promise chain is broken on each recursion
+ function recurse(i) {
+ console.log("recurse() called with i: " + i);
+ if (i >= arr.length) {
+ resolve();
+ } else {
+ return Promise.delay(_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].CodeInstructionRunTime).then(function() {
+ console.log("About to apply function");
+ var res = func.apply(null, [arr[i]]);
+ console.log("Applied function");
+ ++i;
+ Promise.resolve(res).then(function(val) {
+ recurse(i);
+ }, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ });
+ }
+ }
+ recurse(0);
+ });
+}
+
+function evaluateWhile(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ return new Promise(function (resolve, reject) {
+ function recurse() {
+ //Don't return a promise so the promise chain is broken on each recursion (saving memory)
+ evaluate(exp.test, workerScript).then(function(resCond) {
+ if (resCond) {
+ return evaluate(exp.body, workerScript).catch(function(e) {
+ if (e == "CONTINUESTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "CONTINUESTATEMENT")) {
+ //Continue statement, recurse
+ return evaluateWhile(exp, workerScript).then(function(foo) {
+ return Promise.resolve("endWhileLoop");
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.reject(e);
+ }
+ }).then(recurse, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ resolve();
+ }
+ }).catch(function(e) {
+ reject(e);
+ });
+ }
+ recurse();
+ });
+}
+
+function evaluateProg(exp, workerScript, index) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ if (index >= exp.body.length) {
+ return Promise.resolve("progFinished");
+ } else {
+ //Evaluate this line of code in the prog
+ //After the code finishes evaluating, evaluate the next line recursively
+ return evaluate(exp.body[index], workerScript).then(function(res) {
+ return evaluateProg(exp, workerScript, index + 1);
+ }).then(function(res) {
+ return Promise.resolve(workerScript);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
}
}
-function deleteGangDisplayContent() {
- if (gangContainer != null) {Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElementById"])(gangContainer.id);}
+function evaluateImport(exp, workerScript, checkingRam=false) {
+ //When its checking RAM, it exports an array of nodes for each imported function
+ var ramCheckRes = [];
- gangContentCreated = false;
- gangContainer = null;
- managementButton = null;
- territoryButton = null;
+ var env = workerScript.env;
+ if (env.stopFlag) {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(workerScript);
+ }
- //Subpages
- gangManagementSubpage = null;
- gangTerritorySubpage = null;
+ //Get source script and name of all functions to import
+ var scriptName = exp.source.value;
+ var namespace, namespaceObj, allFns = false, fnNames = [];
+ if (exp.specifiers.length === 1 && exp.specifiers[0].type === "ImportNamespaceSpecifier") {
+ allFns = true;
+ namespace = exp.specifiers[0].local.name;
+ } else {
+ for (var i = 0; i < exp.specifiers.length; ++i) {
+ fnNames.push(exp.specifiers[i].local.name);
+ }
+ }
- //Gang Management Elements
- gangDesc = null;
- gangInfo = null;
- gangRecruitMemberButton = null;
- gangRecruitRequirementText = null;
- gangExpandAllButton = null;
- gangCollapseAllButton = null;
- gangMemberFilter = null;
- gangManageEquipmentButton = null;
- gangMemberList = null;
+ //Get the code
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_5__["getServer"])(workerScript.serverIp), code = "";
+ if (server == null) {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to identify server. This is a bug please report to dev", exp));
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename === scriptName) {
+ code = server.scripts[i].code;
+ break;
+ }
+ }
+ if (code === "") {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Could not find script " + scriptName + " to import", exp));
+ }
- //Gang Equipment Upgrade Elements
- gangMemberUpgradeBox = null;
- gangMemberUpgradeBoxContent = null;
- gangMemberUpgradeBoxFilter = null;
- gangMemberUpgradeBoxElements = null;
+ //Create the AST
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["parse"])(code, {sourceType:"module"});
+ } catch(e) {
+ console.log("Failed to parse import script");
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to import functions from " + scriptName +
+ " This is most likely due to a syntax error in the imported script", exp));
+ }
+
+ if (allFns) {
+ //A namespace is implemented as a JS obj
+ env.set(namespace, {});
+ namespaceObj = env.get(namespace);
+ }
+
+ //Search through the AST for all imported functions
+ var queue = [ast];
+ while (queue.length != 0) {
+ var node = queue.shift();
+ switch (node.type) {
+ case "BlockStatement":
+ case "Program":
+ for (var i = 0; i < node.body.length; ++i) {
+ if (node.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) {
+ queue.push(node.body[i]);
+ }
+ }
+ break;
+ case "FunctionDeclaration":
+ if (node.id && node.id.name) {
+ if (allFns) {
+ //Import all functions under this namespace
+ if (checkingRam) {
+ ramCheckRes.push(node);
+ } else {
+ namespaceObj[node.id.name] = node;
+ }
+ } else {
+ //Only import specified functions
+ if (fnNames.includes(node.id.name)) {
+ if (checkingRam) {
+ ramCheckRes.push(node);
+ } else {
+ env.set(node.id.name, node);
+ }
+
+ }
+ }
+ } else {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration in imported script " + scriptName, exp));
+ }
+ break;
+ default:
+ break;
+ }
+
+ for (var prop in node) {
+ if (node.hasOwnProperty(prop)) {
+ if (node[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) {
+ queue.push(node[prop]);
+ }
+ }
+ }
+ }
+ if (!checkingRam) {workerScript.scriptRef.log("Imported functions from " + scriptName);}
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.resolve(true);
+}
+
+function killNetscriptDelay(workerScript) {
+ if (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ if (workerScript.delay) {
+ clearTimeout(workerScript.delay);
+ workerScript.delayResolve();
+ }
+ }
+}
+
+function netscriptDelay(time, workerScript) {
+ return new Promise(function(resolve, reject) {
+ workerScript.delay = setTimeout(()=>{
+ workerScript.delay = null;
+ resolve();
+ }, time);
+ workerScript.delayResolve = resolve;
+ });
+}
+
+function makeRuntimeRejectMsg(workerScript, msg, exp=null) {
+ var lineNum = "";
+ if (exp != null) {
+ var num = getErrorLineNumber(exp, workerScript);
+ lineNum = " (Line " + num + ")"
+ }
+ return "|"+workerScript.serverIp+"|"+workerScript.name+"|" + msg + lineNum;
+}
+
+//Run a script from inside a script using run() command
+function runScriptFromScript(server, scriptname, args, workerScript, threads=1) {
+ //Check if the script is already running
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_7__["findRunningScript"])(scriptname, args, server);
+ if (runningScriptObj != null) {
+ workerScript.scriptRef.log(scriptname + " is already running on " + server.hostname);
+ return Promise.resolve(false);
+ }
+
+ //'null/undefined' arguments are not allowed
+ for (var i = 0; i < args.length; ++i) {
+ if (args[i] == null) {
+ workerScript.scriptRef.log("ERROR: Cannot execute a script with null/undefined as an argument");
+ return Promise.resolve(false);
+ }
+ }
+
+ //Check if the script exists and if it does run it
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename == scriptname) {
+ //Check for admin rights and that there is enough RAM availble to run
+ var script = server.scripts[i];
+ var ramUsage = script.ramUsage;
+ threads = Math.round(Number(threads)); //Convert to number and round
+ ramUsage = ramUsage * threads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot run script " + scriptname + " on " + server.hostname + " because you do not have root access!");
+ return Promise.resolve(false);
+ } else if (ramUsage > ramAvailable){
+ workerScript.scriptRef.log("Cannot run script " + scriptname + "(t=" + threads + ") on " + server.hostname + " because there is not enough available RAM!");
+ return Promise.resolve(false);
+ } else {
+ //Able to run script
+ if(workerScript.disableLogs.ALL == null && workerScript.disableLogs.exec == null && workerScript.disableLogs.run == null && workerScript.disableLogs.spawn == null) {
+ workerScript.scriptRef.log("Running script: " + scriptname + " on " + server.hostname + " with " + threads + " threads and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__["printArray"])(args) + ". May take a few seconds to start up...");
+ }
+ var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_7__["RunningScript"](script, args);
+ runningScriptObj.threads = threads;
+ server.runningScripts.push(runningScriptObj); //Push onto runningScripts
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["addWorkerScript"])(runningScriptObj, server);
+ return Promise.resolve(true);
+ }
+ }
+ }
+ workerScript.scriptRef.log("Could not find script " + scriptname + " on " + server.hostname);
+ return Promise.resolve(false);
+}
+
+function getErrorLineNumber(exp, workerScript) {
+ var code = workerScript.scriptRef.scriptRef.code;
+
+ //Split code up to the start of the node
+ try {
+ code = code.substring(0, exp.start);
+ return (code.match(/\n/g) || []).length + 1;
+ } catch(e) {
+ return -1;
+ }
+}
+
+function isScriptErrorMessage(msg) {
+ if (!Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(msg)) {return false;}
+ let splitMsg = msg.split("|");
+ if (splitMsg.length != 4){
+ return false;
+ }
+ var ip = splitMsg[1];
+ if (!Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__["isValidIPAddress"])(ip)) {
+ return false;
+ }
+ return true;
+}
+
+//The same as Player's calculateHackingChance() function but takes in the server as an argument
+function scriptCalculateHackingChance(server) {
+ var difficultyMult = (100 - server.hackDifficulty) / 100;
+ var skillMult = (1.75 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill) + (0.2 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence);
+ var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
+ var chance = skillChance * difficultyMult * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_chance_mult;
+ if (chance > 1) {return 1;}
+ if (chance < 0) {return 0;}
+ else {return chance;}
+}
+
+//The same as Player's calculateHackingTime() function but takes in the server as an argument
+function scriptCalculateHackingTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var hackingTime = 5 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return hackingTime;
+}
+
+//The same as Player's calculateExpGain() function but takes in the server as an argument
+function scriptCalculateExpGain(server) {
+ if (server.baseDifficulty == null) {
+ server.baseDifficulty = server.hackDifficulty;
+ }
+ return (server.baseDifficulty * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_exp_mult * 0.3 + 3) * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].HackExpGain;
+}
+
+//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
+function scriptCalculatePercentMoneyHacked(server) {
+ var difficultyMult = (100 - server.hackDifficulty) / 100;
+ var skillMult = (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill - (server.requiredHackingSkill - 1)) / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill;
+ var percentMoneyHacked = difficultyMult * skillMult * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_money_mult / 240;
+ if (percentMoneyHacked < 0) {return 0;}
+ if (percentMoneyHacked > 1) {return 1;}
+ return percentMoneyHacked * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ScriptHackMoney;
+}
+
+//Amount of time to execute grow() in milliseconds
+function scriptCalculateGrowTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var growTime = 16 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return growTime * 1000;
+}
+
+//Amount of time to execute weaken() in milliseconds
+function scriptCalculateWeakenTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var weakenTime = 20 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return weakenTime * 1000;
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
/***/ }),
-/* 35 */
+/* 32 */
+/*!************************!*\
+ !*** ./utils/acorn.js ***!
+ \************************/
/***/ (function(module, exports, __webpack_require__) {
/*
@@ -41507,32 +34336,33 @@ Object.defineProperty(exports, '__esModule', { value: true });
})));
/***/ }),
-/* 36 */
+/* 33 */
+/*!*********************!*\
+ !*** ./src/Gang.js ***!
+ \*********************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HacknetNode", function() { return HacknetNode; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPlayerHacknetNodeWrappers", function() { return createPlayerHacknetNodeWrappers; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayHacknetNodesContent", function() { return displayHacknetNodesContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCostOfNextHacknetNode", function() { return getCostOfNextHacknetNode; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getHacknetNode", function() { return getHacknetNode; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMaxNumberLevelUpgrades", function() { return getMaxNumberLevelUpgrades; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hacknetNodesInit", function() { return hacknetNodesInit; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processAllHacknetNodeEarnings", function() { return processAllHacknetNodeEarnings; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseHacknet", function() { return purchaseHacknet; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesContent", function() { return updateHacknetNodesContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesMultiplierButtons", function() { return updateHacknetNodesMultiplierButtons; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateTotalHacknetProduction", function() { return updateTotalHacknetProduction; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
-/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(24);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gang", function() { return Gang; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayGangContent", function() { return displayGangContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateGangContent", function() { return updateGangContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAllGangs", function() { return loadAllGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllGangs", function() { return AllGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resetGangs", function() { return resetGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteGangDisplayContent", function() { return deleteGangDisplayContent; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
@@ -41543,641 +34373,1478 @@ __webpack_require__.r(__webpack_exports__);
-/**
- * Overwrites the inner text of the specified HTML element if it is different from what currently exists.
- * @param {string} elementId The HTML ID to find the first instance of.
- * @param {string} text The inner text that should be set.
- */
-function updateText(elementId, text) {
- var el = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])(elementId);
- if (el.innerText != text) {
- el.innerText = text;
- }
-};
-/* HacknetNode.js */
-function hacknetNodesInit() {
- var performMapping = function(x) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])("hacknet-nodes-" + x.id + "-multiplier")
- .addEventListener("click", function() {
- hacknetNodePurchaseMultiplier = x.multiplier;
- updateHacknetNodesMultiplierButtons();
- updateHacknetNodesContent();
- return false;
- });
- };
-
- var mappings = [
- { id: "1x", multiplier: 1 },
- { id: "5x", multiplier: 5 },
- { id: "10x", multiplier: 10 },
- { id: "max", multiplier: 0 }
- ];
- for (var elem of mappings) {
- // Encapsulate in a function so that the appropriate scope is kept in the click handler.
- performMapping(elem);
- }
-}
-
-document.addEventListener("DOMContentLoaded", hacknetNodesInit, false);
-
-function HacknetNode(name) {
- this.level = 1;
- this.ram = 1; //GB
- this.cores = 1;
-
- this.name = name;
-
- this.totalMoneyGenerated = 0;
- this.onlineTimeSeconds = 0;
-
- this.moneyGainRatePerSecond = 0;
-}
-
-
-HacknetNode.prototype.updateMoneyGainRate = function() {
- //How much extra $/s is gained per level
- var gainPerLevel = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMoneyGainPerLevel;
-
- this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
- Math.pow(1.035, this.ram-1) *
- ((this.cores + 5) / 6) *
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_money_mult *
- _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].HacknetNodeMoney;
- if (isNaN(this.moneyGainRatePerSecond)) {
- this.moneyGainRatePerSecond = 0;
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__["dialogBoxCreate"])("Error in calculating Hacknet Node production. Please report to game developer");
- }
-
- updateTotalHacknetProduction();
-}
-
-HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) {
- levels = Math.round(levels);
- if (isNaN(levels) || levels < 1) {
- return 0;
- }
-
- var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeLevelMult;
- var totalMultiplier = 0; //Summed
- var currLevel = this.level;
- for (var i = 0; i < levels; ++i) {
- totalMultiplier += Math.pow(mult, currLevel);
- ++currLevel;
- }
-
- return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode / 2 * totalMultiplier * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_level_cost_mult;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.getLevelUpgradeCost = function(levels=1) {
- return this.calculateLevelUpgradeCost(levels);
-}
-
-HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
- levels = Math.round(levels);
- var cost = this.calculateLevelUpgradeCost(levels);
- if (isNaN(cost) || levels < 0) {
- return false;
- }
-
- if (this.level + levels > _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel) {
- var diff = Math.max(0, _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - this.level);
- return this.purchaseLevelUpgrade(diff);
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
- return false;
- }
-
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
- this.level += levels;
- this.updateMoneyGainRate();
- return true;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.upgradeLevel = function(levels=1) {
- let res = this.purchaseLevelUpgrade(levels);
- createPlayerHacknetNodeWrappers();
- return res;
-}
-
-HacknetNode.prototype.calculateRamUpgradeCost = function() {
- var numUpgrades = Math.log2(this.ram);
-
- //Calculate cost
- //Base cost of RAM is 50k per 1GB, increased by some multiplier for each time RAM is upgraded
- var baseCost = this.ram * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostFor1GBOfRamHacknetNode;
- var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeRamMult, numUpgrades);
- return baseCost * mult * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_ram_cost_mult;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.getRamUpgradeCost = function() {
- return this.calculateRamUpgradeCost();
-}
-
-HacknetNode.prototype.purchaseRamUpgrade = function() {
- var cost = this.calculateRamUpgradeCost();
- if (isNaN(cost)) {
- return false;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
- return false;
- }
-
- if (this.ram >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxRam) {
- return false;
- }
-
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
- this.ram *= 2; //Ram is always doubled
- this.updateMoneyGainRate();
- return true;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.upgradeRam = function() {
- let res = this.purchaseRamUpgrade();
- createPlayerHacknetNodeWrappers();
- return res;
-}
-
-HacknetNode.prototype.calculateCoreUpgradeCost = function() {
- var coreBaseCost = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNodeCore;
- var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeCoreMult;
- return coreBaseCost * Math.pow(mult, this.cores - 1) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_core_cost_mult;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.getCoreUpgradeCost = function() {
- let res = this.calculateCoreUpgradeCost();
- createPlayerHacknetNodeWrappers();
- return res;
-}
-
-HacknetNode.prototype.purchaseCoreUpgrade = function() {
- var cost = this.calculateCoreUpgradeCost();
- if (isNaN(cost)) {
- return false;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
- return false;
- }
-
- if (this.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {
- return false;
- }
-
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
- ++this.cores;
- this.updateMoneyGainRate();
- return true;
-}
-
-//Wrapper function for Netscript
-HacknetNode.prototype.upgradeCore = function() {
- return this.purchaseCoreUpgrade();
-}
-
-/* Saving and loading HackNets */
-HacknetNode.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_toJSON"])("HacknetNode", this);
-}
-
-HacknetNode.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_fromJSON"])(HacknetNode, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Reviver"].constructors.HacknetNode = HacknetNode;
-
-var HacknetNodeWrapper = function(hacknetNodeObj) {
- var _node = hacknetNodeObj;
- return {
- name : _node.name,
- level : _node.level,
- ram : _node.ram,
- cores : _node.cores,
- totalMoneyGenerated : _node.totalMoneyGenerated,
- onlineTimeSeconds : _node.onlineTimeSeconds,
- moneyGainRatePerSecond : _node.moneyGainRatePerSecond,
- upgradeLevel : function(n) {
- return _node.upgradeLevel(n);
- },
- upgradeRam : function() {
- return _node.upgradeRam();
- },
- upgradeCore : function() {
- return _node.upgradeCore();
- },
- getLevelUpgradeCost : function(n) {
- return _node.getLevelUpgradeCost(n);
- },
- getRamUpgradeCost : function() {
- return _node.getRamUpgradeCost();
- },
- getCoreUpgradeCost : function() {
- return _node.getCoreUpgradeCost();
+/* Gang.js */
+//Switch between territory and management screen with 1 and 2
+$(document).keydown(function(event) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Gang && !_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoBoxOpen"]) {
+ if (gangMemberFilter != null && gangMemberFilter === document.activeElement) {return;}
+ if (event.keyCode === 49) {
+ if(gangTerritorySubpage.style.display === "block") {
+ managementButton.click();
+ }
+ } else if (event.keyCode === 50) {
+ if (gangManagementSubpage.style.display === "block") {
+ territoryButton.click();
+ }
}
}
+});
+
+//Delete upgrade box when clicking outside
+$(document).mousedown(function(event) {
+ var boxId = "gang-member-upgrade-popup-box";
+ var contentId = "gang-member-upgrade-popup-box-content";
+ if (gangMemberUpgradeBoxOpened) {
+ if ( $(event.target).closest("#" + contentId).get(0) == null ) {
+ //Delete the box
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBox);
+ gangMemberUpgradeBox = null;
+ gangMemberUpgradeBoxContent = null;
+ gangMemberUpgradeBoxOpened = false;
+ gangMemberUpgradeBoxElements = null;
+ }
+ }
+});
+
+let GangNames = ["Slum Snakes", "Tetrads", "The Syndicate", "The Dark Army", "Speakers for the Dead",
+ "NiteSec", "The Black Hand"];
+let AllGangs = {
+ "Slum Snakes" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Tetrads" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Syndicate" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Dark Army" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Speakers for the Dead" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "NiteSec" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Black Hand" : {
+ power: 1,
+ territory: 1/7,
+ },
}
-function purchaseHacknet() {
- /* INTERACTIVE TUTORIAL */
- if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialIsRunning"]) {
- if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["currITutorialStep"] == _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialSteps"].HacknetNodesIntroduction) {
- Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialNextStep"])();
+function resetGangs() {
+ AllGangs = {
+ "Slum Snakes" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Tetrads" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Syndicate" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Dark Army" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Speakers for the Dead" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "NiteSec" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Black Hand" : {
+ power: 1,
+ territory: 1/7,
+ },
+ }
+}
+
+function loadAllGangs(saveString) {
+ AllGangs = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"]);
+}
+
+//Power is an estimate of a gang's ability to gain/defend territory
+let gangStoredPowerCycles = 0;
+function processAllGangPowerGains(numCycles=1) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ gangStoredPowerCycles += numCycles;
+ if (gangStoredPowerCycles < 150) {return;}
+ var playerGangName = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName;
+ for (var name in AllGangs) {
+ if (AllGangs.hasOwnProperty(name)) {
+ if (name == playerGangName) {
+ AllGangs[name].power += _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.calculatePower();
+ } else {
+ var gain = Math.random() * 0.02; //TODO Adjust as necessary
+ AllGangs[name].power += (gain);
+ }
+ }
+ }
+
+ gangStoredPowerCycles -= 150;
+}
+
+let gangStoredTerritoryCycles = 0;
+function processAllGangTerritory(numCycles=1) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ gangStoredTerritoryCycles += numCycles;
+ if (gangStoredTerritoryCycles < _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer) {return;}
+
+ for (var i = 0; i < GangNames.length; ++i) {
+ var other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
+ while(other == i) {
+ other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
+ }
+ var thisPwr = AllGangs[GangNames[i]].power;
+ var otherPwr = AllGangs[GangNames[other]].power;
+ var thisChance = thisPwr / (thisPwr + otherPwr);
+
+ if (Math.random() < thisChance) {
+ if (AllGangs[GangNames[other]].territory <= 0) {
+ return;
+ }
+ AllGangs[GangNames[i]].territory += 0.0001;
+ AllGangs[GangNames[other]].territory -= 0.0001;
} else {
+ if (AllGangs[GangNames[i]].territory <= 0) {
+ return;
+ }
+ AllGangs[GangNames[i]].territory -= 0.0001;
+ AllGangs[GangNames[other]].territory += 0.0001;
+ }
+ }
+
+ gangStoredTerritoryCycles -= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer;
+}
+
+/* faction - Name of corresponding faction
+ hacking - Boolean indicating whether its a hacking gang or not
+ */
+function Gang(facName, hacking=false) {
+ this.facName = facName;
+ this.members = []; //Array of GangMembers
+ this.wanted = 1;
+ this.respect = 1;
+ this.power = 0;
+
+ this.isHackingGang = hacking;
+
+ this.respectGainRate = 0;
+ this.wantedGainRate = 0;
+ this.moneyGainRate = 0;
+
+ //When processing gains, this stores the number of cycles until some
+ //limit is reached, and then calculates and applies the gains only at that limit
+ this.storedCycles = 0;
+}
+
+Gang.prototype.process = function(numCycles=1) {
+ this.processGains(numCycles);
+ this.processExperienceGains(numCycles);
+ processAllGangPowerGains(numCycles);
+ processAllGangTerritory(numCycles);
+}
+
+Gang.prototype.processGains = function(numCycles=1) {
+ this.storedCycles += numCycles;
+ if (isNaN(this.storedCycles)) {
+ console.log("ERROR: Gang's storedCylces is NaN");
+ this.storedCycles = 0;
+ }
+ if (this.storedCycles < 25) {return;} //Only process every 5 seconds at least
+
+ //Get gains per cycle
+ var moneyGains = 0, respectGains = 0, wantedLevelGains = 0;
+ for (var i = 0; i < this.members.length; ++i) {
+ respectGains += (this.members[i].calculateRespectGain());
+ wantedLevelGains += (this.members[i].calculateWantedLevelGain());
+ moneyGains += (this.members[i].calculateMoneyGain());
+ }
+ this.respectGainRate = respectGains;
+ this.wantedGainRate = wantedLevelGains;
+ this.moneyGainRate = moneyGains;
+
+ if (!isNaN(respectGains)) {
+ var gain = respectGains * this.storedCycles;
+ this.respect += (gain);
+ //Faction reputation gains is respect gain divided by some constant
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][this.facName];
+ if (!(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("ERROR: Could not get Faction associates with your gang. This is a bug, please report to game dev");
+ } else {
+ var favorMult = 1 + (fac.favor / 100);
+ fac.playerReputation += ((_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * gain * favorMult) / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangRespectToReputationRatio);
+ }
+
+ } else {
+ console.log("ERROR: respectGains is NaN");
+ }
+ if (!isNaN(wantedLevelGains)) {
+ if (this.wanted === 1 && wantedLevelGains < 0) {
+ //Do nothing
+ } else {
+ this.wanted += (wantedLevelGains * this.storedCycles);
+ if (this.wanted < 1) {this.wanted = 1;}
+ }
+ } else {
+ console.log("ERROR: wantedLevelGains is NaN");
+ }
+ if (!isNaN(moneyGains)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainMoney(moneyGains * this.storedCycles);
+ } else {
+ console.log("ERROR: respectGains is NaN");
+ }
+
+ this.storedCycles = 0;
+}
+
+Gang.prototype.processExperienceGains = function(numCycles=1) {
+ for (var i = 0; i < this.members.length; ++i) {
+ this.members[i].gainExperience(numCycles);
+ this.members[i].updateSkillLevels();
+ }
+}
+
+//Calculates power GAIN, which is added onto the Gang's existing power
+Gang.prototype.calculatePower = function() {
+ var memberTotal = 0;
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task instanceof GangMemberTask &&
+ this.members[i].task.name == "Territory Warfare") {
+ memberTotal += this.members[i].calculatePower();
+ }
+ }
+ return (0.0005 * memberTotal);
+}
+
+Gang.prototype.autoAssignMemberToTask = function(taskName) {
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task.name === taskName) {
+ this.members[i].assignToTask(taskName);
+ return true;
+ }
+ }
+ return false;
+}
+
+Gang.prototype.autoUnassignMemberFromTask = function(taskName) {
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task.name === taskName) {
+ this.members[i].unassignFromTask();
+ return true;
+ }
+ }
+ return false;
+}
+
+Gang.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("Gang", this);
+}
+
+Gang.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(Gang, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.Gang = Gang;
+
+/*** Gang Member object ***/
+function GangMember(name) {
+ this.name = name;
+ this.task = GangMemberTasks["Unassigned"]; //GangMemberTask object
+ this.city = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].city;
+
+ this.hack = 1;
+ this.str = 1;
+ this.def = 1;
+ this.dex = 1;
+ this.agi = 1;
+ this.cha = 1;
+
+ this.hack_exp = 0;
+ this.str_exp = 0;
+ this.def_exp = 0;
+ this.dex_exp = 0;
+ this.agi_exp = 0;
+ this.cha_exp = 0;
+
+ this.hack_mult = 1;
+ this.str_mult = 1;
+ this.def_mult = 1;
+ this.dex_mult = 1;
+ this.agi_mult = 1;
+ this.cha_mult = 1;
+
+ this.upgrades = []; //Names of upgrades
+}
+
+//Same formula for Player
+GangMember.prototype.calculateSkill = function(exp, mult=1) {
+ return Math.max(Math.floor(mult*(32 * Math.log(exp + 534.5) - 200)), 1);
+}
+
+GangMember.prototype.updateSkillLevels = function() {
+ this.hack = this.calculateSkill(this.hack_exp, this.hack_mult);
+ this.str = this.calculateSkill(this.str_exp, this.str_mult);
+ this.def = this.calculateSkill(this.def_exp, this.def_mult);
+ this.dex = this.calculateSkill(this.dex_exp, this.dex_mult);
+ this.agi = this.calculateSkill(this.agi_exp, this.agi_mult);
+ this.cha = this.calculateSkill(this.cha_exp, this.cha_mult);
+}
+
+GangMember.prototype.calculatePower = function() {
+ return (this.hack + this.str + this.def +
+ this.dex + this.agi + this.cha) / 100;
+}
+
+GangMember.prototype.assignToTask = function(taskName) {
+ if (GangMemberTasks.hasOwnProperty(taskName)) {
+ this.task = GangMemberTasks[taskName];
+ } else {
+ this.task = GangMemberTasks["Unassigned"];
+ }
+}
+
+GangMember.prototype.unassignFromTask = function() {
+ if (GangMemberTasks.hasOwnProperty("Unassigned")) {
+ this.task = GangMemberTasks["Unassigned"];
+ } else {
+ console.log("ERROR: Can't find Unassigned Gang member task");
+ this.task = null;
+ }
+}
+
+//Gains are per cycle
+GangMember.prototype.calculateRespectGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
+ return 12 * task.baseRespect * statWeight * territoryMult * respectMult;
+}
+
+GangMember.prototype.calculateWantedLevelGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ if (task.baseWanted < 0) {
+ return task.baseWanted * statWeight * territoryMult;
+ } else {
+ return 6 * task.baseWanted / (3 * statWeight * territoryMult);
+ }
+}
+
+GangMember.prototype.calculateMoneyGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
+ return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
+}
+
+GangMember.prototype.gainExperience = function(numCycles=1) {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask)) {return;}
+ this.hack_exp += (task.hackWeight / 1500) * task.difficulty * numCycles;
+ this.str_exp += (task.strWeight / 1500) * task.difficulty * numCycles;
+ this.def_exp += (task.defWeight / 1500) * task.difficulty * numCycles;
+ this.dex_exp += (task.dexWeight / 1500) * task.difficulty * numCycles;
+ this.agi_exp += (task.agiWeight / 1500) * task.difficulty * numCycles;
+ this.cha_exp += (task.chaWeight / 1500) * task.difficulty * numCycles;
+}
+
+GangMember.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMember", this);
+}
+
+GangMember.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMember, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMember = GangMember;
+
+//Defines tasks that Gang Members can work on
+function GangMemberTask(name="", desc="",
+ params={baseRespect: 0, baseWanted: 0, baseMoney: 0,
+ hackWeight: 0, strWeight: 0, defWeight: 0,
+ dexWeight: 0, agiWeight: 0, chaWeight: 0,
+ difficulty: 0}) {
+ this.name = name;
+ this.desc = desc;
+
+ this.baseRespect = params.baseRespect ? params.baseRespect : 0;
+ this.baseWanted = params.baseWanted ? params.baseWanted : 0;
+ this.baseMoney = params.baseMoney ? params.baseMoney : 0;
+
+ //Weights must add up to 100
+ this.hackWeight = params.hackWeight ? params.hackWeight : 0;
+ this.strWeight = params.strWeight ? params.strWeight : 0;
+ this.defWeight = params.defWeight ? params.defWeight : 0;
+ this.dexWeight = params.dexWeight ? params.dexWeight : 0;
+ this.agiWeight = params.agiWeight ? params.agiWeight : 0;
+ this.chaWeight = params.chaWeight ? params.chaWeight : 0;
+
+ //1 - 100
+ this.difficulty = params.difficulty ? params.difficulty : 1;
+}
+
+GangMemberTask.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberTask", this);
+}
+
+GangMemberTask.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberTask, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberTask = GangMemberTask;
+
+//TODO Human trafficking and an equivalent hacking crime
+let GangMemberTasks = {
+ "Unassigned" : new GangMemberTask(
+ "Unassigned",
+ "This gang member is currently idle"),
+ "Ransomware" : new GangMemberTask(
+ "Ransomware",
+ "Assign this gang member to create and distribute ransomware
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
+ hackWeight: 100, difficulty: 1}),
+ "Phishing" : new GangMemberTask(
+ "Phishing",
+ "Assign this gang member to attempt phishing scams and attacks
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 2.5,
+ hackWeight: 85, chaWeight: 15, difficulty: 3}),
+ "Identity Theft" : new GangMemberTask(
+ "Identity Theft",
+ "Assign this gang member to attempt identity theft
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0001, baseWanted: 0.01, baseMoney: 6,
+ hackWeight: 80, chaWeight: 20, difficulty: 4}),
+ "DDoS Attacks" : new GangMemberTask(
+ "DDoS Attacks",
+ "Assign this gang member to carry out DDoS attacks
" +
+ "Increases respect - Increases wanted level",
+ {baseRespect: 0.0004, baseWanted: 0.05,
+ hackWeight: 100, difficulty: 7}),
+ "Plant Virus" : new GangMemberTask(
+ "Plant Virus",
+ "Assign this gang member to create and distribute malicious viruses
" +
+ "Increases respect - Increases wanted level",
+ {baseRespect: 0.0006, baseWanted: 0.05,
+ hackWeight: 100, difficulty: 10}),
+ "Fraud & Counterfeiting" : new GangMemberTask(
+ "Fraud & Counterfeiting",
+ "Assign this gang member to commit financial fraud and digital counterfeiting
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.0005, baseWanted: 0.1, baseMoney: 15,
+ hackWeight: 80, chaWeight: 20, difficulty: 17}),
+ "Money Laundering" : new GangMemberTask(
+ "Money Laundering",
+ "Assign this gang member to launder money
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0006, baseWanted:0.2, baseMoney: 40,
+ hackWeight: 75, chaWeight: 25, difficulty: 20}),
+ "Cyberterrorism" : new GangMemberTask(
+ "Cyberterrorism",
+ "Assign this gang member to commit acts of cyberterrorism
" +
+ "Greatly increases respect - Greatly increases wanted level",
+ {baseRespect: 0.001, baseWanted: 0.5,
+ hackWeight: 80, chaWeight: 20, difficulty: 33}),
+ "Ethical Hacking" : new GangMemberTask(
+ "Ethical Hacking",
+ "Assign this gang member to be an ethical hacker for corporations
" +
+ "Earns money - Lowers wanted level",
+ {baseWanted: -0.001, baseMoney: 1,
+ hackWeight: 90, chaWeight: 10, difficulty: 1}),
+ "Mug People" : new GangMemberTask(
+ "Mug People",
+ "Assign this gang member to mug random people on the streets
" +
+ "Earns money - Slightly increases respect - Very slightly increases wanted level",
+ {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
+ strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 10, chaWeight: 15, difficulty: 1}),
+ "Deal Drugs" : new GangMemberTask(
+ "Deal Drugs",
+ "Assign this gang member to sell drugs.
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 4,
+ agiWeight: 20, dexWeight: 20, chaWeight: 60, difficulty: 3}),
+ "Run a Con" : new GangMemberTask(
+ "Run a Con",
+ "Assign this gang member to run cons
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.00015, baseWanted: 0.01, baseMoney: 10,
+ strWeight: 5, defWeight: 5, agiWeight: 25, dexWeight: 25, chaWeight: 40, difficulty: 10}),
+ "Armed Robbery" : new GangMemberTask(
+ "Armed Robbery",
+ "Assign this gang member to commit armed robbery on stores, banks and armored cars
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.00015, baseWanted: 0.05, baseMoney: 25,
+ hackWeight: 20, strWeight: 15, defWeight: 15, agiWeight: 10, dexWeight: 20, chaWeight: 20,
+ difficulty: 17}),
+ "Traffick Illegal Arms" : new GangMemberTask(
+ "Traffick Illegal Arms",
+ "Assign this gang member to traffick illegal arms
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0003, baseWanted: 0.1, baseMoney: 40,
+ hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, chaWeight: 75,
+ difficulty: 25}),
+ "Threaten & Blackmail" : new GangMemberTask(
+ "Threaten & Blackmail",
+ "Assign this gang member to threaten and black mail high-profile targets
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.0002, baseWanted: 0.05, baseMoney: 15,
+ hackWeight: 25, strWeight: 25, dexWeight: 25, chaWeight: 25, difficulty: 28}),
+ "Terrorism" : new GangMemberTask(
+ "Terrorism",
+ "Assign this gang member to commit acts of terrorism
" +
+ "Greatly increases respect - Greatly increases wanted level",
+ {baseRespect: 0.001, baseWanted: 1,
+ hackWeight: 20, strWeight: 20, defWeight: 20,dexWeight: 20, chaWeight: 20,
+ difficulty: 33}),
+ "Vigilante Justice" : new GangMemberTask(
+ "Vigilante Justice",
+ "Assign this gang member to be a vigilante and protect the city from criminals
" +
+ "Decreases wanted level",
+ {baseWanted: -0.001,
+ hackWeight: 20, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight:20,
+ difficulty: 1}),
+ "Train Combat" : new GangMemberTask(
+ "Train Combat",
+ "Assign this gang member to increase their combat stats (str, def, dex, agi)",
+ {strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 25, difficulty: 5}),
+ "Train Hacking" : new GangMemberTask(
+ "Train Hacking",
+ "Assign this gang member to train their hacking skills",
+ {hackWeight: 100, difficulty: 8}),
+ "Territory Warfare" : new GangMemberTask(
+ "Territory Warfare",
+ "Assign this gang member to engage in territorial warfare with other gangs. " +
+ "Members assigned to this task will help increase your gang's territory " +
+ "and will defend your territory from being taken.",
+ {hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight: 20,
+ chaWeight: 5, difficulty: 3}),
+}
+
+
+function GangMemberUpgrade(name="", desc="", cost=0, type="w") {
+ this.name = name;
+ this.desc = desc;
+ this.cost = cost;
+ this.type = type; //w, a, v, r
+}
+
+//Passes in a GangMember object
+GangMemberUpgrade.prototype.apply = function(member) {
+ switch(this.name) {
+ case "Baseball Bat":
+ member.str_mult *= 1.05;
+ member.def_mult *= 1.05;
+ break;
+ case "Katana":
+ member.str_mult *= 1.1;
+ member.def_mult *= 1.1;
+ member.dex_mult *= 1.1;
+ break;
+ case "Glock 18C":
+ member.str_mult *= 1.15;
+ member.def_mult *= 1.15;
+ member.dex_mult *= 1.15;
+ member.agi_mult *= 1.15;
+ break;
+ case "P90C":
+ member.str_mult *= 1.2;
+ member.def_mult *= 1.2;
+ member.agi_mult *= 1.1;
+ break;
+ case "Steyr AUG":
+ member.str_mult *= 1.25;
+ member.def_mult *= 1.25;
+ break;
+ case "AK-47":
+ member.str_mult *= 1.5;
+ member.def_mult *= 1.5;
+ break;
+ case "M15A10 Assault Rifle":
+ member.str_mult *= 1.6;
+ member.def_mult *= 1.6;
+ break;
+ case "AWM Sniper Rifle":
+ member.str_mult *= 1.5;
+ member.dex_mult *= 1.5;
+ member.agi_mult *= 1.5;
+ break;
+ case "Bulletproof Vest":
+ member.def_mult *= 1.05;
+ break;
+ case "Full Body Armor":
+ member.def_mult *= 1.1;
+ break;
+ case "Liquid Body Armor":
+ member.def_mult *= 1.25;
+ member.agi_mult *= 1.25;
+ break;
+ case "Graphene Plating Armor":
+ member.def_mult *= 1.5;
+ break;
+ case "Ford Flex V20":
+ member.agi_mult *= 1.1;
+ member.cha_mult *= 1.1;
+ break;
+ case "ATX1070 Superbike":
+ member.agi_mult *= 1.15;
+ member.cha_mult *= 1.15;
+ break;
+ case "Mercedes-Benz S9001":
+ member.agi_mult *= 1.2;
+ member.cha_mult *= 1.2;
+ break;
+ case "White Ferrari":
+ member.agi_mult *= 1.25;
+ member.cha_mult *= 1.25;
+ break;
+ case "NUKE Rootkit":
+ member.hack_mult *= 1.1;
+ break;
+ case "Soulstealer Rootkit":
+ member.hack_mult *= 1.2;
+ break;
+ case "Demon Rootkit":
+ member.hack_mult *= 1.3;
+ break;
+ default:
+ console.log("ERROR: Could not find this upgrade: " + this.name);
+ break;
+ }
+}
+
+GangMemberUpgrade.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberUpgrade", this);
+}
+
+GangMemberUpgrade.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberUpgrade, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberUpgrade = GangMemberUpgrade;
+
+let GangMemberUpgrades = {
+ "Baseball Bat" : new GangMemberUpgrade("Baseball Bat",
+ "Increases strength and defense by 5%", 1e6, "w"),
+ "Katana" : new GangMemberUpgrade("Katana",
+ "Increases strength, defense, and dexterity by 10%", 12e6, "w"),
+ "Glock 18C" : new GangMemberUpgrade("Glock 18C",
+ "Increases strength, defense, dexterity, and agility by 15%", 25e6, "w"),
+ "P90C" : new GangMemberUpgrade("P90C",
+ "Increases strength and defense by 20%. Increases agility by 10%", 50e6, "w"),
+ "Steyr AUG" : new GangMemberUpgrade("Steyr AUG",
+ "Increases strength and defense by 25%", 60e6, "w"),
+ "AK-47" : new GangMemberUpgrade("AK-47",
+ "Increases strength and defense by 50%", 100e6, "w"),
+ "M15A10 Assault Rifle" : new GangMemberUpgrade("M15A10 Assault Rifle",
+ "Increases strength and defense by 60%", 150e6, "w"),
+ "AWM Sniper Rifle" : new GangMemberUpgrade("AWM Sniper Rifle",
+ "Increases strength, dexterity, and agility by 50%", 225e6, "w"),
+ "Bulletproof Vest" : new GangMemberUpgrade("Bulletproof Vest",
+ "Increases defense by 5%", 2e6, "a"),
+ "Full Body Armor" : new GangMemberUpgrade("Full Body Armor",
+ "Increases defense by 10%", 5e6, "a"),
+ "Liquid Body Armor" : new GangMemberUpgrade("Liquid Body Armor",
+ "Increases defense and agility by 25%", 25e6, "a"),
+ "Graphene Plating Armor" : new GangMemberUpgrade("Graphene Plating Armor",
+ "Increases defense by 50%", 40e6, "a"),
+ "Ford Flex V20" : new GangMemberUpgrade("Ford Flex V20",
+ "Increases agility and charisma by 10%", 3e6, "v"),
+ "ATX1070 Superbike" : new GangMemberUpgrade("ATX1070 Superbike",
+ "Increases agility and charisma by 15%", 9e6, "v"),
+ "Mercedes-Benz S9001" : new GangMemberUpgrade("Mercedes-Benz S9001",
+ "Increases agility and charisma by 20%", 18e6, "v"),
+ "White Ferrari" : new GangMemberUpgrade("White Ferrari",
+ "Increases agility and charisma by 25%", 30e6, "v"),
+ "NUKE Rootkit" : new GangMemberUpgrade("NUKE Rootkit",
+ "Increases hacking by 10%", 5e6, "r"),
+ "Soulstealer Rootkit" : new GangMemberUpgrade("Soulstealer Rootkit",
+ "Increases hacking by 20%", 15e6, "r"),
+ "Demon Rootkit" : new GangMemberUpgrade("Demon Rootkit",
+ "Increases hacking by 30%", 50e6, "r"),
+}
+
+//Create a pop-up box that lets player purchase upgrades
+let gangMemberUpgradeBoxOpened = false;
+function createGangMemberUpgradeBox(initialFilter="") {
+ var boxId = "gang-member-upgrade-popup-box";
+ if (gangMemberUpgradeBoxOpened) {
+ //Already opened, refreshing
+ if (gangMemberUpgradeBoxElements == null || gangMemberUpgradeBox == null || gangMemberUpgradeBoxContent == null) {
+ console.log("ERROR: Refreshing Gang member upgrade box throws error because required elements are null");
return;
}
- }
- /* END INTERACTIVE TUTORIAL */
-
- var cost = getCostOfNextHacknetNode();
- if (isNaN(cost)) {
- throw new Error("Cost is NaN");
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
- //dialogBoxCreate("You cannot afford to purchase a Hacknet Node!");
- return false;
- }
-
- //Auto generate a name for the node for now...TODO
- var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
- var name = "hacknet-node-" + numOwned;
- var node = new HacknetNode(name);
- node.updateMoneyGainRate();
-
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.push(node);
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Page.HacknetNodes) {
- displayHacknetNodesContent();
- }
- createPlayerHacknetNodeWrappers();
- updateTotalHacknetProduction();
- return numOwned;
-}
-
-//Calculates the total production from all HacknetNodes
-function updateTotalHacknetProduction() {
- var total = 0;
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- total += _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction = total;
-}
-
-function getCostOfNextHacknetNode() {
- //Cost increases exponentially based on how many you own
- var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
- var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodePurchaseNextMult;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode * Math.pow(mult, numOwned) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_purchase_cost_mult;
-}
-
-var hacknetNodePurchaseMultiplier = 1;
-function updateHacknetNodesMultiplierButtons() {
- var mult1x = document.getElementById("hacknet-nodes-1x-multiplier");
- var mult5x = document.getElementById("hacknet-nodes-5x-multiplier");
- var mult10x = document.getElementById("hacknet-nodes-10x-multiplier");
- var multMax = document.getElementById("hacknet-nodes-max-multiplier");
- mult1x.setAttribute("class", "a-link-button");
- mult5x.setAttribute("class", "a-link-button");
- mult10x.setAttribute("class", "a-link-button");
- multMax.setAttribute("class", "a-link-button");
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length == 0) {
- mult1x.setAttribute("class", "a-link-button-inactive");
- mult5x.setAttribute("class", "a-link-button-inactive");
- mult10x.setAttribute("class", "a-link-button-inactive");
- multMax.setAttribute("class", "a-link-button-inactive");
- } else if (hacknetNodePurchaseMultiplier == 1) {
- mult1x.setAttribute("class", "a-link-button-inactive");
- } else if (hacknetNodePurchaseMultiplier == 5) {
- mult5x.setAttribute("class", "a-link-button-inactive");
- } else if (hacknetNodePurchaseMultiplier == 10) {
- mult10x.setAttribute("class", "a-link-button-inactive");
- } else {
- multMax.setAttribute("class", "a-link-button-inactive");
- }
-}
-
-//Calculate the maximum number of times the Player can afford to upgrade
-//a Hacknet Node's level"
-function getMaxNumberLevelUpgrades(nodeObj) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(1))) {
- return 0;
- }
-
- var min = 1;
- var max = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - 1;
- var levelsToMax = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - nodeObj.level;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) {
- return levelsToMax;
- }
-
- while (min <= max) {
- var curr = (min + max) / 2 | 0;
- if (curr != _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel &&
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr)) &&
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr + 1))) {
- return Math.min(levelsToMax, curr);
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr))) {
- max = curr - 1;
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr))) {
- min = curr + 1;
- } else {
- return Math.min(levelsToMax, curr);
+ for (var i = 1; i < gangMemberUpgradeBoxElements.length; ++i) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBoxElements[i]);
}
- }
-}
+ gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter];
-//Creates Hacknet Node DOM elements when the page is opened
-function displayHacknetNodesContent() {
- //Update Hacknet Nodes button
- var newPurchaseButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["clearEventListeners"])("hacknet-nodes-purchase-button");
-
- newPurchaseButton.addEventListener("click", function() {
- purchaseHacknet();
- return false;
- });
-
- //Handle Purchase multiplier buttons
- updateHacknetNodesMultiplierButtons();
-
- //Remove all old hacknet Node DOM elements
- var hacknetNodesList = document.getElementById("hacknet-nodes-list");
- while (hacknetNodesList.firstChild) {
- hacknetNodesList.removeChild(hacknetNodesList.firstChild);
- }
-
- //Then re-create them
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- createHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
-
- updateHacknetNodesContent();
-}
-
-//Update information on all Hacknet Node DOM elements
-function updateHacknetNodesContent() {
- //Set purchase button to inactive if not enough money, and update its price display
- var cost = getCostOfNextHacknetNode();
- var purchaseButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])("hacknet-nodes-purchase-button");
- var formattedCost = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(cost, 2);
-
- updateText("hacknet-nodes-purchase-button", "Purchase Hacknet Node - $" + formattedCost);
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
- purchaseButton.setAttribute("class", "a-link-button-inactive");
- } else {
- purchaseButton.setAttribute("class", "a-link-button");
- }
-
- //Update player's money
- updateText("hacknet-nodes-player-money", "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.toNumber(), 2));
- updateText("hacknet-nodes-total-production", "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction, 2) + " / second");
-
- //Update information in each owned hacknet node
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- updateHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
-}
-
-//Creates a single Hacknet Node DOM element
-function createHacknetNodeDomElement(nodeObj) {
- var nodeName = nodeObj.name;
-
- var nodeLevelContainer = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
- class: "hacknet-node-level-container row",
- innerHTML: "
" +
+ "If a gang member is not earning much money or respect, the task that you " +
+ "have assigned to that member might be too difficult. Consider training that " +
+ "member's stats or choosing an easier task. The tasks closer to the " +
+ "top of the dropdown list are generally easier. Alternatively, the gang member's " +
+ "low production might be due to the fact that your wanted level is too high. " +
+ "Consider assigning a few members to the '" + lowerWantedTask + "' " +
+ "task to lower your wanted level.
" +
+ "Installing Augmentations does NOT reset your progress with your Gang. " +
+ "Furthermore, after installing Augmentations, you will " +
+ "automatically be a member of whatever Faction you created your gang with.
"
+ });
+ gangManagementSubpage.appendChild(gangDesc);
+
+ gangInfo = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-info", width:"70%"});
+ gangManagementSubpage.appendChild(gangInfo);
+
+ gangRecruitMemberButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ id:"gang-management-recruit-member-btn", class:"a-link-button-inactive",
+ innerHTML:"Recruit Gang Member", display:"inline-block", margin:"10px",
+ clickListener:()=>{
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetNoButton"])();
+ yesBtn.innerHTML = "Recruit Gang Member";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", ()=>{
+ var name = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetInput"])();
+ if (name === "") {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You must enter a name for your Gang member!");
+ } else {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
+ if (name == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You already have a gang member with this name!");
+ return false;
+ }
+ }
+ var member = new GangMember(name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.push(member);
+ createGangMemberDisplayElement(member);
+ updateGangContent();
+ }
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxCreate"])("Please enter a name for your new Gang member:");
+ return false;
+ }
+ });
+ gangManagementSubpage.appendChild(gangRecruitMemberButton);
+
+ //Text for how much reputation is required for recruiting next memberList
+ gangRecruitRequirementText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {color:"red", id:"gang-recruit-requirement-text"});
+ gangManagementSubpage.appendChild(gangRecruitRequirementText);
+
+ //Gang Member List management buttons (Expand/Collapse All, select a single member)
+ gangManagementSubpage.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+ gangExpandAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Expand All",
+ clickListener:()=>{
+ var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ var hdr = allHeaders[i];
+ if (!hdr.classList.contains("active")) {
+ hdr.click();
+ }
+ }
+ return false;
+ }
+ });
+ gangCollapseAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Collapse All",
+ clickListener:()=>{
+ var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ var hdr = allHeaders[i];
+ if (hdr.classList.contains("active")) {
+ hdr.click();
+ }
+ }
+ return false;
+ }
+ });
+ gangMemberFilter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("input", {
+ type:"text", placeholder:"Filter gang members", margin:"5px", padding:"5px",
+ onkeyup:()=>{
+ displayGangMemberList();
+ }
+ });
+ gangManageEquipmentButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Manage Equipment",
+ clickListener:()=>{
+ createGangMemberUpgradeBox();
+ }
+ });
+ gangManagementSubpage.appendChild(gangExpandAllButton);
+ gangManagementSubpage.appendChild(gangCollapseAllButton);
+ gangManagementSubpage.appendChild(gangMemberFilter);
+ gangManagementSubpage.appendChild(gangManageEquipmentButton);
+
+ //Gang Member list
+ gangMemberList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("ul", {id:"gang-member-list"});
+ displayGangMemberList();
+ gangManagementSubpage.appendChild(gangMemberList);
+
+ //Subpage for seeing gang territory information
+ gangTerritorySubpage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id:"gang-territory-subpage", display:"none"
+ });
+
+ //Info text for territory page
+ gangTerritoryDescText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
+ width:"70%",
+ innerHTML:"This page shows how much territory your Gang controls. This statistic is listed as a percentage, " +
+ "which represents how much of the total territory you control.
" +
+ "Territory gain and loss is processed automatically and is updated every ~30 seconds. Your chances " +
+ "to gain and lose territory depend on your Gang's power, which is listed in the display below. " +
+ "Your gang's power is determined by the stats of all Gang members you have assigned to the " +
+ "'Territory Warfare' task. Gang members that are not assigned to this task do not contribute to " +
+ "your Gang's power.
" +
+ "The amount of territory you have affects all aspects of your Gang members' production, including " +
+ "money, respect, and wanted level. It is very beneficial to have high territory control.
"
+ });
+ gangTerritorySubpage.appendChild(gangTerritoryDescText);
+
+ var territoryBorder = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("fieldset", {width:"50%", display:"inline-block"});
+
+ gangTerritoryInfoText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-territory-info"});
+
+ territoryBorder.appendChild(gangTerritoryInfoText);
+ gangTerritorySubpage.appendChild(territoryBorder);
+
+ gangContainer.appendChild(gangTerritorySubpage);
+ gangContainer.appendChild(gangManagementSubpage);
+ document.getElementById("entire-game-container").appendChild(gangContainer);
+ }
+ gangContainer.style.display = "block";
+ updateGangContent();
+}
+
+function displayGangMemberList() {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeChildrenFromElement"])(gangMemberList);
+ var members = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members;
+ var filter = gangMemberFilter.value.toString();
+ for (var i = 0; i < members.length; ++i) {
+ if (members[i].name.indexOf(filter) > -1 || members[i].task.name.indexOf(filter) > -1) {
+ createGangMemberDisplayElement(members[i]);
+ }
+ }
+ //setGangMemberClickHandlers(); //Set buttons to toggle the gang member info panels
+}
+
+function updateGangContent() {
+ if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+
+ if(gangTerritorySubpage.style.display === "block") {
+ //Update territory information
+ gangTerritoryInfoText.innerHTML = "";
+ for (var gangname in AllGangs) {
+ if (AllGangs.hasOwnProperty(gangname)) {
+ var gangTerritoryInfo = AllGangs[gangname];
+ let territory = gangTerritoryInfo.territory*100;
+
+ //Fix some rounding issues graphically
+ let displayNumber;
+ if (territory <= 0) {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2);
+ } else if (territory >= 100) {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2);
+ } else {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territory, 2);
+ }
+
+ if (gangname == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName) {
+ gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " +
+ displayNumber + "%
");
+ } else {
+ gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " +
+ displayNumber + "%
");
+ }
+ }
+ }
} else {
- var upgradeRamCost = nodeObj.calculateRamUpgradeCost();
- updateText("hacknet-node-upgrade-ram-" + nodeName, "Upgrade - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeRamCost, 2));
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeRamCost)) {
- upgradeRamButton.setAttribute("class", "a-link-button-inactive");
+ //Update information for overall gang
+ if (gangInfo instanceof Element) {
+ var faction = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName];
+ var rep;
+ if (!(faction instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
+ rep = "ERROR";
+ } else {
+ rep = faction.playerReputation;
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeChildrenFromElement"])(gangInfo);
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Respect
+ display:"inline-block",
+ innerText:"Respect: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect, 6) +
+ " (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respectGainRate, 6) + " / sec)",
+ tooltip:"Represents the amount of respect your gang has from other gangs and criminal " +
+ "organizations. Your respect affects the amount of money " +
+ "your gang members will earn, and also determines how much " +
+ "reputation you are earning with your gang's corresponding Faction."
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Wanted level
+ display:"inline-block",
+ innerText:"Wanted Level: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted, 6) +
+ " (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wantedGainRate, 6) + " / sec)",
+ tooltip:"Represents how much the gang is wanted by law enforcement. The higher " +
+ "your gang's wanted level, the harder it will be for your gang members " +
+ "to make money and earn respect. Note that the minimum wanted level is 1."
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ var wantedPenalty = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
+ wantedPenalty = (1 - wantedPenalty) * 100;
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Wanted Level multiplier
+ display:"inline-block",
+ innerText:"Wanted Level Penalty: -" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(wantedPenalty, 2) + "%",
+ tooltip:"Penalty for respect and money gain rates due to Wanted Level"
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Money gain rate
+ display:"inline-block",
+ innerText:"Money gain rate: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.moneyGainRate, 2) +
+ " / sec",
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ //Fix some rounding issues graphically
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory * 100;
+ let displayNumber;
+ if (territoryMult <= 0) {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2);
+ } else if (territoryMult >= 100) {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2);
+ } else {
+ displayNumber = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult, 2);
+ }
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Territory multiplier
+ display:"inline-block",
+ innerText:"Territory: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(displayNumber, 3) + "%",
+ tooltip:"The percentage of total territory your Gang controls"
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Faction reputation
+ display:"inline-block",
+ innerText:"Faction reputation: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(rep, 3)
+ }));
+ gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
} else {
- upgradeRamButton.setAttribute("class", "a-link-button");
+ console.log("ERROR: gang-info DOM element DNE");
+ }
+
+ //Toggle the 'Recruit member button' if valid
+ var numMembers = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length;
+ var repCost = 0;
+ if (numMembers > 0) {
+ var repCost = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangRecruitCostMultiplier, numMembers);
+ }
+ var faction = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName];
+ if (faction == null) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Could not find your gang's faction. This is probably a bug please report to dev");
+ return;
+ }
+ var btn = gangRecruitMemberButton;
+ if (numMembers >= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaximumGangMembers) {
+ btn.className = "a-link-button-inactive";
+ gangRecruitRequirementText.style.display = "block";
+ gangRecruitRequirementText.innerHTML =
+ "You have reached the maximum amount of gang members";
+ } else if (faction.playerReputation >= repCost) {
+ btn.className = "a-link-button";
+ gangRecruitRequirementText.style.display = "none";
+ } else {
+ btn.className = "a-link-button-inactive";
+ gangRecruitRequirementText.style.display = "block";
+ gangRecruitRequirementText.innerHTML =
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(repCost, 2) + " Faction reputation needed to recruit next member";
+ }
+
+ //Update information for each gang member
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
+ updateGangMemberDisplayElement(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]);
}
}
+}
- //Upgrade Cores
- var upgradeCoreButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])("hacknet-node-upgrade-core-" + nodeName);
+//Takes in a GangMember object
+function createGangMemberDisplayElement(memberObj) {
+ if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ var name = memberObj.name;
- if (nodeObj.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {
- updateText("hacknet-node-upgrade-core-" + nodeName, "MAX CORES");
- upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
+ var accordion = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createAccordionElement"])({
+ id:name + "gang-member",
+ hdrText:name,
+ });
+ var li = accordion[0];
+ var hdr = accordion[1];
+ var gangMemberDiv = accordion[2];
+
+ //Gang member content divided into 3 panels:
+ //Stats Panel
+ var statsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id: name + "gang-member-stats", class: "gang-member-info-div",
+ width:"30%", display:"inline"
+ });
+ var statsP = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
+ id:name + "gang-member-stats-text", display:"inline"
+ });
+
+ statsDiv.appendChild(statsP);
+ //statsDiv.appendChild(upgradeButton);
+
+ //Panel for Selecting task and show respect/wanted gain
+ var taskDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id: name + "gang-member-task", class:"gang-member-info-div",
+ width:"30%", display:"inline"
+ });
+ var taskSelector = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("select", {
+ color:"white", backgroundColor:"black",
+ id:name + "gang-member-task-selector"
+ });
+
+ var tasks = null;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.isHackingGang) {
+ tasks = ["---", "Ransomware", "Phishing", "Identity Theft", "DDoS Attacks",
+ "Plant Virus", "Fraud & Counterfeiting","Money Laundering",
+ "Cyberterrorism", "Ethical Hacking", "Train Combat",
+ "Train Hacking", "Territory Warfare"];
} else {
- var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost();
- updateText("hacknet-node-upgrade-core-" + nodeName, "Upgrade - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeCoreCost, 2));
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeCoreCost)) {
- upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
- } else {
- upgradeCoreButton.setAttribute("class", "a-link-button");
+ tasks = ["---", "Mug People", "Deal Drugs", "Run a Con", "Armed Robbery",
+ "Traffick Illegal Arms", "Threaten & Blackmail",
+ "Terrorism", "Vigilante Justice", "Train Combat",
+ "Train Hacking", "Territory Warfare"];
+ }
+ for (var i = 0; i < tasks.length; ++i) {
+ var option = document.createElement("option");
+ option.text = tasks[i];
+ taskSelector.add(option);
+ }
+ taskSelector.addEventListener("change", function() {
+ var task = taskSelector.options[taskSelector.selectedIndex].text;
+ memberObj.assignToTask(task);
+ setGangMemberTaskDescription(memberObj, task);
+ updateGangContent();
+ });
+ //Set initial task in selector element
+ if (memberObj.task instanceof GangMemberTask) {
+ var taskName = memberObj.task.name;
+ var taskIndex = 0;
+ for (let i = 0; i < tasks.length; ++i) {
+ if (taskName == tasks[i]) {
+ taskIndex = i;
+ break;
+ }
}
+ taskSelector.selectedIndex = taskIndex;
+ }
+
+ var gainInfo = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:name + "gang-member-gain-info"});
+ taskDiv.appendChild(taskSelector);
+ taskDiv.appendChild(gainInfo);
+
+ //Panel for Description of task
+ var taskDescDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id:name + "gang-member-task-desc", class:"gang-member-info-div",
+ width:"30%", display:"inline"
+ });
+
+ var taskDescP = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id: name + "gang-member-task-description", display:"inline"});
+ taskDescDiv.appendChild(taskDescP);
+
+ statsDiv.style.width = "30%";
+ taskDiv.style.width = "30%";
+ taskDescDiv.style.width = "30%";
+ statsDiv.style.display = "inline";
+ taskDiv.style.display = "inline";
+ taskDescDiv.style.display = "inline";
+ gangMemberDiv.appendChild(statsDiv);
+ gangMemberDiv.appendChild(taskDiv);
+ gangMemberDiv.appendChild(taskDescDiv);
+
+ gangMemberList.appendChild(li);
+ setGangMemberTaskDescription(memberObj, taskName); //Initialize description
+ updateGangMemberDisplayElement(memberObj);
+}
+
+function updateGangMemberDisplayElement(memberObj) {
+ if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ var name = memberObj.name;
+
+ //TODO Add upgrade information
+ var stats = document.getElementById(name + "gang-member-stats-text");
+ if (stats) {
+ stats.innerHTML =
+ "Hacking: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.hack, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.hack_exp).format('(0.00a)') + " exp)
" +
+ "Strength: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.str, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.str_exp).format('(0.00a)') + " exp)
" +
+ "Defense: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.def, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.def_exp).format('(0.00a)') + " exp)
" +
+ "Dexterity: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.dex, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.dex_exp).format('(0.00a)') + " exp)
" +
+ "Agility: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.agi, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.agi_exp).format('(0.00a)') + " exp)
" +
+ "Charisma: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.cha, 0) + " (" + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(memberObj.cha_exp).format('(0.00a)') + " exp)
";
+ }
+
+ var gainInfo = document.getElementById(name + "gang-member-gain-info");
+ if (gainInfo) {
+ gainInfo.innerHTML =
+ "Money: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateMoneyGain(), 2) + " / sec
" +
+ "Respect: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateRespectGain(), 6) + " / sec
" +
+ "Wanted Level: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(5*memberObj.calculateWantedLevelGain(), 6) + " / sec
";
}
}
-function createPlayerHacknetNodeWrappers() {
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] = new HacknetNodeWrapper(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+function setGangMemberTaskDescription(memberObj, taskName) {
+ var name = memberObj.name;
+ var taskDesc = document.getElementById(name + "gang-member-task-description");
+ if (taskDesc) {
+ var task = GangMemberTasks[taskName];
+ if (task == null) {return;}
+ var desc = task.desc;
+ taskDesc.innerHTML = desc;
}
}
-function updatePlayerHacknetNodeWrappers() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length !== _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length) {
- return createPlayerHacknetNodeWrappers();
- }
+function deleteGangDisplayContent() {
+ if (gangContainer != null) {Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElementById"])(gangContainer.id);}
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length; ++i) {
- if (!(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] instanceof HacknetNodeWrapper)) {
- return createPlayerHacknetNodeWrappers();
- }
+ gangContentCreated = false;
+ gangContainer = null;
+ managementButton = null;
+ territoryButton = null;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].level = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].level;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].ram = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].ram;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].cores = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].cores;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].totalMoneyGenerated = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].totalMoneyGenerated;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].onlineTimeSeconds = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].onlineTimeSeconds;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].moneyGainRatePerSecond = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
- }
-}
+ //Subpages
+ gangManagementSubpage = null;
+ gangTerritorySubpage = null;
-function processAllHacknetNodeEarnings(numCycles) {
- var total = 0;
- updatePlayerHacknetNodeWrappers();
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- total += processSingleHacknetNodeEarnings(numCycles, _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
+ //Gang Management Elements
+ gangDesc = null;
+ gangInfo = null;
+ gangRecruitMemberButton = null;
+ gangRecruitRequirementText = null;
+ gangExpandAllButton = null;
+ gangCollapseAllButton = null;
+ gangMemberFilter = null;
+ gangManageEquipmentButton = null;
+ gangMemberList = null;
- return total;
-}
-
-function processSingleHacknetNodeEarnings(numCycles, nodeObj) {
- var cyclesPerSecond = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed;
- var earningPerCycle = nodeObj.moneyGainRatePerSecond / cyclesPerSecond;
- if (isNaN(earningPerCycle)) {
- console.error("Hacknet Node '" + nodeObj.name + "' Calculated earnings is NaN");
- earningPerCycle = 0;
- }
-
- var totalEarnings = numCycles * earningPerCycle;
- nodeObj.totalMoneyGenerated += totalEarnings;
- nodeObj.onlineTimeSeconds += (numCycles * (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed / 1000));
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainMoney(totalEarnings);
- return totalEarnings;
-}
-
-function getHacknetNode(name) {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].name == name) {
- return _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i];
- }
- }
-
- return null;
+ //Gang Equipment Upgrade Elements
+ gangMemberUpgradeBox = null;
+ gangMemberUpgradeBoxContent = null;
+ gangMemberUpgradeBoxFilter = null;
+ gangMemberUpgradeBoxElements = null;
}
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 37 */
+/* 34 */
+/*!************************!*\
+ !*** ./src/RedPill.js ***!
+ \************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "redPillFlag", function() { return redPillFlag; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hackWorldDaemon", function() { return hackWorldDaemon; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
-/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(56);
-/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(40);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(21);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(12);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Prestige.js */ 53);
+/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SourceFile.js */ 38);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 18);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
@@ -42506,10 +36173,4095 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 38 */
+/* 35 */
+/*!****************************!*\
+ !*** ./src/Bladeburner.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bladeburner", function() { return Bladeburner; });
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./RedPill.js */ 34);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Terminal.js */ 18);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12__);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
+
+var CyclesPerSecond = 5; //Game cycle is 200 ms
+
+var StaminaGainPerSecond = 0.0085;
+var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty
+var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain
+
+var 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
+var DiffMultExponentialFactor = 0.28;
+var DiffMultLinearFactor = 650;
+
+var EffAgiLinearFactor = 90e3;
+var EffDexLinearFactor = 90e3;
+var EffAgiExponentialFactor = 0.031;
+var EffDexExponentialFactor = 0.03;
+
+var BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action
+
+var PopulationThreshold = 1e9; //Population at which success rates start being affected
+var ChaosThreshold = 50; //City chaos level after which it starts making tasks harder
+
+var BaseStatGain = 1; //Base stat gain per second
+var BaseIntGain = 0.001; //Base intelligence stat gain
+
+var ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value
+
+var RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank
+var RankNeededForFaction = 25;
+
+var ContractSuccessesPerLevel = 3; //How many successes you need to level up a contract
+var OperationSuccessesPerLevel = 2.5; //How many successes you need to level up an op
+
+var RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point
+
+var ContractBaseMoneyGain = 10e3; //Base Money Gained per contract
+
+//DOM related variables
+var ActiveActionCssClass = "bladeburner-active-action";
+
+//Console related stuff
+var consoleHistory = []; //Console command history
+var consoleHistoryIndex = 0;
+var consoleHelpText = {
+ helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.
" +
+ "automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks
" +
+ "clear/cls Clear the console
" +
+ "help [cmd] Display this help text, or help text for a specific command
" +
+ "log [en/dis] [type] Enable or disable logging for events and actions
" +
+ "skill [action] [name] Level or display info about your Bladeburner skills
" +
+ "start [type] [name] Start a Bladeburner action/task
" +
+ "stop Stops your current Bladeburner action/task
",
+ automate:"automate [var] [val] [hi/low]
" +
+ "A simple way to automate your Bladeburner actions. This console command can be used " +
+ "to automatically start an action when your stamina rises above a certain threshold, and " +
+ "automatically switch to another action when your stamina drops below another threshold.
" +
+ "automate status - Check the current status of your automation and get a brief description of what it'll do
" +
+ "automate en - Enable the automation feature
" +
+ "automate dis - Disable the automation feature
" +
+ "There are four properties that must be set for this automation to work properly. Here is how to set them:
" +
+ "automate stamina 100 high
" +
+ "automate contract Tracking high
" +
+ "automate stamina 50 low
" +
+ 'automate general "Field Analysis" low
' +
+ "Using the four console commands above will set the automation to perform Tracking contracts " +
+ "if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below " +
+ "50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must " +
+ "exactly match whatever the name is in the UI.",
+ clear:"clear
Clears the console",
+ cls:"cls
Clears the console",
+ help:"help [command]
" +
+ "Running 'help' with no arguments displays the general help text, which lists all console commands " +
+ "and a brief description of what they do. A command can be specified to get more specific help text " +
+ "about that particular command. For example:
" +
+ "help automate
" +
+ "will display specific information about using the automate console command",
+ log:"log [en/dis] [type]
" +
+ "Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged " +
+ "in the console. There are also random events that are logged in the console as well. The five categories of " +
+ "things that get logged are:
" +
+ "[general, contracts, ops, blackops, events]
" +
+ "The logging for these categories can be enabled or disabled like so:
" +
+ "log dis contracts - Disables logging that occurs when contracts are completed
" +
+ "log en contracts - Enables logging that occurs when contracts are completed
" +
+ "log dis events - Disables logging for Bladeburner random events
" +
+ "Logging can be universally enabled/disabled using the 'all' keyword:
" +
+ "log dis all
" +
+ "log en all",
+ skill:"skill [action] [name]
" +
+ "Level or display information about your skills.
" +
+ "To display information about all of your skills and your multipliers, use:
" +
+ "skill list
" +
+ "To display information about a specific skill, specify the name of the skill afterwards. " +
+ "Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If " +
+ "the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
" +
+ "skill list Reaper
" +
+ 'skill list "Digital Observer"
' +
+ "This console command can also be used to level up skills:
" +
+ "skill level [skill name]",
+ start:"start [type] [name]
" +
+ "Start an action. An action is specified by its type and its name. The " +
+ "name is case-sensitive. It must appear exactly as it does in the UI. If " +
+ "the name of the action has whitespace, enclose it in double quotation marks. " +
+ "Valid action types include:
" +
+ "[general, contract, op, blackop]
" +
+ "Examples:
" +
+ 'start contract Tracking
' +
+ 'start op "Undercover Operation"
',
+ stop:"stop
" +
+ "Stop your current action and go idle",
+}
+
+//Keypresses for Console
+$(document).keydown(function(event) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
+ //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
+ // DomElems.consoleInput.focus();
+ //}
+
+ if (!(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner instanceof Bladeburner)) {return;}
+
+ //NOTE: Keycodes imported from Terminal.js
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].ENTER) {
+ event.preventDefault();
+ var command = DomElems.consoleInput.value;
+ if (command.length > 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.postToConsole("> " + command);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.resetConsoleInput();
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner.executeConsoleCommands(command);
+ }
+ }
+
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].UPARROW) {
+ if (DomElems.consoleInput == null) {return;}
+ var i = consoleHistoryIndex;
+ var len = consoleHistory.length;
+
+ if (len === 0) {return;}
+ if (i < 0 || i > len) {
+ consoleHistoryIndex = len;
+ }
+
+ if (i !== 0) {
+ --consoleHistoryIndex;
+ }
+
+ var prevCommand = consoleHistory[consoleHistoryIndex];
+ DomElems.consoleInput.value = prevCommand;
+ setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);
+ }
+
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_8__["KEY"].DOWNARROW) {
+ if (DomElems.consoleInput == null) {return;}
+ var i = consoleHistoryIndex;
+ var len = consoleHistory.length;
+
+ if (len == 0) {return;}
+ if (i < 0 || i > len) {
+ consoleHistoryIndex = len;
+ }
+
+ //Latest command, put nothing
+ if (i == len || i == len-1) {
+ consoleHistoryIndex = len;
+ DomElems.consoleInput.value = "";
+ } else {
+ ++consoleHistoryIndex;
+ var prevCommand = consoleHistory[consoleHistoryIndex];
+ DomElems.consoleInput.value = prevCommand;
+ }
+ }
+ }
+});
+
+function City(params={}) {
+ this.name = params.name ? params.name : _Location_js__WEBPACK_IMPORTED_MODULE_5__["Locations"].Sector12;
+
+ //Synthoid population and estimate
+ this.pop = params.pop ? params.pop : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(800e6, 1.2*PopulationThreshold);
+ this.popEst = this.pop * (Math.random() + 0.5);
+
+ //Number of Synthoid communities population and estimate
+ this.comms = params.comms ? params.comms : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 40);
+ this.commsEst = this.comms + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-2, 2);
+ if (this.commsEst < 0) {this.commsEst = 0;}
+ this.chaos = 0;
+}
+
+City.prototype.improvePopulationEstimateByCount = function(n) {
+ if (isNaN(n)) {throw new Error("NaN passeed into City.improvePopulationEstimateByCount()");}
+ if (this.popEst < this.pop) {
+ this.popEst += n;
+ if (this.popEst > this.pop) {this.popEst = this.pop;}
+ } else if (this.popEst > this.pop) {
+ this.popEst -= n;
+ if (this.popEst < this.pop) {this.popEst = this.pop;}
+ }
+}
+
+//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
+City.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {
+ p = p*skillMult;
+ if (isNaN(p)) {throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()");}
+ if (this.popEst < this.pop) {
+ ++this.popEst; //In case estimate is 0
+ this.popEst *= (1 + (p/100));
+ if (this.popEst > this.pop) {this.popEst = this.pop;}
+ } else if (this.popEst > this.pop) {
+ this.popEst *= (1 - (p/100));
+ if (this.popEst < this.pop) {this.popEst = this.pop;}
+ }
+}
+
+City.prototype.improveCommunityEstimate = function(n=1) {
+ if (isNaN(n)) {throw new Error("NaN passed into City.improveCommunityEstimate()");}
+ if (this.commsEst < this.comms) {
+ this.commsEst += n;
+ if (this.commsEst > this.comms) {this.commsEst = this.comms;}
+ } else if (this.commsEst > this.comms) {
+ this.commsEst -= n;
+ if (this.commsEst < this.comms) {this.commsEst = this.comms;}
+ }
+}
+
+//@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;
+ if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}
+ if (params.estOffset) {
+ this.popEst = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(this.popEst, params.estOffset);
+ }
+ 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
+City.prototype.changePopulationByPercentage = function(p, params={}) {
+ if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
+ if (p === 0) {return;}
+ var change = Math.round(this.pop * (p/100));
+
+ //Population always changes by at least 1
+ if (params.nonZero && change === 0) {
+ p > 0 ? change = 1 : change = -1;
+ }
+
+ this.pop += change;
+ if (params.changeEstEqually) {
+ this.popEst += change;
+ if (this.popEst < 0) {this.popEst = 0;}
+ }
+ return change;
+}
+
+City.prototype.changeChaosByCount = function(n) {
+ if (isNaN(n)) {throw new Error("NaN passed into City.changeChaosByCount()");}
+ if (n === 0) {return;}
+ this.chaos += n;
+ if (this.chaos < 0) {this.chaos = 0;}
+}
+
+//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
+City.prototype.changeChaosByPercentage = function(p) {
+ if (isNaN(p)) {throw new Error("NaN passed into City.chaosChaosByPercentage()");}
+ if (p === 0) {return;}
+ var change = this.chaos * (p/100);
+ this.chaos += change;
+ if (this.chaos < 0) {this.chaos = 0;}
+}
+
+City.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("City", this);
+}
+City.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(City, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.City = City;
+
+function Skill(params={name:"foo", desc:"foo"}) {
+ if (params.name) {
+ this.name = params.name;
+ } else {
+ throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor");
+ }
+ if (params.desc) {
+ this.desc = params.desc;
+ } else {
+ throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor");
+ }
+ this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points
+ this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level
+
+ if (params.maxLvl) {this.maxLvl = params.maxLvl;}
+
+ //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
+ if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
+
+ if (params.actionTime) {this.actionTime = params.actionTime;}
+ if (params.effHack) {this.effHack = params.effHack;}
+ if (params.effStr) {this.effStr = params.effStr;}
+ if (params.effDef) {this.effDef = params.effDef;}
+ if (params.effDex) {this.effDex = params.effDex;}
+ if (params.effAgi) {this.effAgi = params.effAgi;}
+ if (params.effCha) {this.effCha = params.effCha;}
+
+ if (params.stamina) {this.stamina = params.stamina;}
+
+ //Equipment
+ 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)) * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerSkillCost;
+}
+var Skills = {};
+var SkillNames = {
+ BladesIntuition: "Blade's Intuition",
+ Reaper: "Reaper",
+ Cloak: "Cloak",
+ Marksman: "Marksman",
+ WeaponProficiency: "Weapon Proficiency",
+ Overclock: "Overclock",
+ EvasiveSystem: "Evasive System",
+ ShortCircuit: "Short-Circuit",
+ DigitalObserver: "Digital Observer",
+ Datamancer: "Datamancer",
+ Tracer: "Tracer",
+ CybersEdge: "Cyber's Edge"
+}
+
+//Base Class for Contracts, Operations, and BlackOps
+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
+ this.level = 1;
+ this.maxLevel = 1;
+ this.autoLevel = true;
+ this.baseDifficulty = params.baseDifficulty ? Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(params.baseDifficulty, 10) : 100;
+ this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;
+
+ //Rank increase/decrease is affected by this exponent
+ this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;
+
+ this.successes = 0;
+ this.failures = 0;
+
+ //All of these scale with level/difficulty
+ this.rankGain = params.rankGain ? params.rankGain : 0;
+ if (params.rankLoss) {this.rankLoss = params.rankLoss;}
+ if (params.hpLoss) {
+ this.hpLoss = params.hpLoss;
+ this.hpLost = 0;
+ }
+
+ //Action Category. Current categories are stealth and kill
+ 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"
+ this.count = params.count ? params.count : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1e3, 25e3);
+ this.countGrowth = params.countGrowth ? params.countGrowth : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5);
+
+ //Weighting of each stat in determining action success rate
+ var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};
+ this.weights = params.weights ? params.weights : defaultWeights;
+
+ //Check to make sure weights are summed properly
+ var sum = 0;
+ for (var weight in this.weights) {
+ if (this.weights.hasOwnProperty(weight)) {
+ sum += this.weights[weight];
+ }
+ }
+ if (sum - 1 >= 10 * Number.EPSILON) {
+ throw new Error("Invalid weights when constructing Action " + this.name +
+ ". The weights should sum up to 1. They sum up to :" + 1);
+ }
+
+ //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};
+ this.decays = params.decays ? params.decays : defaultDecays;
+ for (var decay in this.decays) {
+ if (this.decays.hasOwnProperty(decay)) {
+ if (this.decays[decay] > 1) {
+ throw new Error("Invalid decays when constructing " +
+ "Action " + this.name + ". " +
+ "Decay value cannot be greater than 1");
+ }
+ }
+ }
+}
+
+Action.prototype.getDifficulty = function() {
+ var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);
+ if (isNaN(difficulty)) {throw new Error("Calculated NaN in Action.getDifficulty()");}
+ return difficulty;
+}
+
+//@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();
+ var competence = 0;
+ for (var stat in this.weights) {
+ if (this.weights.hasOwnProperty(stat)) {
+ var playerStatLvl = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queryStatFromString(stat);
+ var key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
+ var effMultiplier = inst.skillMultipliers[key];
+ if (effMultiplier == null) {
+ console.log("ERROR: Failed to find Bladeburner Skill multiplier for: " + stat);
+ effMultiplier = 1;
+ }
+ competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));
+ }
+ }
+ competence *= inst.calculateStaminaPenalty();
+
+ //For Operations, factor in team members
+ if (this instanceof Operation || this instanceof BlackOperation) {
+ if (this.teamCount && this.teamCount > 0) {
+ this.teamCount = Math.min(this.teamCount, inst.teamSize);
+ var teamMultiplier = Math.pow(this.teamCount, 0.05);
+ competence *= teamMultiplier;
+ }
+ }
+
+ //Lower city population results in lower chances
+ if (!(this instanceof BlackOperation)) {
+ var city = inst.getCurrentCity();
+ if (params.est) {
+ competence *= (city.popEst / PopulationThreshold);
+ } else {
+ competence *= (city.pop / PopulationThreshold);
+ }
+
+ //Too high of a chaos results in lower chances
+ if (city.chaos > ChaosThreshold) {
+ var diff = 1 + (city.chaos - ChaosThreshold);
+ var mult = Math.pow(diff, 0.1);
+ difficulty *= mult;
+ }
+
+ //For Raid Operations, no communities = fail
+ if (this instanceof Operation && this.name === "Raid") {
+ if (city.comms <= 0) {return 0;}
+ }
+ }
+
+ //Factor skill multipliers into success chance
+ competence *= inst.skillMultipliers.successChanceAll;
+ if (this instanceof Operation || this instanceof BlackOperation) {
+ competence *= inst.skillMultipliers.successChanceOperation;
+ }
+ if (this instanceof Contract) {
+ competence *= inst.skillMultipliers.successChanceContract;
+ }
+ if (this.isStealth) {
+ competence *= inst.skillMultipliers.successChanceStealth;
+ }
+ if (this.isKill) {
+ competence *= inst.skillMultipliers.successChanceKill;
+ }
+
+ //Augmentation multiplier
+ competence *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult;
+
+ if (isNaN(competence)) {throw new Error("Competence calculated as NaN in Action.getSuccessChance()");}
+ return Math.min(1, competence / difficulty);
+}
+
+//Tests for success. Should be called when an action has completed
+// @inst - Bladeburner Object
+Action.prototype.attempt = function(inst) {
+ return (Math.random() < this.getSuccessChance(inst));
+}
+
+Action.prototype.getActionTime = function(inst) {
+ var difficulty = this.getDifficulty();
+ var baseTime = difficulty / DifficultyToTimeFactor;
+ var skillFac = inst.skillMultipliers.actionTime; //Always < 1
+
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * inst.skillMultipliers.effAgi;
+ var effDexterity = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity * inst.skillMultipliers.effDex;
+ var statFac = 0.5 * (Math.pow(effAgility, EffAgiExponentialFactor) +
+ Math.pow(effDexterity, EffDexExponentialFactor) +
+ (effAgility / EffAgiLinearFactor) +
+ (effDexterity / EffDexLinearFactor)); //Always > 1
+
+ baseTime = Math.max(1, baseTime * skillFac / statFac);
+
+ if (this instanceof Contract) {
+ return Math.ceil(baseTime);
+ } else if (this instanceof Operation) {
+ return Math.ceil(baseTime);
+ } else if (this instanceof BlackOperation) {
+ return Math.ceil(baseTime * 1.5);
+ } else {
+ throw new Error("Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation");
+ }
+}
+
+Action.prototype.getSuccessesNeededForNextLevel = function(baseSuccessesPerLevel) {
+ return Math.ceil((0.5) * (this.maxLevel) * (2 * baseSuccessesPerLevel + (this.maxLevel-1)));
+}
+
+Action.prototype.setMaxLevel = function(baseSuccessesPerLevel) {
+ if (this.successes >= this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel)) {
+ ++this.maxLevel;
+ }
+}
+
+Action.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Action", this);
+}
+Action.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Action, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Action = Action;
+var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
+
+//Action Identifier
+var ActionTypes = Object.freeze({
+ "Idle": 1,
+ "Contract": 2,
+ "Operation": 3,
+ "BlackOp": 4,
+ "BlackOperation": 4,
+ "Training": 5,
+ "Recruitment": 6,
+ "FieldAnalysis": 7,
+ "Field Analysis": 7
+});
+function ActionIdentifier(params={}) {
+ if (params.name) {this.name = params.name;}
+ if (params.type) {this.type = params.type;}
+}
+ActionIdentifier.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("ActionIdentifier", this);
+}
+ActionIdentifier.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(ActionIdentifier, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.ActionIdentifier = ActionIdentifier;
+
+//Contracts
+function Contract(params={}) {
+ Action.call(this, params);
+}
+Contract.prototype = Object.create(Action.prototype);
+Contract.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Contract", this);
+}
+Contract.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Contract, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Contract = Contract;
+
+//Operations
+function Operation(params={}) {
+ Action.call(this, 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 Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Operation", this);
+}
+Operation.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Operation, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Operation = Operation;
+
+//Black Operations
+function BlackOperation(params={}) {
+ Operation.call(this, params);
+
+ //Black ops are one time missions
+ this.count = 1;
+ this.countGrowth = 0;
+}
+BlackOperation.prototype = Object.create(Action.prototype);
+BlackOperation.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("BlackOperation", this);
+}
+BlackOperation.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(BlackOperation, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.BlackOperation = BlackOperation;
+var BlackOperations = {};
+
+function Bladeburner(params={}) {
+ this.numHosp = 0; //Number of hospitalizations
+ this.moneyLost = 0; //Money lost due to hospitalizations
+ this.rank = 0;
+ this.maxRank = 0; //Used to determine skill points
+
+ this.skillPoints = 0;
+ this.totalSkillPoints = 0;
+
+ this.teamSize = 0; //Number of team members
+ this.teamLost = 0; //Number of team members lost
+
+ this.storedCycles = 0;
+
+ this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 600); //5-10 minutes
+
+ //These times are in seconds
+ this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)
+ this.actionTimeCurrent = 0;
+
+ //ActionIdentifier Object
+ var idleActionType = ActionTypes["Idle"];
+ this.action = new ActionIdentifier({type:idleActionType});
+
+ this.cities = {};
+ for (var i = 0; i < CityNames.length; ++i) {
+ this.cities[CityNames[i]] = new City({name:CityNames[i]});
+ }
+ this.city = _Location_js__WEBPACK_IMPORTED_MODULE_5__["Locations"].Sector12;
+
+ //Map of SkillNames -> level
+ this.skills = {};
+ this.skillMultipliers = {};
+ this.updateSkillMultipliers(); //Calls resetSkillMultipliers()
+
+ //Max Stamina is based on stats and Bladeburner-specific bonuses
+ this.staminaBonus = 0; //Gained from training
+ this.maxStamina = 0;
+ 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.
+ this.contracts = {};
+ this.operations = {};
+
+ //Object that contains name of all Black Operations that have been completed
+ this.blackops = {};
+
+ //Flags for whether these actions should be logged to console
+ this.logging = {
+ general:true,
+ contracts:true,
+ ops:true,
+ blackops:true,
+ events:true,
+ }
+
+ //Simple automation values
+ this.automateEnabled = false;
+ this.automateActionHigh = 0;
+ this.automateThreshHigh = 0; //Stamina Threshold
+ this.automateActionLow = 0;
+ this.automateThreshLow = 0; //Stamina Threshold
+
+ //Initialization
+ initBladeburner();
+ this.initializeDomElementRefs();
+ if (params.new) {this.create();}
+}
+
+Bladeburner.prototype.prestige = function() {
+ this.resetAction();
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"]["Bladeburners"];
+ if (this.rank >= RankNeededForFaction) {
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
+ }
+}
+
+Bladeburner.prototype.create = function() {
+ this.contracts["Tracking"] = new Contract({
+ name:"Tracking",
+ desc:"Identify and locate Synthoids. This contract involves reconnaissance " +
+ "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
" +
+ "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " +
+ "whatever city you are currently in.",
+ baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,
+ rankGain:0.3, hpLoss:0.5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5),
+ weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},
+ isStealth:true
+ });
+ this.contracts["Bounty Hunter"] = new Contract({
+ name:"Bounty Hunter",
+ desc:"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
" +
+ "Successfully completing a Bounty Hunter contract will lower the population in your " +
+ "current city, and will also increase its chaos level.",
+ baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,
+ rankGain:0.9, hpLoss:1,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 3),
+ weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
+ isKill:true
+ });
+ this.contracts["Retirement"] = new Contract({
+ name:"Retirement",
+ desc:"Hunt down and retire (kill) rogue Synthoids.
" +
+ "Successfully copmleting a Retirement contract will lower the population in your current " +
+ "city, and will also increase its chaos level.",
+ baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,
+ rankGain:0.6, hpLoss:1,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1,4),
+ weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
+ isKill:true
+ });
+
+ this.operations["Investigation"] = new Operation({
+ name:"Investigation",
+ desc:"As a field agent, investigate and identify Synthoid " +
+ "populations, movements, and operations.
Successful " +
+ "Investigation ops will increase the accuracy of your " +
+ "synthoid data.
" +
+ "You will NOT lose HP from failed Investigation ops.",
+ baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,
+ rankGain:2, rankLoss:0.2,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(50, 400), countGrowth:1,
+ weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},
+ decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Undercover Operation"] = new Operation({
+ name:"Undercover Operation",
+ desc:"Conduct undercover operations to identify hidden " +
+ "and underground Synthoid communities and organizations.
" +
+ "Successful Undercover ops will increase the accuracy of your synthoid " +
+ "data.",
+ baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,
+ rankGain:4, rankLoss:0.4, hpLoss:2,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(50, 300), countGrowth:1,
+ weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},
+ decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Sting Operation"] = new Operation({
+ name:"Sting Operation",
+ desc:"Conduct a sting operation to bait and capture particularly " +
+ "notorious Synthoid criminals.",
+ baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,
+ rankGain:5, rankLoss:0.5, hpLoss:2.5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25,400), countGrowth:0.75,
+ weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},
+ decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Raid"] = new Operation({
+ name:"Raid",
+ desc:"Lead an assault on a known Synthoid community. Note that " +
+ "there must be an existing Synthoid community in your current city " +
+ "in order for this Operation to be successful",
+ baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,
+ rankGain:50,rankLoss:2.5,hpLoss:50,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 150), countGrowth:0.2,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
+ isKill:true
+ });
+ this.operations["Stealth Retirement Operation"] = new Operation({
+ name:"Stealth Retirement Operation",
+ desc:"Lead a covert operation to retire Synthoids. The " +
+ "objective is to complete the task without " +
+ "drawing any attention. Stealth and discretion are key.",
+ baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,
+ rankGain:20, rankLoss:2, hpLoss:10,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 250), countGrowth:0.1,
+ weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
+ decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
+ isStealth:true, isKill:true
+ });
+ this.operations["Assassination"] = new Operation({
+ name:"Assassination",
+ desc:"Assassinate Synthoids that have been identified as " +
+ "important, high-profile social and political leaders " +
+ "in the Synthoid communities.",
+ baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,
+ rankGain:40, rankLoss:4, hpLoss:5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(25, 200), countGrowth:0.1,
+ weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},
+ isStealth:true, isKill:true
+ });
+}
+
+Bladeburner.prototype.storeCycles = function(numCycles=1) {
+ this.storedCycles += numCycles;
+}
+
+Bladeburner.prototype.process = function() {
+ //Extreme condition...if Operation Daedalus is complete trigger the BitNode
+ if (_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["redPillFlag"] === false && this.blackops.hasOwnProperty("Operation Daedalus")) {
+ return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN);
+ }
+
+ //If the Player starts doing some other actions, set action to idle and alert
+ if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].BladesSimulacrum].owned === false && _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].isWorking) {
+ if (this.action.type !== ActionTypes["Idle"]) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Your Bladeburner action was cancelled because you started " +
+ "doing something else");
+ }
+ this.resetAction();
+ }
+
+ //A 'tick' for this mechanic is one second (= 5 game cycles)
+ if (this.storedCycles >= CyclesPerSecond) {
+ var seconds = Math.floor(this.storedCycles / CyclesPerSecond);
+ seconds = Math.min(seconds, 5); //Max of 5 'ticks'
+ this.storedCycles -= seconds * CyclesPerSecond;
+
+ //Stamina
+ this.calculateMaxStamina();
+ this.stamina += (this.calculateStaminaGainPerSecond() * seconds);
+ this.stamina = Math.min(this.maxStamina, this.stamina);
+
+ //Count increase for contracts/operations
+ for (var contractName in this.contracts) {
+ if (this.contracts.hasOwnProperty(contractName)) {
+ var contract = this.contracts[contractName];
+ contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);
+ }
+ }
+ for (var operationName in this.operations) {
+ if (this.operations.hasOwnProperty(operationName)) {
+ var op = this.operations[operationName];
+ op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);
+ }
+ }
+
+ //Chaos goes down very slowly
+ for (var i = 0; i < CityNames.length; ++i) {
+ var city = this.cities[CityNames[i]];
+ if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
+ city.chaos -= (0.0001 * seconds);
+ city.chaos = Math.max(0, city.chaos);
+ }
+
+ //Random Events
+ this.randomEventCounter -= seconds;
+ if (this.randomEventCounter <= 0) {
+ this.randomEvent();
+ this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(300, 600);
+ }
+
+ this.processAction(seconds);
+
+ //Automation
+ if (this.automateEnabled) {
+ if (this.stamina <= this.automateThreshLow) {
+ if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {
+ this.action = this.automateActionLow;
+ this.startAction(this.action);
+ }
+ } else if (this.stamina >= this.automateThreshHigh) {
+ if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {
+ this.action = this.automateActionHigh;
+ this.startAction(this.action);
+ }
+ }
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
+ this.updateContent();
+ }
+ }
+}
+
+Bladeburner.prototype.calculateMaxStamina = function() {
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * this.skillMultipliers.effAgi;
+ var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);
+ maxStamina *= this.skillMultipliers.stamina;
+ maxStamina *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult;
+ if (isNaN(maxStamina)) {throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()");}
+ this.maxStamina = maxStamina;
+}
+
+Bladeburner.prototype.calculateStaminaGainPerSecond = function() {
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility * this.skillMultipliers.effAgi;
+ var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;
+ var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);
+ return gain * (this.skillMultipliers.stamina * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult);
+}
+
+Bladeburner.prototype.calculateStaminaPenalty = function() {
+ return Math.min(1, this.stamina / (0.5 * this.maxStamina));
+}
+
+Bladeburner.prototype.changeRank = function(change) {
+ if (isNaN(change)) {throw new Error("NaN passed into Bladeburner.changeRank()");}
+ this.rank += change;
+ if (this.rank < 0) {this.rank = 0;}
+ this.maxRank = Math.max(this.rank, this.maxRank);
+
+ var bladeburnersFactionName = "Bladeburners";
+ if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["factionExists"])(bladeburnersFactionName)) {
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"][bladeburnersFactionName];
+ if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Faction"])) {
+ throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
+ }
+ if (bladeburnerFac.isMember) {
+ var favorBonus = 1 + (bladeburnerFac.favor / 100);
+ bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult * favorBonus);
+ }
+ }
+
+ //Gain skill points. You get 1 every 4 ranks
+ var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;
+ if (this.maxRank >= rankNeededForSp) {
+ //Calculate how many skill points to gain
+ var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);
+ this.skillPoints += gainedSkillPoints;
+ this.totalSkillPoints += gainedSkillPoints;
+ }
+}
+
+Bladeburner.prototype.getCurrentCity = function() {
+ var city = this.cities[this.city];
+ if (!(city instanceof City)) {
+ throw new Error("Bladeburner.getCurrentCity() did not properly return a City object");
+ }
+ return city;
+}
+
+Bladeburner.prototype.resetSkillMultipliers = function() {
+ this.skillMultipliers = {
+ successChanceAll:1,
+ successChanceStealth:1,
+ successChanceKill:1,
+ successChanceContract:1,
+ successChanceOperation:1,
+ successChanceEstimate:1,
+ actionTime:1,
+ effHack:1,
+ effStr:1,
+ effDef:1,
+ effDex:1,
+ effAgi:1,
+ effCha:1,
+ effInt:1,
+ stamina:1,
+ weaponAbility:1,
+ gunAbility:1,
+ };
+}
+
+Bladeburner.prototype.updateSkillMultipliers = function() {
+ this.resetSkillMultipliers();
+ for (var skillName in this.skills) {
+ if (this.skills.hasOwnProperty(skillName)) {
+ var skill = Skills[skillName];
+ if (skill == null) {
+ throw new Error("Could not find Skill Object for: " + skillName);
+ }
+ var level = this.skills[skillName];
+ if (level == null || level <= 0) {continue;} //Not upgraded
+
+ var multiplierNames = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multiplierNames.length; ++i) {
+ var multiplierName = multiplierNames[i];
+ if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {
+ var value = skill[multiplierName] * level;
+ var multiplierValue = 1 + (value / 100);
+ if (multiplierName === "actionTime") {
+ multiplierValue = 1 - (value / 100);
+ }
+ this.skillMultipliers[multiplierName] *= multiplierValue;
+ }
+ }
+ }
+ }
+}
+
+Bladeburner.prototype.upgradeSkill = function(skill) {
+ //This does NOT handle deduction of skill points
+ var skillName = skill.name;
+ if (this.skills[skillName]) {
+ ++this.skills[skillName];
+ } else {
+ this.skills[skillName] = 1;
+ }
+ if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {
+ throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]);
+ }
+ this.updateSkillMultipliers();
+}
+
+Bladeburner.prototype.getActionObject = function(actionId) {
+ //Given an ActionIdentifier object, returns the corresponding
+ //Contract, Operation, or BlackOperation object
+ switch (actionId.type) {
+ case ActionTypes["Contract"]:
+ return this.contracts[actionId.name];
+ break;
+ case ActionTypes["Operation"]:
+ return this.operations[actionId.name];
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ return BlackOperations[actionId.name];
+ break;
+ default:
+ return null;
+ console.log("WARNING: Bladeburner.getActionObject() called with an unexpected " +
+ "ActionIdentifier type: " + actionId.type);
+ }
+}
+
+//Sets the player to the "IDLE" action
+Bladeburner.prototype.resetAction = function() {
+ this.action = new ActionIdentifier({type:ActionTypes.Idle});
+}
+
+Bladeburner.prototype.startAction = function(actionId) {
+ if (actionId == null) {return;}
+ this.action = actionId;
+ this.actionTimeCurrent = 0;
+ switch (actionId.type) {
+ case ActionTypes["Idle"]:
+ this.actionTimeToComplete = 0;
+ break;
+ case ActionTypes["Contract"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error("Failed to get Contract Object for: " + actionId.name);
+ }
+ if (action.count < 1) {return this.resetAction();}
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Operation"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error ("Failed to get Operation Object for: " + actionId.name);
+ }
+ if (action.count < 1) {return this.resetAction();}
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error("Failed to get BlackOperation object for: " + actionId.name);
+ }
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Training"]:
+ this.actionTimeToComplete = 30;
+ break;
+ case ActionTypes["Recruitment"]:
+ this.actionTimeToComplete = this.getRecruitmentTime();
+ break;
+ case ActionTypes["FieldAnalysis"]:
+ case ActionTypes["Field Analysis"]:
+ this.actionTimeToComplete = 30;
+ break;
+ default:
+ throw new Error("Invalid Action Type in Bladeburner.startAction(): " + actionId.type);
+ break;
+ }
+}
+
+Bladeburner.prototype.processAction = function(seconds) {
+ if (this.action.type === ActionTypes["Idle"]) {return;}
+ if (this.actionTimeToComplete <= 0) {
+ console.log("action.type: " + this.action.type);
+ throw new Error("Invalid actionTimeToComplete value: " + this.actionTimeToComplete);
+ }
+ if (!(this.action instanceof ActionIdentifier)) {
+ throw new Error("Bladeburner.action is not an ActionIdentifier Object");
+ }
+
+ this.actionTimeCurrent += seconds;
+ if (this.actionTimeCurrent >= this.actionTimeToComplete) {
+ return this.completeAction();
+ }
+}
+
+Bladeburner.prototype.completeAction = function() {
+ switch (this.action.type) {
+ case ActionTypes["Contract"]:
+ case ActionTypes["Operation"]:
+ try {
+ var isOperation = (this.action.type === ActionTypes["Operation"]);
+ var action = this.getActionObject(this.action);
+ if (action == null) {
+ throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
+ }
+ var difficulty = action.getDifficulty();
+ var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
+ var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);
+
+ //Stamina loss is based on difficulty
+ this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
+ if (this.stamina < 0) {this.stamina = 0;}
+
+ //Process Contract/Operation success/failure
+ if (action.attempt(this)) {
+ this.gainActionStats(action, true);
+ ++action.successes;
+ --action.count;
+
+ //Earn money for contracts
+ var moneyGain = 0;
+ if (!isOperation) {
+ moneyGain = ContractBaseMoneyGain * rewardMultiplier;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainMoney(moneyGain);
+ }
+
+ if (isOperation) {
+ action.setMaxLevel(OperationSuccessesPerLevel);
+ } else {
+ action.setMaxLevel(ContractSuccessesPerLevel);
+ }
+ if (action.rankGain) {
+ var gain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankGain * rewardMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerRank, 10);
+ this.changeRank(gain);
+ if (isOperation && this.logging.ops) {
+ this.log(action.name + " successfully completed! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(gain, 3) + " rank");
+ } else if (!isOperation && this.logging.contracts) {
+ this.log(action.name + " contract successfully completed! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(gain, 3) + " rank and " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(moneyGain).format("$0.000a"));
+ }
+ }
+ isOperation ? this.completeOperation(true) : this.completeContract(true);
+ } else {
+ this.gainActionStats(action, false);
+ ++action.failures;
+ var loss = 0, damage = 0;
+ if (action.rankLoss) {
+ loss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankLoss * rewardMultiplier, 10);
+ this.changeRank(-1 * loss);
+ }
+ if (action.hpLoss) {
+ damage = action.hpLoss * difficultyMultiplier;
+ damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(damage, 10));
+ this.hpLost += damage;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].takeDamage(damage)) {
+ ++this.numHosp;
+ this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].max_hp);
+ }
+ }
+ var logLossText = "";
+ if (loss > 0) {logLossText += "Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(loss, 3) + " rank.";}
+ if (damage > 0) {logLossText += "Took " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(damage, 0) + " damage.";}
+ if (isOperation && this.logging.ops) {
+ this.log(action.name + " failed! " + logLossText);
+ } else if (!isOperation && this.logging.contracts) {
+ this.log(action.name + " contract failed! " + logLossText);
+ }
+ isOperation ? this.completeOperation(false) : this.completeContract(false);
+ }
+ if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel
+ this.startAction(this.action); //Repeat action
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ try {
+ var action = this.getActionObject(this.action);
+ if (action == null || !(action instanceof BlackOperation)) {
+ throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
+ }
+ var difficulty = action.getDifficulty();
+ var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
+
+ //Stamina loss is based on difficulty
+ this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
+ if (this.stamina < 0) {this.stamina = 0;}
+
+ //Team loss variables
+ var teamCount = action.teamCount, teamLossMax;
+
+ if (action.attempt(this)) {
+ this.gainActionStats(action, true);
+ action.count = 0;
+ this.blackops[action.name] = true;
+ var rankGain = 0;
+ if (action.rankGain) {
+ rankGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankGain * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].BladeburnerRank, 10);
+ this.changeRank(rankGain);
+ }
+ teamLossMax = Math.ceil(teamCount/2);
+
+ //Operation Daedalus
+ if (action.name === "Operation Daedalus") {
+ this.resetAction();
+ return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_7__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN);
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
+ this.createActionAndSkillsContent();
+ }
+
+ if (this.logging.blackops) {
+ this.log(action.name + " successful! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(rankGain, 1) + " rank");
+ }
+ } else {
+ this.gainActionStats(action, false);
+ var rankLoss = 0, damage = 0;
+ if (action.rankLoss) {
+ rankLoss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(action.rankLoss, 10);
+ this.changeRank(-1 * rankLoss);
+ }
+ if (action.hpLoss) {
+ damage = action.hpLoss * difficultyMultiplier;
+ damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["addOffset"])(damage, 10));
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].takeDamage(damage)) {
+ ++this.numHosp;
+ this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].max_hp);
+ }
+ }
+ teamLossMax = Math.floor(teamCount);
+
+ if (this.logging.blackops) {
+ this.log(action.name + " failed! Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(rankLoss, 1) + " rank and took" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(damage, 0) + " damage");
+ }
+ }
+
+ this.resetAction(); //Stop regardless of success or fail
+
+ //Calculate team lossses
+ if (teamCount >= 1) {
+ var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, teamLossMax);
+ this.teamSize -= losses;
+ this.teamLost += losses;
+ if (this.logging.blackops) {
+ this.log("You lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(losses, 0) + " team members during " + action.name);
+ }
+ }
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Training"]:
+ this.stamina -= (0.5 * BaseStaminaLoss);
+ var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult,
+ defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult,
+ dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult,
+ agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult,
+ staminaGain = 0.04 * this.skillMultipliers.stamina;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainStrengthExp(strExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDefenseExp(defExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDexterityExp(dexExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainAgilityExp(agiExpGain);
+ this.staminaBonus += (staminaGain);
+ if (this.logging.general) {
+ this.log("Training completed. Gained: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(strExpGain, 1) + " str exp, " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(defExpGain, 1) + " def exp, " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(dexExpGain, 1) + " dex exp, " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(agiExpGain, 1) + " agi exp, " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(staminaGain, 3) + " max stamina");
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ case ActionTypes["FieldAnalysis"]:
+ case ActionTypes["Field Analysis"]:
+ //Does not use stamina. Effectiveness depends on hacking, int, and cha
+ var eff = 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_skill, 0.3) +
+ 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].intelligence, 0.9) +
+ 0.02 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma, 0.3);
+ eff *= _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult;
+ if (isNaN(eff) || eff < 0) {
+ throw new Error("Field Analysis Effectiveness calculated to be NaN or negative");
+ }
+ var hackingExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult,
+ charismaExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainHackingExp(hackingExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainIntelligenceExp(BaseIntGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(charismaExpGain);
+ this.changeRank(0.1);
+ console.log("DEBUG: Field Analysis effectiveness is " + (eff * this.skillMultipliers.successChanceEstimate));
+ this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
+ if (this.logging.general) {
+ this.log("Field analysis completed. Gained 0.1 rank, " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(hackingExpGain, 1) + " hacking exp, and " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(charismaExpGain, 1) + " charisma exp");
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ case ActionTypes["Recruitment"]:
+ var successChance = this.getRecruitmentSuccessChance();
+ console.log("Bladeburner recruitment success chance: " + successChance);
+ if (Math.random() < successChance) {
+ var expGain = 2 * BaseStatGain * this.actionTimeToComplete;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(expGain);
+ ++this.teamSize;
+ if (this.logging.general) {
+ this.log("Successfully recruited a team member! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(expGain, 1) + " charisma exp");
+ }
+ } else {
+ var expGain = BaseStatGain * this.actionTimeToComplete;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(expGain);
+ if (this.logging.general) {
+ this.log("Failed to recruit a team member. Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(expGain, 1) + " charisma exp");
+ }
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ default:
+ break;
+ }
+}
+
+Bladeburner.prototype.completeContract = function(success) {
+ if (this.action.type !== ActionTypes.Contract) {
+ throw new Error("completeContract() called even though current action is not a Contract");
+ }
+ var city = this.getCurrentCity();
+ if (success) {
+ switch (this.action.name) {
+ case "Tracking":
+ //Increase estimate accuracy by a relatively small amount
+ city.improvePopulationEstimateByCount(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(100, 1e3));
+ break;
+ case "Bounty Hunter":
+ city.changePopulationByCount(-1, {estChange:-1});
+ city.changeChaosByCount(0.02);
+ break;
+ case "Retirement":
+ city.changePopulationByCount(-1, {estChange:-1});
+ city.changeChaosByCount(0.04);
+ break;
+ default:
+ throw new Error("Invalid Action name in completeContract: " + this.action.name);
+ }
+ }
+}
+
+Bladeburner.prototype.completeOperation = function(success) {
+ if (this.action.type !== ActionTypes.Operation) {
+ throw new Error("completeOperation() called even though current action is not an Operation");
+ }
+ var action = this.getActionObject(this.action);
+ if (action == null) {
+ throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
+ }
+
+ //Calculate team losses
+ var teamCount = action.teamCount, max;
+ if (teamCount >= 1) {
+ if (success) {
+ max = Math.ceil(teamCount/2);
+ } else {
+ max = Math.floor(teamCount)
+ }
+ var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, max);
+ this.teamSize -= losses;
+ this.teamLost += losses;
+ if (this.logging.ops && losses > 0) {
+ this.log("Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(losses, 0) + " team members during this " + action.name);
+ }
+ }
+
+ var city = this.getCurrentCity();
+ if (this.logging.ops) {
+ if (success) {
+ this.log(action.name + " completed successfully! ")
+ } else {
+
+ }
+ }
+ switch (action.name) {
+ case "Investigation":
+ if (success) {
+ city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);
+ if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
+ city.improveCommunityEstimate(1);
+ }
+ } else {
+ this.triggerPotentialMigration(this.city, 0.1);
+ }
+ break;
+ case "Undercover Operation":
+ if (success) {
+ city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);
+ if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
+ city.improveCommunityEstimate(1);
+ }
+ } else {
+ this.triggerPotentialMigration(this.city, 0.15);
+ }
+ break;
+ case "Sting Operation":
+ if (success) {
+ city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});
+ }
+ city.changeChaosByCount(0.1);
+ break;
+ case "Raid":
+ if (success) {
+ city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});
+ --city.comms;
+ --city.commsEst;
+ } else {
+ var change = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-3, -1);
+ city.changePopulationByPercentage(change, {nonZero:true});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(1, 5));
+ break;
+ case "Stealth Retirement Operation":
+ if (success) {
+ city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-3, -1));
+ break;
+ case "Assassination":
+ if (success) {
+ city.changePopulationByCount(-1, {estChange:-1});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(-5, 5));
+ break;
+ default:
+ throw new Error("Invalid Action name in completeOperation: " + this.action.name);
+ }
+}
+
+Bladeburner.prototype.getRecruitmentTime = function() {
+ var effCharisma = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma * this.skillMultipliers.effCha;
+ var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;
+ return Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));
+}
+
+Bladeburner.prototype.getRecruitmentSuccessChance = function() {
+ return Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma, 0.45) / (this.teamSize + 1);
+}
+
+//Process stat gains from Contracts, Operations, and Black Operations
+//@action(Action obj) - Derived action class
+//@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
+ var difficultyMult = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
+
+ var time = this.actionTimeToComplete;
+ var successMult = success ? 1 : 0.5;
+
+ var unweightedGain = time * BaseStatGain * successMult * difficultyMult;
+ var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainHackingExp(unweightedGain * action.weights.hack * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainStrengthExp(unweightedGain * action.weights.str * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDefenseExp(unweightedGain * action.weights.def * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainDexterityExp(unweightedGain * action.weights.dex * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainAgilityExp(unweightedGain * action.weights.agi * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainCharismaExp(unweightedGain * action.weights.cha * _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].gainIntelligenceExp(unweightedIntGain * action.weights.int);
+}
+
+Bladeburner.prototype.randomEvent = function() {
+ var chance = Math.random();
+
+ //Choose random source/destination city for events
+ var sourceCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
+ var sourceCity = this.cities[sourceCityName];
+ if (!(sourceCity instanceof City)) {
+ throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
+ }
+
+ var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
+ while (destCityName === sourceCityName) {
+ destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
+ }
+ var destCity = this.cities[destCityName];
+
+ if (!(sourceCity instanceof City) || !(destCity instanceof City)) {
+ throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
+ }
+
+ if (chance <= 0.05) {
+ //New Synthoid Community, 5%
+ ++sourceCity.comms;
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a new Synthoid community was formed in a city");
+ }
+ } else if (chance <= 0.1) {
+ //Synthoid Community Migration, 5%
+ if (sourceCity.comms <= 0) {
+ //If no comms in source city, then instead trigger a new Synthoid community event
+ ++sourceCity.comms;
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a new Synthoid community was formed in a city");
+ }
+ } else {
+ --sourceCity.comms;
+ ++destCity.comms;
+
+ //Change pop
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ destCity.pop += count;
+
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city");
+ }
+ }
+ } else if (chance <= 0.3) {
+ //New Synthoids (non community), 20%
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(8, 24) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
+ }
+ } else if (chance <= 0.5) {
+ //Synthoid migration (non community) 20%
+ this.triggerMigration(sourceCityName);
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a large number of Synthoids migrated from " + sourceCityName + " to some other city");
+ }
+ } else if (chance <= 0.7) {
+ //Synthoid Riots (+chaos), 20%
+ sourceCity.chaos += 1;
+ sourceCity.chaos *= (1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(5, 10) / 100);
+ if (this.logging.events) {
+ this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
+ }
+ } else if (chance <= 0.9) {
+ //Less Synthoids, 20%
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(5, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
+ }
+ }
+ //20% chance of nothing happening
+}
+
+Bladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {
+ if (chance == null || isNaN(chance)) {
+ console.log("ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()");
+ }
+ if (chance > 1) {chance /= 100;}
+ if (Math.random() < chance) {this.triggerMigration(sourceCityName);}
+}
+
+Bladeburner.prototype.triggerMigration = function(sourceCityName) {
+ var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
+ while (destCityName === sourceCityName) {
+ destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(0, 5)];
+ }
+ var destCity = this.cities[destCityName];
+ var sourceCity = this.cities[sourceCityName];
+ if (destCity == null || sourceCity == null) {
+ throw new Error("Failed to find City with name: " + destCityName);
+ }
+ var rand = Math.random(), percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(3, 15) / 100;
+
+ if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration
+ percentage *= Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["getRandomInt"])(2, 4); //Migration increases population change
+ --sourceCity.comms;
+ ++destCity.comms;
+ }
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ destCity.pop += count;
+}
+
+var DomElems = {};
+
+Bladeburner.prototype.initializeDomElementRefs = function() {
+ DomElems = {
+ bladeburnerDiv: null,
+
+ //Main Divs
+ overviewConsoleParentDiv: null,
+
+ overviewDiv: null, //Overview of stats that stays fixed on left
+ actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)
+ currentTab: null, //Contracts, Operations, Black Ops, Skills
+
+ consoleDiv: null,
+ consoleTable: null,
+ consoleInputRow: null, //tr
+ consoleInputCell: null, //td
+ consoleInputHeader: null, //"> "
+ consoleInput: null, //Actual input element
+
+ //Overview Content
+ overviewRank: null,
+ overviewStamina: null,
+ overviewStaminaHelpTip: null,
+ overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city
+ overviewEstPop: null,
+ overviewEstPopHelpTip: null,
+ overviewEstComms: null,
+ overviewChaos: null,
+ overviewSkillPoints: null,
+ overviewAugSuccessMult: null,
+ overviewAugMaxStaminaMult: null,
+ overviewAugStaminaGainMult: null,
+ overviewAugAnalysisMult: null,
+
+ //Actions and Skills Content
+ actionsAndSkillsDesc: null,
+ actionsAndSkillsList: null, //ul element of all UI elements in this panel
+ generalActions: {},
+ contracts: {},
+ operations: {},
+ blackops: {},
+ skills: {},
+ skillPointsDisplay: null,
+ };
+}
+
+Bladeburner.prototype.createContent = function() {
+ DomElems.bladeburnerDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ id:"bladeburner-container", position:"fixed", class:"generic-menupage-container",
+ });
+
+ //Parent Div for Overview and Console
+ DomElems.overviewConsoleParentDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ height:"60%", display:"block", position:"relative",
+ });
+
+ //Overview and Action/Skill pane
+ DomElems.overviewDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ width:"30%", display:"inline-block", border:"1px solid white",
+ });
+
+ DomElems.actionAndSkillsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ height:"60%", width:"70%", display:"block",
+ border:"1px solid white", margin:"6px", padding:"6px",
+ });
+
+ DomElems.currentTab = "general";
+
+ this.createOverviewContent();
+ this.createActionAndSkillsContent();
+
+ //Console
+ DomElems.consoleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-console-div",
+ clickListener:()=>{
+ if (DomElems.consoleInput instanceof Element) {
+ DomElems.consoleInput.focus();
+ }
+ return false;
+ }
+ });
+ DomElems.consoleTable = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("table", {class:"bladeburner-console-table"});
+ DomElems.consoleInputRow = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("tr", {class:"bladeburner-console-input-row", id:"bladeubrner-console-input-row"});
+ DomElems.consoleInputCell = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("td", {class:"bladeburner-console-input-cell"});
+ DomElems.consoleInputHeader = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {innerText:"> "});
+ DomElems.consoleInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
+ type:"text", class:"bladeburner-console-input", tabIndex:1,
+ onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}
+ });
+
+ DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);
+ DomElems.consoleInputCell.appendChild(DomElems.consoleInput);
+ DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);
+ DomElems.consoleTable.appendChild(DomElems.consoleInputRow);
+ DomElems.consoleDiv.appendChild(DomElems.consoleTable);
+
+ DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);
+ DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);
+ DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);
+ DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);
+
+ document.getElementById("entire-game-container").appendChild(DomElems.bladeburnerDiv);
+
+ this.postToConsole("Bladeburner Console BETA");
+ this.postToConsole("Type 'help' to see console commands");
+ DomElems.consoleInput.focus();
+}
+
+Bladeburner.prototype.clearContent = function() {
+ if (DomElems.bladeburnerDiv instanceof Element) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.bladeburnerDiv);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElement"])(DomElems.bladeburnerDiv);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems);
+ this.initializeDomElementRefs();
+}
+
+Bladeburner.prototype.createOverviewContent = function() {
+ if (DomElems.overviewDiv == null) {
+ throw new Error("Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null");
+ }
+
+ DomElems.overviewRank = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"Rank: ",
+ display:"inline-block",
+ tooltip:"Your rank within the Bladeburner division",
+ });
+
+ DomElems.overviewStamina = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"inline-block",
+ });
+
+ DomElems.overviewStaminaHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ innerText:"?", class:"help-tip",
+ clickListener:()=>{
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Performing actions will use up your stamina.
" +
+ "Your max stamina is determined primarily by your agility stat.
" +
+ "Your stamina gain rate is determined by both your agility and your " +
+ "max stamina. Higher max stamina leads to a higher gain rate.
" +
+ "Once your " +
+ "stamina falls below 50% of its max value, it begins to negatively " +
+ "affect the success rate of your contracts/operations. This penalty " +
+ "is shown in the overview panel. If the penalty is 15%, then this means " +
+ "your success rate would be multipled by 85% (100 - 15).
" +
+ "Your max stamina and stamina gain rate can also be increased by " +
+ "training, or through skills and Augmentation upgrades.");
+ }
+ });
+
+ DomElems.overviewGen1 = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ });
+
+ DomElems.overviewEstPop = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"Est. Synthoid Population: ",
+ display:"inline-block",
+ tooltip:"This is your Bladeburner division's estimate of how many Synthoids exist " +
+ "in your current city."
+ });
+
+ DomElems.overviewEstPopHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ innerText:"?", class:"help-tip",
+ clickListener:()=>{
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("The success rate of your contracts/operations depends on " +
+ "the population of Synthoids in your current city. " +
+ "The success rate that is shown to you is only an estimate, " +
+ "and it is based on your Synthoid population estimate.
" +
+ "Therefore, it is important that this Synthoid population estimate " +
+ "is accurate so that you have a better idea of your " +
+ "success rate for contracts/operations. Certain " +
+ "actions will increase the accuracy of your population " +
+ "estimate.
" +
+ "The Synthoid populations of cities can change due to your " +
+ "actions or random events. If random events occur, they will " +
+ "be logged in the Bladeburner Console.");
+ }
+ });
+
+ DomElems.overviewEstComms = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"Est. Synthoid Communities: ",
+ display:"inline-block",
+ tooltip:"This is your Bladeburner divison's estimate of how many Synthoid " +
+ "communities exist in your current city.",
+ });
+
+ DomElems.overviewChaos = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"City Chaos: ",
+ display:"inline-block",
+ tooltip:"The city's chaos level due to tensions and conflicts between humans and Synthoids. " +
+ "Having too high of a chaos level can make contracts and operations harder."
+ });
+
+ DomElems.overviewSkillPoints = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
+
+ DomElems.overviewAugSuccessMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugMaxStaminaMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugStaminaGainMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugAnalysisMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {display:"block"});
+
+
+ DomElems.overviewDiv.appendChild(DomElems.overviewRank);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewStamina);
+ DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);
+ DomElems.overviewDiv.appendChild(DomElems.overviewGen1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewChaos);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 2);
+ DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);
+
+ //Travel to new city button
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerHTML:"Travel", class:"a-link-button", display:"inline-block",
+ clickListener:()=>{
+ var popupId = "bladeburner-travel-popup-cancel-btn";
+ var popupArguments = [];
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Cancel Button
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId); return false;
+ }
+ }))
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", { //Info Text
+ innerText:"Travel to a different city for your Bladeburner " +
+ "activities. This does not cost any money. The city you are " +
+ "in for your Bladeburner duties does not affect " +
+ "your location in the game otherwise",
+ }));
+ for (var i = 0; i < CityNames.length; ++i) {
+ (function(inst, i) {
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ //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:()=>{
+ inst.city = CityNames[i];
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
+ inst.updateOverviewContent();
+ return false;
+ }
+ }));
+ })(this, i);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, popupArguments);
+ }
+ }));
+
+ //Faction button
+ const bladeburnersFactionName = "Bladeburners";
+ if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["factionExists"])(bladeburnersFactionName)) {
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"][bladeburnersFactionName];
+ if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Faction"])) {
+ throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
+ }
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Faction", class:"a-link-button", display:"inline-block",
+ tooltip:"Apply to the Bladeburner Faction, or go to the faction page if you are already a member",
+ clickListener:()=>{
+ if (bladeburnerFac.isMember) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["displayFactionContent"])(bladeburnersFactionName);
+ } else {
+ if (this.rank >= RankNeededForFaction) {
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Congratulations! You were accepted into the Bladeburners faction");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.overviewDiv);
+ this.createOverviewContent();
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You need a rank of 25 to join the Bladeburners Faction!")
+ }
+ }
+ return false;
+ }
+ }));
+ }
+
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
+
+ this.updateOverviewContent();
+}
+
+Bladeburner.prototype.createActionAndSkillsContent = function() {
+ if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.actionAndSkillsDiv);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.generalActions);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.contracts);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.operations);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.blackops);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["clearObject"])(DomElems.skills);
+
+ //Navigation buttons
+ var currTab = DomElems.currentTab.toLowerCase();
+ var buttons = ["General", "Contracts", "Operations", "BlackOps", "Skills"];
+ for (var i = 0; i < buttons.length; ++i) {
+ (function(buttons, i, inst, currTab) {
+
+ DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:buttons[i],
+ class:currTab === buttons[i].toLowerCase() ? "bladeburner-nav-button-inactive" : "bladeburner-nav-button",
+ clickListener:()=>{
+ DomElems.currentTab = buttons[i].toLowerCase();
+ inst.createActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }) (buttons, i, this, currTab);
+ }
+
+ //General info/description for each action
+ DomElems.actionsAndSkillsDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block", margin:"4px", padding:"4px"
+ });
+
+ //List for actions/skills
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.actionsAndSkillsList);
+ DomElems.actionsAndSkillsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("ul");
+
+ switch(currTab) {
+ case "general":
+ this.createGeneralActionsContent();
+ break;
+ case "contracts":
+ this.createContractsContent();
+ break;
+ case "operations":
+ this.createOperationsContent();
+ break;
+ case "blackops":
+ this.createBlackOpsContent();
+ break;
+ case "skills":
+ this.createSkillsContent();
+ break;
+ default:
+ throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
+ }
+ this.updateContent();
+
+ DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);
+ DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);
+}
+
+Bladeburner.prototype.createGeneralActionsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createGeneralActionsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerText =
+ "These are generic actions that will assist you in your Bladeburner " +
+ "duties. They will not affect your Bladeburner rank in any way."
+
+ for (var actionName in GeneralActions) {
+ if (GeneralActions.hasOwnProperty(actionName)) {
+ DomElems.generalActions[actionName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-action", name:actionName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createContractsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createContractsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Complete contracts in order to increase your Bitburner rank and earn money. " +
+ "Failing a contract will cause you to lose HP, which can lead to hospitalization.
" +
+ "You can unlock higher-level contracts by successfully completing them. " +
+ "Higher-level contracts are more difficult, but grant more rank, experience, and money.";
+
+ for (var contractName in this.contracts) {
+ if (this.contracts.hasOwnProperty(contractName)) {
+ DomElems.contracts[contractName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-action", name:contractName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createOperationsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createOperationsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Carry out operations for the Bladeburner division. " +
+ "Failing an operation will reduce your Bladeburner rank. It will also " +
+ "cause you to lose HP, which can lead to hospitalization. In general, " +
+ "operations are harder and more punishing than contracts, " +
+ "but are also more rewarding.
" +
+ "Operations can affect the chaos level and Synthoid population of your " +
+ "current city. The exact effects vary between different Operations.
" +
+ "For operations, you can use a team. You must first recruit team members. " +
+ "Having a larger team will improves your chances of success.
" +
+ "You can unlock higher-level operations by successfully completing them. " +
+ "Higher-level operations are more difficult, but grant more rank and experience.";
+
+ for (var operationName in this.operations) {
+ if (this.operations.hasOwnProperty(operationName)) {
+ DomElems.operations[operationName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-action", name:operationName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createBlackOpsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createBlackOpsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Black Operations (Black Ops) are special, one-time covert operations. " +
+ "Each Black Op must be unlocked successively by completing " +
+ "the one before it.
" +
+ "Like normal operations, you may use a team for Black Ops. Failing " +
+ "a black op will incur heavy HP and rank losses.";
+
+ //Put Black Operations in sequence of required rank
+ var blackops = [];
+ for (var blackopName in BlackOperations) {
+ if (BlackOperations.hasOwnProperty(blackopName)) {
+ blackops.push(BlackOperations[blackopName]);
+ }
+ }
+ blackops.sort(function(a, b) {
+ return (a.reqdRank - b.reqdRank);
+ });
+
+ for (var i = 0; i < blackops.length; ++i) {
+ DomElems.blackops[blackops[i].name] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-action", name:blackops[i].name
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);
+ if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops
+ }
+}
+
+Bladeburner.prototype.createSkillsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createSkillsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ //Display Current multipliers
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "You will gain one skill point every " + RanksPerSkillPoint + " ranks.
" +
+ "Note that when upgrading a skill, the benefit for that skill is additive. " +
+ "However, the effects of different skills with each other is multiplicative.
"
+ var multKeys = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multKeys.length; ++i) {
+ var mult = this.skillMultipliers[multKeys[i]];
+ if (mult && mult !== 1) {
+ mult = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(mult, 3);
+ switch(multKeys[i]) {
+ case "successChanceAll":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Total Success Chance: x" + mult + "
";
+ break;
+ case "successChanceStealth":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Stealth Success Chance: x" + mult + "
";
+ break;
+ case "successChanceKill":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Retirement Success Chance: x" + mult + "
";
+ break;
+ case "successChanceContract":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Contract Success Chance: x" + mult + "
";
+ break;
+ case "successChanceOperation":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Operation Success Chance: x" + mult + "
";
+ break;
+ case "successChanceEstimate":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Synthoid Data Estimate: x" + mult + "
";
+ break;
+ case "actionTime":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Action Time: x" + mult + "
";
+ break;
+ case "effHack":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Hacking Skill: x" + mult + "
";
+ break;
+ case "effStr":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Strength: x" + mult + "
";
+ break;
+ case "effDef":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Defense: x" + mult + "
";
+ break;
+ case "effDex":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Dexterity: x" + mult + "
";
+ break;
+ case "effAgi":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Agility: x" + mult + "
";
+ break;
+ case "effCha":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Charisma: x" + mult + "
";
+ break;
+ case "effInt":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Intelligence: x" + mult + "
";
+ break;
+ case "stamina":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Stamina: x" + mult + "
";
+ break;
+ case "weaponAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML +=
+ break;
+ case "gunAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML
+ break;
+ default:
+ console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
+ break;
+ }
+ }
+ }
+
+ //Skill Points
+ DomElems.skillPointsDisplay = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerHTML:"
Skill Points: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0) + ""
+ });
+ DomElems.actionAndSkillsDiv.appendChild(DomElems.skillPointsDisplay);
+
+ //UI Element for each skill
+ for (var skillName in Skills) {
+ if (Skills.hasOwnProperty(skillName)) {
+ DomElems.skills[skillName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("div", {
+ class:"bladeburner-action", name:skillName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);
+ }
+ }
+}
+
+Bladeburner.prototype.updateContent = function() {
+ this.updateOverviewContent();
+ this.updateActionAndSkillsContent();
+}
+
+Bladeburner.prototype.updateOverviewContent = function() {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {return;}
+ DomElems.overviewRank.childNodes[0].nodeValue = "Rank: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.rank, 2);
+ DomElems.overviewStamina.innerText = "Stamina: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.stamina, 3) + " / " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.maxStamina, 3);
+ DomElems.overviewGen1.innerHTML =
+ "Stamina Penalty: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])((1-this.calculateStaminaPenalty())*100, 1) + "%
" +
+ "Team Size: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.teamSize, 0) + "
" +
+ "Team Members Lost: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.teamLost, 0) + "
" +
+ "Num Times Hospitalized: " + this.numHosp + "
" +
+ "Money Lost From Hospitalizations: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(this.moneyLost).format("$0.000a") + "
" +
+ "Current City: " + this.city + "
";
+
+ DomElems.overviewEstPop.childNodes[0].nodeValue = "Est. Synthoid Population: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_12___default()(this.getCurrentCity().popEst).format("0.000a");
+ DomElems.overviewEstComms.childNodes[0].nodeValue = "Est. Synthoid Communities: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.getCurrentCity().comms, 0);
+ DomElems.overviewChaos.childNodes[0].nodeValue = "City Chaos: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.getCurrentCity().chaos);
+ DomElems.overviewSkillPoints.innerText = "Skill Points: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0);
+ DomElems.overviewAugSuccessMult.innerText = "Aug. Success Chance Mult: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult*100, 1) + "%";
+ DomElems.overviewAugMaxStaminaMult.innerText = "Aug. Max Stamina Mult: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult*100, 1) + "%";
+ DomElems.overviewAugStaminaGainMult.innerText = "Aug. Stamina Gain Mult: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult*100, 1) + "%";
+ DomElems.overviewAugAnalysisMult.innerText = "Aug. Field Analysis Mult: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult*100, 1) + "%";
+}
+
+Bladeburner.prototype.updateActionAndSkillsContent = function() {
+ if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
+ switch(DomElems.currentTab.toLowerCase()) {
+ case "general":
+ var actionElems = Object.keys(DomElems.generalActions);
+ for (var i = 0; i < actionElems.length; ++i) {
+ var actionElem = DomElems.generalActions[actionElems[i]];
+ var name = actionElem.name;
+ var actionObj = GeneralActions[name];
+ if (actionObj == null) {
+ throw new Error("Could not find Object " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ if (this.action.type === ActionTypes[name]) {
+ actionElem.classList.add(ActiveActionCssClass);
+ } else {
+ actionElem.classList.remove(ActiveActionCssClass);
+ }
+ this.updateGeneralActionsUIElement(actionElem, actionObj);
+ }
+ break;
+ case "contracts":
+ var contractElems = Object.keys(DomElems.contracts);
+ for (var i = 0; i < contractElems.length; ++i) {
+ var contractElem = DomElems.contracts[contractElems[i]];
+ var name = contractElem.name;
+ if (this.action.type === ActionTypes["Contract"] && name === this.action.name) {
+ contractElem.classList.add(ActiveActionCssClass);
+ } else {
+ contractElem.classList.remove(ActiveActionCssClass);
+ }
+ var contract = this.contracts[name];
+ if (contract == null) {
+ throw new Error("Could not find Contract " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateContractsUIElement(contractElem, contract);
+ }
+ break;
+ case "operations":
+ var operationElems = Object.keys(DomElems.operations);
+ for (var i = 0; i < operationElems.length; ++i) {
+ var operationElem = DomElems.operations[operationElems[i]];
+ var name = operationElem.name;
+ if (this.action.type === ActionTypes["Operation"] && name === this.action.name) {
+ operationElem.classList.add(ActiveActionCssClass);
+ } else {
+ operationElem.classList.remove(ActiveActionCssClass);
+ }
+ var operation = this.operations[name];
+ if (operation == null) {
+ throw new Error("Could not find Operation " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateOperationsUIElement(operationElem, operation);
+ }
+ break;
+ case "blackops":
+ var blackopsElems = Object.keys(DomElems.blackops);
+ for (var i = 0; i < blackopsElems.length; ++i) {
+ var blackopElem = DomElems.blackops[blackopsElems[i]];
+ var name = blackopElem.name;
+ if (this.action.type === ActionTypes["BlackOperation"] && name === this.action.name) {
+ blackopElem.classList.add(ActiveActionCssClass);
+ } else {
+ blackopElem.classList.remove(ActiveActionCssClass);
+ }
+ var blackop = BlackOperations[name];
+ if (blackop == null) {
+ throw new Error("Could not find BlackOperation " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateBlackOpsUIElement(blackopElem, blackop);
+ }
+ break;
+ case "skills":
+ DomElems.skillPointsDisplay.innerHTML = "
Skill Points: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skillPoints, 0) + "";
+
+ var skillElems = Object.keys(DomElems.skills);
+ for (var i = 0; i < skillElems.length; ++i) {
+ var skillElem = DomElems.skills[skillElems[i]];
+ var name = skillElem.name;
+ var skill = Skills[name];
+ if (skill == null) {
+ throw new Error("Could not find Skill " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateSkillsUIElement(skillElem, skill);
+ }
+ break;
+ default:
+ throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
+ }
+}
+
+Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block",
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
+ }));
+ } else {
+ //Start button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes[action.name];
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", { //Info
+ innerHTML:action.desc, display:"inline-block"
+ }));
+
+
+}
+
+Bladeburner.prototype.updateContractsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block"
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
+ }));
+ } else { //Start button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ padding:"3px", margin:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes.Contract;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }
+
+ //Level and buttons to change level
+ var maxLevel = (action.level >= action.maxLevel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
+ display:"inline-block",
+ innerText:"Level: " + action.level + " / " + action.maxLevel,
+ tooltip:action.getSuccessesNeededForNextLevel(ContractSuccessesPerLevel) + " successes " +
+ "needed for next level"
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
+ display:"inline",
+ clickListener:()=>{
+ ++action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateContractsUIElement(el, action);
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
+ display:"inline",
+ clickListener:()=>{
+ --action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateContractsUIElement(el, action);
+ return false;
+ }
+ }));
+
+ var actionTime = action.getActionTime(this);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", { //Info
+ display:"inline-block",
+ innerHTML:action.desc + "\n\n" +
+ "Estimated success chance: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required (s): " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 0) + "\n" +
+ "Contracts remaining: " + Math.floor(action.count) + "\n" +
+ "Successes: " + action.successes + "\n" +
+ "Failures: " + action.failures,
+ }));
+
+ //Autolevel Checkbox
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
+ var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("label", {
+ for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
+ tooltip:"Automatically increase contract level when possible"
+ }));
+ var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
+ type:"checkbox", id:autolevelCheckboxId, margin:"4px",
+ checked:action.autoLevel,
+ changeListener:()=>{
+ action.autoLevel = autolevelCheckbox.checked;
+ }
+ });
+ el.appendChild(autolevelCheckbox);
+}
+
+Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block"
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
+ }));
+ } else { //Start button and set Team Size button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes.Operation;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ var popupId = "bladeburner-operation-set-team-size-popup";
+ var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"Enter the amount of team members you would like to take on these " +
+ "operations. If you do not have the specified number of team members, " +
+ "then as many as possible will be used. Note that team members may " +
+ "be lost during operations."
+
+ });
+ var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
+ type:"number", placeholder: "Team Members"
+ });
+ var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Confirm", class:"a-link-button",
+ clickListener:()=>{
+ var num = Math.round(parseFloat(input.value));
+ if (isNaN(num)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
+ } else {
+ action.teamCount = num;
+ this.updateOperationsUIElement(el, action);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
+ }
+ }));
+ }
+
+ //Level and buttons to change level
+ var maxLevel = (action.level >= action.maxLevel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
+ display:"inline-block",
+ innerText:"Level: " + action.level + " / " + action.maxLevel,
+ tooltip:action.getSuccessesNeededForNextLevel(OperationSuccessesPerLevel) + " successes " +
+ "needed for next level"
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
+ display:"inline",
+ clickListener:()=>{
+ ++action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateOperationsUIElement(el, action);
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
+ display:"inline",
+ clickListener:()=>{
+ --action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateOperationsUIElement(el, action);
+ return false;
+ }
+ }));
+
+ //General Info
+ var difficulty = action.getDifficulty();
+ var actionTime = action.getActionTime(this);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("pre", {
+ display:"inline-block",
+ innerHTML:action.desc + "\n\n" +
+ "Estimated success chance: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required(s): " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 1) + "\n" +
+ "Operations remaining: " + Math.floor(action.count) + "\n" +
+ "Successes: " + action.successes + "\n" +
+ "Failures: " + action.failures,
+ }));
+
+ //Autolevel Checkbox
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("br"));
+ var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("label", {
+ for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
+ tooltip:"Automatically increase operation level when possible"
+ }));
+ var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
+ type:"checkbox", id:autolevelCheckboxId, margin:"4px",
+ checked:action.autoLevel,
+ changeListener:()=>{
+ action.autoLevel = autolevelCheckbox.checked;
+ }
+ });
+ el.appendChild(autolevelCheckbox);
+}
+
+Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var isCompleted = (this.blackops[action.name] != null);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+ var difficulty = action.getDifficulty();
+ var actionTime = action.getActionTime(this);
+ var hasReqdRank = this.rank >= action.reqdRank;
+
+ //UI for Completed Black Op
+ if (isCompleted) {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", {
+ innerText:action.name + " (COMPLETED)", display:"block",
+ }));
+ return;
+ }
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block",
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createProgressBarText"])({progress:progress})
+ }));
+ } else {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Start button
+ innerText:"Start", margin:"3px", padding:"3px",
+ class:hasReqdRank ? "a-link-button" : "a-link-button-inactive",
+ clickListener:()=>{
+ this.action.type = ActionTypes.BlackOperation;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Set Team Size Button
+ innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ var popupId = "bladeburner-operation-set-team-size-popup";
+ var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ innerText:"Enter the amount of team members you would like to take on this " +
+ "BlackOp. If you do not have the specified number of team members, " +
+ "then as many as possible will be used. Note that team members may " +
+ "be lost during operations."
+
+ });
+ var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("input", {
+ type:"number", placeholder: "Team Members"
+ });
+ var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Confirm", class:"a-link-button",
+ clickListener:()=>{
+ var num = Math.round(parseFloat(input.value));
+ if (isNaN(num)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
+ } else {
+ action.teamCount = num;
+ this.updateBlackOpsUIElement(el, action);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", {
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
+ }
+ }));
+ }
+
+ //Info
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"inline-block",
+ innerHTML:"
" + action.desc + "
",
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block", color:hasReqdRank ? "white" : "red",
+ innerHTML:"Required Rank: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(action.reqdRank, 0) + "
"
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"inline-block",
+ innerHTML:"Estimated Success Chance: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required(s): " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(actionTime, 1),
+ }))
+}
+
+Bladeburner.prototype.updateSkillsUIElement = function(el, skill) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(el);
+ var skillName = skill.name;
+ var currentLevel = 0;
+ if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
+ currentLevel = this.skills[skillName];
+ }
+ var pointCost = skill.calculateCost(currentLevel);
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("h2", { //Header
+ innerText:skill.name + " (Lvl " + currentLevel + ")", display:"inline-block"
+ }));
+
+ var canLevel = this.skillPoints >= pointCost;
+ var maxLvl = skill.maxLvl ? currentLevel >= skill.maxLvl : false;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("a", { //Level up button
+ innerText:"Level", display:"inline-block",
+ class: canLevel && !maxLvl ? "a-link-button" : "a-link-button-inactive",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ if (this.skillPoints < pointCost) {return;}
+ this.skillPoints -= pointCost;
+ this.upgradeSkill(skill);
+ this.createActionAndSkillsContent();
+ return false;
+ }
+ }));
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["appendLineBreaks"])(el, 2);
+ if (maxLvl) {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ color:"red", display:"block",
+ innerText:"MAX LEVEL"
+ }));
+ } else {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", {
+ display:"block",
+ innerText:"Skill Points required: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(pointCost, 0),
+ }));
+ }
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["createElement"])("p", { //Info/Description
+ innerHTML:skill.desc, display:"inline-block",
+ }));
+}
+
+//Bladeburner Console Window
+Bladeburner.prototype.postToConsole = function(input) {
+ if (input == null || DomElems.consoleDiv == null) {return;}
+ $("#bladeubrner-console-input-row").before(' ');
+ if (DomElems.consoleTable.childNodes.length > 200) {
+ DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
+ }
+ this.updateConsoleScroll();
+}
+
+Bladeburner.prototype.updateConsoleScroll = function() {
+ DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;
+}
+
+Bladeburner.prototype.resetConsoleInput = function() {
+ DomElems.consoleInput.value = "";
+}
+
+Bladeburner.prototype.clearConsole = function() {
+ while (DomElems.consoleTable.childNodes.length > 1) {
+ DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
+ }
+}
+
+Bladeburner.prototype.log = function(input) {
+ //Adds a timestamp and then just calls postToConsole
+ var d = new Date();
+ var timestamp = d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes();
+ this.postToConsole("[" + timestamp + "] " + input);
+}
+
+//Handles a potential series of commands (comm1; comm2; comm3;)
+Bladeburner.prototype.executeConsoleCommands = function(commands) {
+ try {
+ //Console History
+ if (consoleHistory[consoleHistory.length-1] != commands) {
+ consoleHistory.push(commands);
+ if (consoleHistory.length > 50) {
+ consoleHistory.splice(0, 1);
+ }
+ }
+ consoleHistoryIndex = consoleHistory.length;
+
+ var arrayOfCommands = commands.split(";");
+ for (var i = 0; i < arrayOfCommands.length; ++i) {
+ this.executeConsoleCommand(arrayOfCommands[i]);
+ }
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["exceptionAlert"])(e);
+ }
+}
+
+//A single command
+Bladeburner.prototype.executeConsoleCommand = function(command) {
+ command = command.trim();
+ command = command.replace(/\s\s+/g, ' '); //Replace all whitespace w/ a single space
+
+ var args = this.parseCommandArguments(command);
+ if (args.length <= 0) {return;} //Log an error?
+
+ switch(args[0].toLowerCase()) {
+ case "automate":
+ this.executeAutomateConsoleCommand(args);
+ break;
+ case "clear":
+ case "cls":
+ this.clearConsole();
+ break;
+ case "help":
+ this.executeHelpConsoleCommand(args);
+ break;
+ case "log":
+ this.executeLogConsoleCommand(args);
+ break;
+ case "skill":
+ this.executeSkillConsoleCommand(args);
+ break;
+ case "start":
+ this.executeStartConsoleCommand(args);
+ break;
+ case "stop":
+ this.resetAction();
+ break;
+ default:
+ this.postToConsole("Invalid console command");
+ break;
+ }
+}
+
+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
+ var args = [];
+ var start = 0, i = 0;
+ while (i < command.length) {
+ var c = command.charAt(i);
+ if (c === '"') {
+ var endQuote = command.indexOf('"', i+1);
+ if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === " ")) {
+ args.push(command.substr(i+1, (endQuote - i - 1)));
+ if (endQuote === command.length-1) {
+ start = i = endQuote+1;
+ } else {
+ start = i = endQuote+2; //Skip the space
+ }
+ continue;
+ }
+ } else if (c === " ") {
+ args.push(command.substr(start, i-start));
+ start = i+1;
+ }
+ ++i;
+ }
+ if (start !== i) {args.push(command.substr(start, i-start));}
+ console.log("Bladeburner.parseCommandArguments returned: " + args);
+ return args;
+}
+
+Bladeburner.prototype.executeAutomateConsoleCommand = function(args) {
+ if (args.length !== 2 && args.length !== 4) {
+ this.postToConsole("Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info");
+ return;
+ }
+
+ //Enable/Disable
+ if (args.length === 2) {
+ var flag = args[1];
+ if (flag.toLowerCase() === "status") {
+ this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
+ if (this.automateEnabled) {
+ this.postToConsole("When your stamina drops to " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.automateThreshLow, 0) +
+ ", you will automatically switch to " + this.automateActionLow.name +
+ ". When your stamina recovers to " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.automateThreshHigh, 0) + ", you will automatically " +
+ "switch to " + this.automateActionHigh.name + ".");
+ }
+
+ } else if (flag.toLowerCase().includes("en")) {
+ if (!(this.automateActionLow instanceof ActionIdentifier) ||
+ !(this.automateActionHigh instanceof ActionIdentifier)) {
+ return this.log("Failed to enable automation. Actions were not set");
+ }
+ this.automateEnabled = true;
+ this.log("Bladeburner automation enabled");
+ } else if (flag.toLowerCase().includes("d")) {
+ this.automateEnabled = false;
+ this.log("Bladeburner automation disabled");
+ } else {
+ this.log("Invalid argument for 'automate' console command: " + args[1]);
+ }
+ return;
+ }
+
+ //Set variables
+ if (args.length === 4) {
+ var variable = args[1], val = args[2];
+
+ var highLow = false; //True for high, false for low
+ if (args[3].toLowerCase().includes("hi")) {highLow = true;}
+
+ switch (variable) {
+ case "general":
+ case "gen":
+ if (GeneralActions[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes[val], name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid action name specified: " + val);
+ }
+ break;
+ case "contract":
+ case "contracts":
+ if (this.contracts[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes.Contract, name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid contract name specified: " + val);
+ }
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ if (this.operations[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes.Operation, name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid Operation name specified: " + val);
+ }
+ break;
+ case "stamina":
+ if (isNaN(val)) {
+ this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val);
+ } else {
+ if (highLow) {
+ this.automateThreshHigh = Number(val);
+ } else {
+ this.automateThreshLow = Number(val);
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+}
+
+Bladeburner.prototype.executeHelpConsoleCommand = function(args) {
+ if (args.length === 1) {
+ this.postToConsole(consoleHelpText.helpList);
+ } else {
+ for (var i = 1; i < args.length; ++i) {
+ var commandText = consoleHelpText[args[i]];
+ if (commandText != null) {
+ this.postToConsole(commandText);
+ this.postToConsole("' + input + '
");
+ }
+ }
+ }
+}
+
+Bladeburner.prototype.executeLogConsoleCommand = function(args) {
+ if (args.length < 3) {
+ this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]");
+ this.postToConsole("Use 'help log' for more details and examples");
+ return;
+ }
+
+ var flag = true;
+ if (args[1].toLowerCase().includes("d")) {flag = false;} //d for disable
+
+ switch (args[2].toLowerCase()) {
+ case "general":
+ case "gen":
+ this.logging.general = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions");
+ break;
+ case "contract":
+ case "contracts":
+ this.logging.contracts = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts");
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ this.logging.ops = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations");
+ break;
+ case "blackops":
+ case "blackop":
+ case "black operations":
+ case "black operation":
+ this.logging.blackops = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps");
+ break;
+ case "event":
+ case "events":
+ this.logging.events = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for events");
+ break;
+ case "all":
+ this.logging.general = flag;
+ this.logging.contracts = flag;
+ this.logging.ops = flag;
+ this.logging.blackops = flag;
+ this.logging.events = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything");
+ break;
+ default:
+ this.postToConsole("Invalid action/event type specified: " + args[2]);
+ this.postToConsole("Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]");
+ break;
+ }
+}
+
+Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
+ switch (args.length) {
+ case 1:
+ //Display Skill Help Command
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ break;
+ case 2:
+ if (args[1].toLowerCase() === "list") {
+ //List all skills and their level
+ this.postToConsole("Skills: ");
+ var skillNames = Object.keys(Skills);
+ for(var i = 0; i < skillNames.length; ++i) {
+ var skill = Skills[skillNames[i]];
+ var level = 0;
+ if (this.skills[skill.name] != null) {level = this.skills[skill.name];}
+ this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(level, 0));
+ }
+ this.postToConsole(" ");
+ this.postToConsole("Effects: ");
+ var multKeys = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multKeys.length; ++i) {
+ var mult = this.skillMultipliers[multKeys[i]];
+ if (mult && mult !== 1) {
+ mult = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(mult, 3);
+ switch(multKeys[i]) {
+ case "successChanceAll":
+ this.postToConsole("Total Success Chance: x" + mult);
+ break;
+ case "successChanceStealth":
+ this.postToConsole("Stealth Success Chance: x" + mult);
+ break;
+ case "successChanceKill":
+ this.postToConsole("Retirement Success Chance: x" + mult);
+ break;
+ case "successChanceContract":
+ this.postToConsole("Contract Success Chance: x" + mult);
+ break;
+ case "successChanceOperation":
+ this.postToConsole("Operation Success Chance: x" + mult);
+ break;
+ case "successChanceEstimate":
+ this.postToConsole("Synthoid Data Estimate: x" + mult);
+ break;
+ case "actionTime":
+ this.postToConsole("Action Time: x" + mult);
+ break;
+ case "effHack":
+ this.postToConsole("Hacking Skill: x" + mult);
+ break;
+ case "effStr":
+ this.postToConsole("Strength: x" + mult);
+ break;
+ case "effDef":
+ this.postToConsole("Defense: x" + mult);
+ break;
+ case "effDex":
+ this.postToConsole("Dexterity: x" + mult);
+ break;
+ case "effAgi":
+ this.postToConsole("Agility: x" + mult);
+ break;
+ case "effCha":
+ this.postToConsole("Charisma: x" + mult);
+ break;
+ case "effInt":
+ this.postToConsole("Intelligence: x" + mult);
+ break;
+ case "stamina":
+ this.postToConsole("Stamina: x" + mult);
+ break;
+ case "weaponAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML +=
+ break;
+ case "gunAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML
+ break;
+ default:
+ console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
+ break;
+ }
+ }
+ }
+ } else {
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ }
+ break;
+ case 3:
+ var skillName = args[2];
+ var skill = Skills[skillName];
+ if (skill == null || !(skill instanceof Skill)) {
+ return this.postToConsole("Invalid skill name (Note that this is case-sensitive): " + skillName);
+ }
+ if (args[1].toLowerCase() === "list") {
+ this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(this.skills[skill.name]), 0);
+ } else if (args[1].toLowerCase() === "level") {
+ var currentLevel = 0;
+ if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
+ currentLevel = this.skills[skillName];
+ }
+ var pointCost = skill.calculateCost(currentLevel);
+ if (this.skillPoints >= pointCost) {
+ this.skillPoints -= pointCost;
+ this.upgradeSkill(skill);
+ this.log(skill.name + " upgraded to Level " + this.skills[skillName]);
+ this.createActionAndSkillsContent();
+ } else {
+ this.postToConsole("You do not have enough Skill Points to upgrade this. You need " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_13__["formatNumber"])(pointCost, 0));
+ }
+
+ } else {
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ }
+ break;
+ default:
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ break;
+ }
+}
+
+Bladeburner.prototype.executeStartConsoleCommand = function(args) {
+ if (args.length !== 3) {
+ this.postToConsole("Invalid usage of 'start' console command: start [type] [name]");
+ this.postToConsole("Use 'help start' for more info");
+ return;
+ }
+ var name = args[2];
+ switch (args[1].toLowerCase()) {
+ case "general":
+ case "gen":
+ if (GeneralActions[name] != null) {
+ this.action.type = ActionTypes[name];
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid action name specified: " + args[2]);
+ }
+ break;
+ case "contract":
+ case "contracts":
+ if (this.contracts[name] != null) {
+ this.action.type = ActionTypes.Contract;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid contract name specified: " + args[2]);
+ }
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ if (this.operations[name] != null) {
+ this.action.type = ActionTypes.Operation;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid Operation name specified: " + args[2]);
+ }
+ break;
+ case "blackops":
+ case "blackop":
+ case "black operations":
+ case "black operation":
+ if (BlackOperations[name] != null) {
+ this.action.type = ActionTypes.BlackOperation;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid BlackOp name specified: " + args[2]);
+ }
+ break;
+ default:
+ this.postToConsole("Invalid action/event type specified: " + args[1]);
+ this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]");
+ break;
+ }
+}
+
+Bladeburner.prototype.getActionIdFromTypeAndName = function(type="", name="") {
+ if (type === "" || name === "") {return null;}
+ var action = new ActionIdentifier();
+ var convertedType = type.toLowerCase().trim();
+ var convertedName = name.toLowerCase().trim();
+ switch (convertedType) {
+ case "contract":
+ case "contracts":
+ case "contr":
+ action.type = ActionTypes["Contract"];
+ if (this.contracts.hasOwnProperty(name)) {
+ action.name = name;
+ return action;
+ } else {
+ return null;
+ }
+ case "operation":
+ case "operations":
+ case "op":
+ case "ops":
+ action.type = ActionTypes["Operation"];
+ if (this.operations.hasOwnProperty(name)) {
+ action.name = name;
+ return action;
+ } else {
+ return null;
+ }
+ case "blackoperation":
+ case "black operation":
+ case "black operations":
+ case "black op":
+ case "black ops":
+ case "blackop":
+ case "blackops":
+ action.type = ActionTypes["BlackOp"];
+ if (BlackOperations.hasOwnProperty(name)) {
+ action.name = name;
+ return action;
+ } else {
+ return null;
+ }
+ case "general":
+ case "general action":
+ case "gen":
+ break;
+ default:
+ return null;
+ }
+
+ if (convertedType.startsWith("gen")) {
+ switch (convertedName) {
+ case "training":
+ action.type = ActionTypes["Training"];
+ break;
+ case "recruitment":
+ case "recruit":
+ action.type = ActionTypes["Recruitment"];
+ break;
+ case "field analysis":
+ case "fieldanalysis":
+ action.type = ActionTypes["Field Analysis"];
+ break;
+ default:
+ return null;
+ }
+ return action;
+ }
+}
+
+Bladeburner.prototype.getContractNamesNetscriptFn = function() {
+ return Object.keys(this.contracts);
+}
+
+Bladeburner.prototype.getOperationNamesNetscriptFn = function() {
+ return Object.keys(this.operations);
+}
+
+Bladeburner.prototype.getBlackOpNamesNetscriptFn = function() {
+ return Object.keys(BlackOperations);
+}
+
+Bladeburner.prototype.getGeneralActionNamesNetscriptFn = function() {
+ return Object.keys(GeneralActions);
+}
+
+Bladeburner.prototype.getSkillNamesNetscriptFn = function() {
+ return Object.keys(Skills);
+}
+
+Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.startAction() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return false;
+ }
+
+ try {
+ this.startAction(actionId);
+ if (workerScript.shouldLog("startAction")) {
+ workerScript.scriptRef.log("Starting Bladeburner action with type " + type + " and name " + name);
+ }
+ return true;
+ } catch(e) {
+ this.resetAction();
+ workerScript.scriptRef.log("ERROR: Bladeburner.startAction() failed to start action of type " + type + " due to invalid name: " + name +
+ "Note that this name is case-sensitive and whitespace-sensitive");
+ return false;
+ }
+}
+
+Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.getActionTime() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ var actionObj = this.getActionObject(actionId);
+ if (actionObj == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ switch (actionId.type) {
+ case ActionTypes["Contract"]:
+ case ActionTypes["Operation"]:
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ return actionObj.getActionTime(this);
+ case ActionTypes["Training"]:
+ case ActionTypes["Field Analysis"]:
+ case ActionTypes["FieldAnalysis"]:
+ return 30;
+ case ActionTypes["Recruitment"]:
+ return this.getRecruitmentTime();
+ default:
+ workerScript.log(errorLogText);
+ return -1;
+ }
+}
+
+Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.getActionEstimatedSuccessChance() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ var actionObj = this.getActionObject(actionId);
+ if (actionObj == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ switch (actionId.type) {
+ case ActionTypes["Contract"]:
+ case ActionTypes["Operation"]:
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ return actionObj.getSuccessChance(this, {est:true});
+ case ActionTypes["Training"]:
+ case ActionTypes["Field Analysis"]:
+ case ActionTypes["FieldAnalysis"]:
+ return 1;
+ case ActionTypes["Recruitment"]:
+ return this.getRecruitmentSuccessChance();
+ default:
+ workerScript.log(errorLogText);
+ return -1;
+ }
+}
+
+Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.getActionCountRemaining() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ var actionObj = this.getActionObject(actionId);
+ if (actionObj == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ switch (actionId.type) {
+ case ActionTypes["Contract"]:
+ case ActionTypes["Operation"]:
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ return actionObj.count;
+ case ActionTypes["Training"]:
+ case ActionTypes["Field Analysis"]:
+ case ActionTypes["FieldAnalysis"]:
+ return Infinity;
+ default:
+ workerScript.log(errorLogText);
+ return -1;
+ }
+}
+
+Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.getSkillLevel() failed due to an invalid skill specified: " +
+ skillName + ". Note that the name of the skill is case-sensitive";
+
+ if (skillName === "") {
+ //If skill name isn't specified, return an object with all of the player's skill levels
+ let copy = Object.assign({}, this.Skills);
+ return copy;
+ }
+
+ if (!Skills.hasOwnProperty(skillName)) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ if (this.skills[skillName] == null) {
+ return 0;
+ } else {
+ return this.skills[skillName];
+ }
+}
+
+Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.upgradeSkill() failed due to an invalid skill specified: " +
+ skillName + ". Note that the name of the skill is case-sensitive";
+ if (!Skills.hasOwnProperty(skillName)) {
+ workerScript.log(errorLogText);
+ return false;
+ }
+
+ var skill = Skills[skillName];
+ var currentLevel = 0;
+ if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
+ currentLevel = this.skills[skillName];
+ }
+ var cost = skill.calculateCost(currentLevel);
+
+ if (this.skillPoints < cost) {
+ if (workerScript.shouldLog("upgradeSkill")) {
+ workerScript.log("Bladeburner.upgradeSkill() failed because you do not have enough " +
+ "skill points to upgrade " + skillName + " (You have " +
+ this.skillPoints + ", you need " + cost + ")");
+ }
+ return false;
+ }
+
+ this.skillPoints -= cost;
+ this.upgradeSkill(skill);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner && DomElems.currentTab.toLowerCase() === "skills") {
+ this.createActionAndSkillsContent();
+ }
+ if (workerScript.shouldLog("upgradeSkill")) {
+ workerScript.log(skillName + " successfully upgraded to level " + this.skills[skillName]);
+ }
+ return true;
+}
+
+Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript) {
+ if (type === "" && name === "") {
+ return this.teamSize;
+ }
+
+ var errorLogText = "ERROR: Bladeburner.getTeamSize() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ var actionObj = this.getActionObject(actionId);
+ if (actionObj == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ if (actionId.type === ActionTypes["Operation"] ||
+ actionId.type === ActionTypes["BlackOp"] ||
+ actionId.type === ActionTypes["BlackOperation"]) {
+ return actionObj.teamCount;
+ } else {
+ return 0;
+ }
+}
+
+Bladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) {
+ var errorLogText = "ERROR: Bladeburner.setTeamSize() failed due to an invalid action specified. " +
+ "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
+ "name of the operation is case-sensitive.";
+ var actionId = this.getActionIdFromTypeAndName(type, name);
+ if (actionId == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ if (actionId.type !== ActionTypes["Operation"] &&
+ actionId.type !== ActionTypes["BlackOp"] &&
+ actionId.type !== ActionTypes["BlackOperation"]) {
+ workerScript.log("ERROR: Bladeburner.setTeamSize() failed. This function " +
+ "only works for Operations and BlackOps");
+ return -1;
+ }
+
+ var actionObj = this.getActionObject(actionId);
+ if (actionObj == null) {
+ workerScript.log(errorLogText);
+ return -1;
+ }
+
+ var sanitizedSize = Math.round(size);
+ if (isNaN(sanitizedSize)) {
+ workerScript.log("ERROR: Bladeburner.setTeamSize() failed due to an invalid 'size' argument: " + size);
+ return -1;
+ }
+ if (this.teamSize < sanitizedSize) {sanitizedSize = this.teamSize;}
+ actionObj.teamCount = sanitizedSize;
+ if (workerScript.shouldLog("setTeamSize")) {
+ workerScript.log("Team size for " + name + " set to " + sanitizedSize);
+ }
+ return sanitizedSize;
+}
+
+Bladeburner.prototype.getCityEstimatedPopulationNetscriptFn = function(cityName, workerScript) {
+ if (!this.cities.hasOwnProperty(cityName)) {
+ workerScript.log("ERROR: Bladeburner.getCityEstimatedPopulation() failed because the specified " +
+ "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
+ return -1;
+ }
+ return this.cities[cityName].popEst;
+}
+
+Bladeburner.prototype.getCityEstimatedCommunitiesNetscriptFn = function(cityName, workerScript) {
+ if (!this.cities.hasOwnProperty(cityName)) {
+ workerScript.log("ERROR: Bladeburner.getCityEstimatedCommunities() failed because the specified " +
+ "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
+ return -1;
+ }
+ return this.cities[cityName].commsEst;
+}
+
+Bladeburner.prototype.getCityChaosNetscriptFn = function(cityName, workerScript) {
+ if (!this.cities.hasOwnProperty(cityName)) {
+ workerScript.log("ERROR: Bladeburner.getCityChaos() failed because the specified " +
+ "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
+ return -1;
+ }
+ return this.cities[cityName].chaos;
+}
+
+Bladeburner.prototype.switchCityNetscriptFn = function(cityName, workerScript) {
+ if (!this.cities.hasOwnProperty(cityName)) {
+ workerScript.log("ERROR: Bladeburner.switchCity() failed because the specified " +
+ "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
+ return false;
+ }
+ this.city = cityName;
+ return true;
+}
+
+Bladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) {
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_4__["Factions"]["Bladeburners"];
+ if (bladeburnerFac.isMember) {
+ return true;
+ } else if (this.rank >= RankNeededForFaction) {
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_4__["joinFaction"])(bladeburnerFac);
+ if (workerScript.shouldLog("joinBladeburnerFaction")) {
+ workerScript.log("Joined Bladeburners Faction");
+ }
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Bladeburner) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["removeChildrenFromElement"])(DomElems.overviewDiv);
+ this.createOverviewContent();
+ }
+ return true;
+ } else {
+ if (workerScript.shouldLog("joinBladeburnerFaction")) {
+ workerScript.log("Failed to join Bladeburners Faction because " +
+ "you do not have the required " + RankNeededForFaction + " rank");
+ }
+ return false;
+ }
+}
+
+Bladeburner.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Bladeburner", this);
+}
+Bladeburner.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Bladeburner, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_11__["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
+function initBladeburner() {
+ //Skills
+ Skills[SkillNames.BladesIntuition] = new Skill({
+ name:SkillNames.BladesIntuition,
+ desc:"Each level of this skill increases your success chance " +
+ "for all contracts and operations by 3%",
+ baseCost:5, costInc:2,
+ successChanceAll:3
+ });
+ Skills[SkillNames.Reaper] = new Skill({
+ name:SkillNames.Reaper,
+ desc:"Each level of this skill increases your " +
+ "effective combat stats for Bladeburner actions by 3%",
+ baseCost:3, costInc:2,
+ effStr:3, effDef:3, effDex:3, effAgi:3
+ });
+ Skills[SkillNames.Cloak] = new Skill({
+ name:SkillNames.Cloak,
+ desc:"Each level of this skill increases your " +
+ "success chance in stealth-related contracts and operations by 5.5%",
+ baseCost:3, costInc:1,
+ successChanceStealth:5.5
+ });
+
+ //TODO Marksman
+ //TODO Weapon Proficiency
+
+ Skills[SkillNames.Overclock] = new Skill({
+ name:SkillNames.Overclock,
+ desc:"Each level of this skill decreases the time it takes " +
+ "to attempt a contract or operation by 1% (Max Level: 95)",
+ baseCost:5, costInc:1, maxLvl:95,
+ actionTime:1
+ });
+ Skills[SkillNames.EvasiveSystem] = new Skill({
+ name:SkillNames.EvasiveSystem,
+ desc:"Each level of this skill increases your effective " +
+ "dexterity and agility for Bladeburner actions by 5%",
+ baseCost:2, costInc: 1,
+ effDex:5, effAgi:5
+ });
+ Skills[SkillNames.ShortCircuit] = new Skill({
+ name:SkillNames.ShortCircuit,
+ desc:"Each level of this skill increases your success chance " +
+ "in contracts and operations that involve retirement by 5.5%",
+ baseCost:3, costInc:2,
+ successChanceKill:5.5
+ });
+ Skills[SkillNames.DigitalObserver] = new Skill({
+ name:SkillNames.DigitalObserver,
+ desc:"Each level of this skill increases your success chance in " +
+ "all operations by 4%",
+ baseCost:5, costInc:2,
+ successChanceOperation:4
+ });
+ Skills[SkillNames.Datamancer] = new Skill({
+ name:SkillNames.Datamancer,
+ desc:"Each level of this skill increases your effectiveness in " +
+ "synthoid population analysis and investigation by 5%. " +
+ "This affects all actions that can potentially increase " +
+ "the accuracy of your synthoid population/community estimates.",
+ baseCost:3,costInc:1,
+ successChanceEstimate:5
+ });
+ Skills[SkillNames.Tracer] = new Skill({
+ name:SkillNames.Tracer,
+ desc:"Each level of this skill increases your success chance in " +
+ "all contracts by 4%",
+ baseCost:3, costInc:2,
+ successChanceContract:4
+ });
+ Skills[SkillNames.CybersEdge] = new Skill({
+ name:SkillNames.CybersEdge,
+ desc:"Each level of this skill increases your max " +
+ "stamina by 2%",
+ baseCost:1, costInc:3,
+ stamina:2
+ });
+
+ //General Actions
+ var actionName = "Training";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Improve your abilities at the Bladeburner unit's specialized training " +
+ "center. Doing this gives experience for all combat stats and also " +
+ "increases your max stamina."
+ });
+
+ var actionName = "Field Analysis";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Mine and analyze Synthoid-related data. This improve the " +
+ "Bladeburner's unit intelligence on Synthoid locations and " +
+ "activities. Completing this action will improve the accuracy " +
+ "of your Synthoid population estimated in the current city.
" +
+ "Does NOT require stamina."
+ });
+
+ var actionName = "Recruitment";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Attempt to recruit members for your Bladeburner team. These members " +
+ "can help you conduct operations.
" +
+ "Does NOT require stamina."
+ });
+
+ //Black Operations
+ BlackOperations["Operation Typhoon"] = new BlackOperation({
+ name:"Operation Typhoon",
+ desc:"Obadiah Zenyatta is the leader of a RedWater PMC. It has long " +
+ "been known among the intelligence community that Zenyatta, along " +
+ "with the rest of the PMC, is a Synthoid.
" +
+ "The goal of Operation Typhoon is to find and eliminate " +
+ "Zenyatta and RedWater by any means necessary. After the task " +
+ "is completed, the actions must be covered up from the general public.",
+ baseDifficulty:2000, reqdRank:2.5e3,
+ rankGain:50, rankLoss:10, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Zero"] = new BlackOperation({
+ name:"Operation Zero",
+ desc:"AeroCorp is one of the world's largest defense contractors. " +
+ "It's leader, Steve Watataki, is thought to be a supporter of " +
+ "Synthoid rights. He must be removed.
" +
+ "The goal of Operation Zero is to covertly infiltrate AeroCorp and " +
+ "uncover any incriminating evidence or " +
+ "information against Watataki that will cause him to be removed " +
+ "from his position at AeroCorp. Incriminating evidence can be " +
+ "fabricated as a last resort. Be warned that AeroCorp has some of " +
+ "the most advanced security measures in the world.",
+ baseDifficulty:2500, reqdRank:5e3,
+ rankGain:60, rankLoss:15, hpLoss:50,
+ weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation X"] = new BlackOperation({
+ name:"Operation X",
+ desc:"We have recently discovered an underground publication " +
+ "group called Samizdat. Even though most of their publications " +
+ "are nonsensical conspiracy theories, the average human is " +
+ "gullible enough to believe them. Many of their works discuss " +
+ "Synthoids and pose a threat to society. The publications are spreading " +
+ "rapidly in China and other Eastern countries.
" +
+ "Samizdat has done a good job of keeping hidden and anonymous. " +
+ "However, we've just received intelligence that their base of " +
+ "operations is in Ishima's underground sewer systems. Your task is to " +
+ "investigate the sewer systems, and eliminate Samizdat. They must " +
+ "never publish anything again.",
+ baseDifficulty:3000, reqdRank:7.5e3,
+ rankGain:75, rankLoss:15, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Titan"] = new BlackOperation({
+ name:"Operation Titan",
+ desc:"Several months ago Titan Laboratories' Bioengineering department " +
+ "was infiltrated by Synthoids. As far as we know, Titan Laboratories' " +
+ "management has no knowledge about this. We don't know what the " +
+ "Synthoids are up to, but the research that they could " +
+ "be conducting using Titan Laboraties' vast resources is potentially " +
+ "very dangerous.
" +
+ "Your goal is to enter and destroy the Bioengineering department's " +
+ "facility in Aevum. The task is not just to retire the Synthoids there, but " +
+ "also to destroy any information or research at the facility that " +
+ "is relevant to the Synthoids and their goals.",
+ baseDifficulty:4000, reqdRank:10e3,
+ rankGain:100, rankLoss:20, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Ares"] = new BlackOperation({
+ name:"Operation Ares",
+ desc:"One of our undercover agents, Agent Carter, has informed us of a " +
+ "massive weapons deal going down in Dubai between rogue Russian " +
+ "militants and a radical Synthoid community. These weapons are next-gen " +
+ "plasma and energy weapons. It is critical for the safety of humanity " +
+ "that this deal does not happen.
" +
+ "Your task is to intercept the deal. Leave no survivors.",
+ baseDifficulty:5000, reqdRank:12.5e3,
+ rankGain:125, rankLoss:20, hpLoss:200,
+ weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Archangel"] = new BlackOperation({
+ name:"Operation Archangel",
+ desc:"Our analysts have discovered that the popular Red Rabbit brothel in " +
+ "Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence " +
+ "suggests that the profit from this brothel is used to fund a large " +
+ "black market arms trafficking operation.
" +
+ "The goal of this operation is to take out the leaders that are running " +
+ "the Red Rabbit brothel. Try to limit the number of other casualties, " +
+ "but do what you must to complete the mission.",
+ baseDifficulty:7500, reqdRank:15e3,
+ rankGain:200, rankLoss:20, hpLoss:25,
+ weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Juggernaut"] = new BlackOperation({
+ name:"Operation Juggernaut",
+ desc:"The CIA has just encountered a new security threat. A new " +
+ "criminal group, lead by a shadowy operative who calls himself " +
+ "Juggernaut, has been smuggling drugs and weapons (including " +
+ "suspected bioweapons) into Sector-12. We also have reason " +
+ "to believe the tried to break into one of Universal Energy's " +
+ "facilities in order to cause a city-wide blackout. The CIA " +
+ "suspects that Juggernaut is a heavily-augmented Synthoid, and " +
+ "have thus enlisted our help.
" +
+ "Your mission is to eradicate Juggernaut and his followers.",
+ baseDifficulty:10e3, reqdRank:20e3,
+ rankGain:300, rankLoss:40, hpLoss:300,
+ weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Red Dragon"] = new BlackOperation({
+ name:"Operation Red Dragon",
+ desc:"The Tetrads criminal organization is suspected of " +
+ "reverse-engineering the MK-VI Synthoid design. We believe " +
+ "they altered and possibly improved the design and began " +
+ "manufacturing their own Synthoid models in order to bolster " +
+ "their criminal activities.
" +
+ "Your task is to infiltrate and destroy the Tetrads' base of operations " +
+ "in Los Angeles. Intelligence tells us that their base houses " +
+ "one of their Synthoid manufacturing units.",
+ baseDifficulty:12.5e3, reqdRank:25e3,
+ rankGain:500, rankLoss:50, hpLoss:500,
+ weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation K"] = new BlackOperation({
+ name:"Operation K",
+ desc:"CODE RED SITUATION. Our intelligence tells us that VitaLife " +
+ "has discovered a new android cloning technology. This technology " +
+ "is supposedly capable of cloning Synthoid, not only physically " +
+ "but also their advanced AI modules. We do not believe that " +
+ "VitaLife is trying to use this technology illegally or " +
+ "maliciously, but if any Synthoids were able to infiltrate the " +
+ "corporation and take advantage of this technology then the " +
+ "results would be catastrophic.
" +
+ "We do not have the power or jurisdiction to shutdown this down " +
+ "through legal or political means, so we must resort to a covert " +
+ "operation. Your goal is to destroy this technology and eliminate" +
+ "anyone who was involved in its creation.",
+ baseDifficulty:15e3, reqdRank:30e3,
+ rankGain:750, rankLoss:60, hpLoss:1000,
+ weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Deckard"] = new BlackOperation({
+ name:"Operation Deckard",
+ desc:"Despite your success in eliminating VitaLife's new android-replicating " +
+ "technology in Operation K, we've discovered that a small group of " +
+ "MK-VI Synthoids were able to make off with the schematics and design " +
+ "of the technology before the Operation. It is almost a certainty that " +
+ "these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising." +
+ "The goal of Operation Deckard is to hunt down these Synthoids and retire " +
+ "them. I don't need to tell you how critical this mission is.",
+ baseDifficulty:20e3, reqdRank:40e3,
+ rankGain:1e3, rankLoss:75, hpLoss:200,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Tyrell"] = new BlackOperation({
+ name:"Operation Tyrell",
+ desc:"A week ago Blade Industries reported a small break-in at one " +
+ "of their Aevum Augmentation storage facitilities. We figured out " +
+ "that The Dark Army was behind the heist, and didn't think any more " +
+ "of it. However, we've just discovered that several known MK-VI Synthoids " +
+ "were part of that break-in group.
" +
+ "We cannot have Synthoids upgrading their already-enhanced abilities " +
+ "with Augmentations. Your task is to hunt down the associated Dark Army " +
+ "members and eliminate them.",
+ baseDifficulty:25e3, reqdRank:50e3,
+ rankGain:1.5e3, rankLoss:100, hpLoss:500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Wallace"] = new BlackOperation({
+ name:"Operation Wallace",
+ desc:"Based on information gathered from Operation Tyrell, we've discovered " +
+ "that The Dark Army was well aware that there were Synthoids amongst " +
+ "their ranks. Even worse, we believe that The Dark Army is working " +
+ "together with other criminal organizations such as The Syndicate and " +
+ "that they are planning some sort of large-scale takeover of multiple major " +
+ "cities, most notably Aevum. We suspect that Synthoids have infiltrated " +
+ "the ranks of these criminal factions and are trying to stage another " +
+ "Synthoid uprising.
" +
+ "The best way to deal with this is to prevent it before it even happens. " +
+ "The goal of Operation Wallace is to destroy the Dark Army and " +
+ "Syndicate factions in Aevum immediately. Leave no survivors.",
+ baseDifficulty:30e3, reqdRank:75e3,
+ rankGain:2e3, rankLoss:150, hpLoss:1500,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Shoulder of Orion"] = new BlackOperation({
+ name:"Operation Shoulder of Orion",
+ desc:"China's Solaris Space Systems is secretly launching the first " +
+ "manned spacecraft in over a decade using Synthoids. We believe " +
+ "China is trying to establish the first off-world colonies.
" +
+ "The mission is to prevent this launch without instigating an " +
+ "international conflict. When you accept this mission you will be " +
+ "officially disavowed by the NSA and the national government until after you " +
+ "successfully return. In the event of failure, all of the operation's " +
+ "team members must not let themselves be captured alive.",
+ baseDifficulty:35e3, reqdRank:100e3,
+ rankGain:2.5e3, rankLoss:500, hpLoss:1500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation Hyron"] = new BlackOperation({
+ name:"Operation Hyron",
+ desc:"Our intelligence tells us that Fulcrum Technologies is developing " +
+ "a quantum supercomputer using human brains as core " +
+ "processors. This supercomputer " +
+ "is rumored to be able to store vast amounts of data and " +
+ "perform computations unmatched by any other supercomputer on the " +
+ "planet. But more importantly, the use of organic human brains " +
+ "means that the supercomputer may be able to reason abstractly " +
+ "and become self-aware.
" +
+ "I do not need to remind you why sentient-level AIs pose a serious " +
+ "thread to all of mankind.
" +
+ "The research for this project is being conducted at one of Fulcrum " +
+ "Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. " +
+ "Infiltrate the compound, delete and destroy the work, and then find and kill the " +
+ "project lead.",
+ baseDifficulty:40e3, reqdRank:125e3,
+ rankGain:3e3, rankLoss:1e3, hpLoss:500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Morpheus"] = new BlackOperation({
+ name:"Operation Morpheus",
+ desc:"DreamSense Technologies is an advertising company that uses " +
+ "special technology to transmit their ads into the peoples " +
+ "dreams and subconcious. They do this using broadcast transmitter " +
+ "towers. Based on information from our agents and informants in " +
+ "Chonqging, we have reason to believe that one of the broadcast " +
+ "towers there has been compromised by Synthoids and is being used " +
+ "to spread pro-Synthoid propaganda.
" +
+ "The mission is to destroy this broadcast tower. Speed and " +
+ "stealth are of the upmost important for this.",
+ baseDifficulty:45e3, reqdRank:150e3,
+ rankGain:4e3, rankLoss:1e3, hpLoss:100,
+ weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation Ion Storm"] = new BlackOperation({
+ name:"Operation Ion Storm",
+ desc:"Our analysts have uncovered a gathering of MK-VI Synthoids " +
+ "that have taken up residence in the Sector-12 Slums. We " +
+ "don't know if they are rogue Synthoids from the Uprising, " +
+ "but we do know that they have been stockpiling " +
+ "weapons, money, and other resources. This makes them dangerous.
" +
+ "This is a full-scale assault operation to find and retire all of these " +
+ "Synthoids in the Sector-12 Slums.",
+ baseDifficulty:50e3, reqdRank:175e3,
+ rankGain:5e3, rankLoss:1e3, hpLoss:5000,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Annihilus"] = new BlackOperation({
+ name:"Operation Annihilus",
+ desc:"Our superiors have ordered us to eradicate everything and everyone " +
+ "in an underground facility located in Aevum. They tell us " +
+ "that the facility houses many dangerous Synthoids and " +
+ "belongs to a terrorist organization called " +
+ "'The Covenant'. We have no prior intelligence about this " +
+ "organization, so you are going in blind.",
+ baseDifficulty:55e3, reqdRank:200e3,
+ rankGain:7.5e3, rankLoss:1e3, hpLoss:10e3,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Ultron"] = new BlackOperation({
+ name:"Operation Ultron",
+ desc:"OmniTek Incorporated, the original designer and manufacturer of Synthoids, " +
+ "has notified us of a malfunction in their AI design. This malfunction, " +
+ "when triggered, causes MK-VI Synthoids to become radicalized and seek out " +
+ "the destruction of humanity. They say that this bug affects all MK-VI Synthoids, " +
+ "not just the rogue ones from the Uprising.
" +
+ "OmniTek has also told us they they believe someone has triggered this " +
+ "malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids " +
+ "are now amassing in Volhaven to form a terrorist group called Ultron.
" +
+ "Intelligence suggests Ultron is heavily armed and that their members are " +
+ "augmented. We believe Ultron is making moves to take control of " +
+ "and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
" +
+ "Your task is to find and destroy Ultron.",
+ baseDifficulty:60e3, reqdRank:250e3,
+ rankGain:10e3, rankLoss:2e3, hpLoss:10e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Centurion"] = new BlackOperation({
+ name:"Operation Centurion",
+ desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
+ "Throughout all of humanity's history, we have relied on " +
+ "technology to survive, conquer, and progress. Its advancement became our primary goal. " +
+ "And at the peak of human civilization technology turned into " +
+ "power. Global, absolute power.
" +
+ "It seems that the universe is not without a sense of irony.
" +
+ "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
+ baseDifficulty:70e3, reqdRank:300e3,
+ rankGain:15e3, rankLoss:5e3, hpLoss:10e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+ BlackOperations["Operation Vindictus"] = new BlackOperation({
+ name:"Operation Vindictus",
+ desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
+ "The bits are all around us. The daemons that hold the Node " +
+ "together can manifest themselves in many different ways.
" +
+ "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
+ baseDifficulty:75e3, reqdRank:350e3,
+ rankGain:20e3, rankLoss:20e3, hpLoss:20e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+ BlackOperations["Operation Daedalus"] = new BlackOperation({
+ name:"Operation Daedalus",
+ desc:"Yesterday we obeyed kings and bent our neck to emperors. " +
+ "Today we kneel only to truth.",
+ baseDifficulty:80e3, reqdRank:400e3,
+ rankGain:40e3, rankLoss:10e3, hpLoss:100e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
+
+/***/ }),
+/* 36 */
+/*!********************************************************!*\
+ !*** ./node_modules/jszip/lib/stream/GenericWorker.js ***!
+ \********************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -42779,7 +40531,10 @@ module.exports = GenericWorker;
/***/ }),
-/* 39 */
+/* 37 */
+/*!********************************************!*\
+ !*** ./node_modules/jquery/dist/jquery.js ***!
+ \********************************************/
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
@@ -53150,7 +50905,10 @@ return jQuery;
/***/ }),
-/* 40 */
+/* 38 */
+/*!***************************!*\
+ !*** ./src/SourceFile.js ***!
+ \***************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -53159,8 +50917,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayerOwnedSourceFile", function() { return PlayerOwnedSourceFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applySourceFile", function() { return applySourceFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSourceFiles", function() { return initSourceFiles; });
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 13);
@@ -53403,326 +51161,30 @@ function applySourceFile(srcFile) {
/***/ }),
-/* 41 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; });
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
-/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(49);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2);
-
-
-
-
-
-
-
-
-
-
-/* {
- * serverName: {
- * header: Server Header Element
- * panel: Server Panel List (ul) element
- * scripts: {
- * script id: Ref to Script information
- * }
- * }
- * ...
- */
-let ActiveScriptsUI = {};
-let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
-
-function createActiveScriptsServerPanel(server) {
- let hostname = server.hostname;
-
- var activeScriptsList = document.getElementById("active-scripts-list");
-
- let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname});
- let li = res[0];
- var hdr = res[1];
- let panel = res[2];
-
- if (ActiveScriptsUI[hostname] != null) {
- console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
- return;
- }
-
- var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul");
- panel.appendChild(panelScriptList);
- activeScriptsList.appendChild(li);
-
- ActiveScriptsUI[hostname] = {
- header: hdr,
- panel: panel,
- 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
- };
-
- return li;
-}
-
-//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) {
- console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
- return;
- }
-
- //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");
- return;
- }
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header);
- delete ActiveScriptsUI[hostname];
-}
-
-function addActiveScriptsItem(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()");
- return;
- }
- let hostname = server.hostname;
-
- ActiveScriptsTasks.push(function(workerscript, hostname) {
- if (ActiveScriptsUI[hostname] == null) {
- createActiveScriptsServerPanel(server);
- }
-
- //Create the unique identifier (key) for this script
- var itemNameArray = ["active", "scripts", hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:workerscript.name});
- let li = res[0];
- let hdr = res[1];
- let panel = res[2];
-
- hdr.classList.remove("accordion-header");
- hdr.classList.add("active-scripts-script-header");
- 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
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
- innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" +
- "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args)
- }));
- var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
- innerText:"Loading...", fontSize:"14px",
- });
- panel.appendChild(panelText);
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br"));
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
- innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px",
- clickListener:()=>{
- Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef);
- return false;
- }
- }));
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
- innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px",
- clickListener:()=>{
- Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete...");
- return false;
- }
- }));
-
- //Append element to list
- ActiveScriptsUI[hostname]["panelList"].appendChild(li);
- ActiveScriptsUI[hostname].scripts[itemName] = li;
- ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr;
- ActiveScriptsUI[hostname].scriptStats[itemName] = panelText;
- }.bind(null, workerscript, hostname));
-}
-
-function deleteActiveScriptsItem(workerscript) {
- ActiveScriptsTasks.push(function(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " +
- "you tried to delete a large number of scripts and also deleted servers at the " +
- "same time. It's not a big deal, just save and refresh the game.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null) {
- console.log("ERROR: Trying to delete Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
- return;
- }
-
- var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- let li = ActiveScriptsUI[hostname].scripts[itemName];
- if (li == null) {
- console.log("ERROR: Cannot find Active Script UI element for workerscript: ");
- console.log(workerscript);
- return;
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(li);
- delete ActiveScriptsUI[hostname].scripts[itemName];
- delete ActiveScriptsUI[hostname].scriptHdrs[itemName];
- delete ActiveScriptsUI[hostname].scriptStats[itemName];
- if (Object.keys(ActiveScriptsUI[hostname].scripts).length === 0) {
- deleteActiveScriptsServerPanel(server);
- }
- }.bind(null, workerscript));
-}
-
-//Update the ActiveScriptsItems array
-function updateActiveScriptsItems(maxTasks=100) {
- //Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
- //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once...
- let numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
- for (let i = 0; i < numTasks; ++i) {
- let task = ActiveScriptsTasks.shift();
- try {
- task();
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
- console.log(task);
- }
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;}
- var total = 0;
- for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) {
- try {
- total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
- }
- }
- document.getElementById("active-scripts-total-prod").innerHTML =
- "Total online production of Active Scripts: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" +
- "Total online production since last Aug installation: " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)";
- return total;
-}
-
-//Updates the content of the given item in the Active Scripts list
-function updateActiveScriptsItemContent(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null) {
- return; //Hasn't been created yet. We'll skip it
- }
-
- var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) {
- return; //Hasn't been fully added yet. We'll skip it
- }
- var item = ActiveScriptsUI[hostname].scriptStats[itemName];
-
- //Update the text if necessary. This fn returns the online $/s production
- return updateActiveScriptsText(workerscript, item, itemName);
-}
-
-function updateActiveScriptsText(workerscript, item, itemName) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == null) {
- console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
- return;
- }
-
- var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
-
- //Only update if the item is visible
- if (ActiveScriptsUI[hostname].header.classList.contains("active") === false) {return onlineMps;}
- if (ActiveScriptsUI[hostname].scriptHdrs[itemName].classList.contains("active") === false) {return onlineMps;}
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item);
-
- //Online
- var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2);
- var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " ");
-
- var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second";
- var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime;
- var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " ");
-
- //Offline
- var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2);
- var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " ");
-
- var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
- var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second";
- var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime;
- var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " ");
-
- item.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" +
- onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" +
- offlineMpsText + "
" + offlineEpsText + "
";
- return onlineMps;
-}
-
-
-
-
-/***/ }),
-/* 42 */
+/* 39 */
+/*!**********************************!*\
+ !*** ./src/CompanyManagement.js ***!
+ \**********************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Corporation", function() { return Corporation; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
-/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(52);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(0);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(9);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(13);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Literature.js */ 49);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! decimal.js */ 19);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(12);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
@@ -54634,7 +52096,7 @@ Industry.prototype.updateWarehouseSizeUsed = function(warehouse) {
var prod = this.products[prodName];
warehouse.sizeUsed += (prod.data[warehouse.loc][0] * prod.siz);
if (prod.data[warehouse.loc][0] > 0) {
- warehouse.breakdown += (prodName + ": " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(prod.data[warehouse.loc][0] * prod.siz, 0) + "
");
+ warehouse.breakdown += (prodName + ": " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(prod.data[warehouse.loc][0] * prod.siz, 0) + "
");
}
}
}
@@ -54921,7 +52383,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
var mat = warehouse.materials[matName];
var sCost;
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(mat.sCost)) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(mat.sCost)) {
sCost = mat.sCost.replace(/MP/g, mat.bCost);
sCost = eval(sCost);
} else {
@@ -54951,7 +52413,7 @@ Industry.prototype.processMaterials = function(marketCycles=1, company) {
company.getSalesMultiplier() * advertisingFactor;
var sellAmt;
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(mat.sllman[1])) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(mat.sllman[1])) {
//Dynamically evaluated
var tmp = mat.sllman[1].replace(/MAX/g, maxSell);
tmp = tmp.replace(/PROD/g, mat.prd);
@@ -55196,7 +52658,7 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
//Calculate Sale Cost (sCost), which could be dynamically evaluated
var sCost;
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sCost)) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sCost)) {
sCost = product.sCost.replace(/MP/g, product.pCost + product.rat / product.mku);
sCost = eval(sCost);
} else {
@@ -55215,7 +52677,7 @@ Industry.prototype.processProduct = function(marketCycles=1, product, corporatio
var maxSell = 0.5 * Math.pow(product.rat, 0.65) * marketFactor * corporation.getSalesMultiplier() *
Math.pow(markup, 2) * businessFactor * advertisingFactor;
var sellAmt;
- if (product.sllman[city][0] && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sllman[city][1])) {
+ if (product.sllman[city][0] && Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sllman[city][1])) {
//Sell amount is dynamically evaluated
var tmp = product.sllman[city][1].replace(/MAX/g, maxSell);
tmp = tmp.replace(/PROD/g, product.data[city][1]);
@@ -55481,15 +52943,15 @@ Employee.prototype.createUI = function(panel, corporation) {
panel.style.color = "white";
panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
id:"cmpy-mgmt-employee-" + this.name + "-panel-text",
- innerHTML:"Morale: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.mor, 3) + "
" +
- "Happiness: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.hap, 3) + "
" +
- "Energy: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.ene, 3) + "
" +
- "Age: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.age, 3) + "
" +
- "Intelligence: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effInt, 3) + "
" +
- "Charisma: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCha, 3) + "
" +
- "Experience: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.exp, 3) + "
" +
- "Creativity: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCre, 3) + "
" +
- "Efficiency: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effEff, 3) + "
" +
+ innerHTML:"Morale: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.mor, 3) + "
" +
+ "Happiness: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.hap, 3) + "
" +
+ "Energy: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.ene, 3) + "
" +
+ "Age: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.age, 3) + "
" +
+ "Intelligence: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effInt, 3) + "
" +
+ "Charisma: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCha, 3) + "
" +
+ "Experience: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.exp, 3) + "
" +
+ "Creativity: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCre, 3) + "
" +
+ "Efficiency: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effEff, 3) + "
" +
"Salary: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.sal).format("$0.000a") + "/ s
",
}));
@@ -55531,15 +52993,15 @@ Employee.prototype.updateUI = function(panel, corporation) {
if (text == null) {
return this.createUI(panel);
}
- text.innerHTML = "Morale: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.mor, 3) + "
" +
- "Happiness: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.hap, 3) + "
" +
- "Energy: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.ene, 3) + "
" +
- "Age: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.age, 3) + "
" +
- "Intelligence: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effInt, 3) + "
" +
- "Charisma: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCha, 3) + "
" +
- "Experience: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.exp, 3) + "
" +
- "Creativity: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCre, 3) + "
" +
- "Efficiency: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effEff, 3) + "
" +
+ text.innerHTML = "Morale: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.mor, 3) + "
" +
+ "Happiness: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.hap, 3) + "
" +
+ "Energy: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.ene, 3) + "
" +
+ "Age: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.age, 3) + "
" +
+ "Intelligence: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effInt, 3) + "
" +
+ "Charisma: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCha, 3) + "
" +
+ "Experience: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.exp, 3) + "
" +
+ "Creativity: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effCre, 3) + "
" +
+ "Efficiency: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(effEff, 3) + "
" +
"Salary: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.sal).format("$0.000a") + "/ s
";
}
@@ -55672,11 +53134,11 @@ OfficeSpace.prototype.findEmployees = function(parentRefs) {
var createEmpDiv = function(employee, office) {
var div = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
class:"cmpy-mgmt-find-employee-option",
- innerHTML: "Intelligence: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.int, 1) + "
" +
- "Charisma: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.cha, 1) + "
" +
- "Experience: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.exp, 1) + "
" +
- "Creativity: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.cre, 1) + "
" +
- "Efficiency: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.eff, 1) + "
" +
+ innerHTML: "Intelligence: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.int, 1) + "
" +
+ "Charisma: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.cha, 1) + "
" +
+ "Experience: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.exp, 1) + "
" +
+ "Creativity: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.cre, 1) + "
" +
+ "Efficiency: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(employee.eff, 1) + "
" +
"Salary: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(employee.sal).format('$0.000a') + " \ s
",
clickListener:()=>{
office.hireEmployee(employee, parentRefs);
@@ -55753,7 +53215,7 @@ OfficeSpace.prototype.hireRandomEmployee = function(parentRefs) {
salary: sal * mult,
});
- var name = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["generateRandomString"])(7);
+ var name = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["generateRandomString"])(7);
for (var i = 0; i < this.employees.length; ++i) {
if (this.employees[i].name === name) {
@@ -55834,7 +53296,7 @@ Warehouse.prototype.updateMaterialSizeUsed = function() {
if (MaterialSizes.hasOwnProperty(matName)) {
this.sizeUsed += (mat.qty * MaterialSizes[matName]);
if (mat.qty > 0) {
- this.breakdown += (matName + ": " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qty * MaterialSizes[matName], 0) + "
");
+ this.breakdown += (matName + ": " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.qty * MaterialSizes[matName], 0) + "
");
}
}
}
@@ -55972,8 +53434,8 @@ Warehouse.prototype.updateUI = function(parentRefs) {
//Storage text
var storageText = "Storage: " +
- (this.sizedUsed >= this.size ? Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sizeUsed, 3) : Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sizeUsed, 3)) +
- "/" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.size, 3);
+ (this.sizedUsed >= this.size ? Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sizeUsed, 3) : Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sizeUsed, 3)) +
+ "/" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.size, 3);
if (this.breakdown != null && this.breakdown != "") {
storageText += ("" +
this.breakdown + "");
@@ -56052,21 +53514,21 @@ Warehouse.prototype.createMaterialUI = function(mat, matName, parentRefs) {
//If Market Research upgrades are unlocked, add competition and demand info
var cmpAndDmdText = "";
if (company.unlockUpgrades[2] === 1) {
- cmpAndDmdText += "
Demand: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.dmd, 3);
+ cmpAndDmdText += "
Demand: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.dmd, 3);
}
if (company.unlockUpgrades[3] === 1) {
- cmpAndDmdText += "
Competition: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.cmp, 3);
+ cmpAndDmdText += "
Competition: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.cmp, 3);
}
- var innerTxt = "
Prod: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.prd, 3) + "/s
Sell: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.sll, 3) +
- "/s
Export: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.totalExp, 3) + "/s
Import: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.imp, 3) + "/s" + cmpAndDmdText + "
" +
- "
Prod: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.prd, 3) + "/s
Sell: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.sll, 3) +
+ "/s
Export: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.totalExp, 3) + "/s
Import: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mat.imp, 3) + "/s" + cmpAndDmdText + "
" +
+ "
" +
- "
" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.prog, 2) + "% complete",
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.prog, 2) + "% complete",
}));
return div;
}
@@ -56415,25 +53877,25 @@ Warehouse.prototype.createProductUI = function(product, parentRefs) {
//Completed products
var cmpAndDmdText = "";
if (company.unlockUpgrades[2] === 1) {
- cmpAndDmdText += "
Demand: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.dmd, 3);
+ cmpAndDmdText += "
Demand: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.dmd, 3);
}
if (company.unlockUpgrades[3] === 1) {
- cmpAndDmdText += "
Competition: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.cmp, 3);
+ cmpAndDmdText += "
Competition: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.cmp, 3);
}
var totalGain = product.data[city][1] - product.data[city][2]; //Production - sale
div.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerHTML: "
" +
- "Sell: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/s
" +
- "
" +
- "Performance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.per, 3) + "
" +
- "Durability: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.dur, 3) + "
" +
- "Reliability: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.rel, 3) + "
" +
- "Aesthetics: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.aes, 3) + "
" +
- "Features: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.fea, 3) +
+ innerHTML: "
" +
+ "Sell: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/s
" +
+ "
" +
+ "Performance: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.per, 3) + "
" +
+ "Durability: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.dur, 3) + "
" +
+ "Reliability: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.rel, 3) + "
" +
+ "Aesthetics: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.aes, 3) + "
" +
+ "Features: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.fea, 3) +
cmpAndDmdText + "
" +
"
" +
@@ -56448,10 +53910,10 @@ Warehouse.prototype.createProductUI = function(product, parentRefs) {
div.appendChild(buttonPanel);
//Sell button
- var sellInnerTextString = (product.sllman[city][1] === -1 ? "Sell (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/MAX)" :
- "Sell (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.sllman[city][1], 3) + ")");
+ var sellInnerTextString = (product.sllman[city][1] === -1 ? "Sell (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/MAX)" :
+ "Sell (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.data[city][2], 3) + "/" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.sllman[city][1], 3) + ")");
if (product.sCost) {
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sCost)) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(product.sCost)) {
sellInnerTextString += (" @ " + product.sCost);
} else {
sellInnerTextString += (" @ " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(product.sCost).format("$0.000a"));
@@ -56577,7 +54039,7 @@ Warehouse.prototype.createProductUI = function(product, parentRefs) {
//Limit production button
var limitProductionInnerText = "Limit Production";
if (product.prdman[city][0]) {
- limitProductionInnerText += " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.prdman[city][1], 3) + ")";
+ limitProductionInnerText += " (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(product.prdman[city][1], 3) + ")";
}
div.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
class:"a-link-button", innerText:limitProductionInnerText,display:"inline-block",
@@ -57317,7 +54779,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
var homeComp = _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].getHomeComputer(), hasHandbook = false,
handbookFn = "corporation-management-handbook.lit";
for (var i = 0; i < homeComp.messages.length; ++i) {
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(homeComp.messages[i]) && homeComp.messages[i] === handbookFn) {
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["isString"])(homeComp.messages[i]) && homeComp.messages[i] === handbookFn) {
hasHandbook = true;
break;
}
@@ -57417,7 +54879,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
"these shares, you must use your own money (NOT your Corporation's funds). " +
"The current price of your " +
"company's stock is " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(currentStockPrice).format("$0.000a") +
- ". Your company currently has " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.issuedShares, 3) + " outstanding stock shares",
+ ". Your company currently has " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.issuedShares, 3) + " outstanding stock shares",
});
var costIndicator = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {});
var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
@@ -57524,7 +54986,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
var totalAmount = Number(money) + (stockShares * stockPrice);
var repGain = totalAmount / BribeToRepRatio;
- repGainText.innerText = "You will gain " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
+ repGainText.innerText = "You will gain " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
" reputation with " +
factionSelector.options[factionSelector.selectedIndex].value +
" with this bribe";
@@ -57547,7 +55009,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
var totalAmount = money + (stockShares * stockPrice);
var repGain = totalAmount / BribeToRepRatio;
console.log("repGain: " + repGain);
- repGainText.innerText = "You will gain " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
+ repGainText.innerText = "You will gain " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
" reputation with " +
factionSelector.options[factionSelector.selectedIndex].value +
" with this bribe";
@@ -57574,7 +55036,7 @@ Corporation.prototype.displayCorporationOverviewContent = function() {
} else {
var totalAmount = money + (stockShares * stockPrice);
var repGain = totalAmount / BribeToRepRatio;
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("You gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("You gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(repGain, 0) +
" reputation with " + fac.name + " by bribing them.");
fac.playerReputation += repGain;
this.funds = this.funds.minus(money);
@@ -57740,7 +55202,7 @@ Corporation.prototype.updateCorporationOverviewContent = function() {
"Total Profits: " + profitStr + " / s
" +
"Publicly Traded: " + (this.public ? "Yes" : "No") + "
" +
"Owned Stock Shares: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.numShares).format('0.000a') + "
" +
- "Stock Price: " + (this.public ? "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sharePrice, 2) : "N/A") + "
";
+ "Stock Price: " + (this.public ? "$" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.sharePrice, 2) : "N/A") + "
";
var prodMult = this.getProductionMultiplier(),
storageMult = this.getStorageMultiplier(),
@@ -57751,15 +55213,15 @@ Corporation.prototype.updateCorporationOverviewContent = function() {
empEffMult = this.getEmployeeEffMultiplier(),
salesMult = this.getSalesMultiplier(),
sciResMult = this.getScientificResearchMultiplier();
- if (prodMult > 1) {txt += "Production Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(prodMult, 3) + "
";}
- if (storageMult > 1) {txt += "Storage Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(storageMult, 3) + "
";}
- if (advMult > 1) {txt += "Advertising Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(advMult, 3) + "
";}
- if (empCreMult > 1) {txt += "Empl. Creativity Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empCreMult, 3) + "
";}
- if (empChaMult > 1) {txt += "Empl. Charisma Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empChaMult, 3) + "
";}
- if (empIntMult > 1) {txt += "Empl. Intelligence Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empIntMult, 3) + "
";}
- if (empEffMult > 1) {txt += "Empl. Efficiency Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empEffMult, 3) + "
";}
- if (salesMult > 1) {txt += "Sales Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(salesMult, 3) + "
";}
- if (sciResMult > 1) {txt += "Scientific Research Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(sciResMult, 3) + "
";}
+ if (prodMult > 1) {txt += "Production Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(prodMult, 3) + "
";}
+ if (storageMult > 1) {txt += "Storage Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(storageMult, 3) + "
";}
+ if (advMult > 1) {txt += "Advertising Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(advMult, 3) + "
";}
+ if (empCreMult > 1) {txt += "Empl. Creativity Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empCreMult, 3) + "
";}
+ if (empChaMult > 1) {txt += "Empl. Charisma Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empChaMult, 3) + "
";}
+ if (empIntMult > 1) {txt += "Empl. Intelligence Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empIntMult, 3) + "
";}
+ if (empEffMult > 1) {txt += "Empl. Efficiency Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(empEffMult, 3) + "
";}
+ if (salesMult > 1) {txt += "Sales Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(salesMult, 3) + "
";}
+ if (sciResMult > 1) {txt += "Scientific Research Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(sciResMult, 3) + "
";}
p.innerHTML = txt;
}
@@ -58251,7 +55713,7 @@ Corporation.prototype.displayDivisionContent = function(division, city) {
mult = office.employees[fooit].throwParty(input.value);
}
Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("You threw a party for the office! The morale and happiness " +
- "of each employee increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])((mult-1) * 100, 2) + "%.");
+ "of each employee increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])((mult-1) * 100, 2) + "%.");
Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
}
}
@@ -58449,19 +55911,19 @@ Corporation.prototype.updateDivisionContent = function(division) {
var ratioFac = advertisingFactors[3];
var totalAdvertisingFac = advertisingFactors[0];
advertisingInfo =
- "
" +
- "Awareness Bonus: x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(awarenessFac, 0.85), 3) + "
" +
- "Popularity Bonus: x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(popularityFac, 0.85), 3) + "
" +
- "Ratio Multiplier: x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(ratioFac, 0.85), 3) + "
"
+ "Awareness Bonus: x" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(awarenessFac, 0.85), 3) + "
" +
+ "Popularity Bonus: x" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(popularityFac, 0.85), 3) + "
" +
+ "Ratio Multiplier: x" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(Math.pow(ratioFac, 0.85), 3) + "
"
}
Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(industryOverviewText);
industryOverviewText.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
innerHTML:"Industry: " + division.type + " (Corp Funds: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.funds.toNumber()).format("$0.000a") + ")
" +
- "Awareness: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.awareness, 3) + "
" +
- "Popularity: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.popularity, 3) + "
" +
+ "Awareness: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.awareness, 3) + "
" +
+ "Popularity: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.popularity, 3) + "
" +
advertisingInfo + "
" +
"Revenue: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s
" +
"Expenses: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s
" +
@@ -58469,7 +55931,7 @@ Corporation.prototype.updateDivisionContent = function(division) {
}));
industryOverviewText.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
marginTop:"2px",
- innerText:"Production Multiplier: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.prodMult, 2),
+ innerText:"Production Multiplier: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.prodMult, 2),
tooltip:"Production gain from owning production-boosting materials " +
"such as hardware, Robots, AI Cores, and Real Estate"
}));
@@ -58491,7 +55953,7 @@ Corporation.prototype.updateDivisionContent = function(division) {
industryOverviewText.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
industryOverviewText.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
display:"inline-block",
- innerText:"Scientific Research: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.sciResearch.qty, 3),
+ innerText:"Scientific Research: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.sciResearch.qty, 3),
tooltip:"Scientific Research increases the quality of the materials and " +
"products that you produce."
}));
@@ -58530,27 +55992,27 @@ Corporation.prototype.updateDivisionContent = function(division) {
avgEnergy = totalEnergy / office.employees.length;
}
industryEmployeeInfo.innerHTML =
- "Avg Employee Morale: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgMorale, 3) + "
" +
- "Avg Employee Happiness: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgHappiness, 3) + "
" +
- "Avg Employee Energy: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgEnergy, 3);
+ "Avg Employee Morale: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgMorale, 3) + "
" +
+ "Avg Employee Happiness: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgHappiness, 3) + "
" +
+ "Avg Employee Energy: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(avgEnergy, 3);
if (vechain) { //VeChain - Statistics
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br", {}));
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Material Production: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getOfficeProductivity(office), 3),
+ innerText:"Material Production: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getOfficeProductivity(office), 3),
tooltip: "The base amount of material this office can produce. Does not include " +
"production multipliers from upgrades and materials. This value is based off " +
"the productivity of your Operations, Engineering, and Management employees"
}));
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br", {}));
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Product Production: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getOfficeProductivity(office, {forProduct:true}), 3),
+ innerText:"Product Production: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getOfficeProductivity(office, {forProduct:true}), 3),
tooltip: "The base amount of any given Product this office can produce. Does not include " +
"production multipliers from upgrades and materials. This value is based off " +
"the productivity of your Operations, Engineering, and Management employees"
}));
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br", {}));
industryEmployeeInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText: "Business Multiplier: x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getBusinessFactor(office), 3),
+ innerText: "Business Multiplier: x" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(division.getBusinessFactor(office), 3),
tooltip: "The effect this office's 'Business' employees has on boosting sales"
}));
}
@@ -58641,225 +56103,2561 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Corpo
/***/ }),
-/* 43 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const DialogBox_1 = __webpack_require__(7);
-const JSONReviver_1 = __webpack_require__(9);
-/**
- * Represents a plain text file that is typically stored on a server.
- */
-class TextFile {
- /**
- * Initiatizes a TextFile from a JSON save state.
- */
- static fromJSON(value) {
- return JSONReviver_1.Generic_fromJSON(TextFile, value.data);
- }
- constructor(fn = "", txt = "") {
- this.fn = (fn.endsWith(".txt") ? fn : `${fn}.txt`).replace(/\s+/g, "");
- this.text = txt;
- }
- /**
- * Concatenates the raw values to the end of current content.
- */
- append(txt) {
- this.text += txt;
- }
- /**
- * Serves the file to the user as a downloadable resource through the browser.
- */
- download() {
- const filename = this.fn;
- const file = new Blob([this.text], { type: "text/plain" });
- /* tslint:disable-next-line:strict-boolean-expressions */
- if (window.navigator.msSaveOrOpenBlob) {
- // IE10+
- window.navigator.msSaveOrOpenBlob(file, filename);
- }
- else {
- // Others
- const a = document.createElement("a");
- const url = URL.createObjectURL(file);
- a.href = url;
- a.download = this.fn;
- document.body.appendChild(a);
- a.click();
- setTimeout(() => {
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- }, 0);
- }
- }
- /**
- * Retrieve the content of the file.
- */
- read() {
- return this.text;
- }
- /**
- * Shows the content to the user via the game's dialog box.
- */
- show() {
- DialogBox_1.dialogBoxCreate(`${this.fn}
${this.text}`, true);
- }
- /**
- * Serialize the current file to a JSON save state.
- */
- toJSON() {
- return JSONReviver_1.Generic_toJSON("TextFile", this);
- }
- /**
- * Replaces the current content with the text provided.
- */
- write(txt) {
- this.text = txt;
- }
-}
-exports.TextFile = TextFile;
-JSONReviver_1.Reviver.constructors.TextFile = TextFile;
-/**
- * Retrieve the file object for the filename on the specified server.
- * @param fn The file name to look for
- * @param server The server object to look in
- * @returns The file object, or null if it couldn't find it.
- */
-function getTextFile(fn, server) {
- const filename = !fn.endsWith(".txt") ? `${fn}.txt` : fn;
- for (const file of server.textFiles) {
- if (file.fn === filename) {
- return file;
- }
- }
- return null;
-}
-exports.getTextFile = getTextFile;
-/**
- * Creates a TextFile on the target server.
- * @param fn The file name to create.
- * @param txt The contents of the file.
- * @param server The server that the file should be created on.
- * @returns The instance of the file.
- */
-function createTextFile(fn, txt, server) {
- if (getTextFile(fn, server) !== null) {
- // This should probably be a `throw`...
- /* tslint:disable-next-line:no-console */
- console.error(`A file named "${fn}" already exists on server ${server.hostname}.`);
- return undefined;
- }
- const file = new TextFile(fn, txt);
- server.textFiles.push(file);
- return file;
-}
-exports.createTextFile = createTextFile;
-/* tslint:disable-next-line:no-unused-variable */
-function deleteTextFile(fn, server) {
- const filename = !fn.endsWith(".txt") ? `${fn}.txt` : fn;
- /* tslint:disable-next-line:typedef */
- for (let i = 0; i < server.textFiles.length; ++i) {
- if (server.textFiles[i].fn === filename) {
- server.textFiles.splice(i, 1);
- return true;
- }
- }
- return false;
-}
-
-
-/***/ }),
-/* 44 */
+/* 40 */
+/*!****************************!*\
+ !*** ./src/HacknetNode.js ***!
+ \****************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; });
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HacknetNode", function() { return HacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPlayerHacknetNodeWrappers", function() { return createPlayerHacknetNodeWrappers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayHacknetNodesContent", function() { return displayHacknetNodesContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCostOfNextHacknetNode", function() { return getCostOfNextHacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getHacknetNode", function() { return getHacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMaxNumberLevelUpgrades", function() { return getMaxNumberLevelUpgrades; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hacknetNodesInit", function() { return hacknetNodesInit; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processAllHacknetNodeEarnings", function() { return processAllHacknetNodeEarnings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseHacknet", function() { return purchaseHacknet; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesContent", function() { return updateHacknetNodesContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesMultiplierButtons", function() { return updateHacknetNodesMultiplierButtons; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateTotalHacknetProduction", function() { return updateTotalHacknetProduction; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__);
-function NetscriptPort() {
- this.data = [];
-}
-NetscriptPort.prototype.write = function(data) {
- this.data.push(data);
- if (this.data.length > _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
- return this.data.shift();
+
+
+
+
+
+
+
+/**
+ * Overwrites the inner text of the specified HTML element if it is different from what currently exists.
+ * @param {string} elementId The HTML ID to find the first instance of.
+ * @param {string} text The inner text that should be set.
+ */
+function updateText(elementId, text) {
+ var el = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])(elementId);
+ if (el.innerText != text) {
+ el.innerText = text;
+ }
+};
+
+/* HacknetNode.js */
+function hacknetNodesInit() {
+ var performMapping = function(x) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])("hacknet-nodes-" + x.id + "-multiplier")
+ .addEventListener("click", function() {
+ hacknetNodePurchaseMultiplier = x.multiplier;
+ updateHacknetNodesMultiplierButtons();
+ updateHacknetNodesContent();
+ return false;
+ });
+ };
+
+ var mappings = [
+ { id: "1x", multiplier: 1 },
+ { id: "5x", multiplier: 5 },
+ { id: "10x", multiplier: 10 },
+ { id: "max", multiplier: 0 }
+ ];
+ for (var elem of mappings) {
+ // Encapsulate in a function so that the appropriate scope is kept in the click handler.
+ performMapping(elem);
}
- return null;
}
-NetscriptPort.prototype.tryWrite = function(data) {
- if (this.data.length >= _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
+document.addEventListener("DOMContentLoaded", hacknetNodesInit, false);
+
+function HacknetNode(name) {
+ this.level = 1;
+ this.ram = 1; //GB
+ this.cores = 1;
+
+ this.name = name;
+
+ this.totalMoneyGenerated = 0;
+ this.onlineTimeSeconds = 0;
+
+ this.moneyGainRatePerSecond = 0;
+}
+
+
+HacknetNode.prototype.updateMoneyGainRate = function() {
+ //How much extra $/s is gained per level
+ var gainPerLevel = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMoneyGainPerLevel;
+
+ this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
+ Math.pow(1.035, this.ram-1) *
+ ((this.cores + 5) / 6) *
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_money_mult *
+ _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].HacknetNodeMoney;
+ if (isNaN(this.moneyGainRatePerSecond)) {
+ this.moneyGainRatePerSecond = 0;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__["dialogBoxCreate"])("Error in calculating Hacknet Node production. Please report to game developer");
+ }
+
+ updateTotalHacknetProduction();
+}
+
+HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) {
+ levels = Math.round(levels);
+ if (isNaN(levels) || levels < 1) {
+ return 0;
+ }
+
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeLevelMult;
+ var totalMultiplier = 0; //Summed
+ var currLevel = this.level;
+ for (var i = 0; i < levels; ++i) {
+ totalMultiplier += Math.pow(mult, currLevel);
+ ++currLevel;
+ }
+
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode / 2 * totalMultiplier * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_level_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getLevelUpgradeCost = function(levels=1) {
+ return this.calculateLevelUpgradeCost(levels);
+}
+
+HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
+ levels = Math.round(levels);
+ var cost = this.calculateLevelUpgradeCost(levels);
+ if (isNaN(cost) || levels < 0) {
return false;
}
- this.data.push(data);
+
+ if (this.level + levels > _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel) {
+ var diff = Math.max(0, _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - this.level);
+ return this.purchaseLevelUpgrade(diff);
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ return false;
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ this.level += levels;
+ this.updateMoneyGainRate();
return true;
}
-NetscriptPort.prototype.read = function() {
- if (this.data.length === 0) {
- return "NULL PORT DATA";
- }
- return this.data.shift();
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeLevel = function(levels=1) {
+ let res = this.purchaseLevelUpgrade(levels);
+ createPlayerHacknetNodeWrappers();
+ return res;
}
-NetscriptPort.prototype.peek = function() {
- if (this.data.length === 0) {
- return "NULL PORT DATA";
+HacknetNode.prototype.calculateRamUpgradeCost = function() {
+ var numUpgrades = Math.log2(this.ram);
+
+ //Calculate cost
+ //Base cost of RAM is 50k per 1GB, increased by some multiplier for each time RAM is upgraded
+ var baseCost = this.ram * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostFor1GBOfRamHacknetNode;
+ var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeRamMult, numUpgrades);
+ return baseCost * mult * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_ram_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getRamUpgradeCost = function() {
+ return this.calculateRamUpgradeCost();
+}
+
+HacknetNode.prototype.purchaseRamUpgrade = function() {
+ var cost = this.calculateRamUpgradeCost();
+ if (isNaN(cost)) {
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ return false;
+ }
+
+ if (this.ram >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxRam) {
+ return false;
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ this.ram *= 2; //Ram is always doubled
+ this.updateMoneyGainRate();
+ return true;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeRam = function() {
+ let res = this.purchaseRamUpgrade();
+ createPlayerHacknetNodeWrappers();
+ return res;
+}
+
+HacknetNode.prototype.calculateCoreUpgradeCost = function() {
+ var coreBaseCost = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNodeCore;
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeCoreMult;
+ return coreBaseCost * Math.pow(mult, this.cores - 1) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_core_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getCoreUpgradeCost = function() {
+ let res = this.calculateCoreUpgradeCost();
+ createPlayerHacknetNodeWrappers();
+ return res;
+}
+
+HacknetNode.prototype.purchaseCoreUpgrade = function() {
+ var cost = this.calculateCoreUpgradeCost();
+ if (isNaN(cost)) {
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ return false;
+ }
+
+ if (this.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {
+ return false;
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ ++this.cores;
+ this.updateMoneyGainRate();
+ return true;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeCore = function() {
+ return this.purchaseCoreUpgrade();
+}
+
+/* Saving and loading HackNets */
+HacknetNode.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_toJSON"])("HacknetNode", this);
+}
+
+HacknetNode.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_fromJSON"])(HacknetNode, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Reviver"].constructors.HacknetNode = HacknetNode;
+
+var HacknetNodeWrapper = function(hacknetNodeObj) {
+ var _node = hacknetNodeObj;
+ return {
+ name : _node.name,
+ level : _node.level,
+ ram : _node.ram,
+ cores : _node.cores,
+ totalMoneyGenerated : _node.totalMoneyGenerated,
+ onlineTimeSeconds : _node.onlineTimeSeconds,
+ moneyGainRatePerSecond : _node.moneyGainRatePerSecond,
+ upgradeLevel : function(n) {
+ return _node.upgradeLevel(n);
+ },
+ upgradeRam : function() {
+ return _node.upgradeRam();
+ },
+ upgradeCore : function() {
+ return _node.upgradeCore();
+ },
+ getLevelUpgradeCost : function(n) {
+ return _node.getLevelUpgradeCost(n);
+ },
+ getRamUpgradeCost : function() {
+ return _node.getRamUpgradeCost();
+ },
+ getCoreUpgradeCost : function() {
+ return _node.getCoreUpgradeCost();
+ }
+ }
+}
+
+function purchaseHacknet() {
+ /* INTERACTIVE TUTORIAL */
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialIsRunning"]) {
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["currITutorialStep"] == _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialSteps"].HacknetNodesIntroduction) {
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialNextStep"])();
+ } else {
+ return;
+ }
+ }
+
+ /* END INTERACTIVE TUTORIAL */
+
+ var cost = getCostOfNextHacknetNode();
+ if (isNaN(cost)) {
+ throw new Error("Cost is NaN");
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ //dialogBoxCreate("You cannot afford to purchase a Hacknet Node!");
+ return false;
+ }
+
+ //Auto generate a name for the node for now...TODO
+ var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
+ var name = "hacknet-node-" + numOwned;
+ var node = new HacknetNode(name);
+ node.updateMoneyGainRate();
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.push(node);
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Page.HacknetNodes) {
+ displayHacknetNodesContent();
+ }
+ createPlayerHacknetNodeWrappers();
+ updateTotalHacknetProduction();
+ return numOwned;
+}
+
+//Calculates the total production from all HacknetNodes
+function updateTotalHacknetProduction() {
+ var total = 0;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ total += _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction = total;
+}
+
+function getCostOfNextHacknetNode() {
+ //Cost increases exponentially based on how many you own
+ var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodePurchaseNextMult;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode * Math.pow(mult, numOwned) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_purchase_cost_mult;
+}
+
+var hacknetNodePurchaseMultiplier = 1;
+function updateHacknetNodesMultiplierButtons() {
+ var mult1x = document.getElementById("hacknet-nodes-1x-multiplier");
+ var mult5x = document.getElementById("hacknet-nodes-5x-multiplier");
+ var mult10x = document.getElementById("hacknet-nodes-10x-multiplier");
+ var multMax = document.getElementById("hacknet-nodes-max-multiplier");
+ mult1x.setAttribute("class", "a-link-button");
+ mult5x.setAttribute("class", "a-link-button");
+ mult10x.setAttribute("class", "a-link-button");
+ multMax.setAttribute("class", "a-link-button");
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length == 0) {
+ mult1x.setAttribute("class", "a-link-button-inactive");
+ mult5x.setAttribute("class", "a-link-button-inactive");
+ mult10x.setAttribute("class", "a-link-button-inactive");
+ multMax.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 1) {
+ mult1x.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 5) {
+ mult5x.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 10) {
+ mult10x.setAttribute("class", "a-link-button-inactive");
} else {
- var foo = this.data.slice();
- return foo[0];
+ multMax.setAttribute("class", "a-link-button-inactive");
}
}
-NetscriptPort.prototype.full = function() {
- return this.data.length == _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity;
+//Calculate the maximum number of times the Player can afford to upgrade
+//a Hacknet Node's level"
+function getMaxNumberLevelUpgrades(nodeObj) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(1))) {
+ return 0;
+ }
+
+ var min = 1;
+ var max = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - 1;
+ var levelsToMax = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - nodeObj.level;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) {
+ return levelsToMax;
+ }
+
+ while (min <= max) {
+ var curr = (min + max) / 2 | 0;
+ if (curr != _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr)) &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr + 1))) {
+ return Math.min(levelsToMax, curr);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr))) {
+ max = curr - 1;
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr))) {
+ min = curr + 1;
+ } else {
+ return Math.min(levelsToMax, curr);
+ }
+ }
}
-NetscriptPort.prototype.empty = function() {
- return this.data.length === 0;
+//Creates Hacknet Node DOM elements when the page is opened
+function displayHacknetNodesContent() {
+ //Update Hacknet Nodes button
+ var newPurchaseButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["clearEventListeners"])("hacknet-nodes-purchase-button");
+
+ newPurchaseButton.addEventListener("click", function() {
+ purchaseHacknet();
+ return false;
+ });
+
+ //Handle Purchase multiplier buttons
+ updateHacknetNodesMultiplierButtons();
+
+ //Remove all old hacknet Node DOM elements
+ var hacknetNodesList = document.getElementById("hacknet-nodes-list");
+ while (hacknetNodesList.firstChild) {
+ hacknetNodesList.removeChild(hacknetNodesList.firstChild);
+ }
+
+ //Then re-create them
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ createHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+
+ updateHacknetNodesContent();
}
-NetscriptPort.prototype.clear = function() {
- this.data.length = 0;
+//Update information on all Hacknet Node DOM elements
+function updateHacknetNodesContent() {
+ //Set purchase button to inactive if not enough money, and update its price display
+ var cost = getCostOfNextHacknetNode();
+ var purchaseButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getElementById"])("hacknet-nodes-purchase-button");
+ var formattedCost = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(cost, 2);
+
+ updateText("hacknet-nodes-purchase-button", "Purchase Hacknet Node - $" + formattedCost);
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ purchaseButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ purchaseButton.setAttribute("class", "a-link-button");
+ }
+
+ //Update player's money
+ updateText("hacknet-nodes-player-money", "$" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.toNumber(), 2));
+ updateText("hacknet-nodes-total-production", "$" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction, 2) + " / second");
+
+ //Update information in each owned hacknet node
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ updateHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+}
+
+//Creates a single Hacknet Node DOM element
+function createHacknetNodeDomElement(nodeObj) {
+ var nodeName = nodeObj.name;
+
+ var nodeLevelContainer = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ class: "hacknet-node-level-container row",
+ innerHTML: "
" +
+ "Player Defense: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].atk;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].atk;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].atk;
+ }
+ this.enemyAtk = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.calculateDefenses = function() {
+ var total = 0;
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ total += this.playerCores[i].def;
+ }
+ for (var i = 0; i < this.playerNodes.length; ++i) {
+ total += this.playerNodes[i].def;
+ }
+ this.playerDef = total;
+ document.getElementById("hacking-mission-player-stats").innerHTML =
+ "Player Attack: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
+ "Player Defense: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].def;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].def;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].def;
+ }
+ this.enemyDef = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.removeAvailablePosition = function(x, y) {
+ for (var i = 0; i < this.availablePositions.length; ++i) {
+ if (this.availablePositions[i][0] === x &&
+ this.availablePositions[i][1] === y) {
+ this.availablePositions.splice(i, 1);
+ return;
+ }
+ }
+ console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y);
+}
+
+HackingMission.prototype.setNodePosition = function(nodeObj, x, y) {
+ if (!(nodeObj instanceof Node)) {
+ console.log("WARNING: Non-Node object passed into setNodePOsition");
+ return;
+ }
+ if (isNaN(x) || isNaN(y)) {
+ console.log("ERR: Invalid values passed as x and y for setNodePosition");
+ console.log(x);
+ console.log(y);
+ return;
+ }
+ nodeObj.pos = [x, y];
+ this.map[x][y] = nodeObj;
+}
+
+HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {
+ var i = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.availablePositions.length - 1);
+ if (this.availablePositions[i][1] < xlimit) {
+ //Recurse if not within limit
+ return this.setNodeRandomPosition(nodeObj, xlimit);
+ }
+ var pos = this.availablePositions.splice(i, 1);
+ pos = pos[0];
+ this.setNodePosition(nodeObj, pos[0], pos[1]);
+}
+
+HackingMission.prototype.createMap = function() {
+ //Use a grid
+ var map = document.createElement("div");
+ map.classList.add("hack-mission-grid");
+ map.setAttribute("id", "hacking-mission-map");
+ document.getElementById("mission-container").appendChild(map);
+
+ //Create random Nodes for every space in the map that
+ //hasn't been filled yet. The stats of each Node will be based on
+ //the player/enemy attack
+ var averageAttack = (this.playerAtk + this.enemyAtk) / 2;
+ for (var x = 0; x < 8; ++x) {
+ for (var y = 0; y < 8; ++y) {
+ if (!(this.map[x][y] instanceof Node)) {
+ var node, type = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, 2);
+ var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.85 + (this.difficulty / 2), 15);
+ switch (type) {
+ case 0: //Spam
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(200, 225)
+ }
+ node = new Node(NodeTypes.Spam, stats);
+ break;
+ case 1: //Transfer
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(250, 275)
+ }
+ node = new Node(NodeTypes.Transfer, stats);
+ break;
+ case 2: //Shield
+ default:
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 70),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(300, 320)
+ }
+ node = new Node(NodeTypes.Shield, stats);
+ break;
+ }
+ this.setNodePosition(node, x, y);
+ this.removeAvailablePosition(x, y);
+ this.miscNodes.push(node);
+ }
+ }
+ }
+
+ //Create DOM elements in order
+ for (var r = 0; r < 8; ++r) {
+ for (var c = 0; c < 8; ++c) {
+ this.createNodeDomElement(this.map[r][c]);
+ }
+ }
+
+ //Configure all Player CPUS
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ console.log("Configuring Player Node: " + this.playerCores[i].el.id);
+ this.configurePlayerNodeElement(this.playerCores[i].el);
+ }
+}
+
+HackingMission.prototype.createNodeDomElement = function(nodeObj) {
+ var nodeDiv = document.createElement("a"), txtEl = document.createElement('p');
+ nodeObj.el = nodeDiv;
+
+ //Set the node element's id based on its coordinates
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ nodeDiv.setAttribute("id", id);
+ txtEl.setAttribute("id", id + "-txt");
+
+ //Set node classes for owner
+ nodeDiv.classList.add("hack-mission-node");
+ if (nodeObj.plyrCtrl) {
+ nodeDiv.classList.add("hack-mission-player-node");
+ } else if (nodeObj.enmyCtrl) {
+ nodeDiv.classList.add("hack-mission-enemy-node");
+ }
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-cpu-node");
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-firewall-node");
+ break;
+ case NodeTypes.Database:
+ txt = "Database
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-database-node");
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-spam-node");
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-transfer-node");
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-shield-node");
+ break;
+ }
+
+ txt += "
Atk: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ "
Def: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ txtEl.innerHTML = txt;
+
+ nodeDiv.appendChild(txtEl);
+ document.getElementById("hacking-mission-map").appendChild(nodeDiv);
+}
+
+HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
+ if (nodeObj.el == null) {
+ console.log("ERR: Calling updateNodeDomElement on a Node without an element");
+ return;
+ }
+
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt");
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Database:
+ txt = "Database
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield
" + "HP: " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ }
+
+ txt += "
Atk: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ "
Def: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ if (nodeObj.action) {
+ txt += "
" + nodeObj.action;
+ }
+ 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
+HackingMission.prototype.getNodeFromElement = function(el) {
+ var id;
+ if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["isString"])(el)) {
+ id = el;
+ } else {
+ id = el.id;
+ }
+ id = id.replace("hacking-mission-node-", "");
+ var res = id.split('-');
+ if (res.length != 2) {
+ console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates");
+ return null;
+ }
+ var x = res[0], y = res[1];
+ if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {
+ console.log("ERROR: Unexpected values for x and y: " + x + ", " + y);
+ return null;
+ }
+ return this.map[x][y];
+}
+
+function selectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("Error getting Node object");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ nodeObj.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(nodeObj);
+}
+
+function multiselectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("ERROR: Getting Node Object in multiselectNode()");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ var type = nodeObj.type;
+ if (type === NodeTypes.Core) {
+ hackMissionInst.playerCores.forEach(function(node) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ });
+ } else {
+ hackMissionInst.playerNodes.forEach(function(node) {
+ if (node.type === type) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ }
+ });
+ }
+}
+
+function clearAllSelectedNodes(hackMissionInst) {
+ if (hackMissionInst.selectedNode.length > 0) {
+ hackMissionInst.selectedNode.forEach(function(node){
+ node.deselect(hackMissionInst.actionButtons);
+ });
+ hackMissionInst.selectedNode.length = 0;
+ }
+}
+
+//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");}
+
+ //Add event listener
+ var self = this;
+ function selectNodeWrapper() {
+ selectNode(self, el);
+ }
+ el.addEventListener("click", selectNodeWrapper);
+
+ function multiselectNodeWrapper() {
+ multiselectNode(self, el);
+ }
+ el.addEventListener("dblclick", multiselectNodeWrapper);
+
+
+ if (el.firstChild) {
+ el.firstChild.addEventListener("click", selectNodeWrapper);
+ }
+}
+
+//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);
+ for (var i = 0; i < this.selectedNode.length; ++i) {
+ if (this.selectedNode[i] == nodeObj) {
+ nodeObj.deselect(this.actionButtons);
+ this.selectedNode.splice(i, 1);
+ break;
+ }
+ }
+}
+
+//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;}
+ if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.nodeReachableByEnemy = function(node) {
+ if (node == null) {return false;}
+ var x = node.pos[0], y = node.pos[1];
+ if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
+ if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.start = function() {
+ this.started = true;
+ this.initJsPlumb();
+ var startBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("hack-mission-start-btn");
+ startBtn.classList.remove("a-link-button");
+ startBtn.classList.add("a-link-button-inactive");
+}
+
+HackingMission.prototype.initJsPlumb = function() {
+ var instance = jsPlumb.getInstance({
+ DragOptions:{cursor:"pointer", zIndex:2000},
+ PaintStyle: {
+ gradient: { stops: [
+ [ 0, "#FFFFFF" ],
+ [ 1, "#FFFFFF" ]
+ ] },
+ stroke: "#FFFFFF",
+ strokeWidth: 8
+ },
+ });
+
+ this.jsplumbinstance = instance;
+
+ //All player cores are sources
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ instance.makeSource(this.playerCores[i].el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Everything else is a target
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ instance.makeTarget(this.enemyCores[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ instance.makeTarget(this.enemyDatabases[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ instance.makeTarget(this.enemyNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.miscNodes.length; ++i) {
+ instance.makeTarget(this.miscNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Clicking a connection drops it
+ instance.bind("click", function(conn, originalEvent) {
+ var endpoints = conn.endpoints;
+ endpoints[0].detachFrom(endpoints[1]);
+ });
+
+ //Connection events
+ instance.bind("connection", (info)=>{
+ var targetNode = this.getNodeFromElement(info.target);
+
+ //Do not detach for enemy nodes
+ var thisNode = this.getNodeFromElement(info.source);
+ if (thisNode.enmyCtrl) {return;}
+
+ //If the node is not reachable, drop the connection
+ if (!this.nodeReachable(targetNode)) {
+ info.sourceEndpoint.detachFrom(info.targetEndpoint);
+ return;
+ }
+
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = info.connection;
+ var targetNode = this.getNodeFromElement(info.target);
+ ++targetNode.targetedCount;
+ });
+
+ //Detach Connection events
+ instance.bind("connectionDetached", (info, originalEvent)=>{
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = null;
+ var targetNode = this.getNodeFromElement(info.target);
+ targetNode.untarget();
+ });
+
+}
+
+//Drops all connections where the specified node is the source
+HackingMission.prototype.dropAllConnectionsFromNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].source == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+}
+
+//Drops all connections where the specified node is the target
+HackingMission.prototype.dropAllConnectionsToNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].target == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+ node.beingTargeted = false;
+}
+
+var storedCycles = 0;
+HackingMission.prototype.process = function(numCycles=1) {
+ if (!this.started) {return;}
+ storedCycles += numCycles;
+ if (storedCycles < 2) {return;} //Only process every 3 cycles minimum
+
+ var res = false;
+ //Process actions of all player nodes
+ this.playerCores.forEach((node)=>{
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.playerNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //Process actions of all enemy nodes
+ this.enemyCores.forEach((node)=>{
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.enemyNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //The hp of enemy databases increases slowly
+ this.enemyDatabases.forEach((node)=>{
+ node.maxhp += (0.1 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ });
+
+ if (res) {
+ this.calculateAttacks();
+ this.calculateDefenses();
+ }
+
+ //Win if all enemy databases are conquered
+ if (this.enemyDatabases.length === 0) {
+ this.finishMission(true);
+ return;
+ }
+
+ //Lose if all your cores are gone
+ if (this.playerCores.length === 0) {
+ this.finishMission(false);
+ return;
+ }
+
+ //Defense/hp of misc nodes increases slowly over time
+ this.miscNodes.forEach((node)=>{
+ node.def += (0.1 * storedCycles);
+ node.maxhp += (0.05 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ if (node.hp > node.maxhp) {node.hp = node.maxhp;}
+ this.updateNodeDomElement(node);
+ });
+
+ //Update timer and check if player lost
+ this.time -= (storedCycles * _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"]._idleSpeed);
+ if (this.time <= 0) {
+ this.finishMission(false);
+ return;
+ }
+ this.updateTimer();
+
+ storedCycles = 0;
+}
+
+//Returns a bool representing whether defenses need to be re-calculated
+HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
+ if (nodeObj.action == null) {
+ return;
+ }
+
+ var targetNode = null, def, atk;
+ if (nodeObj.conn) {
+ if (nodeObj.conn.target != null) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+
+ if (targetNode == null) {
+ //Player is in the middle of dragging the connection,
+ //so the target node is null. Do nothing here
+ } else if (targetNode.plyrCtrl) {
+ def = this.playerDef;
+ atk = this.enemyAtk;
+ } else if (targetNode.enmyCtrl) {
+ def = this.enemyDef;
+ atk = this.playerAtk;
+ } else { //Misc Node
+ def = targetNode.def;
+ nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;
+ }
+ }
+
+ //Calculations are per second, so divide everything by 5
+ var calcStats = false, plyr = nodeObj.plyrCtrl;
+ var enmyHacking = this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionDifficultyToHacking;
+ switch(nodeObj.action) {
+ case NodeActions.Attack:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var dmg = this.calculateAttackDamage(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.hp -= (dmg/5 * numCycles);
+ break;
+ case NodeActions.Scan:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateScanEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.def -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Weaken:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateWeakenEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.atk -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Fortify:
+ var eff = this.calculateFortifyEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ nodeObj.def += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Overflow:
+ var eff = this.calculateOverflowEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ if (nodeObj.def < eff) {break;}
+ nodeObj.def -= (eff/5 * numCycles);
+ nodeObj.atk += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ default:
+ console.log("ERR: Invalid Node Action: " + nodeObj.action);
+ break;
+ }
+
+ //Stats can't go below 0
+ if (nodeObj.atk < 0) {nodeObj.atk = 0;}
+ if (nodeObj.def < 0) {nodeObj.def = 0;}
+ if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}
+ if (targetNode && targetNode.def < 0) {targetNode.def = 0;}
+
+ //Conquering a node
+ if (targetNode && targetNode.hp <= 0) {
+ var conqueredByPlayer = nodeObj.plyrCtrl;
+ targetNode.hp = targetNode.maxhp;
+ targetNode.action = null;
+ targetNode.conn = null;
+ if (this.selectedNode == targetNode) {
+ targetNode.deselect(this.actionButtons);
+ }
+
+ //The conquered node has its stats reduced
+ targetNode.atk /= 2;
+ targetNode.def /= 3.5;
+
+ //Flag for whether the target node was a misc node
+ var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;
+
+ //Remove all connections from Node
+ this.dropAllConnectionsToNode(targetNode);
+ this.dropAllConnectionsFromNode(targetNode);
+
+ //Changes the css class and turn the node into a JsPlumb Source/Target
+ if (conqueredByPlayer) {
+ targetNode.setControlledByPlayer();
+ this.jsplumbinstance.unmakeTarget(targetNode.el);
+ this.jsplumbinstance.makeSource(targetNode.el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ } else {
+ targetNode.setControlledByEnemy();
+ nodeObj.conn = null; //Clear connection
+ this.jsplumbinstance.unmakeSource(targetNode.el);
+ this.jsplumbinstance.makeTarget(targetNode.el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+
+ calcStats = true;
+
+ //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays
+ function swapNodes(orig, dest, targetNode) {
+ for (var i = 0; i < orig.length; ++i) {
+ if (orig[i] == targetNode) {
+ var node = orig.splice(i, 1);
+ node = node[0];
+ dest.push(node);
+ break;
+ }
+ }
+ }
+
+ switch(targetNode.type) {
+ case NodeTypes.Core:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyCores, this.playerCores, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(this.playerCores, this.enemyCores, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Firewall:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyNodes, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Database:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyDatabases, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyDatabases, targetNode);
+ }
+ break;
+ case NodeTypes.Spam:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ //Conquering spam node increases time limit
+ this.time += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionSpamTimeIncrease;
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ }
+
+ break;
+ case NodeTypes.Transfer:
+ //Conquering a Transfer node increases the attack of all cores by some percentages
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.playerCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.enemyCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Shield:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ }
+
+ //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount
+ if (isMiscNode) { //&& conqueredByPlayer) {
+ this.miscNodes.forEach((node)=>{
+ if (node.targetedCount === 0) {
+ node.def *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionMiscDefenseIncrease;
+ }
+ });
+ }
+ }
+
+ //Update node DOMs
+ this.updateNodeDomElement(nodeObj);
+ if (targetNode) {this.updateNodeDomElement(targetNode);}
+ return calcStats;
+}
+
+//Enemy "AI" for CPU Core and Transfer Nodes
+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
+ if (nodeObj.conn == null) {
+ if (this.miscNodes.length === 0) {
+ //Randomly pick a player node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerNodes.length-1);
+ var node;
+ if (this.playerNodes.length === 0) {
+ node = null;
+ } else {
+ node = this.playerNodes[rand];
+ }
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ } else {
+ //Randomly pick a player core and attack it if its reachable
+ rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerCores.length-1);
+ if (this.playerCores.length === 0) {
+ return; //No Misc Nodes, no player Nodes, no Player cores. Player lost
+ } else {
+ node = this.playerCores[rand];
+ }
+
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ }
+ }
+ } else {
+ //Randomly pick a misc node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.miscNodes.length-1);
+ var node = this.miscNodes[rand];
+ if (this.nodeReachableByEnemy(node)) {
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el,
+ });
+ ++node.targetedCount;
+ }
+ }
+
+ //If no connection was made, set the Core to Fortify
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ //If this node has a selected target
+ var targetNode;
+ if (nodeObj.conn.target) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+ if (targetNode == null) {
+ console.log("Error getting Target node Object in enemyAISelectAction()");
+ }
+
+ if (targetNode.def > this.enemyAtk + 15) {
+ if (nodeObj.def < 50) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) {
+ nodeObj.action = NodeActions.Scan;
+ } else {
+ nodeObj.action = NodeActions.Attack;
+ }
+ }
+ break;
+ case NodeTypes.Transfer:
+ //Switch between fortifying and overflowing as necessary
+ if (nodeObj.def < 125) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ break;
+ case NodeTypes.Firewall:
+ case NodeTypes.Shield:
+ nodeObj.action = NodeActions.Fortify;
+ break;
+ default:
+ break;
+ }
+}
+
+var hackEffWeightSelf = 130; //Weight for Node actions on self
+var hackEffWeightTarget = 25; //Weight for Node Actions against Target
+var hackEffWeightAttack = 80; //Weight for Attack action
+
+//Returns damage per cycle based on stats
+HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) {
+ return Math.max(0.55 * (atk + (hacking / hackEffWeightAttack) - def), 1);
+}
+
+HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) {
+ return Math.max(0.6 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2);
+}
+
+HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) {
+ return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2);
+}
+
+HackingMission.prototype.calculateFortifyEffect = function(hacking=0) {
+ return 0.9 * hacking / hackEffWeightSelf;
+}
+
+HackingMission.prototype.calculateOverflowEffect = function(hacking=0) {
+ return 0.95 * hacking / hackEffWeightSelf;
+}
+
+//Updates timer display
+HackingMission.prototype.updateTimer = function() {
+ var timer = document.getElementById("hacking-mission-timer");
+
+ //Convert time remaining to a string of the form mm:ss
+ var seconds = Math.round(this.time / 1000);
+ var minutes = Math.trunc(seconds / 60);
+ seconds %= 60;
+ var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2);
+ timer.innerText = "Time left: " + str;
+}
+
+//The 'win' argument is a bool for whether or not the player won
+HackingMission.prototype.finishMission = function(win) {
+ inMission = false;
+ currMission = null;
+
+ if (win) {
+ var favorMult = 1 + (this.faction.favor / 100);
+ console.log("Hacking mission base reward: " + this.reward);
+ console.log("favorMult: " + favorMult);
+ console.log("rep mult: " + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult);
+ var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission won! You earned " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " reputation with " + this.faction.name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainIntelligenceExp(this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceHackingMissionBaseExpGain);
+ this.faction.playerReputation += gain;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission lost/forfeited! You did not gain any faction reputation.");
+ }
+
+ //Clear mission container
+ var container = document.getElementById("mission-container");
+ while(container.firstChild) {
+ container.removeChild(container.firstChild);
+ }
+
+ //Return to Faction page
+ document.getElementById("mainmenu-container").style.visibility = "visible";
+ document.getElementById("character-overview-wrapper").style.visibility = "visible";
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(this.faction.name);
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
+
+/***/ }),
+/* 42 */
+/*!********************************!*\
+ !*** ./src/ActiveScriptsUI.js ***!
+ \********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; });
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/LogBox.js */ 47);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__);
+
+
+
+
+
+
+
+
+
+
+/* {
+ * serverName: {
+ * header: Server Header Element
+ * panel: Server Panel List (ul) element
+ * scripts: {
+ * script id: Ref to Script information
+ * }
+ * }
+ * ...
+ */
+let ActiveScriptsUI = {};
+let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
+
+function createActiveScriptsServerPanel(server) {
+ let hostname = server.hostname;
+
+ var activeScriptsList = document.getElementById("active-scripts-list");
+
+ let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname});
+ let li = res[0];
+ var hdr = res[1];
+ let panel = res[2];
+
+ if (ActiveScriptsUI[hostname] != null) {
+ console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
+ return;
+ }
+
+ var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul");
+ panel.appendChild(panelScriptList);
+ activeScriptsList.appendChild(li);
+
+ ActiveScriptsUI[hostname] = {
+ header: hdr,
+ panel: panel,
+ 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
+ };
+
+ return li;
+}
+
+//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) {
+ console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
+ return;
+ }
+
+ //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");
+ return;
+ }
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header);
+ delete ActiveScriptsUI[hostname];
+}
+
+function addActiveScriptsItem(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()");
+ return;
+ }
+ let hostname = server.hostname;
+
+ ActiveScriptsTasks.push(function(workerscript, hostname) {
+ if (ActiveScriptsUI[hostname] == null) {
+ createActiveScriptsServerPanel(server);
+ }
+
+ //Create the unique identifier (key) for this script
+ var itemNameArray = ["active", "scripts", hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:workerscript.name});
+ let li = res[0];
+ let hdr = res[1];
+ let panel = res[2];
+
+ hdr.classList.remove("accordion-header");
+ hdr.classList.add("active-scripts-script-header");
+ 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
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
+ innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" +
+ "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args)
+ }));
+ var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
+ innerText:"Loading...", fontSize:"14px",
+ });
+ panel.appendChild(panelText);
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br"));
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
+ innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px",
+ clickListener:()=>{
+ Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef);
+ return false;
+ }
+ }));
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
+ innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px",
+ clickListener:()=>{
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete...");
+ return false;
+ }
+ }));
+
+ //Append element to list
+ ActiveScriptsUI[hostname]["panelList"].appendChild(li);
+ ActiveScriptsUI[hostname].scripts[itemName] = li;
+ ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr;
+ ActiveScriptsUI[hostname].scriptStats[itemName] = panelText;
+ }.bind(null, workerscript, hostname));
+}
+
+function deleteActiveScriptsItem(workerscript) {
+ ActiveScriptsTasks.push(function(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " +
+ "you tried to delete a large number of scripts and also deleted servers at the " +
+ "same time. It's not a big deal, just save and refresh the game.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null) {
+ console.log("ERROR: Trying to delete Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
+ return;
+ }
+
+ var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ let li = ActiveScriptsUI[hostname].scripts[itemName];
+ if (li == null) {
+ console.log("ERROR: Cannot find Active Script UI element for workerscript: ");
+ console.log(workerscript);
+ return;
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(li);
+ delete ActiveScriptsUI[hostname].scripts[itemName];
+ delete ActiveScriptsUI[hostname].scriptHdrs[itemName];
+ delete ActiveScriptsUI[hostname].scriptStats[itemName];
+ if (Object.keys(ActiveScriptsUI[hostname].scripts).length === 0) {
+ deleteActiveScriptsServerPanel(server);
+ }
+ }.bind(null, workerscript));
+}
+
+//Update the ActiveScriptsItems array
+function updateActiveScriptsItems(maxTasks=100) {
+ //Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
+ //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once...
+ let numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
+ for (let i = 0; i < numTasks; ++i) {
+ let task = ActiveScriptsTasks.shift();
+ try {
+ task();
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
+ console.log(task);
+ }
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;}
+ var total = 0;
+ for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) {
+ try {
+ total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
+ }
+ }
+ document.getElementById("active-scripts-total-prod").innerHTML =
+ "Total online production of Active Scripts: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" +
+ "Total online production since last Aug installation: " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)";
+ return total;
+}
+
+//Updates the content of the given item in the Active Scripts list
+function updateActiveScriptsItemContent(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null) {
+ return; //Hasn't been created yet. We'll skip it
+ }
+
+ var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) {
+ return; //Hasn't been fully added yet. We'll skip it
+ }
+ var item = ActiveScriptsUI[hostname].scriptStats[itemName];
+
+ //Update the text if necessary. This fn returns the online $/s production
+ return updateActiveScriptsText(workerscript, item, itemName);
+}
+
+function updateActiveScriptsText(workerscript, item, itemName) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == null) {
+ console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
+ return;
+ }
+
+ var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
+
+ //Only update if the item is visible
+ if (ActiveScriptsUI[hostname].header.classList.contains("active") === false) {return onlineMps;}
+ if (ActiveScriptsUI[hostname].scriptHdrs[itemName].classList.contains("active") === false) {return onlineMps;}
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item);
+
+ //Online
+ var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2);
+ var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " ");
+
+ var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second";
+ var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime;
+ var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " ");
+
+ //Offline
+ var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2);
+ var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " ");
+
+ var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
+ var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second";
+ var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime;
+ var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " ");
+
+ item.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" +
+ onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" +
+ offlineMpsText + "
" + offlineEpsText + "
";
+ return onlineMps;
+}
+
+
+
+
+/***/ }),
+/* 43 */
+/*!***************************!*\
+ !*** ./src/SaveObject.js ***!
+ \***************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "saveObject", function() { return saveObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGame", function() { return loadGame; });
-/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(29);
-/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(11);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(32);
-/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(34);
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(36);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(28);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(0);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(25);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(8);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(22);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(18);
-/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(20);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(7);
-/* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(53);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(9);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(2);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(23);
+/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 25);
+/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Company.js */ 8);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Gang.js */ 33);
+/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HacknetNode.js */ 40);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Server.js */ 11);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 17);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 29);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/GameOptions.js */ 50);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_19__);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! decimal.js */ 19);
@@ -59373,8 +59171,8 @@ function loadImportedGame(saveObj, saveString) {
_Player_js__WEBPACK_IMPORTED_MODULE_9__["Player"].lastUpdate = _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"]._lastUpdate;
_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].start(); //Run main game loop and Scripts loop
Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__["dialogBoxCreate"])("While you were offline, your scripts generated $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(offlineProductionFromHacknetNodes, 2));
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(offlineProductionFromHacknetNodes, 2));
return true;
}
@@ -59478,10 +59276,13 @@ function openImportFileHandler(evt) {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 46 */
+/* 44 */
+/*!***********************************!*\
+ !*** (webpack)/buildin/global.js ***!
+ \***********************************/
/***/ (function(module, exports) {
var g;
@@ -59507,7 +59308,10 @@ module.exports = g;
/***/ }),
-/* 47 */
+/* 45 */
+/*!***********************************************!*\
+ !*** ./node_modules/pako/lib/utils/common.js ***!
+ \***********************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -59619,7 +59423,10 @@ exports.setTyped(TYPED_OK);
/***/ }),
-/* 48 */
+/* 46 */
+/*!*******************************************!*\
+ !*** ./node_modules/jszip/lib/support.js ***!
+ \*******************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -59657,15 +59464,18 @@ else {
}
try {
- exports.nodestream = !!__webpack_require__(114).Readable;
+ exports.nodestream = !!__webpack_require__(/*! readable-stream */ 112).Readable;
} catch(e) {
exports.nodestream = false;
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(60).Buffer))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 56).Buffer))
/***/ }),
-/* 49 */
+/* 47 */
+/*!*************************!*\
+ !*** ./utils/LogBox.js ***!
+ \*************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -59674,8 +59484,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxUpdateText", function() { return logBoxUpdateText; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxOpened", function() { return logBoxOpened; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxCurrentScript", function() { return logBoxCurrentScript; });
-/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
-/* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
+/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 22);
+/* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelperFunctions.js */ 1);
@@ -59744,143 +59554,13 @@ function logBoxUpdateText() {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 37)))
/***/ }),
-/* 50 */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkIfConnectedToDarkweb", function() { return checkIfConnectedToDarkweb; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "executeDarkwebTerminalCommand", function() { return executeDarkwebTerminalCommand; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DarkWebItems", function() { return DarkWebItems; });
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(21);
-/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2);
-
-
-
-
-
-
-
-
-
-/* DarkWeb.js */
-//Posts a "help" message if connected to DarkWeb
-function checkIfConnectedToDarkweb() {
- if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) {
- var darkwebIp = _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"]["Darkweb Server"];
- if (!Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["isValidIPAddress"])(darkwebIp)) {return;}
- if (darkwebIp == _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getCurrentServer().ip) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You are now connected to the dark web. From the dark web you can purchase illegal items. " +
- "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
- "to purchase an item");
- }
- }
-}
-
-//Handler for dark web commands. The terminal's executeCommand() function will pass
-//dark web-specific commands into this. It will pass in the raw split command array
-//rather than the command string
-function executeDarkwebTerminalCommand(commandArray) {
- if (commandArray.length == 0) {return;}
- switch (commandArray[0]) {
- case "buy":
- if (commandArray.length != 2) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Incorrect number of arguments. Usage: ");
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy -l");
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy [item name]");
- return;
- }
- var arg = commandArray[1];
- if (arg == "-l") {
- listAllDarkwebItems();
- } else {
- buyDarkwebItem(arg);
- }
- break;
- default:
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Command not found");
- break;
- }
-}
-
-function listAllDarkwebItems() {
- for(const key in DarkWebItems) {
- const item = DarkWebItems[key];
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])(item.toString());
- }
-}
-
-function buyDarkwebItem(itemName) {
- itemName = itemName.toLowerCase();
-
- // find the program that matches, if any
- let item = null;
- for(const key in DarkWebItems) {
- const i = DarkWebItems[key];
- if(i.program.toLowerCase() == itemName) {
- item = i;
- }
- }
-
- // return if invalid
- if(item === null) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Unrecognized item: "+itemName);
- return;
- }
-
- // return if the player already has it.
- if(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(item.program)) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])('You already have the '+item.program+' program');
- return;
- }
-
- // return if the player doesn't have enough money
- if(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.lt(item.price)) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + item.program);
- return;
- }
-
- // buy and push
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(item.price);
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(item.program);
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])('You have purchased the '+item.program+' program. The new program can be found on your home computer.');
-}
-
-function DarkWebItem(program, price, description) {
- this.program = program;
- this.price = price;
- this.description = description;
-}
-
-// formats the item for the terminal (eg. "BruteSSH.exe - $500,000 - Opens up SSH Ports")
-DarkWebItem.prototype.toString = function() {
- return [this.program, "$"+Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["formatNumber"])(this.price), this.description].join(' - ');
-}
-
-const DarkWebItems = {
- BruteSSHProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].BruteSSHProgram, 500000, "Opens up SSH Ports"),
- FTPCrackProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].FTPCrackProgram, 1500000, "Opens up FTP Ports"),
- RelaySMTPProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].RelaySMTPProgram, 5000000, "Opens up SMTP Ports"),
- HTTPWormProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].HTTPWormProgram, 30000000, "Opens up HTTP Ports"),
- SQLInjectProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].SQLInjectProgram, 250000000, "Opens up SQL Ports"),
- DeepscanV1: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV1, 500000, "Enables 'scan-analyze' with a depth up to 5"),
- DeepscanV2: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV2, 25000000, "Enables 'scan-analyze' with a depth up to 10"),
- AutolinkProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].AutoLink, 1000000, "Enables direct connect via 'scan-analyze'"),
-};
-
-
-
-
-
-/***/ }),
-/* 51 */
+/* 48 */
+/*!************************************************************!*\
+ !*** ./node_modules/readable-stream/lib/_stream_duplex.js ***!
+ \************************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -59914,7 +59594,7 @@ const DarkWebItems = {
/*
${this.text}`, true);
+ }
+ /**
+ * Serialize the current file to a JSON save state.
+ */
+ toJSON() {
+ return JSONReviver_1.Generic_toJSON("TextFile", this);
+ }
+ /**
+ * Replaces the current content with the text provided.
+ */
+ write(txt) {
+ this.text = txt;
+ }
+}
+exports.TextFile = TextFile;
+JSONReviver_1.Reviver.constructors.TextFile = TextFile;
+/**
+ * Retrieve the file object for the filename on the specified server.
+ * @param fn The file name to look for
+ * @param server The server object to look in
+ * @returns The file object, or null if it couldn't find it.
+ */
+function getTextFile(fn, server) {
+ const filename = !fn.endsWith(".txt") ? `${fn}.txt` : fn;
+ for (const file of server.textFiles) {
+ if (file.fn === filename) {
+ return file;
+ }
+ }
+ return null;
+}
+exports.getTextFile = getTextFile;
+/**
+ * Creates a TextFile on the target server.
+ * @param fn The file name to create.
+ * @param txt The contents of the file.
+ * @param server The server that the file should be created on.
+ * @returns The instance of the file.
+ */
+function createTextFile(fn, txt, server) {
+ if (getTextFile(fn, server) !== null) {
+ // This should probably be a `throw`...
+ /* tslint:disable-next-line:no-console */
+ console.error(`A file named "${fn}" already exists on server ${server.hostname}.`);
+ return undefined;
+ }
+ const file = new TextFile(fn, txt);
+ server.textFiles.push(file);
+ return file;
+}
+exports.createTextFile = createTextFile;
+/* tslint:disable-next-line:no-unused-variable */
+function deleteTextFile(fn, server) {
+ const filename = !fn.endsWith(".txt") ? `${fn}.txt` : fn;
+ /* tslint:disable-next-line:typedef */
+ for (let i = 0; i < server.textFiles.length; ++i) {
+ if (server.textFiles[i].fn === filename) {
+ server.textFiles.splice(i, 1);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+/***/ }),
+/* 59 */
+/*!************************!*\
+ !*** ./src/DarkWeb.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkIfConnectedToDarkweb", function() { return checkIfConnectedToDarkweb; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "executeDarkwebTerminalCommand", function() { return executeDarkwebTerminalCommand; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DarkWebItems", function() { return DarkWebItems; });
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CreateProgram.js */ 20);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 18);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/IPAddress.js */ 14);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_5__);
+
+
+
+
+
+
+
+
+
+/* DarkWeb.js */
+//Posts a "help" message if connected to DarkWeb
+function checkIfConnectedToDarkweb() {
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) {
+ var darkwebIp = _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"]["Darkweb Server"];
+ if (!Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["isValidIPAddress"])(darkwebIp)) {return;}
+ if (darkwebIp == _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getCurrentServer().ip) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You are now connected to the dark web. From the dark web you can purchase illegal items. " +
+ "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
+ "to purchase an item");
+ }
+ }
+}
+
+//Handler for dark web commands. The terminal's executeCommand() function will pass
+//dark web-specific commands into this. It will pass in the raw split command array
+//rather than the command string
+function executeDarkwebTerminalCommand(commandArray) {
+ if (commandArray.length == 0) {return;}
+ switch (commandArray[0]) {
+ case "buy":
+ if (commandArray.length != 2) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Incorrect number of arguments. Usage: ");
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy -l");
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy [item name]");
+ return;
+ }
+ var arg = commandArray[1];
+ if (arg == "-l") {
+ listAllDarkwebItems();
+ } else {
+ buyDarkwebItem(arg);
+ }
+ break;
+ default:
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Command not found");
+ break;
+ }
+}
+
+function listAllDarkwebItems() {
+ for(const key in DarkWebItems) {
+ const item = DarkWebItems[key];
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])(item.toString());
+ }
+}
+
+function buyDarkwebItem(itemName) {
+ itemName = itemName.toLowerCase();
+
+ // find the program that matches, if any
+ let item = null;
+ for(const key in DarkWebItems) {
+ const i = DarkWebItems[key];
+ if(i.program.toLowerCase() == itemName) {
+ item = i;
+ }
+ }
+
+ // return if invalid
+ if(item === null) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Unrecognized item: "+itemName);
+ return;
+ }
+
+ // return if the player already has it.
+ if(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(item.program)) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])('You already have the '+item.program+' program');
+ return;
+ }
+
+ // return if the player doesn't have enough money
+ if(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.lt(item.price)) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + item.program);
+ return;
+ }
+
+ // buy and push
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(item.price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(item.program);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])('You have purchased the '+item.program+' program. The new program can be found on your home computer.');
+}
+
+function DarkWebItem(program, price, description) {
+ this.program = program;
+ this.price = price;
+ this.description = description;
+}
+
+// formats the item for the terminal (eg. "BruteSSH.exe - $500,000 - Opens up SSH Ports")
+DarkWebItem.prototype.toString = function() {
+ return [this.program, "$"+Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_5__["formatNumber"])(this.price), this.description].join(' - ');
+}
+
+const DarkWebItems = {
+ BruteSSHProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].BruteSSHProgram.name, 500000, "Opens up SSH Ports"),
+ FTPCrackProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].FTPCrackProgram.name, 1500000, "Opens up FTP Ports"),
+ RelaySMTPProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].RelaySMTPProgram.name, 5000000, "Opens up SMTP Ports"),
+ HTTPWormProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].HTTPWormProgram.name, 30000000, "Opens up HTTP Ports"),
+ SQLInjectProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].SQLInjectProgram.name, 250000000, "Opens up SQL Ports"),
+ DeepscanV1: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV1.name, 500000, "Enables 'scan-analyze' with a depth up to 5"),
+ DeepscanV2: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV2.name, 25000000, "Enables 'scan-analyze' with a depth up to 10"),
+ AutolinkProgram: new DarkWebItem(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].AutoLink.name, 1000000, "Enables direct connect via 'scan-analyze'"),
+};
+
+
+
+
+
+/***/ }),
+/* 60 */,
+/* 61 */
+/*!****************************************************************************!*\
+ !*** ./node_modules/jszip/node_modules/core-js/library/modules/_global.js ***!
+ \****************************************************************************/
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
@@ -63303,7 +63280,10 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ }),
-/* 63 */
+/* 62 */
+/*!***********************************************!*\
+ !*** ./node_modules/jszip/lib/nodejsUtils.js ***!
+ \***********************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -63360,14 +63340,17 @@ module.exports = {
}
};
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(60).Buffer))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 56).Buffer))
/***/ }),
-/* 64 */
+/* 63 */
+/*!*******************************************!*\
+ !*** ./node_modules/safe-buffer/index.js ***!
+ \*******************************************/
/***/ (function(module, exports, __webpack_require__) {
/* eslint-disable node/no-deprecated-api */
-var buffer = __webpack_require__(60)
+var buffer = __webpack_require__(/*! buffer */ 56)
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
@@ -63431,7 +63414,10 @@ SafeBuffer.allocUnsafeSlow = function (size) {
/***/ }),
-/* 65 */
+/* 64 */
+/*!****************************************************!*\
+ !*** ./node_modules/process-nextick-args/index.js ***!
+ \****************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -63480,352 +63466,87 @@ function nextTick(fn, arg1, arg2, arg3) {
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(59)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../process/browser.js */ 57)))
/***/ }),
-/* 66 */
-/***/ (function(module, exports, __webpack_require__) {
-
-var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */
-
-!function() {
- 'use strict'
-
- var re = {
- not_string: /[^s]/,
- not_bool: /[^t]/,
- not_type: /[^T]/,
- not_primitive: /[^v]/,
- number: /[diefg]/,
- numeric_arg: /[bcdiefguxX]/,
- json: /[j]/,
- not_json: /[^j]/,
- text: /^[^\x25]+/,
- modulo: /^\x25{2}/,
- placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
- key: /^([a-z_][a-z_\d]*)/i,
- key_access: /^\.([a-z_][a-z_\d]*)/i,
- index_access: /^\[(\d+)\]/,
- sign: /^[\+\-]/
- }
-
- function sprintf(key) {
- // `arguments` is not an array, but should be fine for this call
- return sprintf_format(sprintf_parse(key), arguments)
- }
-
- function vsprintf(fmt, argv) {
- return sprintf.apply(null, [fmt].concat(argv || []))
- }
-
- function sprintf_format(parse_tree, argv) {
- var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length, is_positive, sign
- for (i = 0; i < tree_length; i++) {
- if (typeof parse_tree[i] === 'string') {
- output += parse_tree[i]
- }
- else if (Array.isArray(parse_tree[i])) {
- match = parse_tree[i] // convenience purposes only
- if (match[2]) { // keyword argument
- arg = argv[cursor]
- for (k = 0; k < match[2].length; k++) {
- if (!arg.hasOwnProperty(match[2][k])) {
- throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]))
- }
- arg = arg[match[2][k]]
- }
- }
- else if (match[1]) { // positional argument (explicit)
- arg = argv[match[1]]
- }
- else { // positional argument (implicit)
- arg = argv[cursor++]
- }
-
- if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) {
- arg = arg()
- }
-
- if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) {
- throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
- }
-
- if (re.number.test(match[8])) {
- is_positive = arg >= 0
- }
-
- switch (match[8]) {
- case 'b':
- arg = parseInt(arg, 10).toString(2)
- break
- case 'c':
- arg = String.fromCharCode(parseInt(arg, 10))
- break
- case 'd':
- case 'i':
- arg = parseInt(arg, 10)
- break
- case 'j':
- arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
- break
- case 'e':
- arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()
- break
- case 'f':
- arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
- break
- case 'g':
- arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg)
- break
- case 'o':
- arg = (parseInt(arg, 10) >>> 0).toString(8)
- break
- case 's':
- arg = String(arg)
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 't':
- arg = String(!!arg)
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'T':
- arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'u':
- arg = parseInt(arg, 10) >>> 0
- break
- case 'v':
- arg = arg.valueOf()
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'x':
- arg = (parseInt(arg, 10) >>> 0).toString(16)
- break
- case 'X':
- arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
- break
- }
- if (re.json.test(match[8])) {
- output += arg
- }
- else {
- if (re.number.test(match[8]) && (!is_positive || match[3])) {
- sign = is_positive ? '+' : '-'
- arg = arg.toString().replace(re.sign, '')
- }
- else {
- sign = ''
- }
- pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '
- pad_length = match[6] - (sign + arg).length
- pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
- output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
- }
- }
- }
- return output
- }
-
- var sprintf_cache = Object.create(null)
-
- function sprintf_parse(fmt) {
- if (sprintf_cache[fmt]) {
- return sprintf_cache[fmt]
- }
-
- var _fmt = fmt, match, parse_tree = [], arg_names = 0
- while (_fmt) {
- if ((match = re.text.exec(_fmt)) !== null) {
- parse_tree.push(match[0])
- }
- else if ((match = re.modulo.exec(_fmt)) !== null) {
- parse_tree.push('%')
- }
- else if ((match = re.placeholder.exec(_fmt)) !== null) {
- if (match[2]) {
- arg_names |= 1
- var field_list = [], replacement_field = match[2], field_match = []
- if ((field_match = re.key.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
- if ((field_match = re.key_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- }
- else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- }
- else {
- throw new SyntaxError('[sprintf] failed to parse named argument key')
- }
- }
- }
- else {
- throw new SyntaxError('[sprintf] failed to parse named argument key')
- }
- match[2] = field_list
- }
- else {
- arg_names |= 2
- }
- if (arg_names === 3) {
- throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
- }
- parse_tree.push(match)
- }
- else {
- throw new SyntaxError('[sprintf] unexpected placeholder')
- }
- _fmt = _fmt.substring(match[0].length)
- }
- return sprintf_cache[fmt] = parse_tree
- }
-
- /**
- * export to either browser or node.js
- */
- /* eslint-disable quote-props */
- if (true) {
- exports['sprintf'] = sprintf
- exports['vsprintf'] = vsprintf
- }
- if (typeof window !== 'undefined') {
- window['sprintf'] = sprintf
- window['vsprintf'] = vsprintf
-
- if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
- return {
- 'sprintf': sprintf,
- 'vsprintf': vsprintf
- }
- }).call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
- }
- }
- /* eslint-enable quote-props */
-}()
-
-
-/***/ }),
-/* 67 */
+/* 65 */
+/*!******************************!*\
+ !*** ./src/NetscriptPort.js ***!
+ \******************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Environment", function() { return Environment; });
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(36);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(30);
-/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(44);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; });
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 17);
-
-
-/* Environment
- * NetScript program environment
- */
-function Environment(workerScript,parent) {
- if (parent){
- //Create a copy of parent's variables
- //this.vars = parent.vars;
- this.vars = Object.assign({}, parent.vars);
- } else {
- this.vars = Object(_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_1__["NetscriptFunctions"])(workerScript);
- }
- this.parent = parent;
- this.stopFlag = false;
+function NetscriptPort() {
+ this.data = [];
}
-Environment.prototype = {
- //Create a "subscope", which is a new new "sub-environment"
- //The subscope is linked to this through its parent variable
- extend: function() {
- return new Environment(null, this);
- },
- //Finds the scope where the variable with the given name is defined
- lookup: function(name) {
- var scope = this;
- while (scope) {
- if (Object.prototype.hasOwnProperty.call(scope.vars, name)) {
- return scope;
- }
- scope = scope.parent;
- }
- return null;
- },
-
- //Get the current value of a variable
- get: function(name) {
- if (name in this.vars) {
- return this.vars[name];
- }
- throw new Error("Undefined variable " + name);
- },
-
- //Sets the value of a variable in any scope
- set: function(name, value) {
- var scope = this.lookup(name);
-
- //If scope has a value, then this variable is already set in a higher scope, so
- //set is there. Otherwise, create a new variable in the local scope
- if (scope !== null) {
- return scope.vars[name] = value;
- } else {
- return this.vars[name] = value;
- }
- },
-
- setArrayElement: function(name, idx, value) {
- if (!(idx instanceof Array)) {
- throw new Error("idx parameter is not an Array");
- }
- var scope = this.lookup(name);
- if (!scope && this.parent) {
- throw new Error("Undefined variable " + name);
- }
- var arr = (scope || this).vars[name];
- if (!(arr.constructor === Array || arr instanceof Array)) {
- throw new Error("Variable is not an array: " + name);
- }
- var res = arr;
- for (var iterator = 0; iterator < idx.length-1; ++iterator) {
- var i = idx[iterator];
- if (!(res instanceof Array) || i >= res.length) {
- throw new Error("Out-of-bounds array access");
- }
- res = res[i];
- }
-
- //Cant assign to ports or HacknetNodes
- if (res[idx[idx.length-1]] instanceof _HacknetNode_js__WEBPACK_IMPORTED_MODULE_0__["HacknetNode"]) {
- throw new Error("Cannot assign a Hacknet Node handle to a new value");
- }
- if (res[idx[idx.length-1]] instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_2__["NetscriptPort"]) {
- throw new Error("Cannot assign a Netscript Port handle to a new value");
- }
- return res[idx[idx.length-1]] = value;
- },
-
- //Creates (or overwrites) a variable in the current scope
- def: function(name, value) {
- return this.vars[name] = value;
+NetscriptPort.prototype.write = function(data) {
+ this.data.push(data);
+ if (this.data.length > _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
+ return this.data.shift();
}
-};
+ return null;
+}
+
+NetscriptPort.prototype.tryWrite = function(data) {
+ if (this.data.length >= _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
+ return false;
+ }
+ this.data.push(data);
+ return true;
+}
+
+NetscriptPort.prototype.read = function() {
+ if (this.data.length === 0) {
+ return "NULL PORT DATA";
+ }
+ return this.data.shift();
+}
+
+NetscriptPort.prototype.peek = function() {
+ if (this.data.length === 0) {
+ return "NULL PORT DATA";
+ } else {
+ var foo = this.data.slice();
+ return foo[0];
+ }
+}
+
+NetscriptPort.prototype.full = function() {
+ return this.data.length == _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity;
+}
+
+NetscriptPort.prototype.empty = function() {
+ return this.data.length === 0;
+}
+
+NetscriptPort.prototype.clear = function() {
+ this.data.length = 0;
+}
/***/ }),
-/* 68 */
+/* 66 */
+/*!******************************!*\
+ !*** ./src/CinematicText.js ***!
+ \******************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cinematicTextFlag", function() { return cinematicTextFlag; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "writeCinematicText", function() { return writeCinematicText; });
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_2__);
@@ -63849,7 +63570,7 @@ function writeCinematicText(lines) {
Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__["removeChildrenFromElement"])(container);
for (var i = 0; i < lines.length; ++i) {
- if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["isString"])(lines[i])) {
+ if (!Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_2__["isString"])(lines[i])) {
throw new Error("Invalid non-string element in 'lines' argument. writeCinematicText() failed");
}
}
@@ -63926,7 +63647,10 @@ function cinematicTextEnd() {
/***/ }),
-/* 69 */
+/* 67 */
+/*!*************************!*\
+ !*** ./src/HelpText.ts ***!
+ \*************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -64147,10 +63871,13 @@ exports.HelpTexts = {
/***/ }),
+/* 68 */,
+/* 69 */,
/* 70 */,
-/* 71 */,
-/* 72 */,
-/* 73 */
+/* 71 */
+/*!************************************************!*\
+ !*** ./node_modules/pako/lib/zlib/messages.js ***!
+ \************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -64189,13 +63916,16 @@ module.exports = {
/***/ }),
-/* 74 */
+/* 72 */
+/*!*****************************************!*\
+ !*** ./node_modules/jszip/lib/crc32.js ***!
+ \*****************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-var utils = __webpack_require__(31);
+var utils = __webpack_require__(/*! ./utils */ 28);
/**
* The following functions come from pako, from pako/lib/zlib/crc32.js
@@ -64273,17 +64003,20 @@ module.exports = function crc32wrapper(input, crc) {
/***/ }),
-/* 75 */
+/* 73 */
+/*!****************************************************!*\
+ !*** ./node_modules/jszip/lib/compressedObject.js ***!
+ \****************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
-var external = __webpack_require__(57);
-var DataWorker = __webpack_require__(100);
-var DataLengthProbe = __webpack_require__(99);
-var Crc32Probe = __webpack_require__(98);
-var DataLengthProbe = __webpack_require__(99);
+var external = __webpack_require__(/*! ./external */ 54);
+var DataWorker = __webpack_require__(/*! ./stream/DataWorker */ 99);
+var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 98);
+var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ 97);
+var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 98);
/**
* Represent a compressed object, with everything needed to decompress it.
@@ -64355,16 +64088,22 @@ module.exports = CompressedObject;
/***/ }),
-/* 76 */
+/* 74 */
+/*!*********************************************************************************!*\
+ !*** ./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js ***!
+ \*********************************************************************************/
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
-module.exports = !__webpack_require__(104)(function(){
+module.exports = !__webpack_require__(/*! ./_fails */ 103)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
-/* 77 */
+/* 75 */
+/*!*******************************************************************************!*\
+ !*** ./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js ***!
+ \*******************************************************************************/
/***/ (function(module, exports) {
module.exports = function(it){
@@ -64372,7 +64111,10 @@ module.exports = function(it){
};
/***/ }),
-/* 78 */
+/* 76 */
+/*!**************************************************************!*\
+ !*** ./node_modules/readable-stream/lib/_stream_writable.js ***!
+ \**************************************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -64405,7 +64147,7 @@ module.exports = function(it){
/*
" +
"You gained:
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
return;
}
var facValue = totalValue * _src_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult *
@@ -72845,8 +73050,8 @@ function infiltrationBoxCreate(inst) {
var moneyValue = totalValue * _src_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].InfiltrationMoneyValue * _src_BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].InfiltrationMoney;
infiltrationSetText("You can sell the classified documents and secrets " +
"you stole from " + inst.companyName + " for $" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(moneyValue, 2) + " on the black market or you can give it " +
- "to a faction to gain " + Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(facValue, 3) + " reputation with " +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(moneyValue, 2) + " on the black market or you can give it " +
+ "to a faction to gain " + Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(facValue, 3) + " reputation with " +
"that faction.");
var selector = document.getElementById("infiltration-faction-select");
selector.innerHTML = "";
@@ -72863,12 +73068,12 @@ function infiltrationBoxCreate(inst) {
Object(_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You sold the classified information you stole from " + inst.companyName +
" for $" + moneyValue + " on the black market!
" +
"You gained:
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
infiltrationBoxClose();
return false;
});
@@ -72885,14 +73090,14 @@ function infiltrationBoxCreate(inst) {
}
faction.playerReputation += facValue;
Object(_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You gave the classified information you stole from " + inst.companyName +
- " to " + facName + " and gained " + Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(facValue, 3) + " reputation with the faction.
" +
+ " to " + facName + " and gained " + Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(facValue, 3) + " reputation with the faction.
" +
"You gained:
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
- Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.hackingExpGained, 3) + " hacking exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.strExpGained, 3) + " str exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.defExpGained, 3) + " def exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.dexExpGained, 3) + " dex exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.agiExpGained, 3) + " agi exp
" +
+ Object(_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(inst.chaExpGained, 3) + " cha exp
");
infiltrationBoxClose();
return false;
});
@@ -72905,19 +73110,23 @@ function infiltrationBoxCreate(inst) {
/***/ }),
/* 120 */
+/*!*****************************!*\
+ !*** ./src/Infiltration.js ***!
+ \*****************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "beginInfiltration", function() { return beginInfiltration; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
-/* harmony import */ var _utils_InfiltrationBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(119);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(2);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 13);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_InfiltrationBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/InfiltrationBox.js */ 119);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 2);
+/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__);
@@ -73082,7 +73291,7 @@ function nextInfiltrationLevel(inst) {
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY killed the security bots! Unfortunately you alerted the " +
"rest of the facility's security. The facility's security " +
- "level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].karma -= 1;
endInfiltrationLevel(inst);
return false;
@@ -73091,7 +73300,7 @@ function nextInfiltrationLevel(inst) {
writeInfiltrationStatusText("You FAILED to kill the security bots. The bots fight back " +
"and raise the alarm! You take " + dmgTaken + " damage and " +
"the facility's security level increases by " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
@@ -73110,7 +73319,7 @@ function nextInfiltrationLevel(inst) {
} else {
writeInfiltrationStatusText("You FAILED to assassinate the security bots. The bots have not detected " +
"you but are now more alert for an intruder. The facility's security level " +
- "has increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "has increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73127,7 +73336,7 @@ function nextInfiltrationLevel(inst) {
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY killed the security guard! Unfortunately you alerted the " +
"rest of the facility's security. The facility's security " +
- "level has increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "level has increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].karma -= 3;
++_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].numPeopleKilled;
endInfiltrationLevel(inst);
@@ -73137,7 +73346,7 @@ function nextInfiltrationLevel(inst) {
writeInfiltrationStatusText("You FAILED to kill the security guard. The guard fights back " +
"and raises the alarm! You take " + dmgTaken + " damage and " +
"the facility's security level has increased by " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
@@ -73159,7 +73368,7 @@ function nextInfiltrationLevel(inst) {
} else {
writeInfiltrationStatusText("You FAILED to assassinate the security guard. The guard has not detected " +
"you but is now more alert for an intruder. The facility's security level " +
- "has increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "has increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73175,14 +73384,14 @@ function nextInfiltrationLevel(inst) {
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY knocked out the security guard! " +
"Unfortunately you made a lot of noise and alerted other security.");
- writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
endInfiltrationLevel(inst);
return false;
} else {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].defense));
writeInfiltrationStatusText("You FAILED to knockout the security guard. The guard " +
"raises the alarm and fights back! You take " + dmgTaken + " damage and " +
- "the facility's security level increases by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "the facility's security level increases by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
@@ -73203,7 +73412,7 @@ function nextInfiltrationLevel(inst) {
var dmgTaken = Math.max(1, Math.round(inst.securityLevel / _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].defense));
writeInfiltrationStatusText("You FAILED to stealthily knockout the security guard. The guard " +
"raises the alarm and fights back! You take " + dmgTaken + " damage and " +
- "the facility's security level increases by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "the facility's security level increases by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].takeDamage(dmgTaken)) {
endInfiltration(inst, false);
}
@@ -73222,7 +73431,7 @@ function nextInfiltrationLevel(inst) {
return false;
} else {
writeInfiltrationStatusText("You FAILED to hack the security system. The facility's " +
- "security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73233,12 +73442,12 @@ function nextInfiltrationLevel(inst) {
var res = attemptInfiltrationDestroySecurity(inst);
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY and violently destroy the security system!");
- writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
endInfiltrationLevel(inst);
return false;
} else {
writeInfiltrationStatusText("You FAILED to destroy the security system. The facility's " +
- "security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73253,7 +73462,7 @@ function nextInfiltrationLevel(inst) {
return false;
} else {
writeInfiltrationStatusText("You FAILED and were detected while trying to sneak past security! The facility's " +
- "security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73264,12 +73473,12 @@ function nextInfiltrationLevel(inst) {
var res = attemptInfiltrationPickLockedDoor(inst);
if (res[0]) {
writeInfiltrationStatusText("You SUCCESSFULLY pick the locked door!");
- writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ writeInfiltrationStatusText("The facility's security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
endInfiltrationLevel(inst);
return false;
} else {
writeInfiltrationStatusText("You FAILED to pick the locked door. The facility's security level " +
- "increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73293,7 +73502,7 @@ function nextInfiltrationLevel(inst) {
} else {
writeInfiltrationStatusText("You FAILED to bribe a guard! The guard is alerting " +
"other security guards about your presence! The facility's " +
- "security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
}
updateInfiltrationButtons(inst, scenario);
updateInfiltrationLevelText(inst);
@@ -73309,7 +73518,7 @@ function nextInfiltrationLevel(inst) {
return false;
} else {
writeInfiltrationStatusText("You FAILED to escape from the facility. You took 1 damage. The facility's " +
- "security level increased by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
+ "security level increased by " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])((res[1]*100)-100, 2).toString() + "%");
if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].takeDamage(1)) {
endInfiltration(inst, false);
}
@@ -73337,8 +73546,8 @@ function endInfiltrationLevel(inst) {
inst.secretsStolen.push(baseSecretValue);
Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You found and stole a set of classified documents from the company. " +
"These classified secrets could probably be sold for money ($" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(secretMoneyValue, 2) + "), or they " +
- "could be given to factions for reputation (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(secretValue, 3) + " rep)");
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(secretMoneyValue, 2) + "), or they " +
+ "could be given to factions for reputation (" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(secretValue, 3) + " rep)");
}
//Increase security level based on difficulty
@@ -73378,15 +73587,15 @@ function updateInfiltrationLevelText(inst) {
document.getElementById("infiltration-level-text").innerHTML =
"Facility name: " + inst.companyName + "
" +
"Clearance Level: " + inst.clearanceLevel + "
" +
- "Security Level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.securityLevel, 3) + "
" +
- "Total reputation value of secrets stolen: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(totalValue, 3) + "
" +
- "Total monetary value of secrets stolen: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(totalMoneyValue, 2) + "
" +
- "Hack exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.hackingExpGained * expMultiplier, 3) + "
" +
- "Str exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.strExpGained * expMultiplier, 3) + "
" +
- "Def exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.defExpGained * expMultiplier, 3) + "
" +
- "Dex exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.dexExpGained * expMultiplier, 3) + "
" +
- "Agi exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.agiExpGained * expMultiplier, 3) + "
" +
- "Cha exp gained: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.chaExpGained * expMultiplier, 3);
+ "Security Level: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.securityLevel, 3) + "
" +
+ "Total reputation value of secrets stolen: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(totalValue, 3) + "
" +
+ "Total monetary value of secrets stolen: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(totalMoneyValue, 2) + "
" +
+ "Hack exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.hackingExpGained * expMultiplier, 3) + "
" +
+ "Str exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.strExpGained * expMultiplier, 3) + "
" +
+ "Def exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.defExpGained * expMultiplier, 3) + "
" +
+ "Dex exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.dexExpGained * expMultiplier, 3) + "
" +
+ "Agi exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.agiExpGained * expMultiplier, 3) + "
" +
+ "Cha exp gained: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(inst.chaExpGained * expMultiplier, 3);
}
function updateInfiltrationButtons(inst, scenario) {
@@ -73405,7 +73614,7 @@ function updateInfiltrationButtons(inst, scenario) {
"" +
"Attempt to escape the facility with the classified secrets and " +
"documents you have stolen. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(escapeChance*100, 2) + "% chance of success. If you fail, " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(escapeChance*100, 2) + "% chance of success. If you fail, " +
"the security level will increase by 5%.";
switch(scenario) {
@@ -73413,55 +73622,55 @@ function updateInfiltrationButtons(inst, scenario) {
document.getElementById("infiltration-pickdoor").innerHTML = "Lockpick" +
"" +
"Attempt to pick the locked door. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(lockpickChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(lockpickChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increased by 1%. If you fail, the " +
"security level will increase by 3%.";
case InfiltrationScenarios.TechOnly:
document.getElementById("infiltration-hacksecurity").innerHTML = "Hack" +
"" +
"Attempt to hack and disable the security system. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(hackChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(hackChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, " +
"the security level will increase by 5%.";
document.getElementById("infiltration-destroysecurity").innerHTML = "Destroy security" +
"" +
"Attempt to violently destroy the security system. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(destroySecurityChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(destroySecurityChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, the " +
"security level will increase by 10%. ";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"" +
"Attempt to sneak past the security system. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. ";
break;
case InfiltrationScenarios.Bots:
document.getElementById("infiltration-kill").innerHTML = "Destroy bots" +
"" +
"Attempt to destroy the security bots through combat. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(killChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(killChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, " +
"the security level will increase by 10%. ";
document.getElementById("infiltration-assassinate").innerHTML = "Assassinate bots" +
"" +
"Attempt to stealthily destroy the security bots through assassination. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(assassinateChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(assassinateChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 10%. ";
document.getElementById("infiltration-hacksecurity").innerHTML = "Hack bots" +
"" +
"Attempt to disable the security bots by hacking them. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(hackChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(hackChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, " +
"the security level will increase by 5%. ";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"" +
"Attempt to sneak past the security bots. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. ";
break;
@@ -73470,39 +73679,39 @@ function updateInfiltrationButtons(inst, scenario) {
document.getElementById("infiltration-kill").innerHTML = "Kill" +
"" +
"Attempt to kill the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(killChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(killChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 5%. If you fail, " +
"the security level will decrease by 10%. ";
document.getElementById("infiltration-knockout").innerHTML = "Knockout" +
"" +
"Attempt to knockout the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(knockoutChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(knockoutChance*100, 2) + "% chance of success. " +
"If you succeed, the security level will increase by 3%. If you fail, the " +
"security level will increase by 10%. ";
document.getElementById("infiltration-stealthknockout").innerHTML = "Stealth Knockout" +
"" +
"Attempt to stealthily knockout the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(stealthKnockoutChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(stealthKnockoutChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 10%. ";
document.getElementById("infiltration-assassinate").innerHTML = "Assassinate" +
"" +
"Attempt to assassinate the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(assassinateChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(assassinateChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 5%. ";
document.getElementById("infiltration-sneak").innerHTML = "Sneak" +
"" +
"Attempt to sneak past the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(sneakChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 8%. ";
document.getElementById("infiltration-bribe").innerHTML = "Bribe" +
"" +
"Attempt to bribe the security guard. You have a " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(bribeChance*100, 2) + "% chance of success. " +
+ Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(bribeChance*100, 2) + "% chance of success. " +
"If you fail, the security level will increase by 15%. ";
break;
}
@@ -73747,6 +73956,9 @@ function getInfiltrationEscapeChance(inst) {
/***/ }),
/* 121 */
+/*!**********************************************!*\
+ !*** ./node_modules/file-saver/FileSaver.js ***!
+ \**********************************************/
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;/* FileSaver.js
@@ -73932,7 +74144,7 @@ var saveAs = saveAs || (function(view) {
if (typeof module !== "undefined" && module.exports) {
module.exports.saveAs = saveAs;
-} else if (("function" !== "undefined" && __webpack_require__(83) !== null) && (__webpack_require__(132) !== null)) {
+} else if (("function" !== "undefined" && __webpack_require__(/*! !webpack amd define */ 81) !== null) && (__webpack_require__(/*! !webpack amd options */ 131) !== null)) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
return saveAs;
}).call(exports, __webpack_require__, exports, module),
@@ -73942,6 +74154,9 @@ if (typeof module !== "undefined" && module.exports) {
/***/ }),
/* 122 */
+/*!*****************************************!*\
+ !*** ./node_modules/jszip/lib/index.js ***!
+ \*****************************************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
@@ -73982,10 +74197,10 @@ function JSZip() {
return newObj;
};
}
-JSZip.prototype = __webpack_require__(183);
-JSZip.prototype.loadAsync = __webpack_require__(137);
-JSZip.support = __webpack_require__(48);
-JSZip.defaults = __webpack_require__(101);
+JSZip.prototype = __webpack_require__(/*! ./object */ 181);
+JSZip.prototype.loadAsync = __webpack_require__(/*! ./load */ 136);
+JSZip.support = __webpack_require__(/*! ./support */ 46);
+JSZip.defaults = __webpack_require__(/*! ./defaults */ 100);
// TODO find a better way to handle this version,
// a require('package.json').version doesn't work with webpack, see #327
@@ -73995,7 +74210,7 @@ JSZip.loadAsync = function (content, options) {
return new JSZip().loadAsync(content, options);
};
-JSZip.external = __webpack_require__(57);
+JSZip.external = __webpack_require__(/*! ./external */ 54);
module.exports = JSZip;
@@ -74006,6 +74221,9 @@ module.exports = JSZip;
/* 126 */,
/* 127 */,
/* 128 */
+/*!**********************************************!*\
+ !*** ./node_modules/uuid/lib/bytesToUuid.js ***!
+ \**********************************************/
/***/ (function(module, exports) {
/**
@@ -74035,6 +74253,9 @@ module.exports = bytesToUuid;
/***/ }),
/* 129 */
+/*!**********************************************!*\
+ !*** ./node_modules/uuid/lib/rng-browser.js ***!
+ \**********************************************/
/***/ (function(module, exports) {
// Unique ID creation requires a high quality random # generator. In the
@@ -74073,6 +74294,9 @@ if (getRandomValues) {
/***/ }),
/* 130 */
+/*!************************************!*\
+ !*** ./src/NetscriptJSPreamble.js ***!
+ \************************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
@@ -74080,9 +74304,9 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "registerEnv", function() { return registerEnv; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unregisterEnv", function() { return unregisterEnv; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeEnvHeader", function() { return makeEnvHeader; });
-/* harmony import */ var uuid_v4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(117);
+/* harmony import */ var uuid_v4__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uuid/v4 */ 117);
/* harmony import */ var uuid_v4__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(uuid_v4__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var sprintf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(66);
+/* harmony import */ var sprintf_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sprintf-js */ 116);
/* harmony import */ var sprintf_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(sprintf_js__WEBPACK_IMPORTED_MODULE_1__);
// A utility function that adds a preamble to each Netscript JS
// script. This preamble will set all the global functions and
@@ -74129,6 +74353,10050 @@ function makeEnvHeader(uuid) {
/***/ }),
/* 131 */
+/*!****************************************!*\
+ !*** (webpack)/buildin/amd-options.js ***!
+ \****************************************/
+/***/ (function(module, exports) {
+
+/* WEBPACK VAR INJECTION */(function(__webpack_amd_options__) {/* globals __webpack_amd_options__ */
+module.exports = __webpack_amd_options__;
+
+/* WEBPACK VAR INJECTION */}.call(this, {}))
+
+/***/ }),
+/* 132 */
+/*!********************************************!*\
+ !*** ./node_modules/jszip/lib/zipEntry.js ***!
+ \********************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+var readerFor = __webpack_require__(/*! ./reader/readerFor */ 89);
+var utils = __webpack_require__(/*! ./utils */ 28);
+var CompressedObject = __webpack_require__(/*! ./compressedObject */ 73);
+var crc32fn = __webpack_require__(/*! ./crc32 */ 72);
+var utf8 = __webpack_require__(/*! ./utf8 */ 52);
+var compressions = __webpack_require__(/*! ./compressions */ 96);
+var support = __webpack_require__(/*! ./support */ 46);
+
+var MADE_BY_DOS = 0x00;
+var MADE_BY_UNIX = 0x03;
+
+/**
+ * Find a compression registered in JSZip.
+ * @param {string} compressionMethod the method magic to find.
+ * @return {Object|null} the JSZip compression object, null if none found.
+ */
+var findCompression = function(compressionMethod) {
+ for (var method in compressions) {
+ if (!compressions.hasOwnProperty(method)) {
+ continue;
+ }
+ if (compressions[method].magic === compressionMethod) {
+ return compressions[method];
+ }
+ }
+ return null;
+};
+
+// class ZipEntry {{{
+/**
+ * An entry in the zip file.
+ * @constructor
+ * @param {Object} options Options of the current file.
+ * @param {Object} loadOptions Options for loading the stream.
+ */
+function ZipEntry(options, loadOptions) {
+ this.options = options;
+ this.loadOptions = loadOptions;
+}
+ZipEntry.prototype = {
+ /**
+ * say if the file is encrypted.
+ * @return {boolean} true if the file is encrypted, false otherwise.
+ */
+ isEncrypted: function() {
+ // bit 1 is set
+ return (this.bitFlag & 0x0001) === 0x0001;
+ },
+ /**
+ * say if the file has utf-8 filename/comment.
+ * @return {boolean} true if the filename/comment is in utf-8, false otherwise.
+ */
+ useUTF8: function() {
+ // bit 11 is set
+ return (this.bitFlag & 0x0800) === 0x0800;
+ },
+ /**
+ * Read the local part of a zip file and add the info in this object.
+ * @param {DataReader} reader the reader to use.
+ */
+ readLocalPart: function(reader) {
+ var compression, localExtraFieldsLength;
+
+ // we already know everything from the central dir !
+ // If the central dir data are false, we are doomed.
+ // On the bright side, the local part is scary : zip64, data descriptors, both, etc.
+ // The less data we get here, the more reliable this should be.
+ // Let's skip the whole header and dash to the data !
+ reader.skip(22);
+ // in some zip created on windows, the filename stored in the central dir contains \ instead of /.
+ // Strangely, the filename here is OK.
+ // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
+ // or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
+ // Search "unzip mismatching "local" filename continuing with "central" filename version" on
+ // the internet.
+ //
+ // I think I see the logic here : the central directory is used to display
+ // content and the local directory is used to extract the files. Mixing / and \
+ // may be used to display \ to windows users and use / when extracting the files.
+ // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
+ this.fileNameLength = reader.readInt(2);
+ localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
+ // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.
+ this.fileName = reader.readData(this.fileNameLength);
+ reader.skip(localExtraFieldsLength);
+
+ if (this.compressedSize === -1 || this.uncompressedSize === -1) {
+ throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory " + "(compressedSize === -1 || uncompressedSize === -1)");
+ }
+
+ compression = findCompression(this.compressionMethod);
+ if (compression === null) { // no compression found
+ throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
+ }
+ this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
+ },
+
+ /**
+ * Read the central part of a zip file and add the info in this object.
+ * @param {DataReader} reader the reader to use.
+ */
+ readCentralPart: function(reader) {
+ this.versionMadeBy = reader.readInt(2);
+ reader.skip(2);
+ // this.versionNeeded = reader.readInt(2);
+ this.bitFlag = reader.readInt(2);
+ this.compressionMethod = reader.readString(2);
+ this.date = reader.readDate();
+ this.crc32 = reader.readInt(4);
+ this.compressedSize = reader.readInt(4);
+ this.uncompressedSize = reader.readInt(4);
+ var fileNameLength = reader.readInt(2);
+ this.extraFieldsLength = reader.readInt(2);
+ this.fileCommentLength = reader.readInt(2);
+ this.diskNumberStart = reader.readInt(2);
+ this.internalFileAttributes = reader.readInt(2);
+ this.externalFileAttributes = reader.readInt(4);
+ this.localHeaderOffset = reader.readInt(4);
+
+ if (this.isEncrypted()) {
+ throw new Error("Encrypted zip are not supported");
+ }
+
+ // will be read in the local part, see the comments there
+ reader.skip(fileNameLength);
+ this.readExtraFields(reader);
+ this.parseZIP64ExtraField(reader);
+ this.fileComment = reader.readData(this.fileCommentLength);
+ },
+
+ /**
+ * Parse the external file attributes and get the unix/dos permissions.
+ */
+ processAttributes: function () {
+ this.unixPermissions = null;
+ this.dosPermissions = null;
+ var madeBy = this.versionMadeBy >> 8;
+
+ // Check if we have the DOS directory flag set.
+ // We look for it in the DOS and UNIX permissions
+ // but some unknown platform could set it as a compatibility flag.
+ this.dir = this.externalFileAttributes & 0x0010 ? true : false;
+
+ if(madeBy === MADE_BY_DOS) {
+ // first 6 bits (0 to 5)
+ this.dosPermissions = this.externalFileAttributes & 0x3F;
+ }
+
+ if(madeBy === MADE_BY_UNIX) {
+ this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;
+ // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
+ }
+
+ // fail safe : if the name ends with a / it probably means a folder
+ if (!this.dir && this.fileNameStr.slice(-1) === '/') {
+ this.dir = true;
+ }
+ },
+
+ /**
+ * Parse the ZIP64 extra field and merge the info in the current ZipEntry.
+ * @param {DataReader} reader the reader to use.
+ */
+ parseZIP64ExtraField: function(reader) {
+
+ if (!this.extraFields[0x0001]) {
+ return;
+ }
+
+ // should be something, preparing the extra reader
+ var extraReader = readerFor(this.extraFields[0x0001].value);
+
+ // I really hope that these 64bits integer can fit in 32 bits integer, because js
+ // won't let us have more.
+ if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
+ this.uncompressedSize = extraReader.readInt(8);
+ }
+ if (this.compressedSize === utils.MAX_VALUE_32BITS) {
+ this.compressedSize = extraReader.readInt(8);
+ }
+ if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
+ this.localHeaderOffset = extraReader.readInt(8);
+ }
+ if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
+ this.diskNumberStart = extraReader.readInt(4);
+ }
+ },
+ /**
+ * Read the central part of a zip file and add the info in this object.
+ * @param {DataReader} reader the reader to use.
+ */
+ readExtraFields: function(reader) {
+ var end = reader.index + this.extraFieldsLength,
+ extraFieldId,
+ extraFieldLength,
+ extraFieldValue;
+
+ if (!this.extraFields) {
+ this.extraFields = {};
+ }
+
+ while (reader.index < end) {
+ extraFieldId = reader.readInt(2);
+ extraFieldLength = reader.readInt(2);
+ extraFieldValue = reader.readData(extraFieldLength);
+
+ this.extraFields[extraFieldId] = {
+ id: extraFieldId,
+ length: extraFieldLength,
+ value: extraFieldValue
+ };
+ }
+ },
+ /**
+ * Apply an UTF8 transformation if needed.
+ */
+ handleUTF8: function() {
+ var decodeParamType = support.uint8array ? "uint8array" : "array";
+ if (this.useUTF8()) {
+ this.fileNameStr = utf8.utf8decode(this.fileName);
+ this.fileCommentStr = utf8.utf8decode(this.fileComment);
+ } else {
+ var upath = this.findExtraFieldUnicodePath();
+ if (upath !== null) {
+ this.fileNameStr = upath;
+ } else {
+ // ASCII text or unsupported code page
+ var fileNameByteArray = utils.transformTo(decodeParamType, this.fileName);
+ this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);
+ }
+
+ var ucomment = this.findExtraFieldUnicodeComment();
+ if (ucomment !== null) {
+ this.fileCommentStr = ucomment;
+ } else {
+ // ASCII text or unsupported code page
+ var commentByteArray = utils.transformTo(decodeParamType, this.fileComment);
+ this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);
+ }
+ }
+ },
+
+ /**
+ * Find the unicode path declared in the extra field, if any.
+ * @return {String} the unicode path, null otherwise.
+ */
+ findExtraFieldUnicodePath: function() {
+ var upathField = this.extraFields[0x7075];
+ if (upathField) {
+ var extraReader = readerFor(upathField.value);
+
+ // wrong version
+ if (extraReader.readInt(1) !== 1) {
+ return null;
+ }
+
+ // the crc of the filename changed, this field is out of date.
+ if (crc32fn(this.fileName) !== extraReader.readInt(4)) {
+ return null;
+ }
+
+ return utf8.utf8decode(extraReader.readData(upathField.length - 5));
+ }
+ return null;
+ },
+
+ /**
+ * Find the unicode comment declared in the extra field, if any.
+ * @return {String} the unicode comment, null otherwise.
+ */
+ findExtraFieldUnicodeComment: function() {
+ var ucommentField = this.extraFields[0x6375];
+ if (ucommentField) {
+ var extraReader = readerFor(ucommentField.value);
+
+ // wrong version
+ if (extraReader.readInt(1) !== 1) {
+ return null;
+ }
+
+ // the crc of the comment changed, this field is out of date.
+ if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {
+ return null;
+ }
+
+ return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));
+ }
+ return null;
+ }
+};
+module.exports = ZipEntry;
+
+
+/***/ }),
+/* 133 */
+/*!***********************************************************!*\
+ !*** ./node_modules/jszip/lib/reader/NodeBufferReader.js ***!
+ \***********************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+var Uint8ArrayReader = __webpack_require__(/*! ./Uint8ArrayReader */ 86);
+var utils = __webpack_require__(/*! ../utils */ 28);
+
+function NodeBufferReader(data) {
+ Uint8ArrayReader.call(this, data);
+}
+utils.inherits(NodeBufferReader, Uint8ArrayReader);
+
+/**
+ * @see DataReader.readData
+ */
+NodeBufferReader.prototype.readData = function(size) {
+ this.checkOffset(size);
+ var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
+ this.index += size;
+ return result;
+};
+module.exports = NodeBufferReader;
+
+
+/***/ }),
+/* 134 */
+/*!*******************************************************!*\
+ !*** ./node_modules/jszip/lib/reader/StringReader.js ***!
+ \*******************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+var DataReader = __webpack_require__(/*! ./DataReader */ 87);
+var utils = __webpack_require__(/*! ../utils */ 28);
+
+function StringReader(data) {
+ DataReader.call(this, data);
+}
+utils.inherits(StringReader, DataReader);
+/**
+ * @see DataReader.byteAt
+ */
+StringReader.prototype.byteAt = function(i) {
+ return this.data.charCodeAt(this.zero + i);
+};
+/**
+ * @see DataReader.lastIndexOfSignature
+ */
+StringReader.prototype.lastIndexOfSignature = function(sig) {
+ return this.data.lastIndexOf(sig) - this.zero;
+};
+/**
+ * @see DataReader.readAndCheckSignature
+ */
+StringReader.prototype.readAndCheckSignature = function (sig) {
+ var data = this.readData(4);
+ return sig === data;
+};
+/**
+ * @see DataReader.readData
+ */
+StringReader.prototype.readData = function(size) {
+ this.checkOffset(size);
+ // this will work because the constructor applied the "& 0xff" mask.
+ var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);
+ this.index += size;
+ return result;
+};
+module.exports = StringReader;
+
+
+/***/ }),
+/* 135 */
+/*!**********************************************!*\
+ !*** ./node_modules/jszip/lib/zipEntries.js ***!
+ \**********************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+var readerFor = __webpack_require__(/*! ./reader/readerFor */ 89);
+var utils = __webpack_require__(/*! ./utils */ 28);
+var sig = __webpack_require__(/*! ./signature */ 90);
+var ZipEntry = __webpack_require__(/*! ./zipEntry */ 132);
+var utf8 = __webpack_require__(/*! ./utf8 */ 52);
+var support = __webpack_require__(/*! ./support */ 46);
+// class ZipEntries {{{
+/**
+ * All the entries in the zip file.
+ * @constructor
+ * @param {Object} loadOptions Options for loading the stream.
+ */
+function ZipEntries(loadOptions) {
+ this.files = [];
+ this.loadOptions = loadOptions;
+}
+ZipEntries.prototype = {
+ /**
+ * Check that the reader is on the specified signature.
+ * @param {string} expectedSignature the expected signature.
+ * @throws {Error} if it is an other signature.
+ */
+ checkSignature: function(expectedSignature) {
+ if (!this.reader.readAndCheckSignature(expectedSignature)) {
+ this.reader.index -= 4;
+ var signature = this.reader.readString(4);
+ throw new Error("Corrupted zip or bug: unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
+ }
+ },
+ /**
+ * Check if the given signature is at the given index.
+ * @param {number} askedIndex the index to check.
+ * @param {string} expectedSignature the signature to expect.
+ * @return {boolean} true if the signature is here, false otherwise.
+ */
+ isSignature: function(askedIndex, expectedSignature) {
+ var currentIndex = this.reader.index;
+ this.reader.setIndex(askedIndex);
+ var signature = this.reader.readString(4);
+ var result = signature === expectedSignature;
+ this.reader.setIndex(currentIndex);
+ return result;
+ },
+ /**
+ * Read the end of the central directory.
+ */
+ readBlockEndOfCentral: function() {
+ this.diskNumber = this.reader.readInt(2);
+ this.diskWithCentralDirStart = this.reader.readInt(2);
+ this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
+ this.centralDirRecords = this.reader.readInt(2);
+ this.centralDirSize = this.reader.readInt(4);
+ this.centralDirOffset = this.reader.readInt(4);
+
+ this.zipCommentLength = this.reader.readInt(2);
+ // warning : the encoding depends of the system locale
+ // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
+ // On a windows machine, this field is encoded with the localized windows code page.
+ var zipComment = this.reader.readData(this.zipCommentLength);
+ var decodeParamType = support.uint8array ? "uint8array" : "array";
+ // To get consistent behavior with the generation part, we will assume that
+ // this is utf8 encoded unless specified otherwise.
+ var decodeContent = utils.transformTo(decodeParamType, zipComment);
+ this.zipComment = this.loadOptions.decodeFileName(decodeContent);
+ },
+ /**
+ * Read the end of the Zip 64 central directory.
+ * Not merged with the method readEndOfCentral :
+ * The end of central can coexist with its Zip64 brother,
+ * I don't want to read the wrong number of bytes !
+ */
+ readBlockZip64EndOfCentral: function() {
+ this.zip64EndOfCentralSize = this.reader.readInt(8);
+ this.reader.skip(4);
+ // this.versionMadeBy = this.reader.readString(2);
+ // this.versionNeeded = this.reader.readInt(2);
+ this.diskNumber = this.reader.readInt(4);
+ this.diskWithCentralDirStart = this.reader.readInt(4);
+ this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
+ this.centralDirRecords = this.reader.readInt(8);
+ this.centralDirSize = this.reader.readInt(8);
+ this.centralDirOffset = this.reader.readInt(8);
+
+ this.zip64ExtensibleData = {};
+ var extraDataSize = this.zip64EndOfCentralSize - 44,
+ index = 0,
+ extraFieldId,
+ extraFieldLength,
+ extraFieldValue;
+ while (index < extraDataSize) {
+ extraFieldId = this.reader.readInt(2);
+ extraFieldLength = this.reader.readInt(4);
+ extraFieldValue = this.reader.readData(extraFieldLength);
+ this.zip64ExtensibleData[extraFieldId] = {
+ id: extraFieldId,
+ length: extraFieldLength,
+ value: extraFieldValue
+ };
+ }
+ },
+ /**
+ * Read the end of the Zip 64 central directory locator.
+ */
+ readBlockZip64EndOfCentralLocator: function() {
+ this.diskWithZip64CentralDirStart = this.reader.readInt(4);
+ this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
+ this.disksCount = this.reader.readInt(4);
+ if (this.disksCount > 1) {
+ throw new Error("Multi-volumes zip are not supported");
+ }
+ },
+ /**
+ * Read the local files, based on the offset read in the central part.
+ */
+ readLocalFiles: function() {
+ var i, file;
+ for (i = 0; i < this.files.length; i++) {
+ file = this.files[i];
+ this.reader.setIndex(file.localHeaderOffset);
+ this.checkSignature(sig.LOCAL_FILE_HEADER);
+ file.readLocalPart(this.reader);
+ file.handleUTF8();
+ file.processAttributes();
+ }
+ },
+ /**
+ * Read the central directory.
+ */
+ readCentralDir: function() {
+ var file;
+
+ this.reader.setIndex(this.centralDirOffset);
+ while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {
+ file = new ZipEntry({
+ zip64: this.zip64
+ }, this.loadOptions);
+ file.readCentralPart(this.reader);
+ this.files.push(file);
+ }
+
+ if (this.centralDirRecords !== this.files.length) {
+ if (this.centralDirRecords !== 0 && this.files.length === 0) {
+ // We expected some records but couldn't find ANY.
+ // This is really suspicious, as if something went wrong.
+ throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
+ } else {
+ // We found some records but not all.
+ // Something is wrong but we got something for the user: no error here.
+ // console.warn("expected", this.centralDirRecords, "records in central dir, got", this.files.length);
+ }
+ }
+ },
+ /**
+ * Read the end of central directory.
+ */
+ readEndOfCentral: function() {
+ var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
+ if (offset < 0) {
+ // Check if the content is a truncated zip or complete garbage.
+ // A "LOCAL_FILE_HEADER" is not required at the beginning (auto
+ // extractible zip for example) but it can give a good hint.
+ // If an ajax request was used without responseType, we will also
+ // get unreadable data.
+ var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);
+
+ if (isGarbage) {
+ throw new Error("Can't find end of central directory : is this a zip file ? " +
+ "If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
+ } else {
+ throw new Error("Corrupted zip: can't find end of central directory");
+ }
+
+ }
+ this.reader.setIndex(offset);
+ var endOfCentralDirOffset = offset;
+ this.checkSignature(sig.CENTRAL_DIRECTORY_END);
+ this.readBlockEndOfCentral();
+
+
+ /* extract from the zip spec :
+ 4) If one of the fields in the end of central directory
+ record is too small to hold required data, the field
+ should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
+ ZIP64 format record should be created.
+ 5) The end of central directory record and the
+ Zip64 end of central directory locator record must
+ reside on the same disk when splitting or spanning
+ an archive.
+ */
+ if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
+ this.zip64 = true;
+
+ /*
+ Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
+ the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents
+ all numbers as 64-bit double precision IEEE 754 floating point numbers.
+ So, we have 53bits for integers and bitwise operations treat everything as 32bits.
+ see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
+ and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
+ */
+
+ // should look for a zip64 EOCD locator
+ offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
+ if (offset < 0) {
+ throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");
+ }
+ this.reader.setIndex(offset);
+ this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
+ this.readBlockZip64EndOfCentralLocator();
+
+ // now the zip64 EOCD record
+ if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {
+ // console.warn("ZIP64 end of central directory not where expected.");
+ this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
+ if (this.relativeOffsetEndOfZip64CentralDir < 0) {
+ throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");
+ }
+ }
+ this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
+ this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
+ this.readBlockZip64EndOfCentral();
+ }
+
+ var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;
+ if (this.zip64) {
+ expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator
+ expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;
+ }
+
+ var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;
+
+ if (extraBytes > 0) {
+ // console.warn(extraBytes, "extra bytes at beginning or within zipfile");
+ if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {
+ // The offsets seem wrong, but we have something at the specified offset.
+ // So… we keep it.
+ } else {
+ // the offset is wrong, update the "zero" of the reader
+ // this happens if data has been prepended (crx files for example)
+ this.reader.zero = extraBytes;
+ }
+ } else if (extraBytes < 0) {
+ throw new Error("Corrupted zip: missing " + Math.abs(extraBytes) + " bytes.");
+ }
+ },
+ prepareReader: function(data) {
+ this.reader = readerFor(data);
+ },
+ /**
+ * Read a zip file and create ZipEntries.
+ * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
+ */
+ load: function(data) {
+ this.prepareReader(data);
+ this.readEndOfCentral();
+ this.readCentralDir();
+ this.readLocalFiles();
+ }
+};
+// }}} end of ZipEntries
+module.exports = ZipEntries;
+
+
+/***/ }),
+/* 136 */
+/*!****************************************!*\
+ !*** ./node_modules/jszip/lib/load.js ***!
+ \****************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+var utils = __webpack_require__(/*! ./utils */ 28);
+var external = __webpack_require__(/*! ./external */ 54);
+var utf8 = __webpack_require__(/*! ./utf8 */ 52);
+var utils = __webpack_require__(/*! ./utils */ 28);
+var ZipEntries = __webpack_require__(/*! ./zipEntries */ 135);
+var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ 97);
+var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ 62);
+
+/**
+ * Check the CRC32 of an entry.
+ * @param {ZipEntry} zipEntry the zip entry to check.
+ * @return {Promise} the result.
+ */
+function checkEntryCRC32(zipEntry) {
+ return new external.Promise(function (resolve, reject) {
+ var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
+ worker.on("error", function (e) {
+ reject(e);
+ })
+ .on("end", function () {
+ if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {
+ reject(new Error("Corrupted zip : CRC32 mismatch"));
+ } else {
+ resolve();
+ }
+ })
+ .resume();
+ });
+}
+
+module.exports = function(data, options) {
+ var zip = this;
+ options = utils.extend(options || {}, {
+ base64: false,
+ checkCRC32: false,
+ optimizedBinaryString: false,
+ createFolders: false,
+ decodeFileName: utf8.utf8decode
+ });
+
+ if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {
+ return external.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file."));
+ }
+
+ return utils.prepareContent("the loaded zip file", data, true, options.optimizedBinaryString, options.base64)
+ .then(function(data) {
+ var zipEntries = new ZipEntries(options);
+ zipEntries.load(data);
+ return zipEntries;
+ }).then(function checkCRC32(zipEntries) {
+ var promises = [external.Promise.resolve(zipEntries)];
+ var files = zipEntries.files;
+ if (options.checkCRC32) {
+ for (var i = 0; i < files.length; i++) {
+ promises.push(checkEntryCRC32(files[i]));
+ }
+ }
+ return external.Promise.all(promises);
+ }).then(function addFiles(results) {
+ var zipEntries = results.shift();
+ var files = zipEntries.files;
+ for (var i = 0; i < files.length; i++) {
+ var input = files[i];
+ zip.file(input.fileNameStr, input.decompressed, {
+ binary: true,
+ optimizedBinaryString: true,
+ date: input.date,
+ dir: input.dir,
+ comment : input.fileCommentStr.length ? input.fileCommentStr : null,
+ unixPermissions : input.unixPermissions,
+ dosPermissions : input.dosPermissions,
+ createFolders: options.createFolders
+ });
+ }
+ if (zipEntries.zipComment.length) {
+ zip.comment = zipEntries.zipComment;
+ }
+
+ return zip;
+ });
+};
+
+
+/***/ }),
+/* 137 */
+/*!*******************************************************************!*\
+ !*** ./node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js ***!
+ \*******************************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+var utils = __webpack_require__(/*! ../utils */ 28);
+var GenericWorker = __webpack_require__(/*! ../stream/GenericWorker */ 36);
+
+/**
+ * A worker that use a nodejs stream as source.
+ * @constructor
+ * @param {String} filename the name of the file entry for this stream.
+ * @param {Readable} stream the nodejs stream.
+ */
+function NodejsStreamInputAdapter(filename, stream) {
+ GenericWorker.call(this, "Nodejs stream input adapter for " + filename);
+ this._upstreamEnded = false;
+ this._bindStream(stream);
+}
+
+utils.inherits(NodejsStreamInputAdapter, GenericWorker);
+
+/**
+ * Prepare the stream and bind the callbacks on it.
+ * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.
+ * @param {Stream} stream the nodejs stream to use.
+ */
+NodejsStreamInputAdapter.prototype._bindStream = function (stream) {
+ var self = this;
+ this._stream = stream;
+ stream.pause();
+ stream
+ .on("data", function (chunk) {
+ self.push({
+ data: chunk,
+ meta : {
+ percent : 0
+ }
+ });
+ })
+ .on("error", function (e) {
+ if(self.isPaused) {
+ this.generatedError = e;
+ } else {
+ self.error(e);
+ }
+ })
+ .on("end", function () {
+ if(self.isPaused) {
+ self._upstreamEnded = true;
+ } else {
+ self.end();
+ }
+ });
+};
+NodejsStreamInputAdapter.prototype.pause = function () {
+ if(!GenericWorker.prototype.pause.call(this)) {
+ return false;
+ }
+ this._stream.pause();
+ return true;
+};
+NodejsStreamInputAdapter.prototype.resume = function () {
+ if(!GenericWorker.prototype.resume.call(this)) {
+ return false;
+ }
+
+ if(this._upstreamEnded) {
+ this.end();
+ } else {
+ this._stream.resume();
+ }
+
+ return true;
+};
+
+module.exports = NodejsStreamInputAdapter;
+
+
+/***/ }),
+/* 138 */
+/*!**********************************************************!*\
+ !*** ./node_modules/jszip/lib/generate/ZipFileWorker.js ***!
+ \**********************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+var utils = __webpack_require__(/*! ../utils */ 28);
+var GenericWorker = __webpack_require__(/*! ../stream/GenericWorker */ 36);
+var utf8 = __webpack_require__(/*! ../utf8 */ 52);
+var crc32 = __webpack_require__(/*! ../crc32 */ 72);
+var signature = __webpack_require__(/*! ../signature */ 90);
+
+/**
+ * Transform an integer into a string in hexadecimal.
+ * @private
+ * @param {number} dec the number to convert.
+ * @param {number} bytes the number of bytes to generate.
+ * @returns {string} the result.
+ */
+var decToHex = function(dec, bytes) {
+ var hex = "", i;
+ for (i = 0; i < bytes; i++) {
+ hex += String.fromCharCode(dec & 0xff);
+ dec = dec >>> 8;
+ }
+ return hex;
+};
+
+/**
+ * Generate the UNIX part of the external file attributes.
+ * @param {Object} unixPermissions the unix permissions or null.
+ * @param {Boolean} isDir true if the entry is a directory, false otherwise.
+ * @return {Number} a 32 bit integer.
+ *
+ * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
+ *
+ * TTTTsstrwxrwxrwx0000000000ADVSHR
+ * ^^^^____________________________ file type, see zipinfo.c (UNX_*)
+ * ^^^_________________________ setuid, setgid, sticky
+ * ^^^^^^^^^________________ permissions
+ * ^^^^^^^^^^______ not used ?
+ * ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
+ */
+var generateUnixExternalFileAttr = function (unixPermissions, isDir) {
+
+ var result = unixPermissions;
+ if (!unixPermissions) {
+ // I can't use octal values in strict mode, hence the hexa.
+ // 040775 => 0x41fd
+ // 0100664 => 0x81b4
+ result = isDir ? 0x41fd : 0x81b4;
+ }
+ return (result & 0xFFFF) << 16;
+};
+
+/**
+ * Generate the DOS part of the external file attributes.
+ * @param {Object} dosPermissions the dos permissions or null.
+ * @param {Boolean} isDir true if the entry is a directory, false otherwise.
+ * @return {Number} a 32 bit integer.
+ *
+ * Bit 0 Read-Only
+ * Bit 1 Hidden
+ * Bit 2 System
+ * Bit 3 Volume Label
+ * Bit 4 Directory
+ * Bit 5 Archive
+ */
+var generateDosExternalFileAttr = function (dosPermissions, isDir) {
+
+ // the dir flag is already set for compatibility
+ return (dosPermissions || 0) & 0x3F;
+};
+
+/**
+ * Generate the various parts used in the construction of the final zip file.
+ * @param {Object} streamInfo the hash with informations about the compressed file.
+ * @param {Boolean} streamedContent is the content streamed ?
+ * @param {Boolean} streamingEnded is the stream finished ?
+ * @param {number} offset the current offset from the start of the zip file.
+ * @param {String} platform let's pretend we are this platform (change platform dependents fields)
+ * @param {Function} encodeFileName the function to encode the file name / comment.
+ * @return {Object} the zip parts.
+ */
+var generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {
+ var file = streamInfo['file'],
+ compression = streamInfo['compression'],
+ useCustomEncoding = encodeFileName !== utf8.utf8encode,
+ encodedFileName = utils.transformTo("string", encodeFileName(file.name)),
+ utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
+ comment = file.comment,
+ encodedComment = utils.transformTo("string", encodeFileName(comment)),
+ utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
+ useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
+ useUTF8ForComment = utfEncodedComment.length !== comment.length,
+ dosTime,
+ dosDate,
+ extraFields = "",
+ unicodePathExtraField = "",
+ unicodeCommentExtraField = "",
+ dir = file.dir,
+ date = file.date;
+
+
+ var dataInfo = {
+ crc32 : 0,
+ compressedSize : 0,
+ uncompressedSize : 0
+ };
+
+ // if the content is streamed, the sizes/crc32 are only available AFTER
+ // the end of the stream.
+ if (!streamedContent || streamingEnded) {
+ dataInfo.crc32 = streamInfo['crc32'];
+ dataInfo.compressedSize = streamInfo['compressedSize'];
+ dataInfo.uncompressedSize = streamInfo['uncompressedSize'];
+ }
+
+ var bitflag = 0;
+ if (streamedContent) {
+ // Bit 3: the sizes/crc32 are set to zero in the local header.
+ // The correct values are put in the data descriptor immediately
+ // following the compressed data.
+ bitflag |= 0x0008;
+ }
+ if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {
+ // Bit 11: Language encoding flag (EFS).
+ bitflag |= 0x0800;
+ }
+
+
+ var extFileAttr = 0;
+ var versionMadeBy = 0;
+ if (dir) {
+ // dos or unix, we set the dos dir flag
+ extFileAttr |= 0x00010;
+ }
+ if(platform === "UNIX") {
+ versionMadeBy = 0x031E; // UNIX, version 3.0
+ extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
+ } else { // DOS or other, fallback to DOS
+ versionMadeBy = 0x0014; // DOS, version 2.0
+ extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
+ }
+
+ // date
+ // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
+ // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
+ // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
+
+ dosTime = date.getUTCHours();
+ dosTime = dosTime << 6;
+ dosTime = dosTime | date.getUTCMinutes();
+ dosTime = dosTime << 5;
+ dosTime = dosTime | date.getUTCSeconds() / 2;
+
+ dosDate = date.getUTCFullYear() - 1980;
+ dosDate = dosDate << 4;
+ dosDate = dosDate | (date.getUTCMonth() + 1);
+ dosDate = dosDate << 5;
+ dosDate = dosDate | date.getUTCDate();
+
+ if (useUTF8ForFileName) {
+ // set the unicode path extra field. unzip needs at least one extra
+ // field to correctly handle unicode path, so using the path is as good
+ // as any other information. This could improve the situation with
+ // other archive managers too.
+ // This field is usually used without the utf8 flag, with a non
+ // unicode path in the header (winrar, winzip). This helps (a bit)
+ // with the messy Windows' default compressed folders feature but
+ // breaks on p7zip which doesn't seek the unicode path extra field.
+ // So for now, UTF-8 everywhere !
+ unicodePathExtraField =
+ // Version
+ decToHex(1, 1) +
+ // NameCRC32
+ decToHex(crc32(encodedFileName), 4) +
+ // UnicodeName
+ utfEncodedFileName;
+
+ extraFields +=
+ // Info-ZIP Unicode Path Extra Field
+ "\x75\x70" +
+ // size
+ decToHex(unicodePathExtraField.length, 2) +
+ // content
+ unicodePathExtraField;
+ }
+
+ if(useUTF8ForComment) {
+
+ unicodeCommentExtraField =
+ // Version
+ decToHex(1, 1) +
+ // CommentCRC32
+ decToHex(crc32(encodedComment), 4) +
+ // UnicodeName
+ utfEncodedComment;
+
+ extraFields +=
+ // Info-ZIP Unicode Path Extra Field
+ "\x75\x63" +
+ // size
+ decToHex(unicodeCommentExtraField.length, 2) +
+ // content
+ unicodeCommentExtraField;
+ }
+
+ var header = "";
+
+ // version needed to extract
+ header += "\x0A\x00";
+ // general purpose bit flag
+ header += decToHex(bitflag, 2);
+ // compression method
+ header += compression.magic;
+ // last mod file time
+ header += decToHex(dosTime, 2);
+ // last mod file date
+ header += decToHex(dosDate, 2);
+ // crc-32
+ header += decToHex(dataInfo.crc32, 4);
+ // compressed size
+ header += decToHex(dataInfo.compressedSize, 4);
+ // uncompressed size
+ header += decToHex(dataInfo.uncompressedSize, 4);
+ // file name length
+ header += decToHex(encodedFileName.length, 2);
+ // extra field length
+ header += decToHex(extraFields.length, 2);
+
+
+ var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;
+
+ var dirRecord = signature.CENTRAL_FILE_HEADER +
+ // version made by (00: DOS)
+ decToHex(versionMadeBy, 2) +
+ // file header (common to file and central directory)
+ header +
+ // file comment length
+ decToHex(encodedComment.length, 2) +
+ // disk number start
+ "\x00\x00" +
+ // internal file attributes TODO
+ "\x00\x00" +
+ // external file attributes
+ decToHex(extFileAttr, 4) +
+ // relative offset of local header
+ decToHex(offset, 4) +
+ // file name
+ encodedFileName +
+ // extra field
+ extraFields +
+ // file comment
+ encodedComment;
+
+ return {
+ fileRecord: fileRecord,
+ dirRecord: dirRecord
+ };
+};
+
+/**
+ * Generate the EOCD record.
+ * @param {Number} entriesCount the number of entries in the zip file.
+ * @param {Number} centralDirLength the length (in bytes) of the central dir.
+ * @param {Number} localDirLength the length (in bytes) of the local dir.
+ * @param {String} comment the zip file comment as a binary string.
+ * @param {Function} encodeFileName the function to encode the comment.
+ * @return {String} the EOCD record.
+ */
+var generateCentralDirectoryEnd = function (entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {
+ var dirEnd = "";
+ var encodedComment = utils.transformTo("string", encodeFileName(comment));
+
+ // end of central dir signature
+ dirEnd = signature.CENTRAL_DIRECTORY_END +
+ // number of this disk
+ "\x00\x00" +
+ // number of the disk with the start of the central directory
+ "\x00\x00" +
+ // total number of entries in the central directory on this disk
+ decToHex(entriesCount, 2) +
+ // total number of entries in the central directory
+ decToHex(entriesCount, 2) +
+ // size of the central directory 4 bytes
+ decToHex(centralDirLength, 4) +
+ // offset of start of central directory with respect to the starting disk number
+ decToHex(localDirLength, 4) +
+ // .ZIP file comment length
+ decToHex(encodedComment.length, 2) +
+ // .ZIP file comment
+ encodedComment;
+
+ return dirEnd;
+};
+
+/**
+ * Generate data descriptors for a file entry.
+ * @param {Object} streamInfo the hash generated by a worker, containing informations
+ * on the file entry.
+ * @return {String} the data descriptors.
+ */
+var generateDataDescriptors = function (streamInfo) {
+ var descriptor = "";
+ descriptor = signature.DATA_DESCRIPTOR +
+ // crc-32 4 bytes
+ decToHex(streamInfo['crc32'], 4) +
+ // compressed size 4 bytes
+ decToHex(streamInfo['compressedSize'], 4) +
+ // uncompressed size 4 bytes
+ decToHex(streamInfo['uncompressedSize'], 4);
+
+ return descriptor;
+};
+
+
+/**
+ * A worker to concatenate other workers to create a zip file.
+ * @param {Boolean} streamFiles `true` to stream the content of the files,
+ * `false` to accumulate it.
+ * @param {String} comment the comment to use.
+ * @param {String} platform the platform to use, "UNIX" or "DOS".
+ * @param {Function} encodeFileName the function to encode file names and comments.
+ */
+function ZipFileWorker(streamFiles, comment, platform, encodeFileName) {
+ GenericWorker.call(this, "ZipFileWorker");
+ // The number of bytes written so far. This doesn't count accumulated chunks.
+ this.bytesWritten = 0;
+ // The comment of the zip file
+ this.zipComment = comment;
+ // The platform "generating" the zip file.
+ this.zipPlatform = platform;
+ // the function to encode file names and comments.
+ this.encodeFileName = encodeFileName;
+ // Should we stream the content of the files ?
+ this.streamFiles = streamFiles;
+ // If `streamFiles` is false, we will need to accumulate the content of the
+ // files to calculate sizes / crc32 (and write them *before* the content).
+ // This boolean indicates if we are accumulating chunks (it will change a lot
+ // during the lifetime of this worker).
+ this.accumulate = false;
+ // The buffer receiving chunks when accumulating content.
+ this.contentBuffer = [];
+ // The list of generated directory records.
+ this.dirRecords = [];
+ // The offset (in bytes) from the beginning of the zip file for the current source.
+ this.currentSourceOffset = 0;
+ // The total number of entries in this zip file.
+ this.entriesCount = 0;
+ // the name of the file currently being added, null when handling the end of the zip file.
+ // Used for the emited metadata.
+ this.currentFile = null;
+
+
+
+ this._sources = [];
+}
+utils.inherits(ZipFileWorker, GenericWorker);
+
+/**
+ * @see GenericWorker.push
+ */
+ZipFileWorker.prototype.push = function (chunk) {
+
+ var currentFilePercent = chunk.meta.percent || 0;
+ var entriesCount = this.entriesCount;
+ var remainingFiles = this._sources.length;
+
+ if(this.accumulate) {
+ this.contentBuffer.push(chunk);
+ } else {
+ this.bytesWritten += chunk.data.length;
+
+ GenericWorker.prototype.push.call(this, {
+ data : chunk.data,
+ meta : {
+ currentFile : this.currentFile,
+ percent : entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100
+ }
+ });
+ }
+};
+
+/**
+ * The worker started a new source (an other worker).
+ * @param {Object} streamInfo the streamInfo object from the new source.
+ */
+ZipFileWorker.prototype.openedSource = function (streamInfo) {
+ this.currentSourceOffset = this.bytesWritten;
+ this.currentFile = streamInfo['file'].name;
+
+ var streamedContent = this.streamFiles && !streamInfo['file'].dir;
+
+ // don't stream folders (because they don't have any content)
+ if(streamedContent) {
+ var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
+ this.push({
+ data : record.fileRecord,
+ meta : {percent:0}
+ });
+ } else {
+ // we need to wait for the whole file before pushing anything
+ this.accumulate = true;
+ }
+};
+
+/**
+ * The worker finished a source (an other worker).
+ * @param {Object} streamInfo the streamInfo object from the finished source.
+ */
+ZipFileWorker.prototype.closedSource = function (streamInfo) {
+ this.accumulate = false;
+ var streamedContent = this.streamFiles && !streamInfo['file'].dir;
+ var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);
+
+ this.dirRecords.push(record.dirRecord);
+ if(streamedContent) {
+ // after the streamed file, we put data descriptors
+ this.push({
+ data : generateDataDescriptors(streamInfo),
+ meta : {percent:100}
+ });
+ } else {
+ // the content wasn't streamed, we need to push everything now
+ // first the file record, then the content
+ this.push({
+ data : record.fileRecord,
+ meta : {percent:0}
+ });
+ while(this.contentBuffer.length) {
+ this.push(this.contentBuffer.shift());
+ }
+ }
+ this.currentFile = null;
+};
+
+/**
+ * @see GenericWorker.flush
+ */
+ZipFileWorker.prototype.flush = function () {
+
+ var localDirLength = this.bytesWritten;
+ for(var i = 0; i < this.dirRecords.length; i++) {
+ this.push({
+ data : this.dirRecords[i],
+ meta : {percent:100}
+ });
+ }
+ var centralDirLength = this.bytesWritten - localDirLength;
+
+ var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);
+
+ this.push({
+ data : dirEnd,
+ meta : {percent:100}
+ });
+};
+
+/**
+ * Prepare the next source to be read.
+ */
+ZipFileWorker.prototype.prepareNextSource = function () {
+ this.previous = this._sources.shift();
+ this.openedSource(this.previous.streamInfo);
+ if (this.isPaused) {
+ this.previous.pause();
+ } else {
+ this.previous.resume();
+ }
+};
+
+/**
+ * @see GenericWorker.registerPrevious
+ */
+ZipFileWorker.prototype.registerPrevious = function (previous) {
+ this._sources.push(previous);
+ var self = this;
+
+ previous.on('data', function (chunk) {
+ self.processChunk(chunk);
+ });
+ previous.on('end', function () {
+ self.closedSource(self.previous.streamInfo);
+ if(self._sources.length) {
+ self.prepareNextSource();
+ } else {
+ self.end();
+ }
+ });
+ previous.on('error', function (e) {
+ self.error(e);
+ });
+ return this;
+};
+
+/**
+ * @see GenericWorker.resume
+ */
+ZipFileWorker.prototype.resume = function () {
+ if(!GenericWorker.prototype.resume.call(this)) {
+ return false;
+ }
+
+ if (!this.previous && this._sources.length) {
+ this.prepareNextSource();
+ return true;
+ }
+ if (!this.previous && !this._sources.length && !this.generatedError) {
+ this.end();
+ return true;
+ }
+};
+
+/**
+ * @see GenericWorker.error
+ */
+ZipFileWorker.prototype.error = function (e) {
+ var sources = this._sources;
+ if(!GenericWorker.prototype.error.call(this, e)) {
+ return false;
+ }
+ for(var i = 0; i < sources.length; i++) {
+ try {
+ sources[i].error(e);
+ } catch(e) {
+ // the `error` exploded, nothing to do
+ }
+ }
+ return true;
+};
+
+/**
+ * @see GenericWorker.lock
+ */
+ZipFileWorker.prototype.lock = function () {
+ GenericWorker.prototype.lock.call(this);
+ var sources = this._sources;
+ for(var i = 0; i < sources.length; i++) {
+ sources[i].lock();
+ }
+};
+
+module.exports = ZipFileWorker;
+
+
+/***/ }),
+/* 139 */
+/*!************************************************!*\
+ !*** ./node_modules/pako/lib/zlib/gzheader.js ***!
+ \************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+// (C) 1995-2013 Jean-loup Gailly and Mark Adler
+// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+function GZheader() {
+ /* true if compressed data believed to be text */
+ this.text = 0;
+ /* modification time */
+ this.time = 0;
+ /* extra flags (not used when writing a gzip file) */
+ this.xflags = 0;
+ /* operating system */
+ this.os = 0;
+ /* pointer to extra field or Z_NULL if none */
+ this.extra = null;
+ /* extra field length (valid if extra != Z_NULL) */
+ this.extra_len = 0; // Actually, we don't need it in JS,
+ // but leave for few code modifications
+
+ //
+ // Setup limits is not necessary because in js we should not preallocate memory
+ // for inflate use constant limit in 65536 bytes
+ //
+
+ /* space at extra (only when reading header) */
+ // this.extra_max = 0;
+ /* pointer to zero-terminated file name or Z_NULL */
+ this.name = '';
+ /* space at name (only when reading header) */
+ // this.name_max = 0;
+ /* pointer to zero-terminated comment or Z_NULL */
+ this.comment = '';
+ /* space at comment (only when reading header) */
+ // this.comm_max = 0;
+ /* true if there was or will be a header crc */
+ this.hcrc = 0;
+ /* true when done reading gzip header (not used when writing a gzip file) */
+ this.done = false;
+}
+
+module.exports = GZheader;
+
+
+/***/ }),
+/* 140 */
+/*!************************************************!*\
+ !*** ./node_modules/pako/lib/zlib/inftrees.js ***!
+ \************************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+// (C) 1995-2013 Jean-loup Gailly and Mark Adler
+// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+var utils = __webpack_require__(/*! ../utils/common */ 45);
+
+var MAXBITS = 15;
+var ENOUGH_LENS = 852;
+var ENOUGH_DISTS = 592;
+//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
+
+var CODES = 0;
+var LENS = 1;
+var DISTS = 2;
+
+var lbase = [ /* Length codes 257..285 base */
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
+];
+
+var lext = [ /* Length codes 257..285 extra */
+ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
+];
+
+var dbase = [ /* Distance codes 0..29 base */
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+ 8193, 12289, 16385, 24577, 0, 0
+];
+
+var dext = [ /* Distance codes 0..29 extra */
+ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
+ 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
+ 28, 28, 29, 29, 64, 64
+];
+
+module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)
+{
+ var bits = opts.bits;
+ //here = opts.here; /* table entry for duplication */
+
+ var len = 0; /* a code's length in bits */
+ var sym = 0; /* index of code symbols */
+ var min = 0, max = 0; /* minimum and maximum code lengths */
+ var root = 0; /* number of index bits for root table */
+ var curr = 0; /* number of index bits for current table */
+ var drop = 0; /* code bits to drop for sub-table */
+ var left = 0; /* number of prefix codes available */
+ var used = 0; /* code entries in table used */
+ var huff = 0; /* Huffman code */
+ var incr; /* for incrementing code, index */
+ var fill; /* index for replicating entries */
+ var low; /* low bits for current root entry */
+ var mask; /* mask for low root bits */
+ var next; /* next available space in table */
+ var base = null; /* base value table to use */
+ var base_index = 0;
+// var shoextra; /* extra bits table to use */
+ var end; /* use base and extra for symbol > end */
+ var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
+ var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
+ var extra = null;
+ var extra_index = 0;
+
+ var here_bits, here_op, here_val;
+
+ /*
+ Process a set of code lengths to create a canonical Huffman code. The
+ code lengths are lens[0..codes-1]. Each length corresponds to the
+ symbols 0..codes-1. The Huffman code is generated by first sorting the
+ symbols by length from short to long, and retaining the symbol order
+ for codes with equal lengths. Then the code starts with all zero bits
+ for the first code of the shortest length, and the codes are integer
+ increments for the same length, and zeros are appended as the length
+ increases. For the deflate format, these bits are stored backwards
+ from their more natural integer increment ordering, and so when the
+ decoding tables are built in the large loop below, the integer codes
+ are incremented backwards.
+
+ This routine assumes, but does not check, that all of the entries in
+ lens[] are in the range 0..MAXBITS. The caller must assure this.
+ 1..MAXBITS is interpreted as that code length. zero means that that
+ symbol does not occur in this code.
+
+ The codes are sorted by computing a count of codes for each length,
+ creating from that a table of starting indices for each length in the
+ sorted table, and then entering the symbols in order in the sorted
+ table. The sorted table is work[], with that space being provided by
+ the caller.
+
+ The length counts are used for other purposes as well, i.e. finding
+ the minimum and maximum length codes, determining if there are any
+ codes at all, checking for a valid set of lengths, and looking ahead
+ at length counts to determine sub-table sizes when building the
+ decoding tables.
+ */
+
+ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
+ for (len = 0; len <= MAXBITS; len++) {
+ count[len] = 0;
+ }
+ for (sym = 0; sym < codes; sym++) {
+ count[lens[lens_index + sym]]++;
+ }
+
+ /* bound code lengths, force root to be within code lengths */
+ root = bits;
+ for (max = MAXBITS; max >= 1; max--) {
+ if (count[max] !== 0) { break; }
+ }
+ if (root > max) {
+ root = max;
+ }
+ if (max === 0) { /* no symbols to code at all */
+ //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
+ //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
+ //table.val[opts.table_index++] = 0; //here.val = (var short)0;
+ table[table_index++] = (1 << 24) | (64 << 16) | 0;
+
+
+ //table.op[opts.table_index] = 64;
+ //table.bits[opts.table_index] = 1;
+ //table.val[opts.table_index++] = 0;
+ table[table_index++] = (1 << 24) | (64 << 16) | 0;
+
+ opts.bits = 1;
+ return 0; /* no symbols, but wait for decoding to report error */
+ }
+ for (min = 1; min < max; min++) {
+ if (count[min] !== 0) { break; }
+ }
+ if (root < min) {
+ root = min;
+ }
+
+ /* check for an over-subscribed or incomplete set of lengths */
+ left = 1;
+ for (len = 1; len <= MAXBITS; len++) {
+ left <<= 1;
+ left -= count[len];
+ if (left < 0) {
+ return -1;
+ } /* over-subscribed */
+ }
+ if (left > 0 && (type === CODES || max !== 1)) {
+ return -1; /* incomplete set */
+ }
+
+ /* generate offsets into symbol table for each length for sorting */
+ offs[1] = 0;
+ for (len = 1; len < MAXBITS; len++) {
+ offs[len + 1] = offs[len] + count[len];
+ }
+
+ /* sort symbols by length, by symbol order within each length */
+ for (sym = 0; sym < codes; sym++) {
+ if (lens[lens_index + sym] !== 0) {
+ work[offs[lens[lens_index + sym]]++] = sym;
+ }
+ }
+
+ /*
+ Create and fill in decoding tables. In this loop, the table being
+ filled is at next and has curr index bits. The code being used is huff
+ with length len. That code is converted to an index by dropping drop
+ bits off of the bottom. For codes where len is less than drop + curr,
+ those top drop + curr - len bits are incremented through all values to
+ fill the table with replicated entries.
+
+ root is the number of index bits for the root table. When len exceeds
+ root, sub-tables are created pointed to by the root entry with an index
+ of the low root bits of huff. This is saved in low to check for when a
+ new sub-table should be started. drop is zero when the root table is
+ being filled, and drop is root when sub-tables are being filled.
+
+ When a new sub-table is needed, it is necessary to look ahead in the
+ code lengths to determine what size sub-table is needed. The length
+ counts are used for this, and so count[] is decremented as codes are
+ entered in the tables.
+
+ used keeps track of how many table entries have been allocated from the
+ provided *table space. It is checked for LENS and DIST tables against
+ the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
+ the initial root table size constants. See the comments in inftrees.h
+ for more information.
+
+ sym increments through all symbols, and the loop terminates when
+ all codes of length max, i.e. all codes, have been processed. This
+ routine permits incomplete codes, so another loop after this one fills
+ in the rest of the decoding tables with invalid code markers.
+ */
+
+ /* set up for code type */
+ // poor man optimization - use if-else instead of switch,
+ // to avoid deopts in old v8
+ if (type === CODES) {
+ base = extra = work; /* dummy value--not used */
+ end = 19;
+
+ } else if (type === LENS) {
+ base = lbase;
+ base_index -= 257;
+ extra = lext;
+ extra_index -= 257;
+ end = 256;
+
+ } else { /* DISTS */
+ base = dbase;
+ extra = dext;
+ end = -1;
+ }
+
+ /* initialize opts for loop */
+ huff = 0; /* starting code */
+ sym = 0; /* starting code symbol */
+ len = min; /* starting code length */
+ next = table_index; /* current table to fill in */
+ curr = root; /* current table index bits */
+ drop = 0; /* current bits to drop from code for index */
+ low = -1; /* trigger new sub-table when len > root */
+ used = 1 << root; /* use root table entries */
+ mask = used - 1; /* mask for comparing low */
+
+ /* check available table space */
+ if ((type === LENS && used > ENOUGH_LENS) ||
+ (type === DISTS && used > ENOUGH_DISTS)) {
+ return 1;
+ }
+
+ /* process all codes and make table entries */
+ for (;;) {
+ /* create table entry */
+ here_bits = len - drop;
+ if (work[sym] < end) {
+ here_op = 0;
+ here_val = work[sym];
+ }
+ else if (work[sym] > end) {
+ here_op = extra[extra_index + work[sym]];
+ here_val = base[base_index + work[sym]];
+ }
+ else {
+ here_op = 32 + 64; /* end of block */
+ here_val = 0;
+ }
+
+ /* replicate for those indices with low len bits equal to huff */
+ incr = 1 << (len - drop);
+ fill = 1 << curr;
+ min = fill; /* save offset to next table */
+ do {
+ fill -= incr;
+ table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;
+ } while (fill !== 0);
+
+ /* backwards increment the len-bit code huff */
+ incr = 1 << (len - 1);
+ while (huff & incr) {
+ incr >>= 1;
+ }
+ if (incr !== 0) {
+ huff &= incr - 1;
+ huff += incr;
+ } else {
+ huff = 0;
+ }
+
+ /* go to next symbol, update count, len */
+ sym++;
+ if (--count[len] === 0) {
+ if (len === max) { break; }
+ len = lens[lens_index + work[sym]];
+ }
+
+ /* create new sub-table if needed */
+ if (len > root && (huff & mask) !== low) {
+ /* if first time, transition to sub-tables */
+ if (drop === 0) {
+ drop = root;
+ }
+
+ /* increment past last table */
+ next += min; /* here min is 1 << curr */
+
+ /* determine length of next table */
+ curr = len - drop;
+ left = 1 << curr;
+ while (curr + drop < max) {
+ left -= count[curr + drop];
+ if (left <= 0) { break; }
+ curr++;
+ left <<= 1;
+ }
+
+ /* check for enough space */
+ used += 1 << curr;
+ if ((type === LENS && used > ENOUGH_LENS) ||
+ (type === DISTS && used > ENOUGH_DISTS)) {
+ return 1;
+ }
+
+ /* point entry in root table to sub-table */
+ low = huff & mask;
+ /*table.op[low] = curr;
+ table.bits[low] = root;
+ table.val[low] = next - opts.table_index;*/
+ table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;
+ }
+ }
+
+ /* fill in remaining table entry if code is incomplete (guaranteed to have
+ at most one remaining entry, since if the code is incomplete, the
+ maximum code length that was allowed to get this far is one bit) */
+ if (huff !== 0) {
+ //table.op[next + huff] = 64; /* invalid code marker */
+ //table.bits[next + huff] = len - drop;
+ //table.val[next + huff] = 0;
+ table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;
+ }
+
+ /* set return parameters */
+ //opts.table_index += used;
+ opts.bits = root;
+ return 0;
+};
+
+
+/***/ }),
+/* 141 */
+/*!***********************************************!*\
+ !*** ./node_modules/pako/lib/zlib/inffast.js ***!
+ \***********************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+// (C) 1995-2013 Jean-loup Gailly and Mark Adler
+// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+// See state defs from inflate.js
+var BAD = 30; /* got a data error -- remain here until reset */
+var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
+
+/*
+ Decode literal, length, and distance codes and write out the resulting
+ literal and match bytes until either not enough input or output is
+ available, an end-of-block is encountered, or a data error is encountered.
+ When large enough input and output buffers are supplied to inflate(), for
+ example, a 16K input buffer and a 64K output buffer, more than 95% of the
+ inflate execution time is spent in this routine.
+
+ Entry assumptions:
+
+ state.mode === LEN
+ strm.avail_in >= 6
+ strm.avail_out >= 258
+ start >= strm.avail_out
+ state.bits < 8
+
+ On return, state.mode is one of:
+
+ LEN -- ran out of enough output space or enough available input
+ TYPE -- reached end of block code, inflate() to interpret next block
+ BAD -- error in block data
+
+ Notes:
+
+ - The maximum input bits used by a length/distance pair is 15 bits for the
+ length code, 5 bits for the length extra, 15 bits for the distance code,
+ and 13 bits for the distance extra. This totals 48 bits, or six bytes.
+ Therefore if strm.avail_in >= 6, then there is enough input to avoid
+ checking for available input while decoding.
+
+ - The maximum bytes that a single length/distance pair can output is 258
+ bytes, which is the maximum length that can be coded. inflate_fast()
+ requires strm.avail_out >= 258 for each loop to avoid checking for
+ output space.
+ */
+module.exports = function inflate_fast(strm, start) {
+ var state;
+ var _in; /* local strm.input */
+ var last; /* have enough input while in < last */
+ var _out; /* local strm.output */
+ var beg; /* inflate()'s initial strm.output */
+ var end; /* while out < end, enough space available */
+//#ifdef INFLATE_STRICT
+ var dmax; /* maximum distance from zlib header */
+//#endif
+ var wsize; /* window size or zero if not using window */
+ var whave; /* valid bytes in the window */
+ var wnext; /* window write index */
+ // Use `s_window` instead `window`, avoid conflict with instrumentation tools
+ var s_window; /* allocated sliding window, if wsize != 0 */
+ var hold; /* local strm.hold */
+ var bits; /* local strm.bits */
+ var lcode; /* local strm.lencode */
+ var dcode; /* local strm.distcode */
+ var lmask; /* mask for first level of length codes */
+ var dmask; /* mask for first level of distance codes */
+ var here; /* retrieved table entry */
+ var op; /* code bits, operation, extra bits, or */
+ /* window position, window bytes to copy */
+ var len; /* match length, unused bytes */
+ var dist; /* match distance */
+ var from; /* where to copy match from */
+ var from_source;
+
+
+ var input, output; // JS specific, because we have no pointers
+
+ /* copy state to local variables */
+ state = strm.state;
+ //here = state.here;
+ _in = strm.next_in;
+ input = strm.input;
+ last = _in + (strm.avail_in - 5);
+ _out = strm.next_out;
+ output = strm.output;
+ beg = _out - (start - strm.avail_out);
+ end = _out + (strm.avail_out - 257);
+//#ifdef INFLATE_STRICT
+ dmax = state.dmax;
+//#endif
+ wsize = state.wsize;
+ whave = state.whave;
+ wnext = state.wnext;
+ s_window = state.window;
+ hold = state.hold;
+ bits = state.bits;
+ lcode = state.lencode;
+ dcode = state.distcode;
+ lmask = (1 << state.lenbits) - 1;
+ dmask = (1 << state.distbits) - 1;
+
+
+ /* decode literals and length/distances until end-of-block or not enough
+ input data or output space */
+
+ top:
+ do {
+ if (bits < 15) {
+ hold += input[_in++] << bits;
+ bits += 8;
+ hold += input[_in++] << bits;
+ bits += 8;
+ }
+
+ here = lcode[hold & lmask];
+
+ dolen:
+ for (;;) { // Goto emulation
+ op = here >>> 24/*here.bits*/;
+ hold >>>= op;
+ bits -= op;
+ op = (here >>> 16) & 0xff/*here.op*/;
+ if (op === 0) { /* literal */
+ //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
+ // "inflate: literal '%c'\n" :
+ // "inflate: literal 0x%02x\n", here.val));
+ output[_out++] = here & 0xffff/*here.val*/;
+ }
+ else if (op & 16) { /* length base */
+ len = here & 0xffff/*here.val*/;
+ op &= 15; /* number of extra bits */
+ if (op) {
+ if (bits < op) {
+ hold += input[_in++] << bits;
+ bits += 8;
+ }
+ len += hold & ((1 << op) - 1);
+ hold >>>= op;
+ bits -= op;
+ }
+ //Tracevv((stderr, "inflate: length %u\n", len));
+ if (bits < 15) {
+ hold += input[_in++] << bits;
+ bits += 8;
+ hold += input[_in++] << bits;
+ bits += 8;
+ }
+ here = dcode[hold & dmask];
+
+ dodist:
+ for (;;) { // goto emulation
+ op = here >>> 24/*here.bits*/;
+ hold >>>= op;
+ bits -= op;
+ op = (here >>> 16) & 0xff/*here.op*/;
+
+ if (op & 16) { /* distance base */
+ dist = here & 0xffff/*here.val*/;
+ op &= 15; /* number of extra bits */
+ if (bits < op) {
+ hold += input[_in++] << bits;
+ bits += 8;
+ if (bits < op) {
+ hold += input[_in++] << bits;
+ bits += 8;
+ }
+ }
+ dist += hold & ((1 << op) - 1);
+//#ifdef INFLATE_STRICT
+ if (dist > dmax) {
+ strm.msg = 'invalid distance too far back';
+ state.mode = BAD;
+ break top;
+ }
+//#endif
+ hold >>>= op;
+ bits -= op;
+ //Tracevv((stderr, "inflate: distance %u\n", dist));
+ op = _out - beg; /* max distance in output */
+ if (dist > op) { /* see if copy from window */
+ op = dist - op; /* distance back in window */
+ if (op > whave) {
+ if (state.sane) {
+ strm.msg = 'invalid distance too far back';
+ state.mode = BAD;
+ break top;
+ }
+
+// (!) This block is disabled in zlib defaults,
+// don't enable it for binary compatibility
+//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+// if (len <= op - whave) {
+// do {
+// output[_out++] = 0;
+// } while (--len);
+// continue top;
+// }
+// len -= op - whave;
+// do {
+// output[_out++] = 0;
+// } while (--op > whave);
+// if (op === 0) {
+// from = _out - dist;
+// do {
+// output[_out++] = output[from++];
+// } while (--len);
+// continue top;
+// }
+//#endif
+ }
+ from = 0; // window index
+ from_source = s_window;
+ if (wnext === 0) { /* very common case */
+ from += wsize - op;
+ if (op < len) { /* some from window */
+ len -= op;
+ do {
+ output[_out++] = s_window[from++];
+ } while (--op);
+ from = _out - dist; /* rest from output */
+ from_source = output;
+ }
+ }
+ else if (wnext < op) { /* wrap around window */
+ from += wsize + wnext - op;
+ op -= wnext;
+ if (op < len) { /* some from end of window */
+ len -= op;
+ do {
+ output[_out++] = s_window[from++];
+ } while (--op);
+ from = 0;
+ if (wnext < len) { /* some from start of window */
+ op = wnext;
+ len -= op;
+ do {
+ output[_out++] = s_window[from++];
+ } while (--op);
+ from = _out - dist; /* rest from output */
+ from_source = output;
+ }
+ }
+ }
+ else { /* contiguous in window */
+ from += wnext - op;
+ if (op < len) { /* some from window */
+ len -= op;
+ do {
+ output[_out++] = s_window[from++];
+ } while (--op);
+ from = _out - dist; /* rest from output */
+ from_source = output;
+ }
+ }
+ while (len > 2) {
+ output[_out++] = from_source[from++];
+ output[_out++] = from_source[from++];
+ output[_out++] = from_source[from++];
+ len -= 3;
+ }
+ if (len) {
+ output[_out++] = from_source[from++];
+ if (len > 1) {
+ output[_out++] = from_source[from++];
+ }
+ }
+ }
+ else {
+ from = _out - dist; /* copy direct from output */
+ do { /* minimum length is three */
+ output[_out++] = output[from++];
+ output[_out++] = output[from++];
+ output[_out++] = output[from++];
+ len -= 3;
+ } while (len > 2);
+ if (len) {
+ output[_out++] = output[from++];
+ if (len > 1) {
+ output[_out++] = output[from++];
+ }
+ }
+ }
+ }
+ else if ((op & 64) === 0) { /* 2nd level distance code */
+ here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
+ continue dodist;
+ }
+ else {
+ strm.msg = 'invalid distance code';
+ state.mode = BAD;
+ break top;
+ }
+
+ break; // need to emulate goto via "continue"
+ }
+ }
+ else if ((op & 64) === 0) { /* 2nd level length code */
+ here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
+ continue dolen;
+ }
+ else if (op & 32) { /* end-of-block */
+ //Tracevv((stderr, "inflate: end of block\n"));
+ state.mode = TYPE;
+ break top;
+ }
+ else {
+ strm.msg = 'invalid literal/length code';
+ state.mode = BAD;
+ break top;
+ }
+
+ break; // need to emulate goto via "continue"
+ }
+ } while (_in < last && _out < end);
+
+ /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
+ len = bits >> 3;
+ _in -= len;
+ bits -= len << 3;
+ hold &= (1 << bits) - 1;
+
+ /* update state and return */
+ strm.next_in = _in;
+ strm.next_out = _out;
+ strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
+ strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
+ state.hold = hold;
+ state.bits = bits;
+ return;
+};
+
+
+/***/ }),
+/* 142 */
+/*!***********************************************!*\
+ !*** ./node_modules/pako/lib/zlib/inflate.js ***!
+ \***********************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+// (C) 1995-2013 Jean-loup Gailly and Mark Adler
+// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+var utils = __webpack_require__(/*! ../utils/common */ 45);
+var adler32 = __webpack_require__(/*! ./adler32 */ 95);
+var crc32 = __webpack_require__(/*! ./crc32 */ 94);
+var inflate_fast = __webpack_require__(/*! ./inffast */ 141);
+var inflate_table = __webpack_require__(/*! ./inftrees */ 140);
+
+var CODES = 0;
+var LENS = 1;
+var DISTS = 2;
+
+/* Public constants ==========================================================*/
+/* ===========================================================================*/
+
+
+/* Allowed flush values; see deflate() and inflate() below for details */
+//var Z_NO_FLUSH = 0;
+//var Z_PARTIAL_FLUSH = 1;
+//var Z_SYNC_FLUSH = 2;
+//var Z_FULL_FLUSH = 3;
+var Z_FINISH = 4;
+var Z_BLOCK = 5;
+var Z_TREES = 6;
+
+
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+var Z_OK = 0;
+var Z_STREAM_END = 1;
+var Z_NEED_DICT = 2;
+//var Z_ERRNO = -1;
+var Z_STREAM_ERROR = -2;
+var Z_DATA_ERROR = -3;
+var Z_MEM_ERROR = -4;
+var Z_BUF_ERROR = -5;
+//var Z_VERSION_ERROR = -6;
+
+/* The deflate compression method */
+var Z_DEFLATED = 8;
+
+
+/* STATES ====================================================================*/
+/* ===========================================================================*/
+
+
+var HEAD = 1; /* i: waiting for magic header */
+var FLAGS = 2; /* i: waiting for method and flags (gzip) */
+var TIME = 3; /* i: waiting for modification time (gzip) */
+var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
+var EXLEN = 5; /* i: waiting for extra length (gzip) */
+var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
+var NAME = 7; /* i: waiting for end of file name (gzip) */
+var COMMENT = 8; /* i: waiting for end of comment (gzip) */
+var HCRC = 9; /* i: waiting for header crc (gzip) */
+var DICTID = 10; /* i: waiting for dictionary check value */
+var DICT = 11; /* waiting for inflateSetDictionary() call */
+var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
+var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
+var STORED = 14; /* i: waiting for stored size (length and complement) */
+var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
+var COPY = 16; /* i/o: waiting for input or output to copy stored block */
+var TABLE = 17; /* i: waiting for dynamic block table lengths */
+var LENLENS = 18; /* i: waiting for code length code lengths */
+var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
+var LEN_ = 20; /* i: same as LEN below, but only first time in */
+var LEN = 21; /* i: waiting for length/lit/eob code */
+var LENEXT = 22; /* i: waiting for length extra bits */
+var DIST = 23; /* i: waiting for distance code */
+var DISTEXT = 24; /* i: waiting for distance extra bits */
+var MATCH = 25; /* o: waiting for output space to copy string */
+var LIT = 26; /* o: waiting for output space to write literal */
+var CHECK = 27; /* i: waiting for 32-bit check value */
+var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
+var DONE = 29; /* finished check, done -- remain here until reset */
+var BAD = 30; /* got a data error -- remain here until reset */
+var MEM = 31; /* got an inflate() memory error -- remain here until reset */
+var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
+
+/* ===========================================================================*/
+
+
+
+var ENOUGH_LENS = 852;
+var ENOUGH_DISTS = 592;
+//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
+
+var MAX_WBITS = 15;
+/* 32K LZ77 window */
+var DEF_WBITS = MAX_WBITS;
+
+
+function zswap32(q) {
+ return (((q >>> 24) & 0xff) +
+ ((q >>> 8) & 0xff00) +
+ ((q & 0xff00) << 8) +
+ ((q & 0xff) << 24));
+}
+
+
+function InflateState() {
+ this.mode = 0; /* current inflate mode */
+ this.last = false; /* true if processing last block */
+ this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
+ this.havedict = false; /* true if dictionary provided */
+ this.flags = 0; /* gzip header method and flags (0 if zlib) */
+ this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
+ this.check = 0; /* protected copy of check value */
+ this.total = 0; /* protected copy of output count */
+ // TODO: may be {}
+ this.head = null; /* where to save gzip header information */
+
+ /* sliding window */
+ this.wbits = 0; /* log base 2 of requested window size */
+ this.wsize = 0; /* window size or zero if not using window */
+ this.whave = 0; /* valid bytes in the window */
+ this.wnext = 0; /* window write index */
+ this.window = null; /* allocated sliding window, if needed */
+
+ /* bit accumulator */
+ this.hold = 0; /* input bit accumulator */
+ this.bits = 0; /* number of bits in "in" */
+
+ /* for string and stored block copying */
+ this.length = 0; /* literal or length of data to copy */
+ this.offset = 0; /* distance back to copy string from */
+
+ /* for table and code decoding */
+ this.extra = 0; /* extra bits needed */
+
+ /* fixed and dynamic code tables */
+ this.lencode = null; /* starting table for length/literal codes */
+ this.distcode = null; /* starting table for distance codes */
+ this.lenbits = 0; /* index bits for lencode */
+ this.distbits = 0; /* index bits for distcode */
+
+ /* dynamic table building */
+ this.ncode = 0; /* number of code length code lengths */
+ this.nlen = 0; /* number of length code lengths */
+ this.ndist = 0; /* number of distance code lengths */
+ this.have = 0; /* number of code lengths in lens[] */
+ this.next = null; /* next available space in codes[] */
+
+ this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
+ this.work = new utils.Buf16(288); /* work area for code table building */
+
+ /*
+ because we don't have pointers in js, we use lencode and distcode directly
+ as buffers so we don't need codes
+ */
+ //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
+ this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
+ this.distdyn = null; /* dynamic table for distance codes (JS specific) */
+ this.sane = 0; /* if false, allow invalid distance too far */
+ this.back = 0; /* bits back of last unprocessed length/lit */
+ this.was = 0; /* initial length of match */
+}
+
+function inflateResetKeep(strm) {
+ var state;
+
+ if (!strm || !strm.state) { return Z_STREAM_ERROR; }
+ state = strm.state;
+ strm.total_in = strm.total_out = state.total = 0;
+ strm.msg = ''; /*Z_NULL*/
+ if (state.wrap) { /* to support ill-conceived Java test suite */
+ strm.adler = state.wrap & 1;
+ }
+ state.mode = HEAD;
+ state.last = 0;
+ state.havedict = 0;
+ state.dmax = 32768;
+ state.head = null/*Z_NULL*/;
+ state.hold = 0;
+ state.bits = 0;
+ //state.lencode = state.distcode = state.next = state.codes;
+ state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
+ state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
+
+ state.sane = 1;
+ state.back = -1;
+ //Tracev((stderr, "inflate: reset\n"));
+ return Z_OK;
+}
+
+function inflateReset(strm) {
+ var state;
+
+ if (!strm || !strm.state) { return Z_STREAM_ERROR; }
+ state = strm.state;
+ state.wsize = 0;
+ state.whave = 0;
+ state.wnext = 0;
+ return inflateResetKeep(strm);
+
+}
+
+function inflateReset2(strm, windowBits) {
+ var wrap;
+ var state;
+
+ /* get the state */
+ if (!strm || !strm.state) { return Z_STREAM_ERROR; }
+ state = strm.state;
+
+ /* extract wrap request from windowBits parameter */
+ if (windowBits < 0) {
+ wrap = 0;
+ windowBits = -windowBits;
+ }
+ else {
+ wrap = (windowBits >> 4) + 1;
+ if (windowBits < 48) {
+ windowBits &= 15;
+ }
+ }
+
+ /* set number of window bits, free window if different */
+ if (windowBits && (windowBits < 8 || windowBits > 15)) {
+ return Z_STREAM_ERROR;
+ }
+ if (state.window !== null && state.wbits !== windowBits) {
+ state.window = null;
+ }
+
+ /* update state and reset the rest of it */
+ state.wrap = wrap;
+ state.wbits = windowBits;
+ return inflateReset(strm);
+}
+
+function inflateInit2(strm, windowBits) {
+ var ret;
+ var state;
+
+ if (!strm) { return Z_STREAM_ERROR; }
+ //strm.msg = Z_NULL; /* in case we return an error */
+
+ state = new InflateState();
+
+ //if (state === Z_NULL) return Z_MEM_ERROR;
+ //Tracev((stderr, "inflate: allocated\n"));
+ strm.state = state;
+ state.window = null/*Z_NULL*/;
+ ret = inflateReset2(strm, windowBits);
+ if (ret !== Z_OK) {
+ strm.state = null/*Z_NULL*/;
+ }
+ return ret;
+}
+
+function inflateInit(strm) {
+ return inflateInit2(strm, DEF_WBITS);
+}
+
+
+/*
+ Return state with length and distance decoding tables and index sizes set to
+ fixed code decoding. Normally this returns fixed tables from inffixed.h.
+ If BUILDFIXED is defined, then instead this routine builds the tables the
+ first time it's called, and returns those tables the first time and
+ thereafter. This reduces the size of the code by about 2K bytes, in
+ exchange for a little execution time. However, BUILDFIXED should not be
+ used for threaded applications, since the rewriting of the tables and virgin
+ may not be thread-safe.
+ */
+var virgin = true;
+
+var lenfix, distfix; // We have no pointers in JS, so keep tables separate
+
+function fixedtables(state) {
+ /* build fixed huffman tables if first call (may not be thread safe) */
+ if (virgin) {
+ var sym;
+
+ lenfix = new utils.Buf32(512);
+ distfix = new utils.Buf32(32);
+
+ /* literal/length table */
+ sym = 0;
+ while (sym < 144) { state.lens[sym++] = 8; }
+ while (sym < 256) { state.lens[sym++] = 9; }
+ while (sym < 280) { state.lens[sym++] = 7; }
+ while (sym < 288) { state.lens[sym++] = 8; }
+
+ inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
+
+ /* distance table */
+ sym = 0;
+ while (sym < 32) { state.lens[sym++] = 5; }
+
+ inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
+
+ /* do this just once */
+ virgin = false;
+ }
+
+ state.lencode = lenfix;
+ state.lenbits = 9;
+ state.distcode = distfix;
+ state.distbits = 5;
+}
+
+
+/*
+ Update the window with the last wsize (normally 32K) bytes written before
+ returning. If window does not exist yet, create it. This is only called
+ when a window is already in use, or when output has been written during this
+ inflate call, but the end of the deflate stream has not been reached yet.
+ It is also called to create a window for dictionary data when a dictionary
+ is loaded.
+
+ Providing output buffers larger than 32K to inflate() should provide a speed
+ advantage, since only the last 32K of output is copied to the sliding window
+ upon return from inflate(), and since all distances after the first 32K of
+ output will fall in the output data, making match copies simpler and faster.
+ The advantage may be dependent on the size of the processor's data caches.
+ */
+function updatewindow(strm, src, end, copy) {
+ var dist;
+ var state = strm.state;
+
+ /* if it hasn't been done already, allocate space for the window */
+ if (state.window === null) {
+ state.wsize = 1 << state.wbits;
+ state.wnext = 0;
+ state.whave = 0;
+
+ state.window = new utils.Buf8(state.wsize);
+ }
+
+ /* copy state->wsize or less output bytes into the circular window */
+ if (copy >= state.wsize) {
+ utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
+ state.wnext = 0;
+ state.whave = state.wsize;
+ }
+ else {
+ dist = state.wsize - state.wnext;
+ if (dist > copy) {
+ dist = copy;
+ }
+ //zmemcpy(state->window + state->wnext, end - copy, dist);
+ utils.arraySet(state.window, src, end - copy, dist, state.wnext);
+ copy -= dist;
+ if (copy) {
+ //zmemcpy(state->window, end - copy, copy);
+ utils.arraySet(state.window, src, end - copy, copy, 0);
+ state.wnext = copy;
+ state.whave = state.wsize;
+ }
+ else {
+ state.wnext += dist;
+ if (state.wnext === state.wsize) { state.wnext = 0; }
+ if (state.whave < state.wsize) { state.whave += dist; }
+ }
+ }
+ return 0;
+}
+
+function inflate(strm, flush) {
+ var state;
+ var input, output; // input/output buffers
+ var next; /* next input INDEX */
+ var put; /* next output INDEX */
+ var have, left; /* available input and output */
+ var hold; /* bit buffer */
+ var bits; /* bits in bit buffer */
+ var _in, _out; /* save starting available input and output */
+ var copy; /* number of stored or match bytes to copy */
+ var from; /* where to copy match bytes from */
+ var from_source;
+ var here = 0; /* current decoding table entry */
+ var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
+ //var last; /* parent table entry */
+ var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
+ var len; /* length to copy for repeats, bits to drop */
+ var ret; /* return code */
+ var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
+ var opts;
+
+ var n; // temporary var for NEED_BITS
+
+ var order = /* permutation of code lengths */
+ [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
+
+
+ if (!strm || !strm.state || !strm.output ||
+ (!strm.input && strm.avail_in !== 0)) {
+ return Z_STREAM_ERROR;
+ }
+
+ state = strm.state;
+ if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
+
+
+ //--- LOAD() ---
+ put = strm.next_out;
+ output = strm.output;
+ left = strm.avail_out;
+ next = strm.next_in;
+ input = strm.input;
+ have = strm.avail_in;
+ hold = state.hold;
+ bits = state.bits;
+ //---
+
+ _in = have;
+ _out = left;
+ ret = Z_OK;
+
+ inf_leave: // goto emulation
+ for (;;) {
+ switch (state.mode) {
+ case HEAD:
+ if (state.wrap === 0) {
+ state.mode = TYPEDO;
+ break;
+ }
+ //=== NEEDBITS(16);
+ while (bits < 16) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
+ state.check = 0/*crc32(0L, Z_NULL, 0)*/;
+ //=== CRC2(state.check, hold);
+ hbuf[0] = hold & 0xff;
+ hbuf[1] = (hold >>> 8) & 0xff;
+ state.check = crc32(state.check, hbuf, 2, 0);
+ //===//
+
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = FLAGS;
+ break;
+ }
+ state.flags = 0; /* expect zlib header */
+ if (state.head) {
+ state.head.done = false;
+ }
+ if (!(state.wrap & 1) || /* check if zlib header allowed */
+ (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {
+ strm.msg = 'incorrect header check';
+ state.mode = BAD;
+ break;
+ }
+ if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {
+ strm.msg = 'unknown compression method';
+ state.mode = BAD;
+ break;
+ }
+ //--- DROPBITS(4) ---//
+ hold >>>= 4;
+ bits -= 4;
+ //---//
+ len = (hold & 0x0f)/*BITS(4)*/ + 8;
+ if (state.wbits === 0) {
+ state.wbits = len;
+ }
+ else if (len > state.wbits) {
+ strm.msg = 'invalid window size';
+ state.mode = BAD;
+ break;
+ }
+ state.dmax = 1 << len;
+ //Tracev((stderr, "inflate: zlib header ok\n"));
+ strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
+ state.mode = hold & 0x200 ? DICTID : TYPE;
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ break;
+ case FLAGS:
+ //=== NEEDBITS(16); */
+ while (bits < 16) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.flags = hold;
+ if ((state.flags & 0xff) !== Z_DEFLATED) {
+ strm.msg = 'unknown compression method';
+ state.mode = BAD;
+ break;
+ }
+ if (state.flags & 0xe000) {
+ strm.msg = 'unknown header flags set';
+ state.mode = BAD;
+ break;
+ }
+ if (state.head) {
+ state.head.text = ((hold >> 8) & 1);
+ }
+ if (state.flags & 0x0200) {
+ //=== CRC2(state.check, hold);
+ hbuf[0] = hold & 0xff;
+ hbuf[1] = (hold >>> 8) & 0xff;
+ state.check = crc32(state.check, hbuf, 2, 0);
+ //===//
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = TIME;
+ /* falls through */
+ case TIME:
+ //=== NEEDBITS(32); */
+ while (bits < 32) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if (state.head) {
+ state.head.time = hold;
+ }
+ if (state.flags & 0x0200) {
+ //=== CRC4(state.check, hold)
+ hbuf[0] = hold & 0xff;
+ hbuf[1] = (hold >>> 8) & 0xff;
+ hbuf[2] = (hold >>> 16) & 0xff;
+ hbuf[3] = (hold >>> 24) & 0xff;
+ state.check = crc32(state.check, hbuf, 4, 0);
+ //===
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = OS;
+ /* falls through */
+ case OS:
+ //=== NEEDBITS(16); */
+ while (bits < 16) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if (state.head) {
+ state.head.xflags = (hold & 0xff);
+ state.head.os = (hold >> 8);
+ }
+ if (state.flags & 0x0200) {
+ //=== CRC2(state.check, hold);
+ hbuf[0] = hold & 0xff;
+ hbuf[1] = (hold >>> 8) & 0xff;
+ state.check = crc32(state.check, hbuf, 2, 0);
+ //===//
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = EXLEN;
+ /* falls through */
+ case EXLEN:
+ if (state.flags & 0x0400) {
+ //=== NEEDBITS(16); */
+ while (bits < 16) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.length = hold;
+ if (state.head) {
+ state.head.extra_len = hold;
+ }
+ if (state.flags & 0x0200) {
+ //=== CRC2(state.check, hold);
+ hbuf[0] = hold & 0xff;
+ hbuf[1] = (hold >>> 8) & 0xff;
+ state.check = crc32(state.check, hbuf, 2, 0);
+ //===//
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ }
+ else if (state.head) {
+ state.head.extra = null/*Z_NULL*/;
+ }
+ state.mode = EXTRA;
+ /* falls through */
+ case EXTRA:
+ if (state.flags & 0x0400) {
+ copy = state.length;
+ if (copy > have) { copy = have; }
+ if (copy) {
+ if (state.head) {
+ len = state.head.extra_len - state.length;
+ if (!state.head.extra) {
+ // Use untyped array for more convenient processing later
+ state.head.extra = new Array(state.head.extra_len);
+ }
+ utils.arraySet(
+ state.head.extra,
+ input,
+ next,
+ // extra field is limited to 65536 bytes
+ // - no need for additional size check
+ copy,
+ /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
+ len
+ );
+ //zmemcpy(state.head.extra + len, next,
+ // len + copy > state.head.extra_max ?
+ // state.head.extra_max - len : copy);
+ }
+ if (state.flags & 0x0200) {
+ state.check = crc32(state.check, input, copy, next);
+ }
+ have -= copy;
+ next += copy;
+ state.length -= copy;
+ }
+ if (state.length) { break inf_leave; }
+ }
+ state.length = 0;
+ state.mode = NAME;
+ /* falls through */
+ case NAME:
+ if (state.flags & 0x0800) {
+ if (have === 0) { break inf_leave; }
+ copy = 0;
+ do {
+ // TODO: 2 or 1 bytes?
+ len = input[next + copy++];
+ /* use constant limit because in js we should not preallocate memory */
+ if (state.head && len &&
+ (state.length < 65536 /*state.head.name_max*/)) {
+ state.head.name += String.fromCharCode(len);
+ }
+ } while (len && copy < have);
+
+ if (state.flags & 0x0200) {
+ state.check = crc32(state.check, input, copy, next);
+ }
+ have -= copy;
+ next += copy;
+ if (len) { break inf_leave; }
+ }
+ else if (state.head) {
+ state.head.name = null;
+ }
+ state.length = 0;
+ state.mode = COMMENT;
+ /* falls through */
+ case COMMENT:
+ if (state.flags & 0x1000) {
+ if (have === 0) { break inf_leave; }
+ copy = 0;
+ do {
+ len = input[next + copy++];
+ /* use constant limit because in js we should not preallocate memory */
+ if (state.head && len &&
+ (state.length < 65536 /*state.head.comm_max*/)) {
+ state.head.comment += String.fromCharCode(len);
+ }
+ } while (len && copy < have);
+ if (state.flags & 0x0200) {
+ state.check = crc32(state.check, input, copy, next);
+ }
+ have -= copy;
+ next += copy;
+ if (len) { break inf_leave; }
+ }
+ else if (state.head) {
+ state.head.comment = null;
+ }
+ state.mode = HCRC;
+ /* falls through */
+ case HCRC:
+ if (state.flags & 0x0200) {
+ //=== NEEDBITS(16); */
+ while (bits < 16) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if (hold !== (state.check & 0xffff)) {
+ strm.msg = 'header crc mismatch';
+ state.mode = BAD;
+ break;
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ }
+ if (state.head) {
+ state.head.hcrc = ((state.flags >> 9) & 1);
+ state.head.done = true;
+ }
+ strm.adler = state.check = 0;
+ state.mode = TYPE;
+ break;
+ case DICTID:
+ //=== NEEDBITS(32); */
+ while (bits < 32) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ strm.adler = state.check = zswap32(hold);
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = DICT;
+ /* falls through */
+ case DICT:
+ if (state.havedict === 0) {
+ //--- RESTORE() ---
+ strm.next_out = put;
+ strm.avail_out = left;
+ strm.next_in = next;
+ strm.avail_in = have;
+ state.hold = hold;
+ state.bits = bits;
+ //---
+ return Z_NEED_DICT;
+ }
+ strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
+ state.mode = TYPE;
+ /* falls through */
+ case TYPE:
+ if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }
+ /* falls through */
+ case TYPEDO:
+ if (state.last) {
+ //--- BYTEBITS() ---//
+ hold >>>= bits & 7;
+ bits -= bits & 7;
+ //---//
+ state.mode = CHECK;
+ break;
+ }
+ //=== NEEDBITS(3); */
+ while (bits < 3) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.last = (hold & 0x01)/*BITS(1)*/;
+ //--- DROPBITS(1) ---//
+ hold >>>= 1;
+ bits -= 1;
+ //---//
+
+ switch ((hold & 0x03)/*BITS(2)*/) {
+ case 0: /* stored block */
+ //Tracev((stderr, "inflate: stored block%s\n",
+ // state.last ? " (last)" : ""));
+ state.mode = STORED;
+ break;
+ case 1: /* fixed block */
+ fixedtables(state);
+ //Tracev((stderr, "inflate: fixed codes block%s\n",
+ // state.last ? " (last)" : ""));
+ state.mode = LEN_; /* decode codes */
+ if (flush === Z_TREES) {
+ //--- DROPBITS(2) ---//
+ hold >>>= 2;
+ bits -= 2;
+ //---//
+ break inf_leave;
+ }
+ break;
+ case 2: /* dynamic block */
+ //Tracev((stderr, "inflate: dynamic codes block%s\n",
+ // state.last ? " (last)" : ""));
+ state.mode = TABLE;
+ break;
+ case 3:
+ strm.msg = 'invalid block type';
+ state.mode = BAD;
+ }
+ //--- DROPBITS(2) ---//
+ hold >>>= 2;
+ bits -= 2;
+ //---//
+ break;
+ case STORED:
+ //--- BYTEBITS() ---// /* go to byte boundary */
+ hold >>>= bits & 7;
+ bits -= bits & 7;
+ //---//
+ //=== NEEDBITS(32); */
+ while (bits < 32) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {
+ strm.msg = 'invalid stored block lengths';
+ state.mode = BAD;
+ break;
+ }
+ state.length = hold & 0xffff;
+ //Tracev((stderr, "inflate: stored length %u\n",
+ // state.length));
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ state.mode = COPY_;
+ if (flush === Z_TREES) { break inf_leave; }
+ /* falls through */
+ case COPY_:
+ state.mode = COPY;
+ /* falls through */
+ case COPY:
+ copy = state.length;
+ if (copy) {
+ if (copy > have) { copy = have; }
+ if (copy > left) { copy = left; }
+ if (copy === 0) { break inf_leave; }
+ //--- zmemcpy(put, next, copy); ---
+ utils.arraySet(output, input, next, copy, put);
+ //---//
+ have -= copy;
+ next += copy;
+ left -= copy;
+ put += copy;
+ state.length -= copy;
+ break;
+ }
+ //Tracev((stderr, "inflate: stored end\n"));
+ state.mode = TYPE;
+ break;
+ case TABLE:
+ //=== NEEDBITS(14); */
+ while (bits < 14) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;
+ //--- DROPBITS(5) ---//
+ hold >>>= 5;
+ bits -= 5;
+ //---//
+ state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;
+ //--- DROPBITS(5) ---//
+ hold >>>= 5;
+ bits -= 5;
+ //---//
+ state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;
+ //--- DROPBITS(4) ---//
+ hold >>>= 4;
+ bits -= 4;
+ //---//
+//#ifndef PKZIP_BUG_WORKAROUND
+ if (state.nlen > 286 || state.ndist > 30) {
+ strm.msg = 'too many length or distance symbols';
+ state.mode = BAD;
+ break;
+ }
+//#endif
+ //Tracev((stderr, "inflate: table sizes ok\n"));
+ state.have = 0;
+ state.mode = LENLENS;
+ /* falls through */
+ case LENLENS:
+ while (state.have < state.ncode) {
+ //=== NEEDBITS(3);
+ while (bits < 3) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);
+ //--- DROPBITS(3) ---//
+ hold >>>= 3;
+ bits -= 3;
+ //---//
+ }
+ while (state.have < 19) {
+ state.lens[order[state.have++]] = 0;
+ }
+ // We have separate tables & no pointers. 2 commented lines below not needed.
+ //state.next = state.codes;
+ //state.lencode = state.next;
+ // Switch to use dynamic table
+ state.lencode = state.lendyn;
+ state.lenbits = 7;
+
+ opts = { bits: state.lenbits };
+ ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
+ state.lenbits = opts.bits;
+
+ if (ret) {
+ strm.msg = 'invalid code lengths set';
+ state.mode = BAD;
+ break;
+ }
+ //Tracev((stderr, "inflate: code lengths ok\n"));
+ state.have = 0;
+ state.mode = CODELENS;
+ /* falls through */
+ case CODELENS:
+ while (state.have < state.nlen + state.ndist) {
+ for (;;) {
+ here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/
+ here_bits = here >>> 24;
+ here_op = (here >>> 16) & 0xff;
+ here_val = here & 0xffff;
+
+ if ((here_bits) <= bits) { break; }
+ //--- PULLBYTE() ---//
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ //---//
+ }
+ if (here_val < 16) {
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ state.lens[state.have++] = here_val;
+ }
+ else {
+ if (here_val === 16) {
+ //=== NEEDBITS(here.bits + 2);
+ n = here_bits + 2;
+ while (bits < n) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ if (state.have === 0) {
+ strm.msg = 'invalid bit length repeat';
+ state.mode = BAD;
+ break;
+ }
+ len = state.lens[state.have - 1];
+ copy = 3 + (hold & 0x03);//BITS(2);
+ //--- DROPBITS(2) ---//
+ hold >>>= 2;
+ bits -= 2;
+ //---//
+ }
+ else if (here_val === 17) {
+ //=== NEEDBITS(here.bits + 3);
+ n = here_bits + 3;
+ while (bits < n) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ len = 0;
+ copy = 3 + (hold & 0x07);//BITS(3);
+ //--- DROPBITS(3) ---//
+ hold >>>= 3;
+ bits -= 3;
+ //---//
+ }
+ else {
+ //=== NEEDBITS(here.bits + 7);
+ n = here_bits + 7;
+ while (bits < n) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ len = 0;
+ copy = 11 + (hold & 0x7f);//BITS(7);
+ //--- DROPBITS(7) ---//
+ hold >>>= 7;
+ bits -= 7;
+ //---//
+ }
+ if (state.have + copy > state.nlen + state.ndist) {
+ strm.msg = 'invalid bit length repeat';
+ state.mode = BAD;
+ break;
+ }
+ while (copy--) {
+ state.lens[state.have++] = len;
+ }
+ }
+ }
+
+ /* handle error breaks in while */
+ if (state.mode === BAD) { break; }
+
+ /* check for end-of-block code (better have one) */
+ if (state.lens[256] === 0) {
+ strm.msg = 'invalid code -- missing end-of-block';
+ state.mode = BAD;
+ break;
+ }
+
+ /* build code tables -- note: do not change the lenbits or distbits
+ values here (9 and 6) without reading the comments in inftrees.h
+ concerning the ENOUGH constants, which depend on those values */
+ state.lenbits = 9;
+
+ opts = { bits: state.lenbits };
+ ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
+ // We have separate tables & no pointers. 2 commented lines below not needed.
+ // state.next_index = opts.table_index;
+ state.lenbits = opts.bits;
+ // state.lencode = state.next;
+
+ if (ret) {
+ strm.msg = 'invalid literal/lengths set';
+ state.mode = BAD;
+ break;
+ }
+
+ state.distbits = 6;
+ //state.distcode.copy(state.codes);
+ // Switch to use dynamic table
+ state.distcode = state.distdyn;
+ opts = { bits: state.distbits };
+ ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
+ // We have separate tables & no pointers. 2 commented lines below not needed.
+ // state.next_index = opts.table_index;
+ state.distbits = opts.bits;
+ // state.distcode = state.next;
+
+ if (ret) {
+ strm.msg = 'invalid distances set';
+ state.mode = BAD;
+ break;
+ }
+ //Tracev((stderr, 'inflate: codes ok\n'));
+ state.mode = LEN_;
+ if (flush === Z_TREES) { break inf_leave; }
+ /* falls through */
+ case LEN_:
+ state.mode = LEN;
+ /* falls through */
+ case LEN:
+ if (have >= 6 && left >= 258) {
+ //--- RESTORE() ---
+ strm.next_out = put;
+ strm.avail_out = left;
+ strm.next_in = next;
+ strm.avail_in = have;
+ state.hold = hold;
+ state.bits = bits;
+ //---
+ inflate_fast(strm, _out);
+ //--- LOAD() ---
+ put = strm.next_out;
+ output = strm.output;
+ left = strm.avail_out;
+ next = strm.next_in;
+ input = strm.input;
+ have = strm.avail_in;
+ hold = state.hold;
+ bits = state.bits;
+ //---
+
+ if (state.mode === TYPE) {
+ state.back = -1;
+ }
+ break;
+ }
+ state.back = 0;
+ for (;;) {
+ here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
+ here_bits = here >>> 24;
+ here_op = (here >>> 16) & 0xff;
+ here_val = here & 0xffff;
+
+ if (here_bits <= bits) { break; }
+ //--- PULLBYTE() ---//
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ //---//
+ }
+ if (here_op && (here_op & 0xf0) === 0) {
+ last_bits = here_bits;
+ last_op = here_op;
+ last_val = here_val;
+ for (;;) {
+ here = state.lencode[last_val +
+ ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
+ here_bits = here >>> 24;
+ here_op = (here >>> 16) & 0xff;
+ here_val = here & 0xffff;
+
+ if ((last_bits + here_bits) <= bits) { break; }
+ //--- PULLBYTE() ---//
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ //---//
+ }
+ //--- DROPBITS(last.bits) ---//
+ hold >>>= last_bits;
+ bits -= last_bits;
+ //---//
+ state.back += last_bits;
+ }
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ state.back += here_bits;
+ state.length = here_val;
+ if (here_op === 0) {
+ //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
+ // "inflate: literal '%c'\n" :
+ // "inflate: literal 0x%02x\n", here.val));
+ state.mode = LIT;
+ break;
+ }
+ if (here_op & 32) {
+ //Tracevv((stderr, "inflate: end of block\n"));
+ state.back = -1;
+ state.mode = TYPE;
+ break;
+ }
+ if (here_op & 64) {
+ strm.msg = 'invalid literal/length code';
+ state.mode = BAD;
+ break;
+ }
+ state.extra = here_op & 15;
+ state.mode = LENEXT;
+ /* falls through */
+ case LENEXT:
+ if (state.extra) {
+ //=== NEEDBITS(state.extra);
+ n = state.extra;
+ while (bits < n) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
+ //--- DROPBITS(state.extra) ---//
+ hold >>>= state.extra;
+ bits -= state.extra;
+ //---//
+ state.back += state.extra;
+ }
+ //Tracevv((stderr, "inflate: length %u\n", state.length));
+ state.was = state.length;
+ state.mode = DIST;
+ /* falls through */
+ case DIST:
+ for (;;) {
+ here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
+ here_bits = here >>> 24;
+ here_op = (here >>> 16) & 0xff;
+ here_val = here & 0xffff;
+
+ if ((here_bits) <= bits) { break; }
+ //--- PULLBYTE() ---//
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ //---//
+ }
+ if ((here_op & 0xf0) === 0) {
+ last_bits = here_bits;
+ last_op = here_op;
+ last_val = here_val;
+ for (;;) {
+ here = state.distcode[last_val +
+ ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
+ here_bits = here >>> 24;
+ here_op = (here >>> 16) & 0xff;
+ here_val = here & 0xffff;
+
+ if ((last_bits + here_bits) <= bits) { break; }
+ //--- PULLBYTE() ---//
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ //---//
+ }
+ //--- DROPBITS(last.bits) ---//
+ hold >>>= last_bits;
+ bits -= last_bits;
+ //---//
+ state.back += last_bits;
+ }
+ //--- DROPBITS(here.bits) ---//
+ hold >>>= here_bits;
+ bits -= here_bits;
+ //---//
+ state.back += here_bits;
+ if (here_op & 64) {
+ strm.msg = 'invalid distance code';
+ state.mode = BAD;
+ break;
+ }
+ state.offset = here_val;
+ state.extra = (here_op) & 15;
+ state.mode = DISTEXT;
+ /* falls through */
+ case DISTEXT:
+ if (state.extra) {
+ //=== NEEDBITS(state.extra);
+ n = state.extra;
+ while (bits < n) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
+ //--- DROPBITS(state.extra) ---//
+ hold >>>= state.extra;
+ bits -= state.extra;
+ //---//
+ state.back += state.extra;
+ }
+//#ifdef INFLATE_STRICT
+ if (state.offset > state.dmax) {
+ strm.msg = 'invalid distance too far back';
+ state.mode = BAD;
+ break;
+ }
+//#endif
+ //Tracevv((stderr, "inflate: distance %u\n", state.offset));
+ state.mode = MATCH;
+ /* falls through */
+ case MATCH:
+ if (left === 0) { break inf_leave; }
+ copy = _out - left;
+ if (state.offset > copy) { /* copy from window */
+ copy = state.offset - copy;
+ if (copy > state.whave) {
+ if (state.sane) {
+ strm.msg = 'invalid distance too far back';
+ state.mode = BAD;
+ break;
+ }
+// (!) This block is disabled in zlib defaults,
+// don't enable it for binary compatibility
+//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+// Trace((stderr, "inflate.c too far\n"));
+// copy -= state.whave;
+// if (copy > state.length) { copy = state.length; }
+// if (copy > left) { copy = left; }
+// left -= copy;
+// state.length -= copy;
+// do {
+// output[put++] = 0;
+// } while (--copy);
+// if (state.length === 0) { state.mode = LEN; }
+// break;
+//#endif
+ }
+ if (copy > state.wnext) {
+ copy -= state.wnext;
+ from = state.wsize - copy;
+ }
+ else {
+ from = state.wnext - copy;
+ }
+ if (copy > state.length) { copy = state.length; }
+ from_source = state.window;
+ }
+ else { /* copy from output */
+ from_source = output;
+ from = put - state.offset;
+ copy = state.length;
+ }
+ if (copy > left) { copy = left; }
+ left -= copy;
+ state.length -= copy;
+ do {
+ output[put++] = from_source[from++];
+ } while (--copy);
+ if (state.length === 0) { state.mode = LEN; }
+ break;
+ case LIT:
+ if (left === 0) { break inf_leave; }
+ output[put++] = state.length;
+ left--;
+ state.mode = LEN;
+ break;
+ case CHECK:
+ if (state.wrap) {
+ //=== NEEDBITS(32);
+ while (bits < 32) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ // Use '|' instead of '+' to make sure that result is signed
+ hold |= input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ _out -= left;
+ strm.total_out += _out;
+ state.total += _out;
+ if (_out) {
+ strm.adler = state.check =
+ /*UPDATE(state.check, put - _out, _out);*/
+ (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
+
+ }
+ _out = left;
+ // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
+ if ((state.flags ? hold : zswap32(hold)) !== state.check) {
+ strm.msg = 'incorrect data check';
+ state.mode = BAD;
+ break;
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ //Tracev((stderr, "inflate: check matches trailer\n"));
+ }
+ state.mode = LENGTH;
+ /* falls through */
+ case LENGTH:
+ if (state.wrap && state.flags) {
+ //=== NEEDBITS(32);
+ while (bits < 32) {
+ if (have === 0) { break inf_leave; }
+ have--;
+ hold += input[next++] << bits;
+ bits += 8;
+ }
+ //===//
+ if (hold !== (state.total & 0xffffffff)) {
+ strm.msg = 'incorrect length check';
+ state.mode = BAD;
+ break;
+ }
+ //=== INITBITS();
+ hold = 0;
+ bits = 0;
+ //===//
+ //Tracev((stderr, "inflate: length matches trailer\n"));
+ }
+ state.mode = DONE;
+ /* falls through */
+ case DONE:
+ ret = Z_STREAM_END;
+ break inf_leave;
+ case BAD:
+ ret = Z_DATA_ERROR;
+ break inf_leave;
+ case MEM:
+ return Z_MEM_ERROR;
+ case SYNC:
+ /* falls through */
+ default:
+ return Z_STREAM_ERROR;
+ }
+ }
+
+ // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
+
+ /*
+ Return from inflate(), updating the total counts and the check value.
+ If there was no progress during the inflate() call, return a buffer
+ error. Call updatewindow() to create and/or update the window state.
+ Note: a memory error from inflate() is non-recoverable.
+ */
+
+ //--- RESTORE() ---
+ strm.next_out = put;
+ strm.avail_out = left;
+ strm.next_in = next;
+ strm.avail_in = have;
+ state.hold = hold;
+ state.bits = bits;
+ //---
+
+ if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&
+ (state.mode < CHECK || flush !== Z_FINISH))) {
+ if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
+ state.mode = MEM;
+ return Z_MEM_ERROR;
+ }
+ }
+ _in -= strm.avail_in;
+ _out -= strm.avail_out;
+ strm.total_in += _in;
+ strm.total_out += _out;
+ state.total += _out;
+ if (state.wrap && _out) {
+ strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
+ (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
+ }
+ strm.data_type = state.bits + (state.last ? 64 : 0) +
+ (state.mode === TYPE ? 128 : 0) +
+ (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
+ if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {
+ ret = Z_BUF_ERROR;
+ }
+ return ret;
+}
+
+function inflateEnd(strm) {
+
+ if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
+ return Z_STREAM_ERROR;
+ }
+
+ var state = strm.state;
+ if (state.window) {
+ state.window = null;
+ }
+ strm.state = null;
+ return Z_OK;
+}
+
+function inflateGetHeader(strm, head) {
+ var state;
+
+ /* check state */
+ if (!strm || !strm.state) { return Z_STREAM_ERROR; }
+ state = strm.state;
+ if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }
+
+ /* save header structure */
+ state.head = head;
+ head.done = false;
+ return Z_OK;
+}
+
+function inflateSetDictionary(strm, dictionary) {
+ var dictLength = dictionary.length;
+
+ var state;
+ var dictid;
+ var ret;
+
+ /* check state */
+ if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
+ state = strm.state;
+
+ if (state.wrap !== 0 && state.mode !== DICT) {
+ return Z_STREAM_ERROR;
+ }
+
+ /* check for correct dictionary identifier */
+ if (state.mode === DICT) {
+ dictid = 1; /* adler32(0, null, 0)*/
+ /* dictid = adler32(dictid, dictionary, dictLength); */
+ dictid = adler32(dictid, dictionary, dictLength, 0);
+ if (dictid !== state.check) {
+ return Z_DATA_ERROR;
+ }
+ }
+ /* copy dictionary to window using updatewindow(), which will amend the
+ existing dictionary if appropriate */
+ ret = updatewindow(strm, dictionary, dictLength, dictLength);
+ if (ret) {
+ state.mode = MEM;
+ return Z_MEM_ERROR;
+ }
+ state.havedict = 1;
+ // Tracev((stderr, "inflate: dictionary set\n"));
+ return Z_OK;
+}
+
+exports.inflateReset = inflateReset;
+exports.inflateReset2 = inflateReset2;
+exports.inflateResetKeep = inflateResetKeep;
+exports.inflateInit = inflateInit;
+exports.inflateInit2 = inflateInit2;
+exports.inflate = inflate;
+exports.inflateEnd = inflateEnd;
+exports.inflateGetHeader = inflateGetHeader;
+exports.inflateSetDictionary = inflateSetDictionary;
+exports.inflateInfo = 'pako inflate (from Nodeca project)';
+
+/* Not implemented
+exports.inflateCopy = inflateCopy;
+exports.inflateGetDictionary = inflateGetDictionary;
+exports.inflateMark = inflateMark;
+exports.inflatePrime = inflatePrime;
+exports.inflateSync = inflateSync;
+exports.inflateSyncPoint = inflateSyncPoint;
+exports.inflateUndermine = inflateUndermine;
+*/
+
+
+/***/ }),
+/* 143 */
+/*!******************************************!*\
+ !*** ./node_modules/pako/lib/inflate.js ***!
+ \******************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+
+var zlib_inflate = __webpack_require__(/*! ./zlib/inflate */ 142);
+var utils = __webpack_require__(/*! ./utils/common */ 45);
+var strings = __webpack_require__(/*! ./utils/strings */ 93);
+var c = __webpack_require__(/*! ./zlib/constants */ 91);
+var msg = __webpack_require__(/*! ./zlib/messages */ 71);
+var ZStream = __webpack_require__(/*! ./zlib/zstream */ 92);
+var GZheader = __webpack_require__(/*! ./zlib/gzheader */ 139);
+
+var toString = Object.prototype.toString;
+
+/**
+ * class Inflate
+ *
+ * Generic JS-style wrapper for zlib calls. If you don't need
+ * streaming behaviour - use more simple functions: [[inflate]]
+ * and [[inflateRaw]].
+ **/
+
+/* internal
+ * inflate.chunks -> Array
+ *
+ * Chunks of output data, if [[Inflate#onData]] not overridden.
+ **/
+
+/**
+ * Inflate.result -> Uint8Array|Array|String
+ *
+ * Uncompressed result, generated by default [[Inflate#onData]]
+ * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
+ * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
+ * push a chunk with explicit flush (call [[Inflate#push]] with
+ * `Z_SYNC_FLUSH` param).
+ **/
+
+/**
+ * Inflate.err -> Number
+ *
+ * Error code after inflate finished. 0 (Z_OK) on success.
+ * Should be checked if broken data possible.
+ **/
+
+/**
+ * Inflate.msg -> String
+ *
+ * Error message, if [[Inflate.err]] != 0
+ **/
+
+
+/**
+ * new Inflate(options)
+ * - options (Object): zlib inflate options.
+ *
+ * Creates new inflator instance with specified params. Throws exception
+ * on bad params. Supported options:
+ *
+ * - `windowBits`
+ * - `dictionary`
+ *
+ * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
+ * for more information on these.
+ *
+ * Additional options, for internal needs:
+ *
+ * - `chunkSize` - size of generated data chunks (16K by default)
+ * - `raw` (Boolean) - do raw inflate
+ * - `to` (String) - if equal to 'string', then result will be converted
+ * from utf8 to utf16 (javascript) string. When string output requested,
+ * chunk length can differ from `chunkSize`, depending on content.
+ *
+ * By default, when no options set, autodetect deflate/gzip data format via
+ * wrapper header.
+ *
+ * ##### Example:
+ *
+ * ```javascript
+ * var pako = require('pako')
+ * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
+ * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
+ *
+ * var inflate = new pako.Inflate({ level: 3});
+ *
+ * inflate.push(chunk1, false);
+ * inflate.push(chunk2, true); // true -> last chunk
+ *
+ * if (inflate.err) { throw new Error(inflate.err); }
+ *
+ * console.log(inflate.result);
+ * ```
+ **/
+function Inflate(options) {
+ if (!(this instanceof Inflate)) return new Inflate(options);
+
+ this.options = utils.assign({
+ chunkSize: 16384,
+ windowBits: 0,
+ to: ''
+ }, options || {});
+
+ var opt = this.options;
+
+ // Force window size for `raw` data, if not set directly,
+ // because we have no header for autodetect.
+ if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
+ opt.windowBits = -opt.windowBits;
+ if (opt.windowBits === 0) { opt.windowBits = -15; }
+ }
+
+ // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
+ if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
+ !(options && options.windowBits)) {
+ opt.windowBits += 32;
+ }
+
+ // Gzip header has no info about windows size, we can do autodetect only
+ // for deflate. So, if window size not set, force it to max when gzip possible
+ if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
+ // bit 3 (16) -> gzipped data
+ // bit 4 (32) -> autodetect gzip/deflate
+ if ((opt.windowBits & 15) === 0) {
+ opt.windowBits |= 15;
+ }
+ }
+
+ this.err = 0; // error code, if happens (0 = Z_OK)
+ this.msg = ''; // error message
+ this.ended = false; // used to avoid multiple onEnd() calls
+ this.chunks = []; // chunks of compressed data
+
+ this.strm = new ZStream();
+ this.strm.avail_out = 0;
+
+ var status = zlib_inflate.inflateInit2(
+ this.strm,
+ opt.windowBits
+ );
+
+ if (status !== c.Z_OK) {
+ throw new Error(msg[status]);
+ }
+
+ this.header = new GZheader();
+
+ zlib_inflate.inflateGetHeader(this.strm, this.header);
+}
+
+/**
+ * Inflate#push(data[, mode]) -> Boolean
+ * - data (Uint8Array|Array|ArrayBuffer|String): input data
+ * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
+ * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.
+ *
+ * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
+ * new output chunks. Returns `true` on success. The last data block must have
+ * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
+ * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
+ * can use mode Z_SYNC_FLUSH, keeping the decompression context.
+ *
+ * On fail call [[Inflate#onEnd]] with error code and return false.
+ *
+ * We strongly recommend to use `Uint8Array` on input for best speed (output
+ * format is detected automatically). Also, don't skip last param and always
+ * use the same type in your code (boolean or number). That will improve JS speed.
+ *
+ * For regular `Array`-s make sure all elements are [0..255].
+ *
+ * ##### Example
+ *
+ * ```javascript
+ * push(chunk, false); // push one of data chunks
+ * ...
+ * push(chunk, true); // push last chunk
+ * ```
+ **/
+Inflate.prototype.push = function (data, mode) {
+ var strm = this.strm;
+ var chunkSize = this.options.chunkSize;
+ var dictionary = this.options.dictionary;
+ var status, _mode;
+ var next_out_utf8, tail, utf8str;
+ var dict;
+
+ // Flag to properly process Z_BUF_ERROR on testing inflate call
+ // when we check that all output data was flushed.
+ var allowBufError = false;
+
+ if (this.ended) { return false; }
+ _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
+
+ // Convert data if needed
+ if (typeof data === 'string') {
+ // Only binary strings can be decompressed on practice
+ strm.input = strings.binstring2buf(data);
+ } else if (toString.call(data) === '[object ArrayBuffer]') {
+ strm.input = new Uint8Array(data);
+ } else {
+ strm.input = data;
+ }
+
+ strm.next_in = 0;
+ strm.avail_in = strm.input.length;
+
+ do {
+ if (strm.avail_out === 0) {
+ strm.output = new utils.Buf8(chunkSize);
+ strm.next_out = 0;
+ strm.avail_out = chunkSize;
+ }
+
+ status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
+
+ if (status === c.Z_NEED_DICT && dictionary) {
+ // Convert data if needed
+ if (typeof dictionary === 'string') {
+ dict = strings.string2buf(dictionary);
+ } else if (toString.call(dictionary) === '[object ArrayBuffer]') {
+ dict = new Uint8Array(dictionary);
+ } else {
+ dict = dictionary;
+ }
+
+ status = zlib_inflate.inflateSetDictionary(this.strm, dict);
+
+ }
+
+ if (status === c.Z_BUF_ERROR && allowBufError === true) {
+ status = c.Z_OK;
+ allowBufError = false;
+ }
+
+ if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
+ this.onEnd(status);
+ this.ended = true;
+ return false;
+ }
+
+ if (strm.next_out) {
+ if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
+
+ if (this.options.to === 'string') {
+
+ next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
+
+ tail = strm.next_out - next_out_utf8;
+ utf8str = strings.buf2string(strm.output, next_out_utf8);
+
+ // move tail
+ strm.next_out = tail;
+ strm.avail_out = chunkSize - tail;
+ if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
+
+ this.onData(utf8str);
+
+ } else {
+ this.onData(utils.shrinkBuf(strm.output, strm.next_out));
+ }
+ }
+ }
+
+ // When no more input data, we should check that internal inflate buffers
+ // are flushed. The only way to do it when avail_out = 0 - run one more
+ // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
+ // Here we set flag to process this error properly.
+ //
+ // NOTE. Deflate does not return error in this case and does not needs such
+ // logic.
+ if (strm.avail_in === 0 && strm.avail_out === 0) {
+ allowBufError = true;
+ }
+
+ } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
+
+ if (status === c.Z_STREAM_END) {
+ _mode = c.Z_FINISH;
+ }
+
+ // Finalize on the last chunk.
+ if (_mode === c.Z_FINISH) {
+ status = zlib_inflate.inflateEnd(this.strm);
+ this.onEnd(status);
+ this.ended = true;
+ return status === c.Z_OK;
+ }
+
+ // callback interim results if Z_SYNC_FLUSH.
+ if (_mode === c.Z_SYNC_FLUSH) {
+ this.onEnd(c.Z_OK);
+ strm.avail_out = 0;
+ return true;
+ }
+
+ return true;
+};
+
+
+/**
+ * Inflate#onData(chunk) -> Void
+ * - chunk (Uint8Array|Array|String): output data. Type of array depends
+ * on js engine support. When string output requested, each chunk
+ * will be string.
+ *
+ * By default, stores data blocks in `chunks[]` property and glue
+ * those in `onEnd`. Override this handler, if you need another behaviour.
+ **/
+Inflate.prototype.onData = function (chunk) {
+ this.chunks.push(chunk);
+};
+
+
+/**
+ * Inflate#onEnd(status) -> Void
+ * - status (Number): inflate status. 0 (Z_OK) on success,
+ * other if not.
+ *
+ * Called either after you tell inflate that the input stream is
+ * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
+ * or if an error happened. By default - join collected chunks,
+ * free memory and fill `results` / `err` properties.
+ **/
+Inflate.prototype.onEnd = function (status) {
+ // On success - join
+ if (status === c.Z_OK) {
+ if (this.options.to === 'string') {
+ // Glue & convert here, until we teach pako to send
+ // utf8 aligned strings to onData
+ this.result = this.chunks.join('');
+ } else {
+ this.result = utils.flattenChunks(this.chunks);
+ }
+ }
+ this.chunks = [];
+ this.err = status;
+ this.msg = this.strm.msg;
+};
+
+
+/**
+ * inflate(data[, options]) -> Uint8Array|Array|String
+ * - data (Uint8Array|Array|String): input data to decompress.
+ * - options (Object): zlib inflate options.
+ *
+ * Decompress `data` with inflate/ungzip and `options`. Autodetect
+ * format via wrapper header by default. That's why we don't provide
+ * separate `ungzip` method.
+ *
+ * Supported options are:
+ *
+ * - windowBits
+ *
+ * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
+ * for more information.
+ *
+ * Sugar (options):
+ *
+ * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
+ * negative windowBits implicitly.
+ * - `to` (String) - if equal to 'string', then result will be converted
+ * from utf8 to utf16 (javascript) string. When string output requested,
+ * chunk length can differ from `chunkSize`, depending on content.
+ *
+ *
+ * ##### Example:
+ *
+ * ```javascript
+ * var pako = require('pako')
+ * , input = pako.deflate([1,2,3,4,5,6,7,8,9])
+ * , output;
+ *
+ * try {
+ * output = pako.inflate(input);
+ * } catch (err)
+ * console.log(err);
+ * }
+ * ```
+ **/
+function inflate(input, options) {
+ var inflator = new Inflate(options);
+
+ inflator.push(input, true);
+
+ // That will never happens, if you don't cheat with options :)
+ if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
+
+ return inflator.result;
+}
+
+
+/**
+ * inflateRaw(data[, options]) -> Uint8Array|Array|String
+ * - data (Uint8Array|Array|String): input data to decompress.
+ * - options (Object): zlib inflate options.
+ *
+ * The same as [[inflate]], but creates raw data, without wrapper
+ * (header and adler32 crc).
+ **/
+function inflateRaw(input, options) {
+ options = options || {};
+ options.raw = true;
+ return inflate(input, options);
+}
+
+
+/**
+ * ungzip(data[, options]) -> Uint8Array|Array|String
+ * - data (Uint8Array|Array|String): input data to decompress.
+ * - options (Object): zlib inflate options.
+ *
+ * Just shortcut to [[inflate]], because it autodetects format
+ * by header.content. Done for convenience.
+ **/
+
+
+exports.Inflate = Inflate;
+exports.inflate = inflate;
+exports.inflateRaw = inflateRaw;
+exports.ungzip = inflate;
+
+
+/***/ }),
+/* 144 */
+/*!*********************************************!*\
+ !*** ./node_modules/pako/lib/zlib/trees.js ***!
+ \*********************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+// (C) 1995-2013 Jean-loup Gailly and Mark Adler
+// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+var utils = __webpack_require__(/*! ../utils/common */ 45);
+
+/* Public constants ==========================================================*/
+/* ===========================================================================*/
+
+
+//var Z_FILTERED = 1;
+//var Z_HUFFMAN_ONLY = 2;
+//var Z_RLE = 3;
+var Z_FIXED = 4;
+//var Z_DEFAULT_STRATEGY = 0;
+
+/* Possible values of the data_type field (though see inflate()) */
+var Z_BINARY = 0;
+var Z_TEXT = 1;
+//var Z_ASCII = 1; // = Z_TEXT
+var Z_UNKNOWN = 2;
+
+/*============================================================================*/
+
+
+function zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }
+
+// From zutil.h
+
+var STORED_BLOCK = 0;
+var STATIC_TREES = 1;
+var DYN_TREES = 2;
+/* The three kinds of block type */
+
+var MIN_MATCH = 3;
+var MAX_MATCH = 258;
+/* The minimum and maximum match lengths */
+
+// From deflate.h
+/* ===========================================================================
+ * Internal compression state.
+ */
+
+var LENGTH_CODES = 29;
+/* number of length codes, not counting the special END_BLOCK code */
+
+var LITERALS = 256;
+/* number of literal bytes 0..255 */
+
+var L_CODES = LITERALS + 1 + LENGTH_CODES;
+/* number of Literal or Length codes, including the END_BLOCK code */
+
+var D_CODES = 30;
+/* number of distance codes */
+
+var BL_CODES = 19;
+/* number of codes used to transfer the bit lengths */
+
+var HEAP_SIZE = 2 * L_CODES + 1;
+/* maximum heap size */
+
+var MAX_BITS = 15;
+/* All codes must not exceed MAX_BITS bits */
+
+var Buf_size = 16;
+/* size of bit buffer in bi_buf */
+
+
+/* ===========================================================================
+ * Constants
+ */
+
+var MAX_BL_BITS = 7;
+/* Bit length codes must not exceed MAX_BL_BITS bits */
+
+var END_BLOCK = 256;
+/* end of block literal code */
+
+var REP_3_6 = 16;
+/* repeat previous bit length 3-6 times (2 bits of repeat count) */
+
+var REPZ_3_10 = 17;
+/* repeat a zero length 3-10 times (3 bits of repeat count) */
+
+var REPZ_11_138 = 18;
+/* repeat a zero length 11-138 times (7 bits of repeat count) */
+
+/* eslint-disable comma-spacing,array-bracket-spacing */
+var extra_lbits = /* extra bits for each length code */
+ [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];
+
+var extra_dbits = /* extra bits for each distance code */
+ [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];
+
+var extra_blbits = /* extra bits for each bit length code */
+ [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];
+
+var bl_order =
+ [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];
+/* eslint-enable comma-spacing,array-bracket-spacing */
+
+/* The lengths of the bit length codes are sent in order of decreasing
+ * probability, to avoid transmitting the lengths for unused bit length codes.
+ */
+
+/* ===========================================================================
+ * Local data. These are initialized only once.
+ */
+
+// We pre-fill arrays with 0 to avoid uninitialized gaps
+
+var DIST_CODE_LEN = 512; /* see definition of array dist_code below */
+
+// !!!! Use flat array instead of structure, Freq = i*2, Len = i*2+1
+var static_ltree = new Array((L_CODES + 2) * 2);
+zero(static_ltree);
+/* The static literal tree. Since the bit lengths are imposed, there is no
+ * need for the L_CODES extra codes used during heap construction. However
+ * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
+ * below).
+ */
+
+var static_dtree = new Array(D_CODES * 2);
+zero(static_dtree);
+/* The static distance tree. (Actually a trivial tree since all codes use
+ * 5 bits.)
+ */
+
+var _dist_code = new Array(DIST_CODE_LEN);
+zero(_dist_code);
+/* Distance codes. The first 256 values correspond to the distances
+ * 3 .. 258, the last 256 values correspond to the top 8 bits of
+ * the 15 bit distances.
+ */
+
+var _length_code = new Array(MAX_MATCH - MIN_MATCH + 1);
+zero(_length_code);
+/* length code for each normalized match length (0 == MIN_MATCH) */
+
+var base_length = new Array(LENGTH_CODES);
+zero(base_length);
+/* First normalized length for each code (0 = MIN_MATCH) */
+
+var base_dist = new Array(D_CODES);
+zero(base_dist);
+/* First normalized distance for each code (0 = distance of 1) */
+
+
+function StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {
+
+ this.static_tree = static_tree; /* static tree or NULL */
+ this.extra_bits = extra_bits; /* extra bits for each code or NULL */
+ this.extra_base = extra_base; /* base index for extra_bits */
+ this.elems = elems; /* max number of elements in the tree */
+ this.max_length = max_length; /* max bit length for the codes */
+
+ // show if `static_tree` has data or dummy - needed for monomorphic objects
+ this.has_stree = static_tree && static_tree.length;
+}
+
+
+var static_l_desc;
+var static_d_desc;
+var static_bl_desc;
+
+
+function TreeDesc(dyn_tree, stat_desc) {
+ this.dyn_tree = dyn_tree; /* the dynamic tree */
+ this.max_code = 0; /* largest code with non zero frequency */
+ this.stat_desc = stat_desc; /* the corresponding static tree */
+}
+
+
+
+function d_code(dist) {
+ return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
+}
+
+
+/* ===========================================================================
+ * Output a short LSB first on the stream.
+ * IN assertion: there is enough room in pendingBuf.
+ */
+function put_short(s, w) {
+// put_byte(s, (uch)((w) & 0xff));
+// put_byte(s, (uch)((ush)(w) >> 8));
+ s.pending_buf[s.pending++] = (w) & 0xff;
+ s.pending_buf[s.pending++] = (w >>> 8) & 0xff;
+}
+
+
+/* ===========================================================================
+ * Send a value on a given number of bits.
+ * IN assertion: length <= 16 and value fits in length bits.
+ */
+function send_bits(s, value, length) {
+ if (s.bi_valid > (Buf_size - length)) {
+ s.bi_buf |= (value << s.bi_valid) & 0xffff;
+ put_short(s, s.bi_buf);
+ s.bi_buf = value >> (Buf_size - s.bi_valid);
+ s.bi_valid += length - Buf_size;
+ } else {
+ s.bi_buf |= (value << s.bi_valid) & 0xffff;
+ s.bi_valid += length;
+ }
+}
+
+
+function send_code(s, c, tree) {
+ send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);
+}
+
+
+/* ===========================================================================
+ * Reverse the first len bits of a code, using straightforward code (a faster
+ * method would use a table)
+ * IN assertion: 1 <= len <= 15
+ */
+function bi_reverse(code, len) {
+ var res = 0;
+ do {
+ res |= code & 1;
+ code >>>= 1;
+ res <<= 1;
+ } while (--len > 0);
+ return res >>> 1;
+}
+
+
+/* ===========================================================================
+ * Flush the bit buffer, keeping at most 7 bits in it.
+ */
+function bi_flush(s) {
+ if (s.bi_valid === 16) {
+ put_short(s, s.bi_buf);
+ s.bi_buf = 0;
+ s.bi_valid = 0;
+
+ } else if (s.bi_valid >= 8) {
+ s.pending_buf[s.pending++] = s.bi_buf & 0xff;
+ s.bi_buf >>= 8;
+ s.bi_valid -= 8;
+ }
+}
+
+
+/* ===========================================================================
+ * Compute the optimal bit lengths for a tree and update the total bit length
+ * for the current block.
+ * IN assertion: the fields freq and dad are set, heap[heap_max] and
+ * above are the tree nodes sorted by increasing frequency.
+ * OUT assertions: the field len is set to the optimal bit length, the
+ * array bl_count contains the frequencies for each bit length.
+ * The length opt_len is updated; static_len is also updated if stree is
+ * not null.
+ */
+function gen_bitlen(s, desc)
+// deflate_state *s;
+// tree_desc *desc; /* the tree descriptor */
+{
+ var tree = desc.dyn_tree;
+ var max_code = desc.max_code;
+ var stree = desc.stat_desc.static_tree;
+ var has_stree = desc.stat_desc.has_stree;
+ var extra = desc.stat_desc.extra_bits;
+ var base = desc.stat_desc.extra_base;
+ var max_length = desc.stat_desc.max_length;
+ var h; /* heap index */
+ var n, m; /* iterate over the tree elements */
+ var bits; /* bit length */
+ var xbits; /* extra bits */
+ var f; /* frequency */
+ var overflow = 0; /* number of elements with bit length too large */
+
+ for (bits = 0; bits <= MAX_BITS; bits++) {
+ s.bl_count[bits] = 0;
+ }
+
+ /* In a first pass, compute the optimal bit lengths (which may
+ * overflow in the case of the bit length tree).
+ */
+ tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */
+
+ for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {
+ n = s.heap[h];
+ bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;
+ if (bits > max_length) {
+ bits = max_length;
+ overflow++;
+ }
+ tree[n * 2 + 1]/*.Len*/ = bits;
+ /* We overwrite tree[n].Dad which is no longer needed */
+
+ if (n > max_code) { continue; } /* not a leaf node */
+
+ s.bl_count[bits]++;
+ xbits = 0;
+ if (n >= base) {
+ xbits = extra[n - base];
+ }
+ f = tree[n * 2]/*.Freq*/;
+ s.opt_len += f * (bits + xbits);
+ if (has_stree) {
+ s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);
+ }
+ }
+ if (overflow === 0) { return; }
+
+ // Trace((stderr,"\nbit length overflow\n"));
+ /* This happens for example on obj2 and pic of the Calgary corpus */
+
+ /* Find the first bit length which could increase: */
+ do {
+ bits = max_length - 1;
+ while (s.bl_count[bits] === 0) { bits--; }
+ s.bl_count[bits]--; /* move one leaf down the tree */
+ s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */
+ s.bl_count[max_length]--;
+ /* The brother of the overflow item also moves one step up,
+ * but this does not affect bl_count[max_length]
+ */
+ overflow -= 2;
+ } while (overflow > 0);
+
+ /* Now recompute all bit lengths, scanning in increasing frequency.
+ * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
+ * lengths instead of fixing only the wrong ones. This idea is taken
+ * from 'ar' written by Haruhiko Okumura.)
+ */
+ for (bits = max_length; bits !== 0; bits--) {
+ n = s.bl_count[bits];
+ while (n !== 0) {
+ m = s.heap[--h];
+ if (m > max_code) { continue; }
+ if (tree[m * 2 + 1]/*.Len*/ !== bits) {
+ // Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
+ s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;
+ tree[m * 2 + 1]/*.Len*/ = bits;
+ }
+ n--;
+ }
+ }
+}
+
+
+/* ===========================================================================
+ * Generate the codes for a given tree and bit counts (which need not be
+ * optimal).
+ * IN assertion: the array bl_count contains the bit length statistics for
+ * the given tree and the field len is set for all tree elements.
+ * OUT assertion: the field code is set for all tree elements of non
+ * zero code length.
+ */
+function gen_codes(tree, max_code, bl_count)
+// ct_data *tree; /* the tree to decorate */
+// int max_code; /* largest code with non zero frequency */
+// ushf *bl_count; /* number of codes at each bit length */
+{
+ var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */
+ var code = 0; /* running code value */
+ var bits; /* bit index */
+ var n; /* code index */
+
+ /* The distribution counts are first used to generate the code values
+ * without bit reversal.
+ */
+ for (bits = 1; bits <= MAX_BITS; bits++) {
+ next_code[bits] = code = (code + bl_count[bits - 1]) << 1;
+ }
+ /* Check that the bit counts in bl_count are consistent. The last code
+ * must be all ones.
+ */
+ //Assert (code + bl_count[MAX_BITS]-1 == (1<