From 521b81aec06883c1e286e4a789ec32f5a8d81973 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Mon, 26 Mar 2018 19:46:21 -0500 Subject: [PATCH] v0.35.2 --- .gitignore | 3 +- README.md | 31 + css/menupages.css | 54 +- dist/bundle.js | 67392 ++++++++++++++++--------------- index.html | 143 +- src/Augmentations.js | 173 +- src/CompanyManagement.js | 387 +- src/Constants.js | 43 +- src/Faction.js | 583 +- src/FactionInfo.js | 98 +- src/Gang.js | 13 +- src/Infiltration.js | 4 +- src/Literature.js | 41 + src/Location.js | 10 +- src/engine.js | 253 +- utils/HelperFunctions.js | 11 +- utils/StringHelperFunctions.js | 7 +- 17 files changed, 34992 insertions(+), 34254 deletions(-) create mode 100644 README.md diff --git a/.gitignore b/.gitignore index 4e1caf1bd..a250514d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ Changelog.txt Netburner.txt -README.md -/node_modules \ No newline at end of file +/node_modules diff --git a/README.md b/README.md new file mode 100644 index 000000000..36a1bf210 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Bitburner +Bitburner is a cyberpunk hacking-themed incremental game. The game can be +played [here](https://danielyxie.github.io/bitburner). + +# Documentation +The game's official documentation can be found [here](http://bitburner.readthedocs.io/en/latest/index.html). Please note that +this is still a work-in-progress and is in its early stages. + +The documentation is created using Sphinx and is hosted on Read The Docs. + +Anyone is welcome to contribute to the documentation by editing the source files +in /doc/ and then making a pull request with your changes/contributions. + +# Wiki +The game's wiki can be found [here](http://bitburner.wikia.com/wiki/Bitburner_Wiki). +Please note that the wiki is in the process of being deprecated. Eventually all of the +wiki content will be moved into the Read The Docs documentation. + +# Contributing +If you would like to make any small change or addition to the game, you may go ahead +and do so by submitting a pull request. + +You will retain all ownership of the Copyright of any contributions you make, +and will have the same rights to use or license your contributions. By +submitting a pull request you agree to grant me perpetual, worldwide, non-exclusive, +transferable, royalty-free, and irrevocable rights to use, publish, and distribute +your contributions to the project. A formal Contributor's License Agreement +will be drawn up in the future. + +If you would like to make significant contributions to the project as a +collaborator, please message me privately. diff --git a/css/menupages.css b/css/menupages.css index f84e5d7d0..93bdf5638 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -367,32 +367,17 @@ padding-top: 10px; } -#factions-list li { - padding: 6px; - margin: 6px; -} - -#faction-favor, #faction-reputation { - display: inline; -} - .faction-work-div { - overflow: hidden; width: 70%; height: 100%; } .faction-work-div-wrapper { - float: left; + overflow:hidden; border: 2px solid #333; - padding: 14px 6px 4px 6px; + padding: 6px; margin: 6px; -} - -#faction-hack-button, -#faction-fieldwork-button, -#faction-securitywork-button { - margin: 8px; + width:70%; } #faction-donate-amount-txt, @@ -408,18 +393,14 @@ width:50%; } -div.faction-clear { - clear: both; -} - #faction-container p, #faction-container pre { padding: 6px; margin: 6px; - width: 70%; } -#faction-info { +#faction-container pre { + width: 70%; white-space: pre-wrap; /* Since CSS 2.1 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ @@ -441,11 +422,6 @@ div.faction-clear { padding: 4px; } -#faction-augmentations-list > li{ - margin: 4px; - padding: 4px; -} - /* World */ #world-container li { margin: 0 0 15px 0; @@ -458,29 +434,13 @@ div.faction-clear { padding-top: 10px; } - -#augmentations-list li, -#queued-augmentations-list li { - width: 70%; - background-color: #333; -} - -#augmentations-list h2, -#augmentations-list p, -#queued-augmentations-list h2, -#queued-augmentations-list p { - margin: 4px; +.augmentations-list button, +.augmentations-list div { color: var(--my-font-color); padding: 8px; - width: 70%; - background-color: #333; text-decoration: none; } -#augmentations-list li p { - width: 95%; -} - /* Tutorial */ #tutorial-container { position: fixed; diff --git a/dist/bundle.js b/dist/bundle.js index 72722eefd..d6ccb00b8 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -60,7 +60,7 @@ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 4); +/******/ return __webpack_require__(__webpack_require__.s = 5); /******/ }) /************************************************************************/ /******/ ([ @@ -70,30 +70,30 @@ "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Player; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return loadPlayer; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Company_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CompanyManagement_js__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Crimes_js__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Gang_js__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Server_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Company_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CompanyManagement_js__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Crimes_js__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Gang_js__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Server_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__SourceFile_js__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_decimal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__SourceFile_js__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_decimal_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_15__utils_decimal_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__utils_numeral_min_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__utils_numeral_min_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_20__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__utils_StringHelperFunctions_js__ = __webpack_require__(6); @@ -2529,7 +2529,7 @@ function dialogBoxCreate(txt, preformatted=false) { -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), /* 2 */ @@ -2551,10 +2551,13 @@ function dialogBoxCreate(txt, preformatted=false) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return removeChildrenFromElement; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return createPopup; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return clearSelector; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__StringHelperFunctions_js__ = __webpack_require__(5); +/* unused harmony export exceptionAlert */ +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__DialogBox_js__ = __webpack_require__(1); //General helper functions + //Returns the size (number of keys) of an object function sizeOfObject(obj) { var size = 0, key; @@ -2608,7 +2611,7 @@ function removeElement(elem) { } function removeChildrenFromElement(el) { - if (Object(__WEBPACK_IMPORTED_MODULE_0__StringHelperFunctions_js__["g" /* isString */])(el)) { + if (Object(__WEBPACK_IMPORTED_MODULE_0__StringHelperFunctions_js__["f" /* isString */])(el)) { el = document.getElementById(el); } if (el == null) {return;} @@ -2761,17 +2764,508 @@ function powerOfTwo(n) { return n && (n & (n-1)) === 0; } +function exceptionAlert(e) { + Object(__WEBPACK_IMPORTED_MODULE_1__DialogBox_js__["a" /* dialogBoxCreate */])("Caught an exception: " + e + "

" + + "This is a bug, please report to game developer with this " + + "message as well as details about how to reproduce the bug.

" + + "If you want to be safe, I suggest refreshing the game WITHOUT saving so that your " + + "safe doesn't get corrupted"); +} + /***/ }), /* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var support = __webpack_require__(20); +var base64 = __webpack_require__(83); +var nodejsUtils = __webpack_require__(50); +var setImmediate = __webpack_require__(138); +var external = __webpack_require__(37); + + +/** + * Convert a string that pass as a "binary string": it should represent a byte + * array but may have > 255 char codes. Be sure to take only the first byte + * and returns the byte array. + * @param {String} str the string to transform. + * @return {Array|Uint8Array} the string in a binary format. + */ +function string2binary(str) { + var result = null; + if (support.uint8array) { + result = new Uint8Array(str.length); + } else { + result = new Array(str.length); + } + return stringToArrayLike(str, result); +} + +/** + * Create a new blob with the given content and the given type. + * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use + * an Uint8Array because the stock browser of android 4 won't accept it (it + * will be silently converted to a string, "[object Uint8Array]"). + * + * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge: + * when a large amount of Array is used to create the Blob, the amount of + * memory consumed is nearly 100 times the original data amount. + * + * @param {String} type the mime type of the blob. + * @return {Blob} the created blob. + */ +exports.newBlob = function(part, type) { + exports.checkSupport("blob"); + + try { + // Blob constructor + return new Blob([part], { + type: type + }); + } + catch (e) { + + try { + // deprecated, browser only, old way + var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder; + var builder = new Builder(); + builder.append(part); + return builder.getBlob(type); + } + catch (e) { + + // well, fuck ?! + throw new Error("Bug : can't construct the Blob."); + } + } + + +}; +/** + * The identity function. + * @param {Object} input the input. + * @return {Object} the same input. + */ +function identity(input) { + return input; +} + +/** + * Fill in an array with a string. + * @param {String} str the string to use. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated). + * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array. + */ +function stringToArrayLike(str, array) { + for (var i = 0; i < str.length; ++i) { + array[i] = str.charCodeAt(i) & 0xFF; + } + return array; +} + +/** + * An helper for the function arrayLikeToString. + * This contains static informations and functions that + * can be optimized by the browser JIT compiler. + */ +var arrayToStringHelper = { + /** + * Transform an array of int into a string, chunk by chunk. + * See the performances notes on arrayLikeToString. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. + * @param {String} type the type of the array. + * @param {Integer} chunk the chunk size. + * @return {String} the resulting string. + * @throws Error if the chunk is too big for the stack. + */ + stringifyByChunk: function(array, type, chunk) { + var result = [], k = 0, len = array.length; + // shortcut + if (len <= chunk) { + return String.fromCharCode.apply(null, array); + } + while (k < len) { + if (type === "array" || type === "nodebuffer") { + result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len)))); + } + else { + result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len)))); + } + k += chunk; + } + return result.join(""); + }, + /** + * Call String.fromCharCode on every item in the array. + * This is the naive implementation, which generate A LOT of intermediate string. + * This should be used when everything else fail. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. + * @return {String} the result. + */ + stringifyByChar: function(array){ + var resultStr = ""; + for(var i = 0; i < array.length; i++) { + resultStr += String.fromCharCode(array[i]); + } + return resultStr; + }, + applyCanBeUsed : { + /** + * true if the browser accepts to use String.fromCharCode on Uint8Array + */ + uint8array : (function () { + try { + return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1; + } catch (e) { + return false; + } + })(), + /** + * true if the browser accepts to use String.fromCharCode on nodejs Buffer. + */ + nodebuffer : (function () { + try { + return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1; + } catch (e) { + return false; + } + })() + } +}; + +/** + * Transform an array-like object to a string. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform. + * @return {String} the result. + */ +function arrayLikeToString(array) { + // Performances notes : + // -------------------- + // String.fromCharCode.apply(null, array) is the fastest, see + // see http://jsperf.com/converting-a-uint8array-to-a-string/2 + // but the stack is limited (and we can get huge arrays !). + // + // result += String.fromCharCode(array[i]); generate too many strings ! + // + // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2 + // TODO : we now have workers that split the work. Do we still need that ? + var chunk = 65536, + type = exports.getTypeOf(array), + canUseApply = true; + if (type === "uint8array") { + canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array; + } else if (type === "nodebuffer") { + canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer; + } + + if (canUseApply) { + while (chunk > 1) { + try { + return arrayToStringHelper.stringifyByChunk(array, type, chunk); + } catch (e) { + chunk = Math.floor(chunk / 2); + } + } + } + + // no apply or chunk error : slow and painful algorithm + // default browser on android 4.* + return arrayToStringHelper.stringifyByChar(array); +} + +exports.applyFromCharCode = arrayLikeToString; + + +/** + * Copy the data from an array-like to an other array-like. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array. + * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated. + * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array. + */ +function arrayLikeToArrayLike(arrayFrom, arrayTo) { + for (var i = 0; i < arrayFrom.length; i++) { + arrayTo[i] = arrayFrom[i]; + } + return arrayTo; +} + +// a matrix containing functions to transform everything into everything. +var transform = {}; + +// string to ? +transform["string"] = { + "string": identity, + "array": function(input) { + return stringToArrayLike(input, new Array(input.length)); + }, + "arraybuffer": function(input) { + return transform["string"]["uint8array"](input).buffer; + }, + "uint8array": function(input) { + return stringToArrayLike(input, new Uint8Array(input.length)); + }, + "nodebuffer": function(input) { + return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length)); + } +}; + +// array to ? +transform["array"] = { + "string": arrayLikeToString, + "array": identity, + "arraybuffer": function(input) { + return (new Uint8Array(input)).buffer; + }, + "uint8array": function(input) { + return new Uint8Array(input); + }, + "nodebuffer": function(input) { + return nodejsUtils.newBufferFrom(input); + } +}; + +// arraybuffer to ? +transform["arraybuffer"] = { + "string": function(input) { + return arrayLikeToString(new Uint8Array(input)); + }, + "array": function(input) { + return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength)); + }, + "arraybuffer": identity, + "uint8array": function(input) { + return new Uint8Array(input); + }, + "nodebuffer": function(input) { + return nodejsUtils.newBufferFrom(new Uint8Array(input)); + } +}; + +// uint8array to ? +transform["uint8array"] = { + "string": arrayLikeToString, + "array": function(input) { + return arrayLikeToArrayLike(input, new Array(input.length)); + }, + "arraybuffer": function(input) { + return input.buffer; + }, + "uint8array": identity, + "nodebuffer": function(input) { + return nodejsUtils.newBufferFrom(input); + } +}; + +// nodebuffer to ? +transform["nodebuffer"] = { + "string": arrayLikeToString, + "array": function(input) { + return arrayLikeToArrayLike(input, new Array(input.length)); + }, + "arraybuffer": function(input) { + return transform["nodebuffer"]["uint8array"](input).buffer; + }, + "uint8array": function(input) { + return arrayLikeToArrayLike(input, new Uint8Array(input.length)); + }, + "nodebuffer": identity +}; + +/** + * Transform an input into any type. + * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer. + * If no output type is specified, the unmodified input will be returned. + * @param {String} outputType the output type. + * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert. + * @throws {Error} an Error if the browser doesn't support the requested output type. + */ +exports.transformTo = function(outputType, input) { + if (!input) { + // undefined, null, etc + // an empty string won't harm. + input = ""; + } + if (!outputType) { + return input; + } + exports.checkSupport(outputType); + var inputType = exports.getTypeOf(input); + var result = transform[inputType][outputType](input); + return result; +}; + +/** + * Return the type of the input. + * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer. + * @param {Object} input the input to identify. + * @return {String} the (lowercase) type of the input. + */ +exports.getTypeOf = function(input) { + if (typeof input === "string") { + return "string"; + } + if (Object.prototype.toString.call(input) === "[object Array]") { + return "array"; + } + if (support.nodebuffer && nodejsUtils.isBuffer(input)) { + return "nodebuffer"; + } + if (support.uint8array && input instanceof Uint8Array) { + return "uint8array"; + } + if (support.arraybuffer && input instanceof ArrayBuffer) { + return "arraybuffer"; + } +}; + +/** + * Throw an exception if the type is not supported. + * @param {String} type the type to check. + * @throws {Error} an Error if the browser doesn't support the requested type. + */ +exports.checkSupport = function(type) { + var supported = support[type.toLowerCase()]; + if (!supported) { + throw new Error(type + " is not supported by this platform"); + } +}; + +exports.MAX_VALUE_16BITS = 65535; +exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1 + +/** + * Prettify a string read as binary. + * @param {string} str the string to prettify. + * @return {string} a pretty string. + */ +exports.pretty = function(str) { + var res = '', + code, i; + for (i = 0; i < (str || "").length; i++) { + code = str.charCodeAt(i); + res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase(); + } + return res; +}; + +/** + * Defer the call of a function. + * @param {Function} callback the function to call asynchronously. + * @param {Array} args the arguments to give to the callback. + */ +exports.delay = function(callback, args, self) { + setImmediate(function () { + callback.apply(self || null, args || []); + }); +}; + +/** + * Extends a prototype with an other, without calling a constructor with + * side effects. Inspired by nodejs' `utils.inherits` + * @param {Function} ctor the constructor to augment + * @param {Function} superCtor the parent constructor to use + */ +exports.inherits = function (ctor, superCtor) { + var Obj = function() {}; + Obj.prototype = superCtor.prototype; + ctor.prototype = new Obj(); +}; + +/** + * Merge the objects passed as parameters into a new one. + * @private + * @param {...Object} var_args All objects to merge. + * @return {Object} a new object with the data of the others. + */ +exports.extend = function() { + var result = {}, i, attr; + for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers + for (attr in arguments[i]) { + if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") { + result[attr] = arguments[i][attr]; + } + } + } + return result; +}; + +/** + * Transform arbitrary content into a Promise. + * @param {String} name a name for the content being processed. + * @param {Object} inputData the content to process. + * @param {Boolean} isBinary true if the content is not an unicode string + * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character. + * @param {Boolean} isBase64 true if the string content is encoded with base64. + * @return {Promise} a promise in a format usable by JSZip. + */ +exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) { + + // if inputData is already a promise, this flatten it. + var promise = external.Promise.resolve(inputData).then(function(data) { + + + var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1); + + if (isBlob && typeof FileReader !== "undefined") { + return new external.Promise(function (resolve, reject) { + var reader = new FileReader(); + + reader.onload = function(e) { + resolve(e.target.result); + }; + reader.onerror = function(e) { + reject(e.target.error); + }; + reader.readAsArrayBuffer(data); + }); + } else { + return data; + } + }); + + return promise.then(function(data) { + var dataType = exports.getTypeOf(data); + + if (!dataType) { + return external.Promise.reject( + new Error("Can't read the data of '" + name + "'. Is it " + + "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?") + ); + } + // special case : it's way easier to work with Uint8Array than with ArrayBuffer + if (dataType === "arraybuffer") { + data = exports.transformTo("uint8array", data); + } else if (dataType === "string") { + if (isBase64) { + data = base64.decode(data); + } + else if (isBinary) { + // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask + if (isOptimizedBinaryString !== true) { + // this is a string, not in a base64 format. + // Be sure that this is a correct "binary string" + data = string2binary(data); + } + } + } + return data; + }); +}; + + +/***/ }), +/* 4 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CONSTANTS; }); let CONSTANTS = { - Version: "0.35.1", + Version: "0.35.2", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -3910,76 +4404,73 @@ let CONSTANTS = { "World Stock Exchange account and TIX API Access
", LatestUpdate: - "v0.35.1
" + - "* You can now easily download all of your scripts/text files as zip folders. Use the 'help download' Terminal command for details
" + - "* Scripts are now downloaded with the .script.js extension at the end of their filename
" + - "* Corporation Management Changes:
" + - "*** Implemented Smart Supply unlock
" + - "*** Changed the way a division's Production Multiplier is calculated. It is now the sum of the individual Production Multiplier " + - "for every city. Therefore, it is now beneficial to open offices in different cities" + - "*** Several small UI/UX improvements
" + - "*** Numerous balance changes. The significant ones are listed below.
" + - "*** Product descriptions will now display their estimated market price
" + - "*** The sale price of Products can no longer be marked up as high as before
" + - "*** Scientific Research now affects the rating of Products
" + - "*** In general, the maximum amount of product you are able to sell is reduced
" + - "*** Sale bonus from advertising (popularity/awareness) now has diminishing returns rather than scaling linearly
" + - "* Experience gained during Infiltration now scales linearly based on the clearance level you reach. Compared to before, " + - "the experience gained will be much less at lower clearance levels, but much more at higher clearance levels
" + - "* The editor can now be used to edit both scripts and text files
" + - "* New Terminal config file that can be edited using the command 'nano .fconf'. Right now there is only one option, but there " + - "will be more in the future.
" + - "* You can now enable Bash-style Terminal hotkeys using the .fconf file referenced above
" + - "* Bug Fix: Fixed an issue with the UI elements of Gang Management persisting across different instances of BitNode-2" + "v0.35.2
" + + "* Corporation Changes:
" + + "*** Fixed an issue with Warehouse upgrade cost. Should now be significantly cheaper than before.
" + + "*** Scientific Research now has a slightly more significant effect on Product quality
" + + "*** The Energy and Water Utilities industries are now slightly more profitable
" + + "*** The Robotics and Computer Hardware industries are now less profitable
" + + "*** The Software industry is slightly less profitable
" + + "*** When selling Materials and Products, the 'PROD' qualifier can now be used " + + "to set dynamic sell amounts based on your production
" + + "*** Exporting MAX should now work properly
" + + "*** You can no longer export past storage limits
" + + "*** Scientific Research production reduced
" + + "*** Effects of AdVert. Inc upgrade were reduced, but the effect that popularity and " + + "awareness have on sales was increased to compensate (popularity/awareness numbers were getting " + + "too big with Advert. Inc)
" + + "*** Bug Fix: Products from Computer Hardware division should now properly have ratings
" + + "* Improved Augmentation UI/UX. Now contains collapsible headers and sort buttons
" + + "* Improved Faction Augmentations display UI/UX. Now contains sort buttons. There is also an option " + + "to disable confirmation when purchasing Augmentations
" } /***/ }), -/* 4 */ +/* 5 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_GameOptions_js__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_GameOptions_js__ = __webpack_require__(70); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_StringHelperFunctions_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(42); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Company_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__CompanyManagement_js__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Fconf_js__ = __webpack_require__(180); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Gang_js__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__HacknetNode_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__InteractiveTutorial_js__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Literature_js__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__Message_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__Missions_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(52); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ActiveScriptsUI_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Company_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__CompanyManagement_js__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Fconf_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Gang_js__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__HacknetNode_js__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__InteractiveTutorial_js__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Literature_js__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__Message_js__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__Missions_js__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptWorker_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__Prestige_js__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__RedPill_js__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__SaveObject_js__ = __webpack_require__(74); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__Script_js__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__Settings_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__SourceFile_js__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__Prestige_js__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__RedPill_js__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__SaveObject_js__ = __webpack_require__(180); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__Script_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__SourceFile_js__ = __webpack_require__(47); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__StockMarket_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__Terminal_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_33__StockMarket_js__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_34__Terminal_js__ = __webpack_require__(24); @@ -4261,7 +4752,7 @@ let Engine = { loadAugmentationsContent: function() { Engine.hideAllContent(); Engine.Display.augmentationsContent.style.display = "block"; - Engine.displayAugmentationsContent(); + Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["g" /* displayAugmentationsContent */])(); Engine.currentPage = Engine.Page.Augmentations; document.getElementById("augmentations-menu-link").classList.add("active"); }, @@ -4589,10 +5080,25 @@ let Engine = { break; } + //Generic Locations (common to every city): + // World Stock Exchange + // Corporation (if applicable) var genericLocationsList = document.getElementById("generic-locations-list"); genericLocationsList.style.display = "inline"; + Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(genericLocationsList); + var li = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li"); + li.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"World Stock Exchange", class:"a-link-button", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_15__Location_js__["a" /* Locations */].WorldStockExchange; + Engine.loadStockMarketContent(); + return false; + } + })); + genericLocationsList.appendChild(li); + if (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].corporation instanceof __WEBPACK_IMPORTED_MODULE_10__CompanyManagement_js__["a" /* Corporation */] && document.getElementById("location-corporation-button") == null) { - var li = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li", {}); + var li = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li"); li.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { innerText:__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].corporation.name, id:"location-corporation-button", class:"a-link-button", @@ -4606,189 +5112,80 @@ let Engine = { }, displayFactionsInfo: function() { - //Clear the list of joined factions - var factionsList = document.getElementById("factions-list"); - while (factionsList.firstChild) { - factionsList.removeChild(factionsList.firstChild); - } + Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(Engine.Display.factionsContent); - //Re-add a link for each faction you are a member of + //Factions + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Factions" + })); + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Lists all factions you have joined" + })); + var factionsList = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("ul"); + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("br")); + + //Add a button for each faction you are a member of for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factions.length; ++i) { (function () { var factionName = __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factions[i]; - //Add the faction to the Factions page content - var item = document.createElement("li"); - var aElem = document.createElement("a"); - aElem.setAttribute("class", "a-link-button"); - aElem.innerHTML = factionName; - aElem.addEventListener("click", function() { - Engine.loadFactionContent(); - Object(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["c" /* displayFactionContent */])(factionName); - return false; - }); - item.appendChild(aElem); - factionsList.appendChild(item); + factionsList.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:factionName, padding:"4px", margin:"4px", + display:"inline-block", + clickListener:()=>{ + Engine.loadFactionContent(); + Object(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["c" /* displayFactionContent */])(factionName); + return false; + } + })); + factionsList.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("br")); }()); //Immediate invocation } + Engine.Display.factionsContent.appendChild(factionsList); + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("br")); - //Clear the list of invitations - var invitationsList = document.getElementById("outstanding-faction-invitations-list"); - while (invitationsList.firstChild) { - invitationsList.removeChild(invitationsList.firstChild); - } + //Invited Factions + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Outstanding Faction Invitations" + })); + Engine.Display.factionsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", { + width:"70%", + innerText:"Lists factions you have been invited to, as well as " + + "factions you have previously rejected. You can accept " + + "these faction invitations at any time." + })); + var invitationsList = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("ul"); - //Add a link to accept for each faction you have invitiations for + //Add a button to accept for each faction you have invitiations for for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations.length; ++i) { (function () { var factionName = __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations[i]; - var item = document.createElement("li"); - - var pElem = document.createElement("p"); - pElem.innerText = factionName; - pElem.style.display = "inline"; - pElem.style.margin = "4px"; - pElem.style.padding = "4px"; - - var aElem = document.createElement("a"); - aElem.innerText = "Accept Faction Invitation"; - aElem.setAttribute("class", "a-link-button"); - aElem.style.display = "inline"; - aElem.style.margin = "4px"; - aElem.style.padding = "4px"; - aElem.addEventListener("click", function() { - Object(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["h" /* joinFaction */])(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["b" /* Factions */][factionName]); - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations[i] == factionName) { - __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations.splice(i, 1); - break; + var item = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li", {padding:"6px", margin:"6px"}); + item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:factionName, display:"inline", margin:"4px", padding:"4px" + })); + item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Accept Faction Invitation", + class:"a-link-button", display:"inline", margin:"4px", padding:"4px", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["h" /* joinFaction */])(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["b" /* Factions */][factionName]); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations[i] == factionName) { + __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].factionInvitations.splice(i, 1); + break; + } } + Engine.displayFactionsInfo(); + return false; } - Engine.displayFactionsInfo(); - return false; - }); + })); - item.appendChild(pElem); - item.appendChild(aElem); - item.style.margin = "6px"; - item.style.padding = "6px"; invitationsList.appendChild(item); }()); } - }, - displayAugmentationsContent: function() { - Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(Engine.Display.augmentationsContent); - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerText:"Purchased Augmentations" - })); - - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("pre", { - width:"70%", whiteSpace:"pre-wrap", display:"block", - innerText:"Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.\n" + - "WARNING: Installing your Augmentations resets most of your progress, including:\n\n" + - "Stats/Skill levels and Experience\n" + - "Money\n" + - "Scripts on every computer but your home computer\n" + - "Purchased servers\n" + - "Hacknet Nodes\n" + - "Faction/Company reputation\n" + - "Stocks\n\n" + - "Installing Augmentations lets you start over with the perks and benefits granted by all " + - "of the Augmentations you have ever installed. Also, you will keep any scripts and RAM/Core upgrades " + - "on your home computer (but you will lose all programs besides NUKE.exe)." - })); - - //Purchased/queued augmentations - var queuedAugmentationsList = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("ul", { - id:"queued-augmentations-list" - }); - - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { - var augName = __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].queuedAugmentations[i].name; - var aug = __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["c" /* Augmentations */][augName]; - - var item = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li", {class:"installed-augmentation"}); - var displayName = augName; - if (augName === __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { - displayName += " - Level " + (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].queuedAugmentations[i].level); - } - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h2", {innerHTML:displayName})); - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", {innerHTML:aug.info})); - - queuedAugmentationsList.appendChild(item); - } - Engine.Display.augmentationsContent.appendChild(queuedAugmentationsList); - - //Install Augmentations button - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Install Augmentations", - tooltip:"'I never asked for this'", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["h" /* installAugmentations */])(); - return false; - } - })); - - //Backup button - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button flashing-button", innerText:"Backup Save (Export)", - tooltip:"It's always a good idea to backup/export your save!", - clickListener:()=>{ - __WEBPACK_IMPORTED_MODULE_27__SaveObject_js__["b" /* saveObject */].exportGame(); - return false; - } - })); - - //Installed augmentations list - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerText:"Installed Augmentations" - })); - Engine.Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", { - width:"70%", whiteSpace:"pre-wrap", - innerText:"List of all Augmentations (including Source Files) that have been " + - "installed. You have gained the effects of these Augmentations" - })); - - var augmentationsList = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("ul", { - id:"augmentations-list" - }); - - //Source Files - Temporary...Will probably put in a separate pane Later - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].sourceFiles.length; ++i) { - var srcFileKey = "SourceFile" + __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].sourceFiles[i].n; - var sourceFileObject = __WEBPACK_IMPORTED_MODULE_31__SourceFile_js__["b" /* SourceFiles */][srcFileKey]; - if (sourceFileObject == null) { - console.log("ERROR: Invalid source file number: " + __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].sourceFiles[i].n); - continue; - } - var item = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li", {class:"installed-augmentation", }); - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h2", { - innerHTML:sourceFileObject.name + "
" + "Level " + (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].sourceFiles[i].lvl) + " / 3", - })); - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML:sourceFileObject.info, - })); - - augmentationsList.appendChild(item); - } - - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].augmentations.length; ++i) { - var augName = __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].augmentations[i].name; - var aug = __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["c" /* Augmentations */][augName]; - - var item = Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("li", {class:"installed-augmentation"}); - var displayName = augName; - if (augName === __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { - displayName += " - Level " + (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].augmentations[i].level); - } - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("h2", {innerHTML:displayName})); - item.appendChild(Object(__WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__["f" /* createElement */])("p", {innerHTML:aug.info})); - - augmentationsList.appendChild(item); - } - Engine.Display.augmentationsContent.appendChild(augmentationsList); + Engine.Display.factionsContent.appendChild(invitationsList); }, displayTutorialContent: function() { @@ -5194,7 +5591,7 @@ let Engine = { Engine.setDisplayElements(); //Sets variables for important DOM elements Engine.init(); //Initialize buttons, work, etc. __WEBPACK_IMPORTED_MODULE_9__Company_js__["d" /* CompanyPositions */].init(); - Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["g" /* initAugmentations */])(); //Also calls Player.reapplyAllAugmentations() + Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["h" /* initAugmentations */])(); //Also calls Player.reapplyAllAugmentations() __WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].reapplyAllSourceFiles(); Object(__WEBPACK_IMPORTED_MODULE_33__StockMarket_js__["h" /* initStockSymbols */])(); if (__WEBPACK_IMPORTED_MODULE_24__Player_js__["a" /* Player */].hasWseAccount) { @@ -5282,7 +5679,7 @@ let Engine = { Object(__WEBPACK_IMPORTED_MODULE_9__Company_js__["h" /* initCompanies */])(); Object(__WEBPACK_IMPORTED_MODULE_13__Faction_js__["f" /* initFactions */])(); __WEBPACK_IMPORTED_MODULE_9__Company_js__["d" /* CompanyPositions */].init(); - Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["g" /* initAugmentations */])(); + Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["h" /* initAugmentations */])(); Object(__WEBPACK_IMPORTED_MODULE_20__Message_js__["d" /* initMessages */])(); Object(__WEBPACK_IMPORTED_MODULE_33__StockMarket_js__["h" /* initStockSymbols */])(); Object(__WEBPACK_IMPORTED_MODULE_19__Literature_js__["a" /* initLiterature */])(); @@ -5328,61 +5725,47 @@ let Engine = { Engine.currentPage = Engine.Page.Terminal; Engine.Display.characterContent = document.getElementById("character-container"); - //Engine.Display.characterContent.style.visibility = "hidden"; Engine.Display.characterContent.style.display = "none"; Engine.Display.scriptEditorContent = document.getElementById("script-editor-container"); - //Engine.Display.scriptEditorContent.style.visibility = "hidden"; Engine.Display.scriptEditorContent.style.display = "none"; Engine.Display.activeScriptsContent = document.getElementById("active-scripts-container"); - //Engine.Display.activeScriptsContent.style.visibility = "hidden"; Engine.Display.activeScriptsContent.style.display = "none"; Engine.Display.hacknetNodesContent = document.getElementById("hacknet-nodes-container"); - //Engine.Display.hacknetNodesContent.style.visibility = "hidden"; Engine.Display.hacknetNodesContent.style.display = "none"; Engine.Display.worldContent = document.getElementById("world-container"); - //Engine.Display.worldContent.style.visibility = "hidden"; Engine.Display.worldContent.style.display = "none"; Engine.Display.createProgramContent = document.getElementById("create-program-container"); - //Engine.Display.createProgramContent.style.visibility = "hidden"; Engine.Display.createProgramContent.style.display = "none"; Engine.Display.factionsContent = document.getElementById("factions-container"); - //Engine.Display.factionsContent.style.visibility = "hidden"; Engine.Display.factionsContent.style.display = "none"; Engine.Display.factionContent = document.getElementById("faction-container"); - //Engine.Display.factionContent.style.visibility = "hidden"; Engine.Display.factionContent.style.display = "none"; Engine.Display.factionAugmentationsContent = document.getElementById("faction-augmentations-container"); - //Engine.Display.factionAugmentationsContent.style.visibility = "hidden"; Engine.Display.factionAugmentationsContent.style.display = "none"; Engine.Display.augmentationsContent = document.getElementById("augmentations-container"); - //Engine.Display.augmentationsContent.style.visibility = "hidden"; Engine.Display.augmentationsContent.style.display = "none"; Engine.Display.tutorialContent = document.getElementById("tutorial-container"); - //Engine.Display.tutorialContent.style.visibility = "hidden"; Engine.Display.tutorialContent.style.display = "none"; Engine.Display.infiltrationContent = document.getElementById("infiltration-container"); - //Engine.Display.infiltrationContent.style.visibility = "hidden"; Engine.Display.infiltrationContent.style.display = "none"; Engine.Display.stockMarketContent = document.getElementById("stock-market-container"); - //Engine.Display.stockMarketContent.style.visibility = "hidden"; Engine.Display.stockMarketContent.style.display = "none"; Engine.Display.missionContent = document.getElementById("mission-container"); - //Engine.Display.missionContent.style.visibility = "hidden"; Engine.Display.missionContent.style.display = "none"; //Character info @@ -5789,18 +6172,17 @@ window.onload = function() { -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), -/* 5 */ +/* 6 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* unused harmony export getIndicesOf */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return convertTimeMsToTimeElapsedString; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return longestCommonStart; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return isString; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isPositiveNumber; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return longestCommonStart; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isString; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return containsAllStrings; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return formatNumber; }); /* unused harmony export numOccurrences */ @@ -5880,11 +6262,6 @@ function isString(str) { return (typeof str === 'string' || str instanceof String); } -//Returns true if string contains only digits (meaning it would be a positive number) -function isPositiveNumber(str) { - return /^\d+$/.test(str); -} - //Returns whether an array contains entirely of string objects function containsAllStrings(arr) { return arr.every(isString); @@ -5964,7 +6341,7 @@ function generateRandomString(n) { /***/ }), -/* 6 */ +/* 7 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -5978,15 +6355,15 @@ function generateRandomString(n) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return initForeignServers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return prestigeAllServers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return prestigeHomeComputer; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Script_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Script_js__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SpecialServerIps_js__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(9); @@ -6791,7 +7168,7 @@ Directory.prototype.getPath = function(name) { /***/ }), -/* 7 */ +/* 8 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -7082,7 +7459,7 @@ function initBitNodeMultipliers() { /***/ }), -/* 8 */ +/* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -7163,7 +7540,277 @@ function Generic_fromJSON(ctor, data) { /***/ }), -/* 9 */ +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/** + * A worker that does nothing but passing chunks to the next one. This is like + * a nodejs stream but with some differences. On the good side : + * - it works on IE 6-9 without any issue / polyfill + * - it weights less than the full dependencies bundled with browserify + * - it forwards errors (no need to declare an error handler EVERYWHERE) + * + * A chunk is an object with 2 attributes : `meta` and `data`. The former is an + * object containing anything (`percent` for example), see each worker for more + * details. The latter is the real data (String, Uint8Array, etc). + * + * @constructor + * @param {String} name the name of the stream (mainly used for debugging purposes) + */ +function GenericWorker(name) { + // the name of the worker + this.name = name || "default"; + // an object containing metadata about the workers chain + this.streamInfo = {}; + // an error which happened when the worker was paused + this.generatedError = null; + // an object containing metadata to be merged by this worker into the general metadata + this.extraStreamInfo = {}; + // true if the stream is paused (and should not do anything), false otherwise + this.isPaused = true; + // true if the stream is finished (and should not do anything), false otherwise + this.isFinished = false; + // true if the stream is locked to prevent further structure updates (pipe), false otherwise + this.isLocked = false; + // the event listeners + this._listeners = { + 'data':[], + 'end':[], + 'error':[] + }; + // the previous worker, if any + this.previous = null; +} + +GenericWorker.prototype = { + /** + * Push a chunk to the next workers. + * @param {Object} chunk the chunk to push + */ + push : function (chunk) { + this.emit("data", chunk); + }, + /** + * End the stream. + * @return {Boolean} true if this call ended the worker, false otherwise. + */ + end : function () { + if (this.isFinished) { + return false; + } + + this.flush(); + try { + this.emit("end"); + this.cleanUp(); + this.isFinished = true; + } catch (e) { + this.emit("error", e); + } + return true; + }, + /** + * End the stream with an error. + * @param {Error} e the error which caused the premature end. + * @return {Boolean} true if this call ended the worker with an error, false otherwise. + */ + error : function (e) { + if (this.isFinished) { + return false; + } + + if(this.isPaused) { + this.generatedError = e; + } else { + this.isFinished = true; + + this.emit("error", e); + + // in the workers chain exploded in the middle of the chain, + // the error event will go downward but we also need to notify + // workers upward that there has been an error. + if(this.previous) { + this.previous.error(e); + } + + this.cleanUp(); + } + return true; + }, + /** + * Add a callback on an event. + * @param {String} name the name of the event (data, end, error) + * @param {Function} listener the function to call when the event is triggered + * @return {GenericWorker} the current object for chainability + */ + on : function (name, listener) { + this._listeners[name].push(listener); + return this; + }, + /** + * Clean any references when a worker is ending. + */ + cleanUp : function () { + this.streamInfo = this.generatedError = this.extraStreamInfo = null; + this._listeners = []; + }, + /** + * Trigger an event. This will call registered callback with the provided arg. + * @param {String} name the name of the event (data, end, error) + * @param {Object} arg the argument to call the callback with. + */ + emit : function (name, arg) { + if (this._listeners[name]) { + for(var i = 0; i < this._listeners[name].length; i++) { + this._listeners[name][i].call(this, arg); + } + } + }, + /** + * Chain a worker with an other. + * @param {Worker} next the worker receiving events from the current one. + * @return {worker} the next worker for chainability + */ + pipe : function (next) { + return next.registerPrevious(this); + }, + /** + * Same as `pipe` in the other direction. + * Using an API with `pipe(next)` is very easy. + * Implementing the API with the point of view of the next one registering + * a source is easier, see the ZipFileWorker. + * @param {Worker} previous the previous worker, sending events to this one + * @return {Worker} the current worker for chainability + */ + registerPrevious : function (previous) { + if (this.isLocked) { + throw new Error("The stream '" + this + "' has already been used."); + } + + // sharing the streamInfo... + this.streamInfo = previous.streamInfo; + // ... and adding our own bits + this.mergeStreamInfo(); + this.previous = previous; + var self = this; + previous.on('data', function (chunk) { + self.processChunk(chunk); + }); + previous.on('end', function () { + self.end(); + }); + previous.on('error', function (e) { + self.error(e); + }); + return this; + }, + /** + * Pause the stream so it doesn't send events anymore. + * @return {Boolean} true if this call paused the worker, false otherwise. + */ + pause : function () { + if(this.isPaused || this.isFinished) { + return false; + } + this.isPaused = true; + + if(this.previous) { + this.previous.pause(); + } + return true; + }, + /** + * Resume a paused stream. + * @return {Boolean} true if this call resumed the worker, false otherwise. + */ + resume : function () { + if(!this.isPaused || this.isFinished) { + return false; + } + this.isPaused = false; + + // if true, the worker tried to resume but failed + var withError = false; + if(this.generatedError) { + this.error(this.generatedError); + withError = true; + } + if(this.previous) { + this.previous.resume(); + } + + return !withError; + }, + /** + * Flush any remaining bytes as the stream is ending. + */ + flush : function () {}, + /** + * Process a chunk. This is usually the method overridden. + * @param {Object} chunk the chunk to process. + */ + processChunk : function(chunk) { + this.push(chunk); + }, + /** + * Add a key/value to be added in the workers chain streamInfo once activated. + * @param {String} key the key to use + * @param {Object} value the associated value + * @return {Worker} the current worker for chainability + */ + withStreamInfo : function (key, value) { + this.extraStreamInfo[key] = value; + this.mergeStreamInfo(); + return this; + }, + /** + * Merge this worker's streamInfo into the chain's streamInfo. + */ + mergeStreamInfo : function () { + for(var key in this.extraStreamInfo) { + if (!this.extraStreamInfo.hasOwnProperty(key)) { + continue; + } + this.streamInfo[key] = this.extraStreamInfo[key]; + } + }, + + /** + * Lock the stream to prevent further updates on the workers chain. + * After calling this method, all calls to pipe will fail. + */ + lock: function () { + if (this.isLocked) { + throw new Error("The stream '" + this + "' has already been used."); + } + this.isLocked = true; + if (this.previous) { + this.previous.lock(); + } + }, + + /** + * + * Pretty print the workers chain. + */ + toString : function () { + var me = "Worker " + this.name; + if (this.previous) { + return this.previous + " -> " + me; + } else { + return me; + } + } +}; + +module.exports = GenericWorker; + + +/***/ }), +/* 11 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @@ -17534,11 +18181,11 @@ return jQuery; /***/ }), -/* 10 */ +/* 12 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getNextNeurofluxLevel; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getNextNeurofluxLevel; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Factions; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return initFactions; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return inviteToFaction; }); @@ -17549,22 +18196,22 @@ return jQuery; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Faction; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return purchaseAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return factionExists; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__FactionInfo_js__ = __webpack_require__(49); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Missions_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__FactionInfo_js__ = __webpack_require__(104); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Missions_js__ = __webpack_require__(44); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Settings_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_FactionInvitationBox_js__ = __webpack_require__(73); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_FactionInvitationBox_js__ = __webpack_require__(179); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__ = __webpack_require__(15); @@ -17584,25 +18231,6 @@ return jQuery; - -//Netburner Faction class -function factionInit() { - $('#faction-donate-input').on('input', function() { - if (__WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Page.Faction) { - var val = document.getElementById("faction-donate-input").value; - if (Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["f" /* isPositiveNumber */])(val)) { - var numMoneyDonate = Number(val); - document.getElementById("faction-donate-rep-gain").innerHTML = - "This donation will result in " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(numMoneyDonate/1000000 * __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].faction_rep_mult, 3) + " reputation gain"; - } else { - document.getElementById("faction-donate-rep-gain").innerHTML = - "This donation will result in 0 reputation gain"; - } - } - }); -} -document.addEventListener("DOMContentLoaded", factionInit, false); - function Faction(name="") { this.name = name; this.augmentations = []; //Name of augmentation only @@ -17963,6 +18591,7 @@ function inviteToFaction(faction) { if (__WEBPACK_IMPORTED_MODULE_8__Settings_js__["a" /* Settings */].SuppressFactionInvites) { faction.alreadyInvited = true; __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].factionInvitations.push(faction.name); + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadFactionsContent(); } else { Object(__WEBPACK_IMPORTED_MODULE_10__utils_FactionInvitationBox_js__["a" /* factionInvitationBoxCreate */])(faction); } @@ -18007,92 +18636,206 @@ function joinFaction(faction) { //Displays the HTML content for a specific faction function displayFactionContent(factionName) { var faction = Factions[factionName]; - document.getElementById("faction-name").innerHTML = factionName; - document.getElementById("faction-info").innerHTML = "" + faction.info + ""; - var repGain = faction.getFavorGain(); - if (repGain.length != 2) {repGain = 0;} - repGain = repGain[0]; - document.getElementById("faction-reputation").innerHTML = "Reputation: " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(faction.playerReputation, 4) + - "You will earn " + - Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 4) + - " faction favor upon resetting after installing an Augmentation"; - document.getElementById("faction-favor").innerHTML = "Faction Favor: " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(faction.favor, 4) + - "Faction favor increases the rate at which " + - "you earn reputation for this faction by 1% per favor. Faction favor " + - "is gained whenever you reset after installing an Augmentation. The amount of " + - "favor you gain depends on how much reputation you have with the faction"; + if (faction == null) { + throw new Error("Invalid factionName passed into displayFactionContent: " + factionName); + } + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(__WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionContent); + var elements = []; - var hackMissionDiv = document.getElementById("faction-hack-mission-div"); - var hackDiv = document.getElementById("faction-hack-div"); - var fieldWorkDiv = document.getElementById("faction-fieldwork-div"); - var securityWorkDiv = document.getElementById("faction-securitywork-div"); - var donateDiv = document.getElementById("faction-donate-div"); - var gangDiv = document.getElementById("faction-gang-div"); + //Header and faction info + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:factionName + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("pre", { + innerHTML:"" + faction.info + "" + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"---------------", + })); - var newHackMissionButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-hack-mission-button"); - var newHackButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-hack-button"); - var newFieldWorkButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-fieldwork-button"); - var newSecurityWorkButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-securitywork-button"); - var newDonateWorkButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-donate-button"); - newHackMissionButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadMissionContent(); - var mission = new __WEBPACK_IMPORTED_MODULE_6__Missions_js__["a" /* HackingMission */](faction.playerReputation, faction); - Object(__WEBPACK_IMPORTED_MODULE_6__Missions_js__["d" /* setInMission */])(true, mission); //Sets inMission flag to true - mission.init(); - return false; + //Faction reputation and favor + var favorGain = faction.getFavorGain(); + if (favorGain.length != 2) {favorGain = 0;} + favorGain = favorGain[0]; + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText: "Reputation: " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(faction.playerReputation, 4), + tooltip:"You will earn " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(favorGain, 4) + + " faction favor upon resetting after installing an Augmentation" + })) + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"---------------", + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Faction Favor: " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(faction.favor, 4), + tooltip:"Faction favor increases the rate at which " + + "you earn reputation for this faction by 1% per favor. Faction favor " + + "is gained whenever you reset after installing an Augmentation. The amount of " + + "favor you gain depends on how much reputation you have with the faction" + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"---------------", + })); + + //Faction Work Description Text + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("pre", { + id:"faction-work-description-text", + innerText:"Perform work/carry out assignments for your faction to help further its cause! By doing so " + + "you will earn reputation for your faction. You will also gain reputation passively over time, " + + "although at a very slow rate. Earning reputation will allow you to purchase Augmentations " + + "through this faction, which are powerful upgrades that enhance your abilities. Note that you cannot " + + "use your terminal or create scripts when you are performing a task!" + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("br")); + + //Hacking Mission Option + var hackMissionDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-hack-mission-div", class:"faction-work-div", }); - - newHackButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionHackWork(faction); - return false; - }); - - newFieldWorkButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionFieldWork(faction); - return false; - }); - - newSecurityWorkButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionSecurityWork(faction); - return false; - }); - - newDonateWorkButton.addEventListener("click", function() { - var donateAmountVal = document.getElementById("faction-donate-input").value; - if (Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["f" /* isPositiveNumber */])(donateAmountVal)) { - var numMoneyDonate = Number(donateAmountVal); - if (__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].money.lt(numMoneyDonate)) { - Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You cannot afford to donate this much money!"); - return; - } - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].loseMoney(numMoneyDonate); - var repGain = numMoneyDonate / 1000000 * __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].faction_rep_mult; - faction.playerReputation += repGain; - Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You just donated $" + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(numMoneyDonate, 2) + " to " + - faction.name + " to gain " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 3) + " reputation"); - displayFactionContent(factionName); - } else { - Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount entered!"); - } - return false; - }); - - - var newPurchaseAugmentationsButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-purchase-augmentations"); - newPurchaseAugmentationsButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].hideAllContent(); - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionAugmentationsContent.style.display = "block"; - - var newBackButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-augmentations-back-button"); - newBackButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadFactionContent(); - displayFactionContent(factionName); + var hackMissionDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + hackMissionDiv.appendChild(hackMissionDivWrapper); + hackMissionDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Hacking Mission", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadMissionContent(); + var mission = new __WEBPACK_IMPORTED_MODULE_6__Missions_js__["a" /* HackingMission */](faction.playerReputation, faction); + Object(__WEBPACK_IMPORTED_MODULE_6__Missions_js__["d" /* setInMission */])(true, mission); //Sets inMission flag to true + mission.init(); return false; - }); - displayFactionAugmentations(factionName); - return false; - }); + } + })); + hackMissionDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Attempt a hacking mission for your faction. " + + "A mission is a mini game that, if won, earns you " + + "significant reputation with this faction. (Recommended hacking level: 200+)" + })); + elements.push(hackMissionDiv); + //Hacking Contracts Option + var hackDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-hack-div", class:"faction-work-div", + }); + var hackDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + hackDiv.appendChild(hackDivWrapper); + hackDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Hacking Contracts", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionHackWork(faction); + return false; + } + })); + hackDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Complete hacking contracts for your faction. " + + "Your effectiveness, which determines how much " + + "reputation you gain for this faction, is based on your hacking skill. " + + "You will gain hacking exp." + })); + elements.push(hackDiv); + + //Field Work Option + var fieldWorkDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-fieldwork-div", class:"faction-work-div" + }); + var fieldWorkDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + fieldWorkDiv.appendChild(fieldWorkDivWrapper); + fieldWorkDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Field Work", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionFieldWork(faction); + return false; + } + })); + fieldWorkDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Carry out field missions for your faction. " + + "Your effectiveness, which determines how much " + + "reputation you gain for this faction, is based on all of your stats. " + + "You will gain exp for all stats." + })); + elements.push(fieldWorkDiv); + + //Security Work Option + var securityWorkDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-securitywork-div", class:"faction-work-div" + }); + var securityWorkDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + securityWorkDiv.appendChild(securityWorkDivWrapper); + securityWorkDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Security Work", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startFactionSecurityWork(faction); + return false; + } + })); + securityWorkDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Serve in a security detail for your faction. " + + "Your effectiveness, which determines how much " + + "reputation you gain for this faction, is based on your combat stats. " + + "You will gain exp for all combat stats." + })); + elements.push(securityWorkDiv); + + //Donate for reputation + var donateDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-donate-div", class:"faction-work-div" + }); + var donateDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + donateDiv.appendChild(donateDivWrapper); + var donateRepGain = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"This donation will result in 0 reputation gain" + }); + var donateAmountInput = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("input", { + placeholder:"Donation amount", + inputListener:()=>{ + var amt = parseFloat(donateAmountInput.value); + if (isNaN(amt) || amt < 0) { + donateRepGain.innerText = "Invalid donate amount entered!"; + } else { + var repGain = amt / 1e6 * __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].faction_rep_mult; + donateRepGain.innerText = "This donation will result in " + + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 3) + " reputation gain"; + } + }, + }); + donateDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Donate Money", + clickListener:()=>{ + var amt = parseFloat(donateAmountInput.value); + if (isNaN(amt) || amt < 0) { + Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount entered!"); + } else if (__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].money.lt(amt)) { + Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You cannot afford to donate this much money!"); + } else { + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].loseMoney(amt); + var repGain = amt / 1e6 * __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].faction_rep_mult; + faction.playerReputation += repGain; + Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You just donated " + __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js___default()(amt).format("$0.000a") + " to " + + faction.name + " to gain " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 3) + " reputation"); + displayFactionContent(factionName); + } + } + })); + donateDivWrapper.appendChild(donateAmountInput); + donateDivWrapper.appendChild(donateRepGain); + elements.push(donateDiv); + + //Purchase Augmentations + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("pre", { + innerHTML: "
As your reputation with this faction rises, you will " + + "unlock Augmentations, which you can purchase to enhance " + + "your abilities.

" + })); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Purchase Augmentations", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].hideAllContent(); + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionAugmentationsContent.style.display = "block"; + + + displayFactionAugmentations(factionName); + return false; + } + })); + + //Gang (BitNode-2) if (__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].bitNodeN == 2 && (factionName == "Slum Snakes" || factionName == "Tetrads" || factionName == "The Syndicate" || factionName == "The Dark Army" || factionName == "Speakers for the Dead" || factionName == "NiteSec" || factionName == "The Black Hand")) { @@ -18103,72 +18846,54 @@ function displayFactionContent(factionName) { securityWorkDiv.style.display = "none"; donateDiv.style.display = "none"; - var gangDiv = document.getElementById("faction-gang-div"); + //Create the 'Manage Gang' button + var gangDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"faction-gang-div", class:"faction-work-div", display:"inline" + }); + var gangDivWrapper = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"faction-work-div-wrapper"}); + gangDiv.appendChild(gangDivWrapper); + gangDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Manage Gang", + clickListener:()=>{ + if (!__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].inGang()) { + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["d" /* yesNoBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["c" /* yesNoBoxGetNoButton */])(); + yesBtn.innerHTML = "Create Gang"; + noBtn.innerHTML = "Cancel"; + yesBtn.addEventListener("click", () => { + var hacking = false; + if (factionName === "NiteSec" || factionName === "The Black Hand") {hacking = true;} + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startGang(factionName, hacking); + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadGangContent(); + Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); + }); + noBtn.addEventListener("click", () => { + Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["b" /* yesNoBoxCreate */])("Would you like to create a new Gang with " + factionName + "?

" + + "Note that this will prevent you from creating a Gang with any other Faction until " + + "this BitNode is destroyed. There are NO differences between the Factions you can " + + "create a Gang with and each of these Factions have all Augmentations available"); + } else { + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadGangContent(); + } + } + })); + gangDivWrapper.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Create and manage a gang for this Faction. " + + "Gangs will earn you money and faction reputation." + })); + //Manage Gang button goes before Faction work stuff + elements.splice(7, 1, gangDiv); if (__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].inGang() && __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].gang.facName != factionName) { //If the player has a gang but its not for this faction - if (gangDiv) { - gangDiv.style.display = "none"; - } - return; + gangDiv.style.display = "none"; } - //Create the "manage gang" button if it doesn't exist - if (gangDiv == null) { - gangDiv = document.createElement("div"); - gangDiv.setAttribute("id", "faction-gang-div"); - gangDiv.setAttribute("class", "faction-work-div"); - gangDiv.style.display = "inline"; - - gangDiv.innerHTML = - '
' + - 'Manage Gang' + - '

' + - 'Create and manage a gang for this Faction. ' + - 'Gangs will earn you money and faction reputation.' + - '

' + - '
' + - '
'; - - var descText = document.getElementById("faction-work-description-text"); - if (descText) { - descText.parentNode.insertBefore(gangDiv, descText.nextSibling); - } else { - console.log("ERROR: faciton-work-description-text not found"); - Object(__WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error loading this page. This is a bug please report to game developer"); - return; - } + //Display all elements + for (var i = 0; i < elements.length; ++i) { + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionContent.appendChild(elements[i]); } - gangDiv.style.display = "inline"; - - var gangButton = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["b" /* clearEventListeners */])("faction-gang-button"); - gangButton.addEventListener("click", function() { - if (!__WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].inGang()) { - var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["d" /* yesNoBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["c" /* yesNoBoxGetNoButton */])(); - yesBtn.innerHTML = "Create Gang"; - noBtn.innerHTML = "Cancel"; - yesBtn.addEventListener("click", () => { - var hacking = false; - if (factionName === "NiteSec" || factionName === "The Black Hand") {hacking = true;} - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].startGang(factionName, hacking); - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadGangContent(); - Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); - }); - noBtn.addEventListener("click", () => { - Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__["b" /* yesNoBoxCreate */])("Would you like to create a new Gang with " + factionName + "?

" + - "Note that this will prevent you from creating a Gang with any other Faction until " + - "this BitNode is destroyed. There are NO differences between the Factions you can " + - "create a Gang with and each of these Factions have all Augmentations available"); - } else { - __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadGangContent(); - } - - }); - return; - } else { - if (gangDiv) {gangDiv.style.display = "none";} } if (faction.isMember) { @@ -18370,28 +19095,138 @@ function displayFactionContent(factionName) { break; } } else { - console.log("Not a member of this faction, cannot display faction information"); + throw new Error("Not a member of this faction, cannot display faction information"); } + + //Display all elements + for (var i = 0; i < elements.length; ++i) { + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionContent.appendChild(elements[i]); + } } +var confirmingPurchases = true; +var sortOption = null; function displayFactionAugmentations(factionName) { - document.getElementById("faction-augmentations-page-desc").innerHTML = - "Lists all Augmentations that are available to purchase from " + factionName + "

" + - "Augmentations are powerful upgrades that will enhance your abilities."; - var faction = Factions[factionName]; - - var augmentationsList = document.getElementById("faction-augmentations-list"); - while (augmentationsList.firstChild) { - augmentationsList.removeChild(augmentationsList.firstChild); + if (faction == null) { + throw new Error("Could not find faction " + factionName + " in displayFactionAugmentations"); } - for (var i = 0; i < faction.augmentations.length; ++i) { + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(__WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionAugmentationsContent); + var elements = []; + + //Back button + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Back", class:"a-link-button", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].loadFactionContent(); + displayFactionContent(factionName); + return false; + } + })); + + //Header text + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("h1", {innerText:"Faction Augmentations"})); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + id:"faction-augmentations-page-desc", + innerHTML:"Lists all Augmentations that are available to purchase from " + factionName + "

" + + "Augmentations are powerful upgrades that will enhance your abilities." + })); + + //Confirming not confirming button + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("label", { + for:"faction-augmentations-confirming-checkbox",innerText:"Confirm Purchases", + color:"white", margin:"4px", padding:"4px", + })); + var confirmingPurchasesCheckbox = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"checkbox", id:"faction-augmentations-confirming-checkbox", checked:confirmingPurchases, + margin:"4px", padding:"4px", + clickListener:()=>{ + confirmingPurchases = confirmingPurchasesCheckbox.checked; + } + }); + elements.push(confirmingPurchasesCheckbox); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("br")); + elements.push(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("br")); + + //Augmentations List + var augmentationsList = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("ul"); + + //Sort buttons + var sortByCostBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Sort by Cost", class:"a-link-button", + clickListener:()=>{ + sortOption = "cost"; + var augs = faction.augmentations.slice(); + augs.sort((augName1, augName2)=>{ + var aug1 = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][augName1], aug2 = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][augName2]; + if (aug1 == null || aug2 == null) { + throw new Error("Invalid Augmentation Names"); + } + return aug1.baseCost - aug2.baseCost; + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(augmentationsList); + createFactionAugmentationDisplayElements(augmentationsList, augs, faction); + } + }); + var sortByRepBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Sort by Reputation", class:"a-link-button", + clickListener:()=>{ + sortOption = "reputation"; + var augs = faction.augmentations.slice(); + augs.sort((augName1, augName2)=>{ + var aug1 = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][augName1], aug2 = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][augName2]; + if (aug1 == null || aug2 == null) { + throw new Error("Invalid Augmentation Names"); + } + return aug1.baseRepRequirement - aug2.baseRepRequirement; + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(augmentationsList); + createFactionAugmentationDisplayElements(augmentationsList, augs, faction); + } + }); + var defaultSortBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Sort by Default Order", class:"a-link-button", + clickListener:()=>{ + sortOption = "default"; + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(augmentationsList); + createFactionAugmentationDisplayElements(augmentationsList, faction.augmentations, faction); + } + }); + elements.push(sortByCostBtn); + elements.push(sortByRepBtn); + elements.push(defaultSortBtn); + switch(sortOption) { + case "cost": + sortByCostBtn.click(); + break; + case "reputation": + sortByRepBtn.click(); + break; + default: + defaultSortBtn.click(); + break; + } + + elements.push(augmentationsList); + + for (var i = 0; i < elements.length; ++i) { + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].Display.factionAugmentationsContent.appendChild(elements[i]); + } +} + +//Takes in an array of Augmentation Names, constructs DOM elements +//to list them on the faction page, and appends them to the given +//DOM element +// @augmentationsList DOM List to append Aug DOM elements to +// @augs Array of Aug names +// @faction Faction for which to display Augmentations +function createFactionAugmentationDisplayElements(augmentationsList, augs, faction) { + for (var i = 0; i < augs.length; ++i) { (function () { - var aug = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][faction.augmentations[i]]; + var aug = __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][augs[i]]; if (aug == null) { - console.log("ERROR: Invalid Augmentation"); - return; + throw new Error("Invalid Augmentation when trying to create Augmentation display Elements"); } var owned = false; for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { @@ -18407,11 +19242,26 @@ function displayFactionAugmentations(factionName) { } } - var item = document.createElement("li"); - var span = document.createElement("span"); - var aDiv = document.createElement("div"); - var aElem = document.createElement("a"); - var pElem = document.createElement("p"); + var item = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("li"); + var span = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("span", {display:"inline-block"}); + var aDiv = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("div", {tooltip:aug.info}); + var aElem = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:aug.name, display:"inline", + clickListener:()=>{ + if (confirmingPurchases) { + purchaseAugmentationBoxCreate(aug, faction); + } else { + purchaseAugmentation(aug, faction); + } + return false; + } + }); + if (aug.name == __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { + aElem.innerText += " - Level " + (getNextNeurofluxLevel()); + } + var pElem = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + display:"inline", + }) var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult; var hasPrereqs = hasAugmentationPrereqs(aug); if (!hasPrereqs) { @@ -18423,35 +19273,16 @@ function displayFactionAugmentations(factionName) { pElem.innerHTML = "ALREADY OWNED"; } else if (faction.playerReputation >= req) { aElem.setAttribute("class", "a-link-button"); - //pElem.innerHTML = "UNLOCKED - $" + formatNumber(aug.baseCost * faction.augmentationPriceMult, 2); pElem.innerHTML = "UNLOCKED - " + __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js___default()(aug.baseCost * faction.augmentationPriceMult).format("$0.000a"); } else { aElem.setAttribute("class", "a-link-button-inactive"); pElem.innerHTML = "LOCKED (Requires " + Object(__WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__["c" /* formatNumber */])(req, 1) + " faction reputation) - " + __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js___default()(aug.baseCost * faction.augmentationPriceMult).format("$0.000a"); pElem.style.color = "red"; } - aElem.style.display = "inline"; - pElem.style.display = "inline"; - aElem.innerHTML = aug.name; - if (aug.name == __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { - aElem.innerHTML += " - Level " + (getNextNeurofluxLevel()); - } - span.style.display = "inline-block" - - //The div will have the tooltip. - aDiv.setAttribute("class", "tooltip"); - aDiv.innerHTML = '' + aug.info + " "; aDiv.appendChild(aElem); - - aElem.addEventListener("click", function() { - purchaseAugmentationBoxCreate(aug, faction); - }); - span.appendChild(aDiv); span.appendChild(pElem); - item.appendChild(span); - augmentationsList.appendChild(item); }()); //Immediate invocation closure } @@ -18600,10 +19431,9 @@ function processPassiveFactionRepGain(numCycles) { -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) /***/ }), -/* 11 */ +/* 13 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -18615,15 +19445,15 @@ function processPassiveFactionRepGain(numCycles) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return addWorkerScript; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateOnlineScriptTimes; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return prestigeWorkerScripts; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__NetscriptPort_js__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Settings_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__NetscriptPort_js__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(40); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -18848,7 +19678,7 @@ function updateOnlineScriptTimes(numCycles = 1) { /***/ }), -/* 12 */ +/* 14 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -18856,7 +19686,7 @@ function updateOnlineScriptTimes(numCycles = 1) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return initSettings; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return setSettingsLabels; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return loadSettings; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__engine_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__engine_js__ = __webpack_require__(5); /* Settings.js */ @@ -18964,7 +19794,173 @@ function setSettingsLabels() { /***/ }), -/* 13 */ +/* 15 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return yesNoBoxCreate; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return yesNoTxtInpBoxCreate; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return yesNoBoxGetYesButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return yesNoBoxGetNoButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return yesNoTxtInpBoxGetYesButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return yesNoTxtInpBoxGetNoButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return yesNoTxtInpBoxGetInput; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return yesNoBoxClose; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return yesNoTxtInpBoxClose; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return yesNoBoxOpen; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__ = __webpack_require__(2); + +/* Generic Yes-No Pop-up box + * Can be used to create pop-up boxes that require a yes/no response from player + */ +var yesNoBoxOpen = false; +function yesNoBoxClose() { + var container = document.getElementById("yes-no-box-container"); + if (container) { + container.style.display = "none"; + } else { + console.log("ERROR: Container not found for YesNoBox"); + } + yesNoBoxOpen = false; + return false; //So that 'return yesNoBoxClose()' is return false in event listeners +} + +function yesNoBoxGetYesButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-yes"); +} + +function yesNoBoxGetNoButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-no"); +} + +function yesNoBoxCreate(txt) { + if (yesNoBoxOpen) {return false;} //Already open + yesNoBoxOpen = true; + var textElement = document.getElementById("yes-no-box-text"); + if (textElement) { + textElement.innerHTML = txt; + } + + var c = document.getElementById("yes-no-box-container"); + if (c) { + c.style.display = "block"; + } else { + console.log("ERROR: Container not found for YesNoBox"); + } + return true; +} + +/* Generic Yes-No POp-up Box with Text input */ +function yesNoTxtInpBoxClose() { + var c = document.getElementById("yes-no-text-input-box-container"); + if (c) { + c.style.display = "none"; + } else { + console.log("ERROR: Container not found for YesNoTextInputBox"); + } + yesNoBoxOpen = false; + document.getElementById("yes-no-text-input-box-input").value = ""; + return false; +} + +function yesNoTxtInpBoxGetYesButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-yes"); +} + +function yesNoTxtInpBoxGetNoButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-no"); +} + +function yesNoTxtInpBoxGetInput() { + var val = document.getElementById("yes-no-text-input-box-input").value; + val = val.replace(/\s+/g, ''); + return val; +} + +function yesNoTxtInpBoxCreate(txt) { + yesNoBoxOpen = true; + var txtE = document.getElementById("yes-no-text-input-box-text"); + if (txtE) { + txtE.innerHTML = txt; + } + + var c = document.getElementById("yes-no-text-input-box-container"); + if (c) { + c.style.display = "block"; + } else { + console.log("ERROR: Container not found for YesNoTextInputBox"); + } + + document.getElementById("yes-no-text-input-box-input").focus(); +} + + + + +/***/ }), +/* 16 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SpecialServerNames; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SpecialServerIps; }); +/* unused harmony export SpecialServerIpsMap */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return loadSpecialServerIps; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return prestigeSpecialServerIps; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return initSpecialServerIps; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__ = __webpack_require__(9); + + +/* Holds IP of Special Servers */ +let SpecialServerNames = { + FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server", + CyberSecServer: "CyberSec Server", + NiteSecServer: "NiteSec Server", + TheBlackHandServer: "The Black Hand Server", + BitRunnersServer: "BitRunners Server", + TheDarkArmyServer: "The Dark Army Server", + DaedalusServer: "Daedalus Server", + WorldDaemon: "w0r1d_d43m0n", +} +function SpecialServerIpsMap() {} + +SpecialServerIpsMap.prototype.addIp = function(name, ip) { + this[name] = ip; +} + +SpecialServerIpsMap.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["b" /* Generic_toJSON */])("SpecialServerIpsMap", this); +} + +SpecialServerIpsMap.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(SpecialServerIpsMap, value.data); +} + +__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["c" /* Reviver */].constructors.SpecialServerIpsMap = SpecialServerIpsMap; + +let SpecialServerIps = new SpecialServerIpsMap(); + +function prestigeSpecialServerIps() { + for (var member in SpecialServerIps) { + delete SpecialServerIps[member]; + } + SpecialServerIps = null; + SpecialServerIps = new SpecialServerIpsMap(); +} + +function loadSpecialServerIps(saveString) { + SpecialServerIps = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["c" /* Reviver */]); +} + +function initSpecialServerIps() { + SpecialServerIps = new SpecialServerIpsMap(); +} + + + + +/***/ }), +/* 17 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve @@ -18981,29 +19977,29 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):"object"==typeof module&&module.exports?module.exports=b():a.numeral=b()}(this,function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.6",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat,scalePercentBy100:g.scalePercentBy100};return b=function(d){var f,g,i,j;if(b.isNumeral(d))f=d.value();else if(0===d||"undefined"==typeof d)f=0;else if(null===d||c.isNaN(d))f=null;else if("string"==typeof d)if(h.zeroFormat&&d===h.zeroFormat)f=0;else if(h.nullFormat&&d===h.nullFormat||!d.replace(/[^0-9]+/g,"").length)f=null;else{for(g in e)if(j="function"==typeof e[g].regexps.unformat?e[g].regexps.unformat():e[g].regexps.unformat,j&&d.match(j)){i=e[g].unformat;break}i=i||b._.stringToNumber,f=i(d)}else f=Number(d)||null;return new a(d,f)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={numberToFormat:function(a,c,d){var e,g,h,i,j,k,l,m=f[b.options.currentLocale],n=!1,o=!1,p=0,q="",r=1e12,s=1e9,t=1e6,u=1e3,v="",w=!1;if(a=a||0,g=Math.abs(a),b._.includes(c,"(")?(n=!0,c=c.replace(/[\(|\)]/g,"")):(b._.includes(c,"+")||b._.includes(c,"-"))&&(j=b._.includes(c,"+")?c.indexOf("+"):0>a?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,b._.includes(c," a")&&(q=" "),c=c.replace(new RegExp(q+"a[kmbt]?"),""),g>=r&&!e||"t"===e?(q+=m.abbreviations.trillion,a/=r):r>g&&g>=s&&!e||"b"===e?(q+=m.abbreviations.billion,a/=s):s>g&&g>=t&&!e||"m"===e?(q+=m.abbreviations.million,a/=t):(t>g&&g>=u&&!e||"k"===e)&&(q+=m.abbreviations.thousand,a/=u)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),p=(c.split(".")[0].split(",")[0].match(/0/g)||[]).length,i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),v=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):v=b._.toFixed(a,i.length,d),h=v.split(".")[0],v=b._.includes(v,".")?m.delimiters.decimal+v.split(".")[1]:"",o&&0===Number(v.slice(1))&&(v="")):h=b._.toFixed(a,0,d),q&&!e&&Number(h)>=1e3&&q!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),q){case m.abbreviations.thousand:q=m.abbreviations.million;break;case m.abbreviations.million:q=m.abbreviations.billion;break;case m.abbreviations.billion:q=m.abbreviations.trillion}if(b._.includes(h,"-")&&(h=h.slice(1),w=!0),h.length0;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;g--)switch(f=i.after[g]){case"$":e=g===i.after.length-1?e+h.currency.symbol:b._.insert(e,h.currency.symbol,-(i.after.length-(1+g)));break;case" ":e=g===i.after.length-1?e+" ":b._.insert(e," ",-(i.after.length-(1+g)+h.currency.symbol.length-1))}return e}})}(),function(){b.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(a,c,d){var e,f="number"!=typeof a||b._.isNaN(a)?"0e+0":a.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=b._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(a){function c(a,c,d,e){var f=b._.correctionFactor(a,c),g=a*f*(c*f)/(f*f);return g}var d=b._.includes(a,"e+")?a.split("e+"):a.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b._.includes(a,"e-")?f*=-1:f,b._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){b.register("format","ordinal",{regexps:{format:/(o)/},format:function(a,c,d){var e,f=b.locales[b.options.currentLocale],g=b._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(a),e=b._.numberToFormat(a,c,d),e+g}})}(),function(){b.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(a,c,d){var e,f=b._.includes(c," %")?" ":"";return b.options.scalePercentBy100&&(a=100*a),c=c.replace(/\s?\%/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(a){var c=b._.stringToNumber(a);return b.options.scalePercentBy100?.01*c:c}})}(),function(){b.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(a,b,c){var d=Math.floor(a/60/60),e=Math.floor((a-60*d*60)/60),f=Math.round(a-60*d*60-60*e);return d+":"+(10>e?"0"+e:e)+":"+(10>f?"0"+f:f)},unformat:function(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}})}(),b}); /***/ }), -/* 14 */ +/* 18 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Locations; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return displayLocationContent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return initLocationButtons; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Company_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompanyManagement_js__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Infiltration_js__ = __webpack_require__(50); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Company_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompanyManagement_js__ = __webpack_require__(53); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Infiltration_js__ = __webpack_require__(105); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__ServerPurchases_js__ = __webpack_require__(72); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__ServerPurchases_js__ = __webpack_require__(178); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__SpecialServerIps_js__ = __webpack_require__(16); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_13__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_StringHelperFunctions_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_YesNoBox_js__ = __webpack_require__(15); @@ -19024,7 +20020,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve /* Display Location Content when visiting somewhere in the World*/ -let Locations = { +var Locations = { //Cities Aevum: "Aevum", //AevumDesc: "" @@ -20566,14 +21562,6 @@ function initLocationButtons() { return false; }); - let worldStockExchange = document.getElementById("generic-location-wse"); - worldStockExchange.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_6__Player_js__["a" /* Player */].location = Locations.WorldStockExchange; - __WEBPACK_IMPORTED_MODULE_4__engine_js__["Engine"].loadStockMarketContent(); - return false; - }); - - //Buttons to interact at a location (apply for job/promotion, train, purchase, etc.) var softwareJob = document.getElementById("location-software-job"); var softwareConsultantJob = document.getElementById("location-software-consultant-job") @@ -21158,173 +22146,7 @@ function purchaseServerBoxCreate(ram, cost) { /***/ }), -/* 15 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return yesNoBoxCreate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return yesNoTxtInpBoxCreate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return yesNoBoxGetYesButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return yesNoBoxGetNoButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return yesNoTxtInpBoxGetYesButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return yesNoTxtInpBoxGetNoButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return yesNoTxtInpBoxGetInput; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return yesNoBoxClose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return yesNoTxtInpBoxClose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return yesNoBoxOpen; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__ = __webpack_require__(2); - -/* Generic Yes-No Pop-up box - * Can be used to create pop-up boxes that require a yes/no response from player - */ -var yesNoBoxOpen = false; -function yesNoBoxClose() { - var container = document.getElementById("yes-no-box-container"); - if (container) { - container.style.display = "none"; - } else { - console.log("ERROR: Container not found for YesNoBox"); - } - yesNoBoxOpen = false; - return false; //So that 'return yesNoBoxClose()' is return false in event listeners -} - -function yesNoBoxGetYesButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-yes"); -} - -function yesNoBoxGetNoButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-no"); -} - -function yesNoBoxCreate(txt) { - if (yesNoBoxOpen) {return false;} //Already open - yesNoBoxOpen = true; - var textElement = document.getElementById("yes-no-box-text"); - if (textElement) { - textElement.innerHTML = txt; - } - - var c = document.getElementById("yes-no-box-container"); - if (c) { - c.style.display = "block"; - } else { - console.log("ERROR: Container not found for YesNoBox"); - } - return true; -} - -/* Generic Yes-No POp-up Box with Text input */ -function yesNoTxtInpBoxClose() { - var c = document.getElementById("yes-no-text-input-box-container"); - if (c) { - c.style.display = "none"; - } else { - console.log("ERROR: Container not found for YesNoTextInputBox"); - } - yesNoBoxOpen = false; - document.getElementById("yes-no-text-input-box-input").value = ""; - return false; -} - -function yesNoTxtInpBoxGetYesButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-yes"); -} - -function yesNoTxtInpBoxGetNoButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-no"); -} - -function yesNoTxtInpBoxGetInput() { - var val = document.getElementById("yes-no-text-input-box-input").value; - val = val.replace(/\s+/g, ''); - return val; -} - -function yesNoTxtInpBoxCreate(txt) { - yesNoBoxOpen = true; - var txtE = document.getElementById("yes-no-text-input-box-text"); - if (txtE) { - txtE.innerHTML = txt; - } - - var c = document.getElementById("yes-no-text-input-box-container"); - if (c) { - c.style.display = "block"; - } else { - console.log("ERROR: Container not found for YesNoTextInputBox"); - } - - document.getElementById("yes-no-text-input-box-input").focus(); -} - - - - -/***/ }), -/* 16 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SpecialServerNames; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SpecialServerIps; }); -/* unused harmony export SpecialServerIpsMap */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return loadSpecialServerIps; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return prestigeSpecialServerIps; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return initSpecialServerIps; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__ = __webpack_require__(8); - - -/* Holds IP of Special Servers */ -let SpecialServerNames = { - FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server", - CyberSecServer: "CyberSec Server", - NiteSecServer: "NiteSec Server", - TheBlackHandServer: "The Black Hand Server", - BitRunnersServer: "BitRunners Server", - TheDarkArmyServer: "The Dark Army Server", - DaedalusServer: "Daedalus Server", - WorldDaemon: "w0r1d_d43m0n", -} -function SpecialServerIpsMap() {} - -SpecialServerIpsMap.prototype.addIp = function(name, ip) { - this[name] = ip; -} - -SpecialServerIpsMap.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["b" /* Generic_toJSON */])("SpecialServerIpsMap", this); -} - -SpecialServerIpsMap.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(SpecialServerIpsMap, value.data); -} - -__WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["c" /* Reviver */].constructors.SpecialServerIpsMap = SpecialServerIpsMap; - -let SpecialServerIps = new SpecialServerIpsMap(); - -function prestigeSpecialServerIps() { - for (var member in SpecialServerIps) { - delete SpecialServerIps[member]; - } - SpecialServerIps = null; - SpecialServerIps = new SpecialServerIpsMap(); -} - -function loadSpecialServerIps(saveString) { - SpecialServerIps = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_0__utils_JSONReviver_js__["c" /* Reviver */]); -} - -function initSpecialServerIps() { - SpecialServerIps = new SpecialServerIpsMap(); -} - - - - -/***/ }), -/* 17 */ +/* 19 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -21332,7 +22154,7 @@ function initSpecialServerIps() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return displayCreateProgramContent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getNumAvailableCreateProgram; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initCreateProgramButtons; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_HelperFunctions_js__ = __webpack_require__(2); @@ -21598,39 +22420,967 @@ function initCreateProgramButtons() { /***/ }), -/* 18 */ +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer) { + +exports.base64 = true; +exports.array = true; +exports.string = true; +exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined"; +exports.nodebuffer = typeof Buffer !== "undefined"; +// contains true if JSZip can read/generate Uint8Array, false otherwise. +exports.uint8array = typeof Uint8Array !== "undefined"; + +if (typeof ArrayBuffer === "undefined") { + exports.blob = false; +} +else { + var buffer = new ArrayBuffer(0); + try { + exports.blob = new Blob([buffer], { + type: "application/zip" + }).size === 0; + } + catch (e) { + try { + var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder; + var builder = new Builder(); + builder.append(buffer); + exports.blob = builder.getBlob('application/zip').size === 0; + } + catch (e) { + exports.blob = false; + } + } +} + +try { + exports.nodestream = !!__webpack_require__(76).Readable; +} catch(e) { + exports.nodestream = false; +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34).Buffer)) + +/***/ }), +/* 21 */ +/***/ (function(module, exports) { + +var g; + +// This works in non-strict mode +g = (function() { + return this; +})(); + +try { + // This works if eval is allowed (see CSP) + g = g || Function("return this")() || (1,eval)("this"); +} catch(e) { + // This works if the window reference is available + if(typeof window === "object") + g = window; +} + +// g can still be undefined, but nothing to do about it... +// We return undefined, instead of nothing here, so it's +// easier to handle this case. if(!global) { ...} + +module.exports = g; + + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + + +var TYPED_OK = (typeof Uint8Array !== 'undefined') && + (typeof Uint16Array !== 'undefined') && + (typeof Int32Array !== 'undefined'); + +function _has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); +} + +exports.assign = function (obj /*from1, from2, from3, ...*/) { + var sources = Array.prototype.slice.call(arguments, 1); + while (sources.length) { + var source = sources.shift(); + if (!source) { continue; } + + if (typeof source !== 'object') { + throw new TypeError(source + 'must be non-object'); + } + + for (var p in source) { + if (_has(source, p)) { + obj[p] = source[p]; + } + } + } + + return obj; +}; + + +// reduce buffer size, avoiding mem copy +exports.shrinkBuf = function (buf, size) { + if (buf.length === size) { return buf; } + if (buf.subarray) { return buf.subarray(0, size); } + buf.length = size; + return buf; +}; + + +var fnTyped = { + arraySet: function (dest, src, src_offs, len, dest_offs) { + if (src.subarray && dest.subarray) { + dest.set(src.subarray(src_offs, src_offs + len), dest_offs); + return; + } + // Fallback to ordinary array + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; + } + }, + // Join array of chunks to single array. + flattenChunks: function (chunks) { + var i, l, len, pos, chunk, result; + + // calculate data length + len = 0; + for (i = 0, l = chunks.length; i < l; i++) { + len += chunks[i].length; + } + + // join chunks + result = new Uint8Array(len); + pos = 0; + for (i = 0, l = chunks.length; i < l; i++) { + chunk = chunks[i]; + result.set(chunk, pos); + pos += chunk.length; + } + + return result; + } +}; + +var fnUntyped = { + arraySet: function (dest, src, src_offs, len, dest_offs) { + for (var i = 0; i < len; i++) { + dest[dest_offs + i] = src[src_offs + i]; + } + }, + // Join array of chunks to single array. + flattenChunks: function (chunks) { + return [].concat.apply([], chunks); + } +}; + + +// Enable/Disable typed arrays use, for testing +// +exports.setTyped = function (on) { + if (on) { + exports.Buf8 = Uint8Array; + exports.Buf16 = Uint16Array; + exports.Buf32 = Int32Array; + exports.assign(exports, fnTyped); + } else { + exports.Buf8 = Array; + exports.Buf16 = Array; + exports.Buf32 = Array; + exports.assign(exports, fnUntyped); + } +}; + +exports.setTyped(TYPED_OK); + + +/***/ }), +/* 23 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateScriptEditorContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadAllRunningScripts; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return findRunningScript; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return RunningScript; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Script; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllServersMap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return scriptEditorInit; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Fconf_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Terminal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__TextFile_js__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__ = __webpack_require__(6); +var ace = __webpack_require__(107); +__webpack_require__(108); +__webpack_require__(109); +__webpack_require__(110); +__webpack_require__(111); +__webpack_require__(112); +__webpack_require__(113); +__webpack_require__(114); +__webpack_require__(115); +__webpack_require__(116); +__webpack_require__(117); +__webpack_require__(118); +__webpack_require__(119); +__webpack_require__(120); + + + + + + + + + + + + + + + + + + + + +var keybindings = { + ace: null, + vim: "ace/keyboard/vim", + emacs: "ace/keyboard/emacs", +}; + +var scriptEditorRamCheck = null, scriptEditorRamText = null; +function scriptEditorInit() { + //Create buttons at the bottom of script editor + var wrapper = document.getElementById("script-editor-buttons-wrapper"); + if (wrapper == null) { + console.log("Error finding 'script-editor-buttons-wrapper'"); + return; + } + var closeButton = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", + innerText:"Save & Close (Ctrl + b)", + clickListener:()=>{ + saveAndCloseScriptEditor(); + return false; + } + }); + + scriptEditorRamText = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("p", { + display:"inline-block", margin:"10px", id:"script-editor-status-text" + }); + + var checkboxLabel = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("label", { + for:"script-editor-ram-check", margin:"4px", marginTop: "8px", + innerText:"Dynamic RAM Usage Checker", color:"white", + tooltip:"Enable/Disable the dynamic RAM Usage display. You may " + + "want to disable it for very long scripts because there may be " + + "performance issues" + }); + + scriptEditorRamCheck = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"checkbox", name:"script-editor-ram-check", id:"script-editor-ram-check", + margin:"4px", marginTop: "8px", + }); + scriptEditorRamCheck.checked = true; + + var documentationButton = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("a", { + display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation", + href:"https://bitburner.readthedocs.io/en/latest/index.html", + target:"_blank" + }); + + wrapper.appendChild(closeButton); + wrapper.appendChild(scriptEditorRamText); + wrapper.appendChild(scriptEditorRamCheck); + wrapper.appendChild(checkboxLabel); + wrapper.appendChild(documentationButton); + + //Initialize ACE Script editor + var editor = ace.edit('javascript-editor'); + editor.getSession().setMode('ace/mode/netscript'); + editor.setTheme('ace/theme/monokai'); + document.getElementById('javascript-editor').style.fontSize='16px'; + editor.setOption("showPrintMargin", false); + + /* Script editor options */ + //Theme + var themeDropdown = document.getElementById("script-editor-option-theme"); + if (__WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme) { + var initialIndex = 2; + for (var i = 0; i < themeDropdown.options.length; ++i) { + if (themeDropdown.options[i].value === __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme) { + initialIndex = i; + break; + } + } + themeDropdown.selectedIndex = initialIndex; + } else { + themeDropdown.selectedIndex = 2; + } + + themeDropdown.onchange = function() { + var val = themeDropdown.value; + __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme = val; + var themePath = "ace/theme/" + val.toLowerCase(); + editor.setTheme(themePath); + }; + themeDropdown.onchange(); + + //Keybinding + var keybindingDropdown = document.getElementById("script-editor-option-keybinding"); + if (__WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding) { + var initialIndex = 0; + for (var i = 0; i < keybindingDropdown.options.length; ++i) { + if (keybindingDropdown.options[i].value === __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding) { + initialIndex = i; + break; + } + } + keybindingDropdown.selectedIndex = initialIndex; + } else { + keybindingDropdown.selectedIndex = 0; + } + keybindingDropdown.onchange = function() { + var val = keybindingDropdown.value; + __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding = val; + editor.setKeyboardHandler(keybindings[val.toLowerCase()]); + }; + keybindingDropdown.onchange(); + + //Highlight Active line + var highlightActiveChkBox = document.getElementById("script-editor-option-highlightactiveline"); + highlightActiveChkBox.onchange = function() { + editor.setHighlightActiveLine(highlightActiveChkBox.checked); + }; + + //Show Invisibles + var showInvisiblesChkBox = document.getElementById("script-editor-option-showinvisibles"); + showInvisiblesChkBox.onchange = function() { + editor.setShowInvisibles(showInvisiblesChkBox.checked); + }; + + //Use Soft Tab + var softTabChkBox = document.getElementById("script-editor-option-usesofttab"); + softTabChkBox.onchange = function() { + editor.getSession().setUseSoftTabs(softTabChkBox.checked); + }; + + //Jshint Maxerr + var maxerr = document.getElementById("script-editor-option-maxerr"); + var maxerrLabel = document.getElementById("script-editor-option-maxerror-value-label"); + maxerrLabel.innerHTML = maxerr.value; + maxerr.onchange = function() { + editor.getSession().$worker.send("changeOptions", [{maxerr:maxerr.value}]); + maxerrLabel.innerHTML = maxerr.value; + } + + //Configure some of the VIM keybindings + ace.config.loadModule('ace/keyboard/vim', function(module) { + var VimApi = module.CodeMirror.Vim; + VimApi.defineEx('write', 'w', function(cm, input) { + saveAndCloseScriptEditor(); + }); + VimApi.defineEx('quit', 'q', function(cm, input) { + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); + }); + VimApi.defineEx('xwritequit', 'x', function(cm, input) { + saveAndCloseScriptEditor(); + }); + VimApi.defineEx('wqwritequit', 'wq', function(cm, input) { + saveAndCloseScriptEditor(); + }); + }); + + //Function autocompleter + editor.setOption("enableBasicAutocompletion", true); + var autocompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + if (prefix.length === 0) {callback(null, []); return;} + var words = []; + var fns = Object(__WEBPACK_IMPORTED_MODULE_5__NetscriptFunctions_js__["a" /* NetscriptFunctions */])(null); + for (var name in fns) { + if (fns.hasOwnProperty(name)) { + words.push({ + name: name, + value: name, + }); + } + } + callback(null, words); + }, + } + editor.completers = [autocompleter]; +} + +//Updates RAM usage in script +function updateScriptEditorContent() { + var filename = document.getElementById("script-editor-filename").value; + if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !filename.endsWith(".script")) { + scriptEditorRamText.innerText = "N/A"; + return; + } + var editor = ace.edit('javascript-editor'); + var code = editor.getValue(); + var codeCopy = code.repeat(1); + var ramUsage = calculateRamUsage(codeCopy); + if (ramUsage !== -1) { + scriptEditorRamText.innerText = "RAM: " + Object(__WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__["c" /* formatNumber */])(ramUsage, 2).toString() + "GB"; + } else { + scriptEditorRamText.innerText = "RAM: Syntax Error"; + } +} + +//Define key commands in script editor (ctrl o to save + close, etc.) +$(document).keydown(function(e) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.ScriptEditor) { + //Ctrl + b + if (e.keyCode == 66 && e.ctrlKey) { + e.preventDefault(); + saveAndCloseScriptEditor(); + } + } +}); + +function saveAndCloseScriptEditor() { + var filename = document.getElementById("script-editor-filename").value; + var editor = ace.edit('javascript-editor'); + var code = editor.getValue(); + if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["b" /* iTutorialIsRunning */] && __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["a" /* currITutorialStep */] == __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["e" /* iTutorialSteps */].TerminalTypeScript) { + if (filename != "foodnstuff.script") { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Leave the script name as 'foodnstuff'!"); + return; + } + code = code.replace(/\s/g, ""); + if (code.indexOf("while(true){hack('foodnstuff');}") == -1) { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Please copy and paste the code from the tutorial!"); + return; + } + Object(__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["c" /* iTutorialNextStep */])(); + } + + if (filename == "") { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must specify a filename!"); + return; + } + + if (checkValidFilename(filename) == false) { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Script filename can contain only alphanumerics, hyphens, and underscores"); + return; + } + + var s = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].getCurrentServer(); + if (filename === ".fconf") { + try { + Object(__WEBPACK_IMPORTED_MODULE_2__Fconf_js__["d" /* parseFconfSettings */])(code); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid .fconf file"); + return; + } + } else if (filename.endsWith(".script")) { + //If the current script already exists on the server, overwrite it + for (var i = 0; i < s.scripts.length; i++) { + if (filename == s.scripts[i].filename) { + s.scripts[i].saveScript(); + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); + return; + } + } + + //If the current script does NOT exist, create a new one + var script = new Script(); + script.saveScript(); + s.scripts.push(script); + } else if (filename.endsWith(".txt")) { + for (var i = 0; i < s.textFiles.length; ++i) { + if (s.textFiles[i].fn === filename) { + s.textFiles[i].write(code); + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); + return; + } + } + var textFile = new __WEBPACK_IMPORTED_MODULE_11__TextFile_js__["a" /* TextFile */](filename, code); + s.textFiles.push(textFile); + } else { + Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid filename. Must be either a script (.script) or " + + " or text file (.txt)") + return; + } + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); +} + +//Checks that the string contains only valid characters for a filename, which are alphanumeric, +// underscores, hyphens, and dots +function checkValidFilename(filename) { + var regex = /^[.a-zA-Z0-9_-]+$/; + + if (filename.match(regex)) { + return true; + } + return false; +} + +function Script() { + this.filename = ""; + this.code = ""; + this.ramUsage = 0; + this.server = ""; //IP of server this script is on +}; + +//Get the script data from the Script Editor and save it to the object +Script.prototype.saveScript = function() { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.ScriptEditor) { + //Update code and filename + var editor = ace.edit('javascript-editor'); + var code = editor.getValue(); + this.code = code.replace(/^\s+|\s+$/g, ''); + + var filename = document.getElementById("script-editor-filename").value; + this.filename = filename; + + //Server + this.server = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].currentServer; + + //Calculate/update ram usage, execution time, etc. + this.updateRamUsage(); + } +} + +//Updates how much RAM the script uses when it is running. +Script.prototype.updateRamUsage = function() { + var codeCopy = this.code.repeat(1); + var res = calculateRamUsage(codeCopy); + if (res !== -1) { + this.ramUsage = res; + } +} + +function calculateRamUsage(codeCopy) { + //Create a temporary/mock WorkerScript and an AST from the code + var currServ = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].getCurrentServer(); + var workerScript = new __WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__["b" /* WorkerScript */]({ + filename:"foo", + scriptRef: {code:""}, + args:[] + }); + workerScript.checkingRam = true; //Netscript functions will return RAM usage + workerScript.serverIp = currServ.ip; + + try { + var ast = Object(__WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["parse"])(codeCopy, {sourceType:"module"}); + } catch(e) { + return -1; + } + + //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes + var queue = [], ramUsage = 1.4; + var whileUsed = false, forUsed = false, ifUsed = false; + queue.push(ast); + while (queue.length != 0) { + var exp = queue.shift(); + switch (exp.type) { + case "ImportDeclaration": + //Gets an array of all imported functions as AST expressions + //and pushes them on the queue. + var res = Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__["b" /* evaluateImport */])(exp, workerScript, true); + for (var i = 0; i < res.length; ++i) { + queue.push(res[i]); + } + break; + case "BlockStatement": + case "Program": + for (var i = 0; i < exp.body.length; ++i) { + if (exp.body[i] instanceof __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["Node"]) { + queue.push(exp.body[i]); + } + } + break; + case "WhileStatement": + if (!whileUsed) { + ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptWhileRamCost; + whileUsed = true; + } + break; + case "ForStatement": + if (!forUsed) { + ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptForRamCost; + forUsed = true; + } + break; + case "IfStatement": + if (!ifUsed) { + ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptIfRamCost; + ifUsed = true; + } + break; + case "Identifier": + if (exp.name in workerScript.env.vars) { + var func = workerScript.env.get(exp.name); + if (typeof func === "function") { + try { + var res = func.apply(null, []); + if (typeof res === "number") { + ramUsage += res; + } + } catch(e) { + console.log("ERROR applying function: " + e); + } + } + } + break; + default: + break; + } + + for (var prop in exp) { + if (exp.hasOwnProperty(prop)) { + if (exp[prop] instanceof __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["Node"]) { + queue.push(exp[prop]); + } + } + } + } + + //Special case: hacknetnodes array + if (codeCopy.includes("hacknetnodes")) { + ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptHacknetNodesRamCost; + } + return ramUsage; +} + +Script.prototype.download = function() { + var filename = this.filename + ".js"; + var file = new Blob([this.code], {type: 'text/plain'}); + if (window.navigator.msSaveOrOpenBlob) {// IE10+ + window.navigator.msSaveOrOpenBlob(file, filename); + } else { // Others + var a = document.createElement("a"), + url = URL.createObjectURL(file); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + setTimeout(function() { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); + } +} + +Script.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Script", this); +} + + +Script.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Script, value.data); +} + +__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.Script = Script; + +//Called when the game is loaded. Loads all running scripts (from all servers) +//into worker scripts so that they will start running +function loadAllRunningScripts() { + var count = 0; + var total = 0; + for (var property in __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */]) { + if (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */].hasOwnProperty(property)) { + var server = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][property]; + + //Reset each server's RAM usage to 0 + server.ramUsed = 0; + + for (var j = 0; j < server.runningScripts.length; ++j) { + count++; + Object(__WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__["c" /* addWorkerScript */])(server.runningScripts[j], server); + + //Offline production + total += scriptCalculateOfflineProduction(server.runningScripts[j]); + } + } + } + return total; + console.log("Loaded " + count.toString() + " running scripts"); +} + +function scriptCalculateOfflineProduction(runningScriptObj) { + //The Player object stores the last update time from when we were online + var thisUpdate = new Date().getTime(); + var lastUpdate = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].lastUpdate; + var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds + console.log("Offline for " + timePassed + " seconds"); + + //Calculate the "confidence" rating of the script's true production. This is based + //entirely off of time. We will arbitrarily say that if a script has been running for + //4 hours (14400 sec) then we are completely confident in its ability + var confidence = (runningScriptObj.onlineRunningTime) / 14400; + if (confidence >= 1) {confidence = 1;} + + //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] + + //Grow + for (var ip in runningScriptObj.dataMap) { + if (runningScriptObj.dataMap.hasOwnProperty(ip)) { + if (runningScriptObj.dataMap[ip][2] == 0 || runningScriptObj.dataMap[ip][2] == null) {continue;} + var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; + if (serv == null) {continue;} + var timesGrown = Math.round(0.5 * runningScriptObj.dataMap[ip][2] / runningScriptObj.onlineRunningTime * timePassed); + 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(__WEBPACK_IMPORTED_MODULE_8__Server_js__["j" /* processSingleServerGrowth */])(serv, timesGrown * 450); + runningScriptObj.log(serv.hostname + " grown by " + Object(__WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growth * 100 - 100, 6) + "% from grow() calls made while offline"); + } + } + + var totalOfflineProduction = 0; + for (var ip in runningScriptObj.dataMap) { + if (runningScriptObj.dataMap.hasOwnProperty(ip)) { + if (runningScriptObj.dataMap[ip][0] == 0 || runningScriptObj.dataMap[ip][0] == null) {continue;} + var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; + if (serv == null) {continue;} + var production = 0.5 * runningScriptObj.dataMap[ip][0] / runningScriptObj.onlineRunningTime * timePassed; + production *= confidence; + if (production > serv.moneyAvailable) { + production = serv.moneyAvailable; + } + totalOfflineProduction += production; + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].gainMoney(production); + console.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname); + runningScriptObj.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname); + serv.moneyAvailable -= production; + if (serv.moneyAvailable < 0) {serv.moneyAvailable = 0;} + if (isNaN(serv.moneyAvailable)) {serv.moneyAvailable = 0;} + } + } + + //Offline EXP gain + //A script's offline production will always be at most half of its online production. + var expGain = 0.5 * (runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime) * timePassed; + expGain *= confidence; + + __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].gainHackingExp(expGain); + + //Update script stats + runningScriptObj.offlineMoneyMade += totalOfflineProduction; + runningScriptObj.offlineRunningTime += timePassed; + runningScriptObj.offlineExpGained += expGain; + + //Fortify a server's security based on how many times it was hacked + for (var ip in runningScriptObj.dataMap) { + if (runningScriptObj.dataMap.hasOwnProperty(ip)) { + if (runningScriptObj.dataMap[ip][1] == 0 || runningScriptObj.dataMap[ip][1] == null) {continue;} + var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; + if (serv == null) {continue;} + var timesHacked = Math.round(0.5 * runningScriptObj.dataMap[ip][1] / runningScriptObj.onlineRunningTime * timePassed); + console.log(runningScriptObj.filename + " hacked " + serv.hostname + " " + timesHacked + " times while offline"); + runningScriptObj.log("Hacked " + serv.hostname + " " + timesHacked + " times while offline"); + serv.fortify(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ServerFortifyAmount * timesHacked); + } + } + + //Weaken + for (var ip in runningScriptObj.dataMap) { + if (runningScriptObj.dataMap.hasOwnProperty(ip)) { + if (runningScriptObj.dataMap[ip][3] == 0 || runningScriptObj.dataMap[ip][3] == null) {continue;} + var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; + if (serv == null) {continue;} + var timesWeakened = Math.round(0.5 * runningScriptObj.dataMap[ip][3] / runningScriptObj.onlineRunningTime * timePassed); + console.log(runningScriptObj.filename + " called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline"); + runningScriptObj.log("Called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline"); + serv.weaken(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * timesWeakened); + } + } + + return totalOfflineProduction; +} + +//Returns a RunningScript object matching the filename and arguments on the +//designated server, and false otherwise +function findRunningScript(filename, args, server) { + for (var i = 0; i < server.runningScripts.length; ++i) { + if (server.runningScripts[i].filename == filename && + Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["d" /* compareArrays */])(server.runningScripts[i].args, args)) { + return server.runningScripts[i]; + } + } + return null; +} + +function RunningScript(script, args) { + if (script == null || script == undefined) {return;} + this.filename = script.filename; + this.args = args; + this.scriptRef = script; + this.server = script.server; //IP Address only + + this.logs = []; //Script logging. Array of strings, with each element being a log entry + this.logUpd = false; + + //Stats to display on the Scripts menu, and used to determine offline progress + this.offlineRunningTime = 0.01; //Seconds + this.offlineMoneyMade = 0; + this.offlineExpGained = 0; + this.onlineRunningTime = 0.01; //Seconds + this.onlineMoneyMade = 0; + this.onlineExpGained = 0; + + this.threads = 1; + + //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] + this.dataMap = new AllServersMap([0, 0, 0, 0], true); +} + +RunningScript.prototype.log = function(txt) { + if (this.logs.length > __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].MaxLogCapacity) { + //Delete first element and add new log entry to the end. + //TODO Eventually it might be better to replace this with circular array + //to improve performance + this.logs.shift(); + } + this.logs.push(txt); + this.logUpd = true; +} + +RunningScript.prototype.displayLog = function() { + for (var i = 0; i < this.logs.length; ++i) { + Object(__WEBPACK_IMPORTED_MODULE_10__Terminal_js__["b" /* post */])(this.logs[i]); + } +} + +RunningScript.prototype.clearLog = function() { + this.logs.length = 0; +} + +//Update the moneyStolen and numTimesHack maps when hacking +RunningScript.prototype.recordHack = function(serverIp, moneyGained, n=1) { + if (this.dataMap == null) { + //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] + this.dataMap = new AllServersMap([0, 0, 0, 0], true); + } + this.dataMap[serverIp][0] += moneyGained; + this.dataMap[serverIp][1] += n; +} + +//Update the grow map when calling grow() +RunningScript.prototype.recordGrow = function(serverIp, n=1) { + if (this.dataMap == null) { + //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] + this.dataMap = new AllServersMap([0, 0, 0, 0], true); + } + this.dataMap[serverIp][2] += n; +} + +//Update the weaken map when calling weaken() { +RunningScript.prototype.recordWeaken = function(serverIp, n=1) { + if (this.dataMap == null) { + //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] + this.dataMap = new AllServersMap([0, 0, 0, 0], true); + } + this.dataMap[serverIp][3] += n; +} + +RunningScript.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("RunningScript", this); +} + + +RunningScript.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(RunningScript, value.data); +} + +__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.RunningScript = RunningScript; + +//Creates an object that creates a map/dictionary with the IP of each existing server as +//a key. Initializes every key with a specified value that can either by a number or an array +function AllServersMap(arr=false, filterOwned=false) { + for (var ip in __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */]) { + if (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */].hasOwnProperty(ip)) { + if (filterOwned && (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip].purchasedByPlayer || __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip].hostname === "home")) { + continue; + } + if (arr) { + this[ip] = [0, 0, 0, 0]; + } else { + this[ip] = 0; + } + } + } +} + +AllServersMap.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("AllServersMap", this); +} + + +AllServersMap.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(AllServersMap, value.data); +} + +__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.AllServersMap = AllServersMap; + + + +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) + +/***/ }), +/* 24 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return postNetburnerText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return post; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Terminal; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Alias_js__ = __webpack_require__(75); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__DarkWeb_js__ = __webpack_require__(66); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Fconf_js__ = __webpack_require__(180); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__HelpText_js__ = __webpack_require__(126); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__InteractiveTutorial_js__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Literature_js__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Message_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptEvaluator_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Alias_js__ = __webpack_require__(74); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__DarkWeb_js__ = __webpack_require__(73); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Fconf_js__ = __webpack_require__(39); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__HelpText_js__ = __webpack_require__(121); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__InteractiveTutorial_js__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Literature_js__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Message_js__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptEvaluator_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__RedPill_js__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Script_js__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Settings_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__RedPill_js__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Script_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__TextFile_js__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__TextFile_js__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__utils_LogBox_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__utils_LogBox_js__ = __webpack_require__(52); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__utils_YesNoBox_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_jszip__ = __webpack_require__(127); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_jszip__ = __webpack_require__(123); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_jszip___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_23_jszip__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_file_saver__ = __webpack_require__(178); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_file_saver__ = __webpack_require__(175); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_file_saver___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_24_file_saver__); @@ -21950,7 +23700,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(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["h" /* longestCommonStart */])(allPossibilities); + var longestStartSubstr = Object(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["g" /* 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 @@ -22082,7 +23832,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 __WEBPACK_IMPORTED_MODULE_9__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["g" /* isString */])(currServ.messages[i]) && + if (!(currServ.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_9__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["f" /* isString */])(currServ.messages[i]) && currServ.messages[i].endsWith(".lit")) { allPos.push(currServ.messages[i]); } @@ -22892,7 +24642,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 __WEBPACK_IMPORTED_MODULE_9__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["g" /* isString */])(f) && f === delTarget) { + if (!(f instanceof __WEBPACK_IMPORTED_MODULE_9__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_19__utils_StringHelperFunctions_js__["f" /* isString */])(f) && f === delTarget) { s.messages.splice(i, 1); return; } @@ -23645,17 +25395,147 @@ let Terminal = { -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), -/* 19 */ +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + + + +/**/ + +var processNextTick = __webpack_require__(48).nextTick; +/**/ + +/**/ +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var util = __webpack_require__(36); +util.inherits = __webpack_require__(31); +/**/ + +var Readable = __webpack_require__(77); +var Writable = __webpack_require__(63); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +Object.defineProperty(Duplex.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +Duplex.prototype._destroy = function (err, cb) { + this.push(null); + this.end(); + + processNextTick(cb, err); +}; + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +/***/ }), +/* 26 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return createRandomIp; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ipExists; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isValidIPAddress; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_Server_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_Server_js__ = __webpack_require__(7); /* Functions to deal with manipulating IP addresses*/ @@ -23702,29 +25582,36 @@ function isValidIPAddress(ipaddress) { /***/ }), -/* 20 */ +/* 27 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return AugmentationNames; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Augmentations; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return PlayerOwnedAugmentation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return installAugmentations; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return initAugmentations; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return installAugmentations; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return initAugmentations; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return applyAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return augmentationExists; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Augmentation; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Prestige_js__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Script_js__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return displayAugmentationsContent; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Prestige_js__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Script_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__SourceFile_js__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_StringHelperFunctions_js__ = __webpack_require__(6); + + + @@ -23740,7 +25627,7 @@ function isValidIPAddress(ipaddress) { //Augmentations function Augmentation(params) { if (params.name == null || params.info == null || params.moneyCost == null || params.repCost == null) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR Creating Augmentations. This is a bug please contact game dev"); + Object(__WEBPACK_IMPORTED_MODULE_10__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR Creating Augmentations. This is a bug please contact game dev"); return; } this.name = params.name; @@ -23760,7 +25647,7 @@ function Augmentation(params) { //Takes in an array of faction names and adds this augmentation to all of those factions Augmentation.prototype.addToFactions = function(factionList) { for (var i = 0; i < factionList.length; ++i) { - var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][factionList[i]]; + var faction = __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */][factionList[i]]; if (faction == null) { console.log("ERROR: Could not find faction with this name:" + factionList[i]); continue; @@ -23770,9 +25657,9 @@ Augmentation.prototype.addToFactions = function(factionList) { } Augmentation.prototype.addToAllFactions = function() { - for (var fac in __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]) { - if (__WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */].hasOwnProperty(fac)) { - var facObj = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][fac]; + for (var fac in __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]) { + if (__WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */].hasOwnProperty(fac)) { + var facObj = __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */][fac]; if (facObj == null) { console.log("ERROR: Invalid faction object"); continue; @@ -23783,14 +25670,14 @@ Augmentation.prototype.addToAllFactions = function() { } Augmentation.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Augmentation", this); + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Augmentation", this); } Augmentation.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Augmentation, value.data); + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Augmentation, value.data); } -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Augmentation = Augmentation; +__WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__["c" /* Reviver */].constructors.Augmentation = Augmentation; let Augmentations = {} @@ -23890,9 +25777,9 @@ let AugmentationNames = { } function initAugmentations() { - for (var name in __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]) { - if (__WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */].hasOwnProperty(name)) { - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][name].augmentations = []; + for (var name in __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]) { + if (__WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */].hasOwnProperty(name)) { + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */][name].augmentations = []; } } //Combat stat augmentations @@ -24711,7 +26598,7 @@ function initAugmentations() { "This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation " + "increases ALL of the player's multipliers by 1%" }); - var nextLevel = Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["e" /* getNextNeurofluxLevel */])(); + var nextLevel = Object(__WEBPACK_IMPORTED_MODULE_3__Faction_js__["e" /* getNextNeurofluxLevel */])(); NeuroFluxGovernor.level = nextLevel - 1; mult = Math.pow(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level); NeuroFluxGovernor.baseRepRequirement = 500 * mult * __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].AugmentationRepMultiplier * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* BitNodeMultipliers */].AugmentationRepCost; @@ -25229,25 +27116,25 @@ function initAugmentations() { AddToAugmentations(SNA); //Update costs based on how many have been purchased - var mult = Math.pow(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].MultipleAugMultiplier, __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations.length); + var mult = Math.pow(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].MultipleAugMultiplier, __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations.length); for (var name in Augmentations) { if (Augmentations.hasOwnProperty(name)) { Augmentations[name].baseCost *= mult; } } - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].reapplyAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].reapplyAllAugmentations(); //In BitNode-2, these crime/evil factions have all AugmentationsAvailable - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].bitNodeN == 2) { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN == 2) { console.log("Adding all augmentations to crime factions for Bit node 2"); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["Slum Snakes"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["Tetrads"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["The Syndicate"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["The Dark Army"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["Speakers for the Dead"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["NiteSec"].addAllAugmentations(); - __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */]["The Black Hand"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["Slum Snakes"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["Tetrads"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["The Syndicate"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["The Dark Army"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["Speakers for the Dead"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["NiteSec"].addAllAugmentations(); + __WEBPACK_IMPORTED_MODULE_3__Faction_js__["b" /* Factions */]["The Black Hand"].addAllAugmentations(); } } @@ -25256,477 +27143,477 @@ function applyAugmentation(aug, reapply=false) { switch(aug.name) { //Combat stat augmentations case AugmentationNames.Targeting1: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.10; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.10; break; case AugmentationNames.Targeting2: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.20; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.20; break; case AugmentationNames.Targeting3: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.30; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.30; break; case AugmentationNames.SyntheticHeart: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.5; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.5; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.5; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.5; break; case AugmentationNames.SynfibrilMuscle: //Medium-high level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.35; break; case AugmentationNames.CombatRib1: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.1; break; case AugmentationNames.CombatRib2: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.15; break; case AugmentationNames.CombatRib3: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.20; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.20; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.20; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.20; break; case AugmentationNames.NanofiberWeave: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.25; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.25; break; case AugmentationNames.SubdermalArmor: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 2.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 2.25; break; case AugmentationNames.WiredReflexes: //Low level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.05; break; case AugmentationNames.GrapheneBoneLacings: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.7; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.7; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.7; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.7; break; case AugmentationNames.BionicSpine: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.16; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.16; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.16; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.16; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.16; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.16; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.16; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.16; break; case AugmentationNames.GrapheneBionicSpine: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.6; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.6; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.6; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.6; break; case AugmentationNames.BionicLegs: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.6; break; case AugmentationNames.GrapheneBionicLegs: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 2.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 2.75; break; //Labor stats augmentations case AugmentationNames.EnhancedSocialInteractionImplant: //Med-high level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.6; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.6; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.6; break; case AugmentationNames.TITN41Injection: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; break; case AugmentationNames.SpeechProcessor: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.2; break; //Hacking augmentations case AugmentationNames.BitWire: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.05; break; case AugmentationNames.ArtificialBioNeuralNetwork: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.12; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.12; break; case AugmentationNames.ArtificialSynapticPotentiation: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.05; break; case AugmentationNames.EnhancedMyelinSheathing: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.08; break; case AugmentationNames.SynapticEnhancement: //Low Level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; break; case AugmentationNames.NeuralRetentionEnhancement: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; break; case AugmentationNames.DataJack: //Med low level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.25; break; case AugmentationNames.ENM: //Medium level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.08; break; case AugmentationNames.ENMCore: //Medium level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.03; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.07; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.07; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.07; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.07; break; case AugmentationNames.ENMCoreV2: //Medium high level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.3; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.08; break; case AugmentationNames.ENMCoreV3: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.1; break; case AugmentationNames.ENMAnalyzeEngine: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.1; break; case AugmentationNames.ENMDMA: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.2; break; case AugmentationNames.Neuralstimulator: //Medium Level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.12; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.12; break; case AugmentationNames.NeuralAccelerator: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.2; break; case AugmentationNames.CranialSignalProcessorsG1: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.05; break; case AugmentationNames.CranialSignalProcessorsG2: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.07; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.07; break; case AugmentationNames.CranialSignalProcessorsG3: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.09; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.09; break; case AugmentationNames.CranialSignalProcessorsG4: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_grow_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_grow_mult *= 1.25; break; case AugmentationNames.CranialSignalProcessorsG5: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.3; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.25; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_grow_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_grow_mult *= 1.75; break; case AugmentationNames.NeuronalDensification: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; break; //Work augmentations case AugmentationNames.NuoptimalInjectorImplant: //Low medium level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.2; break; case AugmentationNames.SpeechEnhancement: //Low level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.1; break; case AugmentationNames.FocusWire: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].work_money_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].work_money_mult *= 1.2; break; case AugmentationNames.PCDNI: //Med level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.3; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.08; break; case AugmentationNames.PCDNIOptimizer: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.75; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.1; break; case AugmentationNames.PCDNINeuralNetwork: //High level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; break; case AugmentationNames.ADRPheromone1: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].faction_rep_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].faction_rep_mult *= 1.1; break; case AugmentationNames.ADRPheromone2: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].faction_rep_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].faction_rep_mult *= 1.2; break; //Hacknet Node Augmentations case AugmentationNames.HacknetNodeCPUUpload: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.85; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.85; break; case AugmentationNames.HacknetNodeCacheUpload: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.10; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= 0.85; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.10; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= 0.85; break; case AugmentationNames.HacknetNodeNICUpload: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.9; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.9; break; case AugmentationNames.HacknetNodeKernelDNI: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.25; break; case AugmentationNames.HacknetNodeCoreDNI: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.45; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.45; break; //Misc augmentations case AugmentationNames.NeuroFluxGovernor: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_grow_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_grow_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].faction_rep_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].faction_rep_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_success_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_success_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.01; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.99; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_ram_cost_mult *= 0.99; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_core_cost_mult *= 0.99; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= 0.99; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_money_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= 0.99; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_ram_cost_mult *= 0.99; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_core_cost_mult *= 0.99; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= 0.99; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].work_money_mult *= 1.01; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].work_money_mult *= 1.01; if (!reapply) { Augmentations[aug.name].level = aug.level; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations[i].level = aug.level; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations[i].level = aug.level; break; } } } break; case AugmentationNames.Neurotrainer1: //Low Level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.1; break; case AugmentationNames.Neurotrainer2: //Medium level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; break; case AugmentationNames.Neurotrainer3: //High Level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.2; break; case AugmentationNames.Hypersight: //Medium high level - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.03; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; break; case AugmentationNames.LuminCloaking1: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.1; break; case AugmentationNames.LuminCloaking2: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.25; break; case AugmentationNames.HemoRecirculator: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.08; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.08; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.08; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.08; break; case AugmentationNames.SmartSonar: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.25; break; case AugmentationNames.PowerRecirculator: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.05; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.1; break; //Unique augmentations (for factions) case AugmentationNames.QLink: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.3; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 2; break; case AugmentationNames.TheRedPill: break; case AugmentationNames.SPTN97: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.75; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.75; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.75; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.75; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.75; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.15; break; case AugmentationNames.HiveMind: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_grow_mult *= 3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_grow_mult *= 3; break; case AugmentationNames.CordiARCReactor: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.35; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.35; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.35; break; case AugmentationNames.SmartJaw: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.5; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.5; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.25; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].faction_rep_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.5; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.5; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].faction_rep_mult *= 1.25; break; case AugmentationNames.Neotra: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.55; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.55; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.55; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.55; break; case AugmentationNames.Xanipher: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_exp_mult *= 1.15; break; case AugmentationNames.nextSENS: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].charisma_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].charisma_mult *= 1.2; break; case AugmentationNames.OmniTekInfoLoad: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.25; break; case AugmentationNames.PhotosyntheticCells: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_mult *= 1.4; break; case AugmentationNames.Neurolink: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_chance_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.05; break; case AugmentationNames.TheBlackHand: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_speed_mult *= 1.02; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_money_mult *= 1.1; break; case AugmentationNames.CRTX42AA: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_mult *= 1.08; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_mult *= 1.08; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.15; break; case AugmentationNames.Neuregen: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacking_exp_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hacking_exp_mult *= 1.4; break; case AugmentationNames.CashRoot: break; case AugmentationNames.NutriGen: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.2; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].agility_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_exp_mult *= 1.2; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].agility_exp_mult *= 1.2; break; case AugmentationNames.INFRARet: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_success_mult *= 1.25; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_success_mult *= 1.25; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.1; break; case AugmentationNames.DermaForce: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.5; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.5; break; case AugmentationNames.GrapheneBrachiBlades: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.4; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_success_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.4; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_success_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.3; break; case AugmentationNames.GrapheneBionicArms: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.85; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.85; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.85; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.85; break; case AugmentationNames.BrachiBlades: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].defense_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_success_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].crime_money_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].defense_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_success_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].crime_money_mult *= 1.15; break; case AugmentationNames.BionicArms: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].strength_mult *= 1.3; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].dexterity_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].strength_mult *= 1.3; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].dexterity_mult *= 1.3; break; case AugmentationNames.SNA: - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].work_money_mult *= 1.1; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].company_rep_mult *= 1.15; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].faction_rep_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].work_money_mult *= 1.1; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].company_rep_mult *= 1.15; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].faction_rep_mult *= 1.15; break; default: throw new Error("ERROR: No such augmentation!"); @@ -25734,8 +27621,8 @@ function applyAugmentation(aug, reapply=false) { } if (aug.name == AugmentationNames.NeuroFluxGovernor) { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { //Already have this aug, just upgrade the level return; } @@ -25744,7 +27631,7 @@ function applyAugmentation(aug, reapply=false) { if (!reapply) { var ownedAug = new PlayerOwnedAugmentation(aug.name); - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations.push(ownedAug); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations.push(ownedAug); } } @@ -25754,29 +27641,29 @@ function PlayerOwnedAugmentation(name) { } function installAugmentations(cbScript=null) { - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations.length == 0) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You have not purchased any Augmentations to install!"); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations.length == 0) { + Object(__WEBPACK_IMPORTED_MODULE_10__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You have not purchased any Augmentations to install!"); return false; } var augmentationList = ""; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { - var aug = Augmentations[__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations[i].name]; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { + var aug = Augmentations[__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations[i].name]; if (aug == null) { console.log("ERROR. Invalid augmentation"); continue; } - applyAugmentation(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations[i]); + applyAugmentation(__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations[i]); augmentationList += (aug.name + "
"); } - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].queuedAugmentations = []; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You slowly drift to sleep as scientists put you under in order " + + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations = []; + Object(__WEBPACK_IMPORTED_MODULE_10__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You slowly drift to sleep as scientists put you under in order " + "to install the following Augmentations:
" + augmentationList + "
You wake up in your home...you feel different..."); - Object(__WEBPACK_IMPORTED_MODULE_5__Prestige_js__["a" /* prestigeAugmentation */])(); + Object(__WEBPACK_IMPORTED_MODULE_6__Prestige_js__["a" /* prestigeAugmentation */])(); //Run a script after prestiging - if (cbScript && Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["g" /* isString */])(cbScript)) { - var home = __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].getHomeComputer(); + if (cbScript && Object(__WEBPACK_IMPORTED_MODULE_13__utils_StringHelperFunctions_js__["f" /* isString */])(cbScript)) { + var home = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].getHomeComputer(); for (var i = 0; i < home.scripts.length; ++i) { if (home.scripts[i].filename === cbScript) { var script = home.scripts[i]; @@ -25785,10 +27672,10 @@ function installAugmentations(cbScript=null) { if (ramUsage > ramAvailable) { return; //Not enough RAM } - var runningScriptObj = new __WEBPACK_IMPORTED_MODULE_6__Script_js__["b" /* RunningScript */](script, []); //No args + var runningScriptObj = new __WEBPACK_IMPORTED_MODULE_7__Script_js__["b" /* RunningScript */](script, []); //No args runningScriptObj.threads = 1; //Only 1 thread home.runningScripts.push(runningScriptObj); - Object(__WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__["c" /* addWorkerScript */])(runningScriptObj, home); + Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["c" /* addWorkerScript */])(runningScriptObj, home); } } } @@ -25804,16 +27691,182 @@ function giveAllAugmentations() { var aug = Augmentations[name]; if (aug == null) {continue;} var ownedAug = new PlayerOwnedAugmentation(name); - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].augmentations.push(ownedAug); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations.push(ownedAug); + } + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].reapplyAllAugmentations(); +} + +function displayAugmentationsContent() { + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(__WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent); + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Purchased Augmentations", + })); + + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("pre", { + width:"70%", whiteSpace:"pre-wrap", display:"block", + innerText:"Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.\n" + + "WARNING: Installing your Augmentations resets most of your progress, including:\n\n" + + "Stats/Skill levels and Experience\n" + + "Money\n" + + "Scripts on every computer but your home computer\n" + + "Purchased servers\n" + + "Hacknet Nodes\n" + + "Faction/Company reputation\n" + + "Stocks\n\n" + + "Installing Augmentations lets you start over with the perks and benefits granted by all " + + "of the Augmentations you have ever installed. Also, you will keep any scripts and RAM/Core upgrades " + + "on your home computer (but you will lose all programs besides NUKE.exe)." + })); + + //Install Augmentations button + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Install Augmentations", + tooltip:"'I never asked for this'", + clickListener:()=>{ + installAugmentations(); + return false; + } + })); + + //Backup button + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button flashing-button", innerText:"Backup Save (Export)", + tooltip:"It's always a good idea to backup/export your save!", + clickListener:()=>{ + saveObject.exportGame(); + return false; + } + })); + + //Purchased/queued augmentations list + var queuedAugmentationsList = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("ul", {class:"augmentations-list"}); + + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { + var augName = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations[i].name; + var aug = Augmentations[augName]; + + var displayName = augName; + if (augName === AugmentationNames.NeuroFluxGovernor) { + displayName += " - Level " + (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].queuedAugmentations[i].level); + } + + var accordion = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["e" /* createAccordionElement */])({hdrText:displayName, panelText:aug.info}); + queuedAugmentationsList.appendChild(accordion[0]); + } + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(queuedAugmentationsList); + + //Installed augmentations list + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Installed Augmentations", marginTop:"8px", + })); + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("p", { + width:"70%", whiteSpace:"pre-wrap", + innerText:"List of all Augmentations (including Source Files) that have been " + + "installed. You have gained the effects of these Augmentations." + })); + + var augmentationsList = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("ul", {class:"augmentations-list"}); + + //Expand/Collapse All buttons + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", fontSize:"14px", innerText:"Expand All", display:"inline-block", + clickListener:()=>{ + var allHeaders = augmentationsList.getElementsByClassName("accordion-header"); + for (var i = 0; i < allHeaders.length; ++i) { + if (!allHeaders[i].classList.contains("active")) {allHeaders[i].click();} + } + } + })); + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", fontSize:"14px", innerText:"Collapse All", display:"inline-block", + clickListener:()=>{ + var allHeaders = augmentationsList.getElementsByClassName("accordion-header"); + for (var i = 0; i < allHeaders.length; ++i) { + if (allHeaders[i].classList.contains("active")) {allHeaders[i].click();} + } + } + })); + + //Sort Buttons + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", fontSize:"14px", innerText:"Sort in Order", + tooltip:"Sorts the Augmentations alphabetically and Source Files in numerical order (1, 2, 3,...)", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(augmentationsList); + + //Create a copy of Player's Source Files and augs array and sort them + var sourceFiles = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].sourceFiles.slice(); + var augs = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations.slice(); + sourceFiles.sort((sf1, sf2)=>{ + return sf1.n - sf2.n; + }); + augs.sort((aug1, aug2)=>{ + return aug1.name <= aug2.name ? -1 : 1; + }); + displaySourceFiles(augmentationsList, sourceFiles); + displayAugmentations(augmentationsList, augs); + } + })); + + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", fontSize:"14px", innerText:"Sort by Acquirement Time", + tooltip:"Sorts the Augmentations and Source Files based on when you acquired them (same as default)", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(augmentationsList); + displaySourceFiles(augmentationsList, __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].sourceFiles); + displayAugmentations(augmentationsList, __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations); + } + })); + + //Source Files - Temporary...Will probably put in a separate pane Later + displaySourceFiles(augmentationsList, __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].sourceFiles); + displayAugmentations(augmentationsList, __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].augmentations); + __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"].Display.augmentationsContent.appendChild(augmentationsList); +} + +//Creates the accordion elements to display Augmentations +// @listElement - List DOM element to append accordion elements to +// @augs - Array of Augmentation objects +function displayAugmentations(listElement, augs) { + for (var i = 0; i < augs.length; ++i) { + var augName = augs[i].name; + var aug = Augmentations[augName]; + + var displayName = augName; + if (augName === AugmentationNames.NeuroFluxGovernor) { + displayName += " - Level " + (augs[i].level); + } + var accordion = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["e" /* createAccordionElement */])({hdrText:displayName, panelText:aug.info}); + listElement.appendChild(accordion[0]); + } +} + +//Creates the accordion elements to display Source Files +// @listElement - List DOM element to append accordion elements to +// @sourceFiles - Array of Source File objects +function displaySourceFiles(listElement, sourceFiles) { + for (var i = 0; i < sourceFiles.length; ++i) { + var srcFileKey = "SourceFile" + sourceFiles[i].n; + var sourceFileObject = __WEBPACK_IMPORTED_MODULE_9__SourceFile_js__["b" /* SourceFiles */][srcFileKey]; + if (sourceFileObject == null) { + console.log("ERROR: Invalid source file number: " + sourceFiles[i].n); + continue; + } + var accordion = Object(__WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__["e" /* createAccordionElement */])({ + hdrText:sourceFileObject.name + "
" + "Level " + (sourceFiles[i].lvl) + " / 3", + panelText:sourceFileObject.info + }); + + listElement.appendChild(accordion[0]); } - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].reapplyAllAugmentations(); } + /***/ }), -/* 21 */ +/* 28 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -25826,10 +27879,10 @@ function giveAllAugmentations() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Company; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return CompanyPosition; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return companyExists; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Location_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Location_js__ = __webpack_require__(18); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_JSONReviver_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_JSONReviver_js__ = __webpack_require__(9); @@ -26980,750 +29033,7 @@ function getJobRequirementText(company, pos, tooltiptext=false) { /***/ }), -/* 22 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateScriptEditorContent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadAllRunningScripts; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return findRunningScript; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return RunningScript; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Script; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllServersMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return scriptEditorInit; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Fconf_js__ = __webpack_require__(180); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Settings_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Terminal_js__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__TextFile_js__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__ = __webpack_require__(5); -var ace = __webpack_require__(52); -__webpack_require__(53); -__webpack_require__(54); -__webpack_require__(55); -__webpack_require__(56); -__webpack_require__(57); -__webpack_require__(58); -__webpack_require__(59); -__webpack_require__(60); -__webpack_require__(61); -__webpack_require__(62); -__webpack_require__(63); -__webpack_require__(64); -__webpack_require__(65); - - - - - - - - - - - - - - - - - - - - -var keybindings = { - ace: null, - vim: "ace/keyboard/vim", - emacs: "ace/keyboard/emacs", -}; - -var scriptEditorRamCheck = null, scriptEditorRamText = null; -function scriptEditorInit() { - //Create buttons at the bottom of script editor - var wrapper = document.getElementById("script-editor-buttons-wrapper"); - if (wrapper == null) { - console.log("Error finding 'script-editor-buttons-wrapper'"); - return; - } - var closeButton = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", - innerText:"Save & Close (Ctrl + b)", - clickListener:()=>{ - saveAndCloseScriptEditor(); - return false; - } - }); - - scriptEditorRamText = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("p", { - display:"inline-block", margin:"10px", id:"script-editor-status-text" - }); - - var checkboxLabel = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("label", { - for:"script-editor-ram-check", margin:"4px", marginTop: "8px", - innerText:"Dynamic RAM Usage Checker", color:"white", - tooltip:"Enable/Disable the dynamic RAM Usage display. You may " + - "want to disable it for very long scripts because there may be " + - "performance issues" - }); - - scriptEditorRamCheck = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"checkbox", name:"script-editor-ram-check", id:"script-editor-ram-check", - margin:"4px", marginTop: "8px", - }); - scriptEditorRamCheck.checked = true; - - var documentationButton = Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["f" /* createElement */])("a", { - display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation", - href:"https://bitburner.readthedocs.io/en/latest/index.html", - target:"_blank" - }); - - wrapper.appendChild(closeButton); - wrapper.appendChild(scriptEditorRamText); - wrapper.appendChild(scriptEditorRamCheck); - wrapper.appendChild(checkboxLabel); - wrapper.appendChild(documentationButton); - - //Initialize ACE Script editor - var editor = ace.edit('javascript-editor'); - editor.getSession().setMode('ace/mode/netscript'); - editor.setTheme('ace/theme/monokai'); - document.getElementById('javascript-editor').style.fontSize='16px'; - editor.setOption("showPrintMargin", false); - - /* Script editor options */ - //Theme - var themeDropdown = document.getElementById("script-editor-option-theme"); - if (__WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme) { - var initialIndex = 2; - for (var i = 0; i < themeDropdown.options.length; ++i) { - if (themeDropdown.options[i].value === __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme) { - initialIndex = i; - break; - } - } - themeDropdown.selectedIndex = initialIndex; - } else { - themeDropdown.selectedIndex = 2; - } - - themeDropdown.onchange = function() { - var val = themeDropdown.value; - __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorTheme = val; - var themePath = "ace/theme/" + val.toLowerCase(); - editor.setTheme(themePath); - }; - themeDropdown.onchange(); - - //Keybinding - var keybindingDropdown = document.getElementById("script-editor-option-keybinding"); - if (__WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding) { - var initialIndex = 0; - for (var i = 0; i < keybindingDropdown.options.length; ++i) { - if (keybindingDropdown.options[i].value === __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding) { - initialIndex = i; - break; - } - } - keybindingDropdown.selectedIndex = initialIndex; - } else { - keybindingDropdown.selectedIndex = 0; - } - keybindingDropdown.onchange = function() { - var val = keybindingDropdown.value; - __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].EditorKeybinding = val; - editor.setKeyboardHandler(keybindings[val.toLowerCase()]); - }; - keybindingDropdown.onchange(); - - //Highlight Active line - var highlightActiveChkBox = document.getElementById("script-editor-option-highlightactiveline"); - highlightActiveChkBox.onchange = function() { - editor.setHighlightActiveLine(highlightActiveChkBox.checked); - }; - - //Show Invisibles - var showInvisiblesChkBox = document.getElementById("script-editor-option-showinvisibles"); - showInvisiblesChkBox.onchange = function() { - editor.setShowInvisibles(showInvisiblesChkBox.checked); - }; - - //Use Soft Tab - var softTabChkBox = document.getElementById("script-editor-option-usesofttab"); - softTabChkBox.onchange = function() { - editor.getSession().setUseSoftTabs(softTabChkBox.checked); - }; - - //Jshint Maxerr - var maxerr = document.getElementById("script-editor-option-maxerr"); - var maxerrLabel = document.getElementById("script-editor-option-maxerror-value-label"); - maxerrLabel.innerHTML = maxerr.value; - maxerr.onchange = function() { - editor.getSession().$worker.send("changeOptions", [{maxerr:maxerr.value}]); - maxerrLabel.innerHTML = maxerr.value; - } - - //Configure some of the VIM keybindings - ace.config.loadModule('ace/keyboard/vim', function(module) { - var VimApi = module.CodeMirror.Vim; - VimApi.defineEx('write', 'w', function(cm, input) { - saveAndCloseScriptEditor(); - }); - VimApi.defineEx('quit', 'q', function(cm, input) { - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); - }); - VimApi.defineEx('xwritequit', 'x', function(cm, input) { - saveAndCloseScriptEditor(); - }); - VimApi.defineEx('wqwritequit', 'wq', function(cm, input) { - saveAndCloseScriptEditor(); - }); - }); - - //Function autocompleter - editor.setOption("enableBasicAutocompletion", true); - var autocompleter = { - getCompletions: function(editor, session, pos, prefix, callback) { - if (prefix.length === 0) {callback(null, []); return;} - var words = []; - var fns = Object(__WEBPACK_IMPORTED_MODULE_5__NetscriptFunctions_js__["a" /* NetscriptFunctions */])(null); - for (var name in fns) { - if (fns.hasOwnProperty(name)) { - words.push({ - name: name, - value: name, - }); - } - } - callback(null, words); - }, - } - editor.completers = [autocompleter]; -} - -//Updates RAM usage in script -function updateScriptEditorContent() { - var filename = document.getElementById("script-editor-filename").value; - if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !filename.endsWith(".script")) { - scriptEditorRamText.innerText = "N/A"; - return; - } - var editor = ace.edit('javascript-editor'); - var code = editor.getValue(); - var codeCopy = code.repeat(1); - var ramUsage = calculateRamUsage(codeCopy); - if (ramUsage !== -1) { - scriptEditorRamText.innerText = "RAM: " + Object(__WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__["c" /* formatNumber */])(ramUsage, 2).toString() + "GB"; - } else { - scriptEditorRamText.innerText = "RAM: Syntax Error"; - } -} - -//Define key commands in script editor (ctrl o to save + close, etc.) -$(document).keydown(function(e) { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.ScriptEditor) { - //Ctrl + b - if (e.keyCode == 66 && e.ctrlKey) { - e.preventDefault(); - saveAndCloseScriptEditor(); - } - } -}); - -function saveAndCloseScriptEditor() { - var filename = document.getElementById("script-editor-filename").value; - var editor = ace.edit('javascript-editor'); - var code = editor.getValue(); - if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["b" /* iTutorialIsRunning */] && __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["a" /* currITutorialStep */] == __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["e" /* iTutorialSteps */].TerminalTypeScript) { - if (filename != "foodnstuff.script") { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Leave the script name as 'foodnstuff'!"); - return; - } - code = code.replace(/\s/g, ""); - if (code.indexOf("while(true){hack('foodnstuff');}") == -1) { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Please copy and paste the code from the tutorial!"); - return; - } - Object(__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["c" /* iTutorialNextStep */])(); - } - - if (filename == "") { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must specify a filename!"); - return; - } - - if (checkValidFilename(filename) == false) { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Script filename can contain only alphanumerics, hyphens, and underscores"); - return; - } - - var s = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].getCurrentServer(); - if (filename === ".fconf") { - try { - Object(__WEBPACK_IMPORTED_MODULE_2__Fconf_js__["d" /* parseFconfSettings */])(code); - } catch(e) { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid .fconf file"); - return; - } - } else if (filename.endsWith(".script")) { - //If the current script already exists on the server, overwrite it - for (var i = 0; i < s.scripts.length; i++) { - if (filename == s.scripts[i].filename) { - s.scripts[i].saveScript(); - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); - return; - } - } - - //If the current script does NOT exist, create a new one - var script = new Script(); - script.saveScript(); - s.scripts.push(script); - } else if (filename.endsWith(".txt")) { - for (var i = 0; i < s.textFiles.length; ++i) { - if (s.textFiles[i].fn === filename) { - s.textFiles[i].write(code); - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); - return; - } - } - var textFile = new __WEBPACK_IMPORTED_MODULE_11__TextFile_js__["a" /* TextFile */](filename, code); - s.textFiles.push(textFile); - } else { - Object(__WEBPACK_IMPORTED_MODULE_13__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid filename. Must be either a script (.script) or " + - " or text file (.txt)") - return; - } - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadTerminalContent(); -} - -//Checks that the string contains only valid characters for a filename, which are alphanumeric, -// underscores, hyphens, and dots -function checkValidFilename(filename) { - var regex = /^[.a-zA-Z0-9_-]+$/; - - if (filename.match(regex)) { - return true; - } - return false; -} - -function Script() { - this.filename = ""; - this.code = ""; - this.ramUsage = 0; - this.server = ""; //IP of server this script is on -}; - -//Get the script data from the Script Editor and save it to the object -Script.prototype.saveScript = function() { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.ScriptEditor) { - //Update code and filename - var editor = ace.edit('javascript-editor'); - var code = editor.getValue(); - this.code = code.replace(/^\s+|\s+$/g, ''); - - var filename = document.getElementById("script-editor-filename").value; - this.filename = filename; - - //Server - this.server = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].currentServer; - - //Calculate/update ram usage, execution time, etc. - this.updateRamUsage(); - } -} - -//Updates how much RAM the script uses when it is running. -Script.prototype.updateRamUsage = function() { - var codeCopy = this.code.repeat(1); - var res = calculateRamUsage(codeCopy); - if (res !== -1) { - this.ramUsage = res; - } -} - -function calculateRamUsage(codeCopy) { - //Create a temporary/mock WorkerScript and an AST from the code - var currServ = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].getCurrentServer(); - var workerScript = new __WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__["b" /* WorkerScript */]({ - filename:"foo", - scriptRef: {code:""}, - args:[] - }); - workerScript.checkingRam = true; //Netscript functions will return RAM usage - workerScript.serverIp = currServ.ip; - - try { - var ast = Object(__WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["parse"])(codeCopy, {sourceType:"module"}); - } catch(e) { - return -1; - } - - //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes - var queue = [], ramUsage = 1.4; - var whileUsed = false, forUsed = false, ifUsed = false; - queue.push(ast); - while (queue.length != 0) { - var exp = queue.shift(); - switch (exp.type) { - case "ImportDeclaration": - //Gets an array of all imported functions as AST expressions - //and pushes them on the queue. - var res = Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptEvaluator_js__["b" /* evaluateImport */])(exp, workerScript, true); - for (var i = 0; i < res.length; ++i) { - queue.push(res[i]); - } - break; - case "BlockStatement": - case "Program": - for (var i = 0; i < exp.body.length; ++i) { - if (exp.body[i] instanceof __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["Node"]) { - queue.push(exp.body[i]); - } - } - break; - case "WhileStatement": - if (!whileUsed) { - ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptWhileRamCost; - whileUsed = true; - } - break; - case "ForStatement": - if (!forUsed) { - ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptForRamCost; - forUsed = true; - } - break; - case "IfStatement": - if (!ifUsed) { - ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptIfRamCost; - ifUsed = true; - } - break; - case "Identifier": - if (exp.name in workerScript.env.vars) { - var func = workerScript.env.get(exp.name); - if (typeof func === "function") { - try { - var res = func.apply(null, []); - if (typeof res === "number") { - ramUsage += res; - } - } catch(e) { - console.log("ERROR applying function: " + e); - } - } - } - break; - default: - break; - } - - for (var prop in exp) { - if (exp.hasOwnProperty(prop)) { - if (exp[prop] instanceof __WEBPACK_IMPORTED_MODULE_12__utils_acorn_js__["Node"]) { - queue.push(exp[prop]); - } - } - } - } - - //Special case: hacknetnodes array - if (codeCopy.includes("hacknetnodes")) { - ramUsage += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ScriptHacknetNodesRamCost; - } - return ramUsage; -} - -Script.prototype.download = function() { - var filename = this.filename + ".js"; - var file = new Blob([this.code], {type: 'text/plain'}); - if (window.navigator.msSaveOrOpenBlob) {// IE10+ - window.navigator.msSaveOrOpenBlob(file, filename); - } else { // Others - var a = document.createElement("a"), - url = URL.createObjectURL(file); - a.href = url; - a.download = filename; - document.body.appendChild(a); - a.click(); - setTimeout(function() { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); - } -} - -Script.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Script", this); -} - - -Script.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Script, value.data); -} - -__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.Script = Script; - -//Called when the game is loaded. Loads all running scripts (from all servers) -//into worker scripts so that they will start running -function loadAllRunningScripts() { - var count = 0; - var total = 0; - for (var property in __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */]) { - if (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */].hasOwnProperty(property)) { - var server = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][property]; - - //Reset each server's RAM usage to 0 - server.ramUsed = 0; - - for (var j = 0; j < server.runningScripts.length; ++j) { - count++; - Object(__WEBPACK_IMPORTED_MODULE_6__NetscriptWorker_js__["c" /* addWorkerScript */])(server.runningScripts[j], server); - - //Offline production - total += scriptCalculateOfflineProduction(server.runningScripts[j]); - } - } - } - return total; - console.log("Loaded " + count.toString() + " running scripts"); -} - -function scriptCalculateOfflineProduction(runningScriptObj) { - //The Player object stores the last update time from when we were online - var thisUpdate = new Date().getTime(); - var lastUpdate = __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].lastUpdate; - var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds - console.log("Offline for " + timePassed + " seconds"); - - //Calculate the "confidence" rating of the script's true production. This is based - //entirely off of time. We will arbitrarily say that if a script has been running for - //4 hours (14400 sec) then we are completely confident in its ability - var confidence = (runningScriptObj.onlineRunningTime) / 14400; - if (confidence >= 1) {confidence = 1;} - - //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] - - //Grow - for (var ip in runningScriptObj.dataMap) { - if (runningScriptObj.dataMap.hasOwnProperty(ip)) { - if (runningScriptObj.dataMap[ip][2] == 0 || runningScriptObj.dataMap[ip][2] == null) {continue;} - var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; - if (serv == null) {continue;} - var timesGrown = Math.round(0.5 * runningScriptObj.dataMap[ip][2] / runningScriptObj.onlineRunningTime * timePassed); - 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(__WEBPACK_IMPORTED_MODULE_8__Server_js__["j" /* processSingleServerGrowth */])(serv, timesGrown * 450); - runningScriptObj.log(serv.hostname + " grown by " + Object(__WEBPACK_IMPORTED_MODULE_16__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growth * 100 - 100, 6) + "% from grow() calls made while offline"); - } - } - - var totalOfflineProduction = 0; - for (var ip in runningScriptObj.dataMap) { - if (runningScriptObj.dataMap.hasOwnProperty(ip)) { - if (runningScriptObj.dataMap[ip][0] == 0 || runningScriptObj.dataMap[ip][0] == null) {continue;} - var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; - if (serv == null) {continue;} - var production = 0.5 * runningScriptObj.dataMap[ip][0] / runningScriptObj.onlineRunningTime * timePassed; - production *= confidence; - if (production > serv.moneyAvailable) { - production = serv.moneyAvailable; - } - totalOfflineProduction += production; - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].gainMoney(production); - console.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname); - runningScriptObj.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname); - serv.moneyAvailable -= production; - if (serv.moneyAvailable < 0) {serv.moneyAvailable = 0;} - if (isNaN(serv.moneyAvailable)) {serv.moneyAvailable = 0;} - } - } - - //Offline EXP gain - //A script's offline production will always be at most half of its online production. - var expGain = 0.5 * (runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime) * timePassed; - expGain *= confidence; - - __WEBPACK_IMPORTED_MODULE_7__Player_js__["a" /* Player */].gainHackingExp(expGain); - - //Update script stats - runningScriptObj.offlineMoneyMade += totalOfflineProduction; - runningScriptObj.offlineRunningTime += timePassed; - runningScriptObj.offlineExpGained += expGain; - - //Fortify a server's security based on how many times it was hacked - for (var ip in runningScriptObj.dataMap) { - if (runningScriptObj.dataMap.hasOwnProperty(ip)) { - if (runningScriptObj.dataMap[ip][1] == 0 || runningScriptObj.dataMap[ip][1] == null) {continue;} - var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; - if (serv == null) {continue;} - var timesHacked = Math.round(0.5 * runningScriptObj.dataMap[ip][1] / runningScriptObj.onlineRunningTime * timePassed); - console.log(runningScriptObj.filename + " hacked " + serv.hostname + " " + timesHacked + " times while offline"); - runningScriptObj.log("Hacked " + serv.hostname + " " + timesHacked + " times while offline"); - serv.fortify(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ServerFortifyAmount * timesHacked); - } - } - - //Weaken - for (var ip in runningScriptObj.dataMap) { - if (runningScriptObj.dataMap.hasOwnProperty(ip)) { - if (runningScriptObj.dataMap[ip][3] == 0 || runningScriptObj.dataMap[ip][3] == null) {continue;} - var serv = __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip]; - if (serv == null) {continue;} - var timesWeakened = Math.round(0.5 * runningScriptObj.dataMap[ip][3] / runningScriptObj.onlineRunningTime * timePassed); - console.log(runningScriptObj.filename + " called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline"); - runningScriptObj.log("Called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline"); - serv.weaken(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * timesWeakened); - } - } - - return totalOfflineProduction; -} - -//Returns a RunningScript object matching the filename and arguments on the -//designated server, and false otherwise -function findRunningScript(filename, args, server) { - for (var i = 0; i < server.runningScripts.length; ++i) { - if (server.runningScripts[i].filename == filename && - Object(__WEBPACK_IMPORTED_MODULE_15__utils_HelperFunctions_js__["d" /* compareArrays */])(server.runningScripts[i].args, args)) { - return server.runningScripts[i]; - } - } - return null; -} - -function RunningScript(script, args) { - if (script == null || script == undefined) {return;} - this.filename = script.filename; - this.args = args; - this.scriptRef = script; - this.server = script.server; //IP Address only - - this.logs = []; //Script logging. Array of strings, with each element being a log entry - this.logUpd = false; - - //Stats to display on the Scripts menu, and used to determine offline progress - this.offlineRunningTime = 0.01; //Seconds - this.offlineMoneyMade = 0; - this.offlineExpGained = 0; - this.onlineRunningTime = 0.01; //Seconds - this.onlineMoneyMade = 0; - this.onlineExpGained = 0; - - this.threads = 1; - - //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] - this.dataMap = new AllServersMap([0, 0, 0, 0], true); -} - -RunningScript.prototype.log = function(txt) { - if (this.logs.length > __WEBPACK_IMPORTED_MODULE_9__Settings_js__["a" /* Settings */].MaxLogCapacity) { - //Delete first element and add new log entry to the end. - //TODO Eventually it might be better to replace this with circular array - //to improve performance - this.logs.shift(); - } - this.logs.push(txt); - this.logUpd = true; -} - -RunningScript.prototype.displayLog = function() { - for (var i = 0; i < this.logs.length; ++i) { - Object(__WEBPACK_IMPORTED_MODULE_10__Terminal_js__["b" /* post */])(this.logs[i]); - } -} - -RunningScript.prototype.clearLog = function() { - this.logs.length = 0; -} - -//Update the moneyStolen and numTimesHack maps when hacking -RunningScript.prototype.recordHack = function(serverIp, moneyGained, n=1) { - if (this.dataMap == null) { - //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] - this.dataMap = new AllServersMap([0, 0, 0, 0], true); - } - this.dataMap[serverIp][0] += moneyGained; - this.dataMap[serverIp][1] += n; -} - -//Update the grow map when calling grow() -RunningScript.prototype.recordGrow = function(serverIp, n=1) { - if (this.dataMap == null) { - //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] - this.dataMap = new AllServersMap([0, 0, 0, 0], true); - } - this.dataMap[serverIp][2] += n; -} - -//Update the weaken map when calling weaken() { -RunningScript.prototype.recordWeaken = function(serverIp, n=1) { - if (this.dataMap == null) { - //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken] - this.dataMap = new AllServersMap([0, 0, 0, 0], true); - } - this.dataMap[serverIp][3] += n; -} - -RunningScript.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("RunningScript", this); -} - - -RunningScript.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(RunningScript, value.data); -} - -__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.RunningScript = RunningScript; - -//Creates an object that creates a map/dictionary with the IP of each existing server as -//a key. Initializes every key with a specified value that can either by a number or an array -function AllServersMap(arr=false, filterOwned=false) { - for (var ip in __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */]) { - if (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */].hasOwnProperty(ip)) { - if (filterOwned && (__WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip].purchasedByPlayer || __WEBPACK_IMPORTED_MODULE_8__Server_js__["b" /* AllServers */][ip].hostname === "home")) { - continue; - } - if (arr) { - this[ip] = [0, 0, 0, 0]; - } else { - this[ip] = 0; - } - } - } -} - -AllServersMap.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["b" /* Generic_toJSON */])("AllServersMap", this); -} - - -AllServersMap.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(AllServersMap, value.data); -} - -__WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].constructors.AllServersMap = AllServersMap; - - - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) - -/***/ }), -/* 23 */ +/* 29 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -27734,41 +29044,41 @@ __WEBPACK_IMPORTED_MODULE_14__utils_JSONReviver_js__["c" /* Reviver */].construc /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return hasWallStreetSF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return hasCorporationSF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return wallStreetSFLvl; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Company_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(66); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Message_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Missions_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(55); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Company_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(73); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Message_js__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Missions_js__ = __webpack_require__(44); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Script_js__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Settings_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Script_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Settings_js__ = __webpack_require__(14); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__Terminal_js__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__TextFile_js__ = __webpack_require__(68); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__NetscriptEnvironment_js__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__NetscriptPort_js__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_decimal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__StockMarket_js__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__Terminal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__TextFile_js__ = __webpack_require__(60); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__ = __webpack_require__(42); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__NetscriptEnvironment_js__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__NetscriptPort_js__ = __webpack_require__(69); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_decimal_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_26__utils_decimal_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__utils_YesNoBox_js__ = __webpack_require__(15); -var sprintf = __webpack_require__(46).sprintf, - vsprintf = __webpack_require__(46).vsprintf +var sprintf = __webpack_require__(72).sprintf, + vsprintf = __webpack_require__(72).vsprintf @@ -29495,7 +30805,7 @@ function NetscriptFunctions(workerScript) { throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); } return port.write(data); - } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(port)) { //Write to text file + } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file var fn = port; var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (server == null) { @@ -29536,7 +30846,7 @@ function NetscriptFunctions(workerScript) { throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer"); } return port.read(); - } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(port)) { //Read from text file + } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file var fn = port; var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (server == null) { @@ -29593,7 +30903,7 @@ function NetscriptFunctions(workerScript) { throw Object(__WEBPACK_IMPORTED_MODULE_23__NetscriptEvaluator_js__["e" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer"); } return port.clear(); - } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(port)) { //Clear text file + } else if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Clear text file var fn = port; var server = Object(__WEBPACK_IMPORTED_MODULE_16__Server_js__["e" /* getServer */])(workerScript.serverIp); if (server == null) { @@ -29668,7 +30978,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 __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(f) && f === fn) { + if (!(f instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(f) && f === fn) { s.messages.splice(i, 1); return true; } @@ -29881,7 +31191,7 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open"); return false; } - if (!Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(txt)) {txt = String(txt);} + if (!Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(txt)) {txt = String(txt);} var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_31__utils_YesNoBox_js__["d" /* yesNoBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_31__utils_YesNoBox_js__["c" /* yesNoBoxGetNoButton */])(); yesBtn.innerHTML = "Yes"; noBtn.innerHTML = "No"; @@ -30601,7 +31911,7 @@ function NetscriptFunctions(workerScript) { return false; } //The Player object's applyForJob function can return string with special error messages - if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(res)) { + if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(res)) { workerScript.scriptRef.log(res); return false; } @@ -31265,7 +32575,7 @@ function NetscriptFunctions(workerScript) { var res = Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["k" /* purchaseAugmentation */])(aug, fac, true); workerScript.scriptRef.log(res); - if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["g" /* isString */])(res) && res.startsWith("You purchased")) { + if (Object(__WEBPACK_IMPORTED_MODULE_30__utils_StringHelperFunctions_js__["f" /* isString */])(res) && res.startsWith("You purchased")) { __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); return true; } else { @@ -31296,7 +32606,7 @@ function NetscriptFunctions(workerScript) { } __WEBPACK_IMPORTED_MODULE_14__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed"); - Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* installAugmentations */])(cbScript); + Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["i" /* installAugmentations */])(cbScript); return true; } } @@ -31306,7 +32616,318 @@ function NetscriptFunctions(workerScript) { /***/ }), -/* 24 */ +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(3); +var support = __webpack_require__(20); +var nodejsUtils = __webpack_require__(50); +var GenericWorker = __webpack_require__(10); + +/** + * The following functions come from pako, from pako/lib/utils/strings + * released under the MIT license, see pako https://github.com/nodeca/pako/ + */ + +// Table with utf8 lengths (calculated by first byte of sequence) +// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, +// because max possible codepoint is 0x10ffff +var _utf8len = new Array(256); +for (var i=0; i<256; i++) { + _utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1); +} +_utf8len[254]=_utf8len[254]=1; // Invalid sequence start + +// convert string to array (typed, when possible) +var string2buf = function (str) { + var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; + + // count binary size + for (m_pos = 0; m_pos < str_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { + c2 = str.charCodeAt(m_pos+1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; + } + + // allocate buffer + if (support.uint8array) { + buf = new Uint8Array(buf_len); + } else { + buf = new Array(buf_len); + } + + // convert + for (i=0, m_pos = 0; i < buf_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) { + c2 = str.charCodeAt(m_pos+1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + if (c < 0x80) { + /* one byte */ + buf[i++] = c; + } else if (c < 0x800) { + /* two bytes */ + buf[i++] = 0xC0 | (c >>> 6); + buf[i++] = 0x80 | (c & 0x3f); + } else if (c < 0x10000) { + /* three bytes */ + buf[i++] = 0xE0 | (c >>> 12); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } else { + /* four bytes */ + buf[i++] = 0xf0 | (c >>> 18); + buf[i++] = 0x80 | (c >>> 12 & 0x3f); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } + } + + return buf; +}; + +// Calculate max possible position in utf8 buffer, +// that will not break sequence. If that's not possible +// - (very small limits) return max size as is. +// +// buf[] - utf8 bytes array +// max - length limit (mandatory); +var utf8border = function(buf, max) { + var pos; + + max = max || buf.length; + if (max > buf.length) { max = buf.length; } + + // go back from last position, until start of sequence found + pos = max-1; + while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } + + // Fuckup - very small and broken sequence, + // return max, because we should return something anyway. + if (pos < 0) { return max; } + + // If we came to start of buffer - that means vuffer is too small, + // return max too. + if (pos === 0) { return max; } + + return (pos + _utf8len[buf[pos]] > max) ? pos : max; +}; + +// convert array to string +var buf2string = function (buf) { + var str, i, out, c, c_len; + var len = buf.length; + + // Reserve max possible length (2 words per char) + // NB: by unknown reasons, Array is significantly faster for + // String.fromCharCode.apply than Uint16Array. + var utf16buf = new Array(len*2); + + for (out=0, i=0; i 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; } + + // apply mask on first byte + c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; + // join the rest + while (c_len > 1 && i < len) { + c = (c << 6) | (buf[i++] & 0x3f); + c_len--; + } + + // terminated by end of string? + if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; } + + if (c < 0x10000) { + utf16buf[out++] = c; + } else { + c -= 0x10000; + utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff); + utf16buf[out++] = 0xdc00 | (c & 0x3ff); + } + } + + // shrinkBuf(utf16buf, out) + if (utf16buf.length !== out) { + if(utf16buf.subarray) { + utf16buf = utf16buf.subarray(0, out); + } else { + utf16buf.length = out; + } + } + + // return String.fromCharCode.apply(null, utf16buf); + return utils.applyFromCharCode(utf16buf); +}; + + +// That's all for the pako functions. + + +/** + * Transform a javascript string into an array (typed if possible) of bytes, + * UTF-8 encoded. + * @param {String} str the string to encode + * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string. + */ +exports.utf8encode = function utf8encode(str) { + if (support.nodebuffer) { + return nodejsUtils.newBufferFrom(str, "utf-8"); + } + + return string2buf(str); +}; + + +/** + * Transform a bytes array (or a representation) representing an UTF-8 encoded + * string into a javascript string. + * @param {Array|Uint8Array|Buffer} buf the data de decode + * @return {String} the decoded string. + */ +exports.utf8decode = function utf8decode(buf) { + if (support.nodebuffer) { + return utils.transformTo("nodebuffer", buf).toString("utf-8"); + } + + buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf); + + return buf2string(buf); +}; + +/** + * A worker to decode utf8 encoded binary chunks into string chunks. + * @constructor + */ +function Utf8DecodeWorker() { + GenericWorker.call(this, "utf-8 decode"); + // the last bytes if a chunk didn't end with a complete codepoint. + this.leftOver = null; +} +utils.inherits(Utf8DecodeWorker, GenericWorker); + +/** + * @see GenericWorker.processChunk + */ +Utf8DecodeWorker.prototype.processChunk = function (chunk) { + + var data = utils.transformTo(support.uint8array ? "uint8array" : "array", chunk.data); + + // 1st step, re-use what's left of the previous chunk + if (this.leftOver && this.leftOver.length) { + if(support.uint8array) { + var previousData = data; + data = new Uint8Array(previousData.length + this.leftOver.length); + data.set(this.leftOver, 0); + data.set(previousData, this.leftOver.length); + } else { + data = this.leftOver.concat(data); + } + this.leftOver = null; + } + + var nextBoundary = utf8border(data); + var usableData = data; + if (nextBoundary !== data.length) { + if (support.uint8array) { + usableData = data.subarray(0, nextBoundary); + this.leftOver = data.subarray(nextBoundary, data.length); + } else { + usableData = data.slice(0, nextBoundary); + this.leftOver = data.slice(nextBoundary, data.length); + } + } + + this.push({ + data : exports.utf8decode(usableData), + meta : chunk.meta + }); +}; + +/** + * @see GenericWorker.flush + */ +Utf8DecodeWorker.prototype.flush = function () { + if(this.leftOver && this.leftOver.length) { + this.push({ + data : exports.utf8decode(this.leftOver), + meta : {} + }); + this.leftOver = null; + } +}; +exports.Utf8DecodeWorker = Utf8DecodeWorker; + +/** + * A worker to endcode string chunks into utf8 encoded binary chunks. + * @constructor + */ +function Utf8EncodeWorker() { + GenericWorker.call(this, "utf-8 encode"); +} +utils.inherits(Utf8EncodeWorker, GenericWorker); + +/** + * @see GenericWorker.processChunk + */ +Utf8EncodeWorker.prototype.processChunk = function (chunk) { + this.push({ + data : exports.utf8encode(chunk.data), + meta : chunk.meta + }); +}; +exports.Utf8EncodeWorker = Utf8EncodeWorker; + + +/***/ }), +/* 31 */ +/***/ (function(module, exports) { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + + +/***/ }), +/* 32 */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeMcl/decimal.js/LICENCE */ @@ -36125,7 +37746,2348 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM /***/ }), -/* 25 */ +/* 33 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Messages; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return checkForMessagesToSend; }); +/* unused harmony export sendMessage */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return showMessage; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadMessages; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initMessages; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Message; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Missions_js__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RedPill_js__ = __webpack_require__(58); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(9); + + + + + + + + + + +/* Message.js */ +function Message(filename="", msg="") { + this.filename = filename; + this.msg = msg; + this.recvd = false; +} + +Message.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Message", this); +} + + +Message.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Message, value.data); +} + +__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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 || !__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])(txt); +} + +//Adds a message to a server +function addMessageToServer(msg, serverHostname) { + var server = Object(__WEBPACK_IMPORTED_MODULE_5__Server_js__["c" /* 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 (__WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["b" /* AugmentationNames */].TheRedPill].owned) { + redpillOwned = true; + } + + if (redpill && redpillOwned && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].sourceFiles.length === 0 && !__WEBPACK_IMPORTED_MODULE_4__RedPill_js__["b" /* redPillFlag */] && !__WEBPACK_IMPORTED_MODULE_2__Missions_js__["c" /* inMission */]) { + if (!__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["b" /* dialogBoxOpened */]) { + sendMessage(redpill, true); + } + } else if (redpill && redpillOwned) { + //If player has already destroyed a BitNode, message is not forced + if (!__WEBPACK_IMPORTED_MODULE_4__RedPill_js__["b" /* redPillFlag */] && !__WEBPACK_IMPORTED_MODULE_2__Missions_js__["c" /* inMission */] && !__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["b" /* dialogBoxOpened */]) { + sendMessage(redpill); + } + } else if (jumper0 && !jumper0.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 25) { + sendMessage(jumper0); + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__["a" /* Programs */].Flight); + } else if (jumper1 && !jumper1.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 40) { + sendMessage(jumper1); + } else if (cybersecTest && !cybersecTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 50) { + sendMessage(cybersecTest); + } else if (jumper2 && !jumper2.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 175) { + sendMessage(jumper2); + } else if (nitesecTest && !nitesecTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 200) { + sendMessage(nitesecTest); + } else if (jumper3 && !jumper3.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 350) { + sendMessage(jumper3); + } else if (jumper4 && !jumper4.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 490) { + sendMessage(jumper4); + } else if (bitrunnersTest && !bitrunnersTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 500) { + sendMessage(bitrunnersTest); + } +} + +function AddToAllMessages(msg) { + Messages[msg.filename] = msg; +} + +let Messages = {} + +function loadMessages(saveString) { + Messages = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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$)")); +} + + + + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global) {/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + + + +var base64 = __webpack_require__(125) +var ieee754 = __webpack_require__(126) +var isArray = __webpack_require__(75) + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(21))) + +/***/ }), +/* 35 */ +/***/ (function(module, exports) { + +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34).Buffer)) + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* global Promise */ + + +// load the global object first: +// - it should be better integrated in the system (unhandledRejection in node) +// - the environment may have a custom Promise implementation (see zone.js) +var ES6Promise = null; +if (typeof Promise !== "undefined") { + ES6Promise = Promise; +} else { + ES6Promise = __webpack_require__(152); +} + +/** + * Let the user use/change some implementations. + */ +module.exports = { + Promise: ES6Promise +}; + + +/***/ }), +/* 38 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -36133,15 +40095,15 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return addActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return deleteActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return updateActiveScriptsItems; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NetscriptWorker_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Server_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Server_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(42); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(52); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(6); @@ -36424,12506 +40386,138 @@ function updateActiveScriptsText(workerscript, item, statsEl=null) { /***/ }), -/* 26 */ +/* 39 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* unused harmony export hacknetNodesInit */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HacknetNode; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return purchaseHacknet; }); -/* unused harmony export updateTotalHacknetProduction */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getCostOfNextHacknetNode; }); -/* unused harmony export updateHacknetNodesMultiplierButtons */ -/* unused harmony export getMaxNumberLevelUpgrades */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return displayHacknetNodesContent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return updateHacknetNodesContent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return processAllHacknetNodeEarnings; }); -/* unused harmony export getHacknetNode */ -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(33); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__ = __webpack_require__(5); - - - - - - - - - - -/* HacknetNode.js */ -function hacknetNodesInit() { - var mult1x = document.getElementById("hacknet-nodes-1x-multiplier"); - mult1x.addEventListener("click", function() { - hacknetNodePurchaseMultiplier = 1; - updateHacknetNodesMultiplierButtons(); - updateHacknetNodesContent(); - return false; - }); - var mult5x = document.getElementById("hacknet-nodes-5x-multiplier"); - mult5x.addEventListener("click", function() { - hacknetNodePurchaseMultiplier = 5; - updateHacknetNodesMultiplierButtons(); - updateHacknetNodesContent(); - return false; - }); - var mult10x = document.getElementById("hacknet-nodes-10x-multiplier"); - mult10x.addEventListener("click", function() { - hacknetNodePurchaseMultiplier = 10; - updateHacknetNodesMultiplierButtons(); - updateHacknetNodesContent(); - return false; - }); - var multMax = document.getElementById("hacknet-nodes-max-multiplier"); - multMax.addEventListener("click", function() { - hacknetNodePurchaseMultiplier = 0; - updateHacknetNodesMultiplierButtons(); - updateHacknetNodesContent(); - return false; - }); -} -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 = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMoneyGainPerLevel; - - this.moneyGainRatePerSecond = (this.level * gainPerLevel) * - Math.pow(1.035, this.ram-1) * - ((this.cores + 5) / 6) * - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult * - __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* BitNodeMultipliers */].HacknetNodeMoney; - if (isNaN(this.moneyGainRatePerSecond)) { - this.moneyGainRatePerSecond = 0; - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeLevelMult; - var totalMultiplier = 0; //Summed - var currLevel = this.level; - for (var i = 0; i < levels; ++i) { - totalMultiplier += Math.pow(mult, currLevel); - ++currLevel; - } - return __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNode / 2 * totalMultiplier * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 > __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel) { - var diff = Math.max(0, __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - this.level); - return this.purchaseLevelUpgrade(diff); - } - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); - this.level += levels; - this.updateMoneyGainRate(); - return true; -} - -//Wrapper function for Netscript -HacknetNode.prototype.upgradeLevel = function(levels=1) { - return this.purchaseLevelUpgrade(levels); -} - -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 * __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHacknetNode; - var mult = Math.pow(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeRamMult, numUpgrades); - return baseCost * mult * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} - if (this.ram >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxRam) {return false;} - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); - this.ram *= 2; //Ram is always doubled - this.updateMoneyGainRate(); - return true; -} - -//Wrapper function for Netscript -HacknetNode.prototype.upgradeRam = function() { - return this.purchaseRamUpgrade(); -} - -HacknetNode.prototype.calculateCoreUpgradeCost = function() { - var coreBaseCost = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNodeCore; - var mult = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeCoreMult; - return coreBaseCost * Math.pow(mult, this.cores-1) * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_core_cost_mult; -} - -//Wrapper function for Netscript -HacknetNode.prototype.getCoreUpgradeCost = function() { - return this.calculateCoreUpgradeCost(); -} - -HacknetNode.prototype.purchaseCoreUpgrade = function() { - var cost = this.calculateCoreUpgradeCost(); - if (isNaN(cost)) {return false;} - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} - if (this.cores >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxCores) {return false;} - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["b" /* Generic_toJSON */])("HacknetNode", this); -} - -HacknetNode.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(HacknetNode, value.data); -} - -__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["c" /* Reviver */].constructors.HacknetNode = HacknetNode; - - -function purchaseHacknet() { - /* INTERACTIVE TUTORIAL */ - if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["b" /* iTutorialIsRunning */]) { - if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["a" /* currITutorialStep */] == __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["e" /* iTutorialSteps */].HacknetNodesIntroduction) { - Object(__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["c" /* iTutorialNextStep */])(); - } else { - return; - } - } - - /* END INTERACTIVE TUTORIAL */ - - var cost = getCostOfNextHacknetNode(); - if (isNaN(cost)) {throw new Error("Cost is NaN"); return;} - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; - var name = "hacknet-node-" + numOwned; - var node = new HacknetNode(name); - node.updateMoneyGainRate(); - - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.push(node); - - displayHacknetNodesContent(); - updateTotalHacknetProduction(); - return numOwned; -} - -//Calculates the total production from all HacknetNodes -function updateTotalHacknetProduction() { - var total = 0; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { - total += __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i].moneyGainRatePerSecond; - } - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].totalHacknetNodeProduction = total; -} - -function getCostOfNextHacknetNode() { - //Cost increases exponentially based on how many you own - var numOwned = __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; - var mult = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodePurchaseNextMult; - return __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNode * Math.pow(mult, numOwned) * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(1))) {return 0;} - var min = 1; - var max = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel-1; - var levelsToMax = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - nodeObj.level; - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) { - return levelsToMax; - } - - while (min <= max) { - var curr = (min + max) / 2 | 0; - if (curr != __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel && - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(curr)) && - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(curr+1))) { - return Math.min(levelsToMax, curr); - } else if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(curr))) { - max = curr - 1; - } else if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(curr))) { - min = curr + 1; - } else { - return Math.min(levelsToMax, curr); - } - } -} - -//Creates Hacknet Node DOM elements when the page is opened -function displayHacknetNodesContent() { - //Update Hacknet Nodes button - var newPurchaseButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["b" /* 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 < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { - createHacknetNodeDomElement(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 = document.getElementById("hacknet-nodes-purchase-button"); - purchaseButton.innerHTML = "Purchase Hacknet Node - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2); - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) { - purchaseButton.setAttribute("class", "a-link-button-inactive"); - } else { - purchaseButton.setAttribute("class", "a-link-button"); - } - - //Update player's money - var moneyElem = document.getElementById("hacknet-nodes-money"); - moneyElem.innerHTML = "Money: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.toNumber(), 2) + "
" + - "Total production from all Hacknet Nodes: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].totalHacknetNodeProduction, 2) + " / second"; - - //Update information in each owned hacknet node - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { - updateHacknetNodeDomElement(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]); - } -} - -//Creates a single Hacknet Node DOM element -function createHacknetNodeDomElement(nodeObj) { - var nodeName = nodeObj.name; - - var listItem = document.createElement("li"); - listItem.setAttribute("class", "hacknet-node"); - - var span = document.createElement("span"); - span.style.display = "inline"; - - var buttonDiv = document.createElement("div"); - buttonDiv.setAttribute("class", "hacknet-node-button-div"); - - //Text - var txt = document.createElement("p"); - //txt.setAttribute("id", "hacknet-node-text-" + nodeName); - txt.id = "hacknet-node-text-" + nodeName; - - //Upgrade buttons - var upgradeLevelButton = document.createElement("a"); - var upgradeRamButton = document.createElement("a"); - var upgradeCoreButton = document.createElement("a"); - - //upgradeLevelButton.setAttribute("id", "hacknet-node-upgrade-level-" + nodeName); - upgradeLevelButton.id = "hacknet-node-upgrade-level-" + nodeName; - upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); - upgradeLevelButton.addEventListener("click", function() { - var numUpgrades = hacknetNodePurchaseMultiplier; - if (hacknetNodePurchaseMultiplier == 0) { - numUpgrades = getMaxNumberLevelUpgrades(nodeObj); - } - nodeObj.purchaseLevelUpgrade(numUpgrades); - updateHacknetNodesContent(); - return false; - }); - //upgradeRamButton.setAttribute("id", "hacknet-node-upgrade-ram-" + nodeName); - upgradeRamButton.id = "hacknet-node-upgrade-ram-" + nodeName; - upgradeRamButton.setAttribute("class", "a-link-button-inactive"); - upgradeRamButton.addEventListener("click", function() { - nodeObj.purchaseRamUpgrade(); - updateHacknetNodesContent(); - return false; - }); - //upgradeCoreButton.setAttribute("id", "hacknet-node-upgrade-core-" + nodeName); - upgradeCoreButton.id = "hacknet-node-upgrade-core-" + nodeName; - upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); - upgradeCoreButton.addEventListener("click", function() { - nodeObj.purchaseCoreUpgrade(); - updateHacknetNodesContent(); - return false; - }); - - //Put all the components together in the li element - span.appendChild(txt); - buttonDiv.appendChild(upgradeLevelButton); - buttonDiv.appendChild(upgradeRamButton); - buttonDiv.appendChild(upgradeCoreButton); - span.appendChild(buttonDiv); - listItem.appendChild(span); - - document.getElementById("hacknet-nodes-list").appendChild(listItem); - - //Set the text and stuff inside the DOM element - updateHacknetNodeDomElement(nodeObj); -} - -//Updates information on a single hacknet node DOM element -function updateHacknetNodeDomElement(nodeObj) { - var nodeName = nodeObj.name; - var txt = document.getElementById("hacknet-node-text-" + nodeName); - if (txt == null) {throw new Error("Cannot find text element");} - txt.innerHTML = "Node name: " + nodeName + "
" + - "Production: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.totalMoneyGenerated, 2) + - " ($" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.moneyGainRatePerSecond, 2) + " / second)
" + - "Level: " + nodeObj.level + "
" + - "RAM: " + nodeObj.ram + "GB
" + - "Cores: " + nodeObj.cores; - - //Upgrade level - var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName); - if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");} - if (nodeObj.level >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel) { - upgradeLevelButton.innerHTML = "MAX LEVEL"; - upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); - } else { - var multiplier = 0; - if (hacknetNodePurchaseMultiplier == 0) { - //Max - multiplier = getMaxNumberLevelUpgrades(nodeObj); - } else { - var levelsToMax = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - nodeObj.level; - multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier); - } - - var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier); - upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier + - " - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeLevelCost, 2); - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeLevelCost)) { - upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); - } else { - upgradeLevelButton.setAttribute("class", "a-link-button"); - } - } - - //Upgrade RAM - var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName); - if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");} - if (nodeObj.ram >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxRam) { - upgradeRamButton.innerHTML = "MAX RAM"; - upgradeRamButton.setAttribute("class", "a-link-button-inactive"); - } else { - var upgradeRamCost = nodeObj.calculateRamUpgradeCost(); - upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeRamCost, 2); - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeRamCost)) { - upgradeRamButton.setAttribute("class", "a-link-button-inactive"); - } else { - upgradeRamButton.setAttribute("class", "a-link-button"); - } - } - - //Upgrade Cores - var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName); - if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");} - if (nodeObj.cores >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxCores) { - upgradeCoreButton.innerHTML = "MAX CORES"; - upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); - } else { - var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost(); - upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeCoreCost, 2); - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeCoreCost)) { - upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); - } else { - upgradeCoreButton.setAttribute("class", "a-link-button"); - } - } -} - -function processAllHacknetNodeEarnings(numCycles) { - var total = 0; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { - total += processSingleHacknetNodeEarnings(numCycles, __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]); - } - return total; -} - -function processSingleHacknetNodeEarnings(numCycles, nodeObj) { - var cyclesPerSecond = 1000 / __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"]._idleSpeed; - var earningPerCycle = nodeObj.moneyGainRatePerSecond / cyclesPerSecond; - if (isNaN(earningPerCycle)) { - console.log("ERROR: Hacknet Node Calculated earnings is NaN"); - earningPerCycle = 0; - } - var totalEarnings = numCycles * earningPerCycle; - nodeObj.totalMoneyGenerated += totalEarnings; - nodeObj.onlineTimeSeconds += (numCycles * (__WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"]._idleSpeed / 1000)); - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].gainMoney(totalEarnings); - return totalEarnings; -} - -function getHacknetNode(name) { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i].name == name) { - return __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]; - } - } - return null; -} - - - - -/***/ }), -/* 27 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Messages; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return checkForMessagesToSend; }); -/* unused harmony export sendMessage */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return showMessage; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadMessages; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initMessages; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Message; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Missions_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__RedPill_js__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(8); - - - - - - - - - - -/* Message.js */ -function Message(filename="", msg="") { - this.filename = filename; - this.msg = msg; - this.recvd = false; -} - -Message.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Message", this); -} - - -Message.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Message, value.data); -} - -__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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 || !__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])(txt); -} - -//Adds a message to a server -function addMessageToServer(msg, serverHostname) { - var server = Object(__WEBPACK_IMPORTED_MODULE_5__Server_js__["c" /* 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 (__WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_0__Augmentations_js__["b" /* AugmentationNames */].TheRedPill].owned) { - redpillOwned = true; - } - - if (redpill && redpillOwned && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].sourceFiles.length === 0 && !__WEBPACK_IMPORTED_MODULE_4__RedPill_js__["b" /* redPillFlag */] && !__WEBPACK_IMPORTED_MODULE_2__Missions_js__["c" /* inMission */]) { - if (!__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["b" /* dialogBoxOpened */]) { - sendMessage(redpill, true); - } - } else if (redpill && redpillOwned) { - //If player has already destroyed a BitNode, message is not forced - if (!__WEBPACK_IMPORTED_MODULE_4__RedPill_js__["b" /* redPillFlag */] && !__WEBPACK_IMPORTED_MODULE_2__Missions_js__["c" /* inMission */] && !__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["b" /* dialogBoxOpened */]) { - sendMessage(redpill); - } - } else if (jumper0 && !jumper0.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 25) { - sendMessage(jumper0); - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__["a" /* Programs */].Flight); - } else if (jumper1 && !jumper1.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 40) { - sendMessage(jumper1); - } else if (cybersecTest && !cybersecTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 50) { - sendMessage(cybersecTest); - } else if (jumper2 && !jumper2.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 175) { - sendMessage(jumper2); - } else if (nitesecTest && !nitesecTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 200) { - sendMessage(nitesecTest); - } else if (jumper3 && !jumper3.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 350) { - sendMessage(jumper3); - } else if (jumper4 && !jumper4.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 490) { - sendMessage(jumper4); - } else if (bitrunnersTest && !bitrunnersTest.recvd && __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill >= 500) { - sendMessage(bitrunnersTest); - } -} - -function AddToAllMessages(msg) { - Messages[msg.filename] = msg; -} - -let Messages = {} - -function loadMessages(saveString) { - Messages = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HackingMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return inMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return setInMission; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return currMission; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb__ = __webpack_require__(67); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_jsplumb__); - - - - - - - - - -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; - } - } -}); - -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 / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToDiffConversion + 1; - console.log("difficulty: " + this.difficulty); - this.reward = 250 + (rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToRewardConversion); -} - -HackingMission.prototype.init = function() { - //Create Header DOM - this.createPageDom(); - - //Create player starting nodes - var home = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer() - for (var i = 0; i < home.cpuCores; ++i) { - var stats = { - atk: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 7.5) + 30, - def: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 20), - hp: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1)); - var numDatabases = Math.min(10, Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(1, Math.round(this.difficulty / 3) + 1)); - var totalNodes = numNodes + numFirewalls + numDatabases; - var xlimit = 7 - Math.floor(totalNodes / 8); - var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.8 + (this.difficulty / 5), 10); - for (var i = 0; i < numNodes; ++i) { - var stats = { - atk: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(80, 86), - def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(5, 10), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 20), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(30, 55), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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 * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; - var headerText = document.createElement("p"); - headerText.innerHTML = "You are about to start a hacking mission! You will gain " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + - "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + - "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + - "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + - "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, 2); - var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.85 + (this.difficulty / 2), 15); - switch (type) { - case 0: //Spam - var stats = { - atk: 0, - def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(15, 45), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(200, 225) - } - node = new Node(NodeTypes.Spam, stats); - break; - case 1: //Transfer - var stats = { - atk: 0, - def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(15, 45), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(250, 275) - } - node = new Node(NodeTypes.Transfer, stats); - break; - case 2: //Shield - default: - var stats = { - atk: 0, - def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(30, 70), - hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-cpu-node"); - break; - case NodeTypes.Firewall: - txt = "Firewall
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-firewall-node"); - break; - case NodeTypes.Database: - txt = "Database
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-database-node"); - break; - case NodeTypes.Spam: - txt = "Spam
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-spam-node"); - break; - case NodeTypes.Transfer: - txt = "Transfer
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-transfer-node"); - break; - case NodeTypes.Shield: - default: - txt = "Shield
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - nodeDiv.classList.add("hack-mission-shield-node"); - break; - } - - txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + - "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Firewall: - txt = "Firewall
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Database: - txt = "Database
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Spam: - txt = "Spam
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Transfer: - txt = "Transfer
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - case NodeTypes.Shield: - default: - txt = "Shield
" + "HP: " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); - break; - } - - txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + - "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* 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 * __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionDifficultyToHacking; - switch(nodeObj.action) { - case NodeActions.Attack: - if (targetNode == null) {break;} - if (nodeObj.conn == null) {break;} - var dmg = this.calculateAttackDamage(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); - targetNode.atk -= (eff/5 * numCycles); - calcStats = true; - break; - case NodeActions.Fortify: - var eff = this.calculateFortifyEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); - nodeObj.def += (eff/5 * numCycles); - calcStats = true; - break; - case NodeActions.Overflow: - var eff = this.calculateOverflowEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; - }); - this.configurePlayerNodeElement(targetNode.el); - } else { - swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); - this.enemyCores.forEach(function(node) { - node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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: " + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult); - var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission won! You earned " + - Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " reputation with " + this.faction.name); - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gainIntelligenceExp(this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceHackingMissionBaseExpGain); - this.faction.playerReputation += gain; - } else { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* 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"; - __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadFactionContent(); - Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["c" /* displayFactionContent */])(this.faction.name); -} - - - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) - -/***/ }), -/* 29 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Gang; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return displayGangContent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateGangContent; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadAllGangs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllGangs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return resetGangs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return deleteGangDisplayContent; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__ = __webpack_require__(15); - - - - - - - - - - - -/* Gang.js */ -//Switch between territory and management screen with 1 and 2 -$(document).keydown(function(event) { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.Gang && !__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["e" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["l" /* 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, __WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* Reviver */]); -} - -//Power is an estimate of a gang's ability to gain/defend territory -let gangStoredPowerCycles = 0; -function processAllGangPowerGains(numCycles=1) { - if (!__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} - gangStoredPowerCycles += numCycles; - if (gangStoredPowerCycles < 150) {return;} - var playerGangName = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName; - for (var name in AllGangs) { - if (AllGangs.hasOwnProperty(name)) { - if (name == playerGangName) { - AllGangs[name].power += __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 (!__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} - gangStoredTerritoryCycles += numCycles; - if (gangStoredTerritoryCycles < __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].GangTerritoryUpdateTimer) {return;} - - for (var i = 0; i < GangNames.length; ++i) { - var other = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, GangNames.length-1); - while(other == i) { - other = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["h" /* 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 -= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][this.facName]; - if (!(fac instanceof __WEBPACK_IMPORTED_MODULE_2__Faction_js__["a" /* Faction */])) { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* 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 += ((__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * gain * favorMult) / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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)) { - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Gang", this); -} - -Gang.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Gang, value.data); -} - -__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* Reviver */].constructors.Gang = Gang; - -/*** Gang Member object ***/ -function GangMember(name) { - this.name = name; - this.task = GangMemberTasks["Unassigned"]; //GangMemberTask object - this.city = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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) { - return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1); -} - -GangMember.prototype.updateSkillLevels = function() { - this.hack = Math.floor(this.calculateSkill(this.hack_exp) * this.hack_mult); - this.str = Math.floor(this.calculateSkill(this.str_exp) * this.str_mult); - this.def = Math.floor(this.calculateSkill(this.def_exp) * this.def_mult); - this.dex = Math.floor(this.calculateSkill(this.dex_exp) * this.dex_mult); - this.agi = Math.floor(this.calculateSkill(this.agi_exp) * this.agi_mult); - this.cha = Math.floor(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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; - if (territoryMult <= 0) {return 0;} - var respectMult = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; - if (territoryMult <= 0) {return 0;} - var respectMult = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMember", this); -} - -GangMember.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMember, value.data); -} - -__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMemberTask", this); -} - -GangMemberTask.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMemberTask, value.data); -} - -__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMemberUpgrade", this); -} - -GangMemberUpgrade.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMemberUpgrade, value.data); -} - -__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["l" /* removeElement */])(gangMemberUpgradeBoxElements[i]); - } - gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter]; - - var filter = gangMemberUpgradeBoxFilter.value.toString(); - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name.indexOf(filter) > -1 || __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].task.name.indexOf(filter) > -1) { - var newPanel = createGangMemberUpgradePanel(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i]); - gangMemberUpgradeBoxContent.appendChild(newPanel); - gangMemberUpgradeBoxElements.push(newPanel); - } - } - } else { - //New popup - gangMemberUpgradeBoxFilter = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name.indexOf(filter) > -1 || __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].task.name.indexOf(filter) > -1) { - gangMemberUpgradeBoxElements.push(createGangMemberUpgradePanel(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i])); - } - } - - gangMemberUpgradeBox = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["g" /* createPopup */])(boxId, gangMemberUpgradeBoxElements); - gangMemberUpgradeBoxContent = document.getElementById(boxId + "-content"); - gangMemberUpgradeBoxOpened = true; - } -} - -//Create upgrade panels for each individual Gang Member -function createGangMemberUpgradePanel(memberObj) { - var container = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - border:"1px solid white", - }); - - var header = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerText:memberObj.name + " (" + memberObj.task.name + ")" - }); - container.appendChild(header); - - var text = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("pre", { - fontSize:"14px", display: "inline-block", width:"20%", - innerText: - "Hack: " + memberObj.hack + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.hack_mult, 2) + ")\n" + - "Str: " + memberObj.str + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.str_mult, 2) + ")\n" + - "Def: " + memberObj.def + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.def_mult, 2) + ")\n" + - "Dex: " + memberObj.dex + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.dex_mult, 2) + ")\n" + - "Agi: " + memberObj.agi + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.agi_mult, 2) + ")\n" + - "Cha: " + memberObj.cha + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); - var armorDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); - var vehicleDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); - var rootkitDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:upg.name + " - " + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(upg.cost).format("$0.000a"), - class:"a-link-button", margin:"2px", padding:"2px", display:"block", - fontSize:"12px", - tooltip:upg.desc, - clickListener:()=>{ - if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].money.lt(upg.cost)) {return false;} - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"gang-container", class:"generic-menupage-container", - }); - - //Get variables - var facName = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName, - members = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members, - wanted = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted, - respect = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect; - - //Buttons to switch between panels - managementButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - display:"block", id:"gang-management-subpage", - }); - - var lowerWantedTask = ""; - if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.isHackingGang) { - lowerWantedTask = "Ethical Hacking"; - } else { - lowerWantedTask = "Vigilante Justice"; - } - gangDesc = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", {id:"gang-info", width:"70%"}); - gangManagementSubpage.appendChild(gangInfo); - - gangRecruitMemberButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerHTML = "Recruit Gang Member"; - noBtn.innerHTML = "Cancel"; - yesBtn.addEventListener("click", ()=>{ - var name = Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])(); - if (name === "") { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must enter a name for your Gang member!"); - } else { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { - if (name == __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name) { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You already have a gang member with this name!"); - return false; - } - } - var member = new GangMember(name); - __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.push(member); - createGangMemberDisplayElement(member); - updateGangContent(); - } - Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - noBtn.addEventListener("click", ()=>{ - Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - gangExpandAllButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", placeholder:"Filter gang members", margin:"5px", padding:"5px", - onkeyup:()=>{ - displayGangMemberList(); - } - }); - gangManageEquipmentButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("ul", {id:"gang-member-list"}); - displayGangMemberList(); - gangManagementSubpage.appendChild(gangMemberList); - - //Subpage for seeing gang territory information - gangTerritorySubpage = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"gang-territory-subpage", display:"none" - }); - - //Info text for territory page - gangTerritoryDescText = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("fieldset", {width:"50%", display:"inline-block"}); - - gangTerritoryInfoText = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(gangMemberList); - var members = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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]; - if (gangname == __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName) { - gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gangTerritoryInfo.power, 6) + "): " + - Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(100*gangTerritoryInfo.territory, 2) + "%

"); - } else { - gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gangTerritoryInfo.power, 6) + "): " + - Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(100*gangTerritoryInfo.territory, 2) + "%

"); - } - } - } - } else { - //Update information for overall gang - if (gangInfo instanceof Element) { - var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName]; - var rep; - if (!(faction instanceof __WEBPACK_IMPORTED_MODULE_2__Faction_js__["a" /* Faction */])) { - rep = "ERROR"; - } else { - rep = faction.playerReputation; - } - Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(gangInfo); - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Respect - display:"inline-block", - innerText:"Respect: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect, 6) + - " (" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Wanted level - display:"inline-block", - innerText:"Wanted Level: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted, 6) + - " (" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - var wantedPenalty = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted); - wantedPenalty = (1 - wantedPenalty) * 100; - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Wanted Level multiplier - display:"inline-block", - innerText:"Wanted Level Penalty: -" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(wantedPenalty, 2) + "%", - tooltip:"Penalty for respect and money gain rates due to Wanted Level" - })); - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Money gain rate - display:"inline-block", - innerText:"Money gain rate: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.moneyGainRate, 2) + - " / sec", - })); - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - var territoryMult = AllGangs[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Territory multiplier - display:"inline-block", - innerText:"Territory: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(territoryMult * 100, 3) + "%", - tooltip:"The percentage of total territory your Gang controls" - })); - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Faction reputation - display:"inline-block", - innerText:"Faction reputation: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(rep, 3) - })); - gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - } else { - console.log("ERROR: gang-info DOM element DNE"); - } - - //Toggle the 'Recruit member button' if valid - var numMembers = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; - var repCost = 0; - if (numMembers > 0) { - var repCost = Math.pow(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].GangRecruitCostMultiplier, numMembers); - } - var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName]; - if (faction == null) { - Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Could not find your gang's faction. This is probably a bug please report to dev"); - return; - } - var btn = gangRecruitMemberButton; - if (numMembers >= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repCost, 2) + " Faction reputation needed to recruit next member"; - } - - //Update information for each gang member - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { - updateGangMemberDisplayElement(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i]); - } - } -} - -//Takes in a GangMember object -function createGangMemberDisplayElement(memberObj) { - if (!gangContentCreated || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} - var name = memberObj.name; - - var accordion = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["e" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id: name + "gang-member-stats", class: "gang-member-info-div", - width:"30%", display:"inline" - }); - var statsP = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id: name + "gang-member-task", class:"gang-member-info-div", - width:"30%", display:"inline" - }); - var taskSelector = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("select", { - color:"white", backgroundColor:"black", - id:name + "gang-member-task-selector" - }); - - var tasks = null; - if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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; - } - } - taskSelector.selectedIndex = taskIndex; - } - - var gainInfo = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", {id:name + "gang-member-gain-info"}); - taskDiv.appendChild(taskSelector); - taskDiv.appendChild(gainInfo); - - //Panel for Description of task - var taskDescDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:name + "gang-member-task-desc", class:"gang-member-info-div", - width:"30%", display:"inline" - }); - - var taskDescP = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.hack, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.hack_exp).format('(0.00a)') + " exp)
" + - "Strength: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.str, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.str_exp).format('(0.00a)') + " exp)
" + - "Defense: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.def, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.def_exp).format('(0.00a)') + " exp)
" + - "Dexterity: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.dex, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.dex_exp).format('(0.00a)') + " exp)
" + - "Agility: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.agi, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.agi_exp).format('(0.00a)') + " exp)
" + - "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.cha, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.cha_exp).format('(0.00a)') + " exp)
"; - } - - var gainInfo = document.getElementById(name + "gang-member-gain-info"); - if (gainInfo) { - gainInfo.innerHTML = - "Money: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateMoneyGain(), 2) + " / sec
" + - "Respect: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateRespectGain(), 6) + " / sec
" + - "Wanted Level: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateWantedLevelGain(), 6) + " / sec
"; - } -} - -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 deleteGangDisplayContent() { - if (gangContainer != null) {Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["m" /* removeElementById */])(gangContainer.id);} - - gangContentCreated = false; - gangContainer = null; - managementButton = null; - territoryButton = null; - - //Subpages - gangManagementSubpage = null; - gangTerritorySubpage = null; - - //Gang Management Elements - gangDesc = null; - gangInfo = null; - gangRecruitMemberButton = null; - gangRecruitRequirementText = null; - gangExpandAllButton = null; - gangCollapseAllButton = null; - gangMemberFilter = null; - gangManageEquipmentButton = null; - gangMemberList = null; - - //Gang Equipment Upgrade Elements - gangMemberUpgradeBox = null; - gangMemberUpgradeBoxContent = null; - gangMemberUpgradeBoxFilter = null; - gangMemberUpgradeBoxElements = null; -} - - - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) - -/***/ }), -/* 30 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return StockMarket; }); -/* unused harmony export StockSymbols */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return SymbolToStockMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return initStockSymbols; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return initStockMarket; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return initSymbolToStockMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return stockMarketCycle; }); -/* unused harmony export buyStock */ -/* unused harmony export sellStock */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return shortStock; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return sellShort; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return updateStockPrices; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return displayStockMarketContent; }); -/* unused harmony export updateStockTicker */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return updateStockPlayerPosition; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return loadStockMarket; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return setStockMarketContentCreated; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return placeOrder; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return cancelOrder; }); -/* unused harmony export Order */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return OrderTypes; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return PositionTypes; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__ = __webpack_require__(15); - - - - - - - - - - - - - - -/* StockMarket.js */ -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(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Stock", this); -} - -Stock.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Stock, value.data); -} - -__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 + " @ " + - __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___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(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Order", this); -} - -Order.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Order, value.data); -} - -__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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, __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* Reviver */]); - } -} - -function initStockSymbols() { - //Stocks for companies at which you can work - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumECorp] = "ECP"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12MegaCorp] = "MGCP"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12BladeIndustries] = "BLD"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumClarkeIncorporated] = "CLRK"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniTekIncorporated] = "OMTK"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FourSigma] = "FSIG"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingKuaiGongInternational] = "KGI"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumFulcrumTechnologies] = "FLCM"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaStormTechnologies] = "STM"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoDefComm] = "DCOMM"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenHeliosLabs] = "HLS"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoVitaLife] = "VITA"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12IcarusMicrosystems] = "ICRS"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12UniversalEnergy] = "UNV"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumAeroCorp] = "AERO"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniaCybersystems] = "OMN"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingSolarisSpaceSystems] = "SLRS"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoGlobalPharmaceuticals] = "GPH"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaNovaMedical] = "NVMD"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumWatchdogSecurity] = "WDS"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp] = "LXO"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction] = "RHOC"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises] = "APHE"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities] = "SYSC"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek] = "CTK"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies] = "NTLK"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaOmegaSoftware] = "OMGA"; - StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumECorp; - var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); - StockMarket[ecorp] = ecorpStk; - - var megacorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12MegaCorp; - var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(25000, 33000)); - StockMarket[megacorp] = megacorpStk; - - var blade = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12BladeIndustries; - var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(15000, 22000)); - StockMarket[blade] = bladeStk; - - var clarke = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumClarkeIncorporated; - var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(15000, 20000)); - StockMarket[clarke] = clarkeStk; - - var omnitek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniTekIncorporated; - var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(35000, 40000)); - StockMarket[omnitek] = omnitekStk; - - var foursigma = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FourSigma; - var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(60000, 70000)); - StockMarket[foursigma] = foursigmaStk; - - var kuaigong = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingKuaiGongInternational; - var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 24000)); - StockMarket[kuaigong] = kuaigongStk; - - var fulcrum = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumFulcrumTechnologies; - var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(30000, 35000)); - StockMarket[fulcrum] = fulcrumStk; - - var storm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaStormTechnologies; - var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(21000, 24000)); - StockMarket[storm] = stormStk; - - var defcomm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoDefComm; - var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 15000)); - StockMarket[defcomm] = defcommStk; - - var helios = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenHeliosLabs; - var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(12000, 16000)); - StockMarket[helios] = heliosStk; - - var vitalife = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoVitaLife; - var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 12000)); - StockMarket[vitalife] = vitalifeStk; - - var icarus = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12IcarusMicrosystems; - var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(16000, 20000)); - StockMarket[icarus] = icarusStk; - - var universalenergy = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12UniversalEnergy; - var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); - StockMarket[universalenergy] = universalenergyStk; - - var aerocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumAeroCorp; - var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 15000)); - StockMarket[aerocorp] = aerocorpStk; - - var omnia = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniaCybersystems; - var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(9000, 12000)); - StockMarket[omnia] = omniaStk; - - var solaris = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingSolarisSpaceSystems; - var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); - StockMarket[solaris] = solarisStk; - - var globalpharm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoGlobalPharmaceuticals; - var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); - StockMarket[globalpharm] = globalpharmStk; - - var nova = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaNovaMedical; - var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); - StockMarket[nova] = novaStk; - - var watchdog = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumWatchdogSecurity; - var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); - StockMarket[watchdog] = watchdogStk; - - var lexocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp; - var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); - StockMarket[lexocorp] = lexocorpStk; - - var rho = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction; - var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(3000, 6000)); - StockMarket[rho] = rhoStk; - - var alpha = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises; - var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); - StockMarket[alpha] = alphaStk; - - var syscore = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities; - var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(4000, 7000)) - StockMarket[syscore] = syscoreStk; - - var computek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek; - var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 5000)); - StockMarket[computek] = computekStk; - - var netlink = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies; - var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 4000)); - StockMarket[netlink] = netlinkStk; - - var omega = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaOmegaSoftware; - var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(3000, 6000)); - StockMarket[omega] = omegaStk; - - var fns = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FoodNStuff; - var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(1000, 4000)); - StockMarket[fns] = fnsStk; - - var sigmacosm = "Sigma Cosmetics"; - var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 3000)); - StockMarket[sigmacosm] = sigmacosmStk; - - var joesguns = "Joes Guns"; - var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(500, 1000)); - StockMarket[joesguns] = joesgunsStk; - - var catalyst = "Catalyst Ventures"; - var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(500, 1000)); - StockMarket[catalyst] = catalystStk; - - var microdyne = "Microdyne Technologies"; - var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); - StockMarket[microdyne] = microdyneStk; - - var titanlabs = "Titan Laboratories"; - var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* 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() { - console.log("Cycling the Stock Market"); - 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this. You need $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString() + "."); - return false; - } - - var origTotal = stock.playerShares * stock.playerAvgPx; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); - var newTotal = origTotal + totalPrice; - stock.playerShares += shares; - stock.playerAvgPx = newTotal / stock.playerShares; - updateStockPlayerPosition(stock); - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(gains); - stock.playerShares -= shares; - if (stock.playerShares == 0) { - stock.playerAvgPx = 0; - } - updateStockPlayerPosition(stock); - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + - "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); - return true; -} - -//Returns true if successful and false otherwise -function shortStock(stock, shares, workerScript=null) { - var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); - if (stock == null || isNaN(shares) || shares < 0) { - if (tixApi) { - workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { - if (tixApi) { - workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " + - "money to purchase this short position. You need " + - __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)')); - } else { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this short position. You need $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + "."); - } - - return false; - } - - var origTotal = stock.playerShortShares * stock.playerAvgShortPx; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at " + - __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. Paid " + - __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)') + " in commission fees."); - } - } else { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); - if (stock == null || isNaN(shares) || shares < 0) { - if (tixApi) { - workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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) - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - if (isNaN(profit)) {profit = 0;} - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(origCost + profit); - if (tixApi) { - workerScript.scriptRef.onlineMoneyMade += profit; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* 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 " + - __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " + - "a total of " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(origCost + profit).format('($0.000a)')); - } - } else { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold your short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + - "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* 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;} - } - - 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 (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; -function displayStockMarketContent() { - if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = false;} - if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = false;} - - //Purchase WSE Account button - var wseAccountButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-account"); - wseAccountButton.innerText = "Buy WSE Account - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost, 2).toString(); - if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost)) { - wseAccountButton.setAttribute("class", "a-link-button"); - } else { - wseAccountButton.setAttribute("class", "a-link-button-inactive"); - } - wseAccountButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = true; - initStockMarket(); - initSymbolToStockMap(); - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost); - displayStockMarketContent(); - return false; - }); - - //Purchase TIX API Access account - var tixApiAccessButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-tix-api"); - tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost, 2).toString(); - if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost)) { - tixApiAccessButton.setAttribute("class", "a-link-button"); - } else { - tixApiAccessButton.setAttribute("class", "a-link-button-inactive"); - } - tixApiAccessButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = true; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost); - displayStockMarketContent(); - return false; - }); - - var stockList = document.getElementById("stock-market-list"); - if (stockList == null) {return;} - - if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { - stockMarketContentCreated = false; - while (stockList.firstChild) { - stockList.removeChild(stockList.firstChild); - } - return; - } - - //Create stock market content if you have an account - if (!stockMarketContentCreated && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { - console.log("Creating Stock Market UI"); - document.getElementById("stock-market-commission").innerHTML = - "Commission Fees: Every transaction you make has a $" + - Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])(txt); - return false; - }); - - //Switch to Portfolio Mode Button - var modeBtn = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-expand-tickers"), - collapseBtn = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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 " + - " || (4734 && event.keyCode<40) " + - " || (event.keyCode==46) )"); - - longShortSelect.classList.add("stock-market-input"); - longShortSelect.setAttribute("id", tickerId + "-pos-selector"); - var longOpt = document.createElement("option"); - longOpt.text = "Long"; - longShortSelect.add(longOpt); - if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* wallStreetSFLvl */] >= 2)) { - var shortOpt = document.createElement("option"); - shortOpt.text = "Short"; - longShortSelect.add(shortOpt); - } - - orderTypeSelect.classList.add("stock-market-input"); - orderTypeSelect.setAttribute("id", tickerId + "-order-selector"); - var marketOpt = document.createElement("option"); - marketOpt.text = "Market Order"; - orderTypeSelect.add(marketOpt); - if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* wallStreetSFLvl */] >= 3)) { - var limitOpt = document.createElement("option"); - limitOpt.text = "Limit Order"; - orderTypeSelect.add(limitOpt); - var stopOpt = document.createElement("option"); - stopOpt.text = "Stop Order"; - orderTypeSelect.add(stopOpt); - } - - buyButton.classList.add("stock-market-input"); - buyButton.classList.add("a-link-button"); - buyButton.innerHTML = "Buy"; - buyButton.addEventListener("click", ()=>{ - var pos = longShortSelect.options[longShortSelect.selectedIndex].text; - pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; - var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; - var shares = Number(document.getElementById(tickerId + "-qty-input").value); - if (isNaN(shares)) {return false;} - switch (ordType) { - case "Market Order": - pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); - break; - case "Limit Order": - case "Stop Order": - var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), - noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerText = "Place Buy " + ordType; - noBtn.innerText = "Cancel Order"; - yesBtn.addEventListener("click", ()=>{ - var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; - if (ordType === "Limit Order") { - type = OrderTypes.LimitBuy; - } else { - type = OrderTypes.StopBuy; - } - placeOrder(stock, shares, price, type, pos); - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - noBtn.addEventListener("click", ()=>{ - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); - break; - default: - console.log("ERROR: Invalid order type"); - break; - } - return false; - }); - - sellButton.classList.add("stock-market-input"); - sellButton.classList.add("a-link-button"); - sellButton.innerHTML = "Sell"; - sellButton.addEventListener("click", ()=>{ - var pos = longShortSelect.options[longShortSelect.selectedIndex].text; - pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; - var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; - var shares = Number(document.getElementById(tickerId + "-qty-input").value); - if (isNaN(shares)) {return false;} - switch (ordType) { - case "Market Order": - pos === PositionTypes.Long ? sellStock(stock, shares) : sellShort(stock, shares, null); - break; - case "Limit Order": - case "Stop Order": - var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), - noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerText = "Place Sell " + ordType; - noBtn.innerText = "Cancel Order"; - yesBtn.addEventListener("click", ()=>{ - var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; - if (ordType === "Limit Order") { - type = OrderTypes.LimitSell; - } else { - type = OrderTypes.StopSell; - } - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - placeOrder(stock, shares, price, type, pos); - }); - noBtn.addEventListener("click", ()=>{ - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); - break; - default: - console.log("ERROR: Invalid order type"); - break; - } - return false; - }); - - buyMaxButton.classList.add("stock-market-input"); - buyMaxButton.classList.add("a-link-button"); - buyMaxButton.innerHTML = "Buy MAX"; - buyMaxButton.addEventListener("click", ()=>{ - var pos = longShortSelect.options[longShortSelect.selectedIndex].text; - pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; - var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; - var money = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.toNumber(); - switch (ordType) { - case "Market Order": - var shares = Math.floor((money - COMM) / stock.price); - pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); - break; - case "Limit Order": - case "Stop Order": - var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), - noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerText = "Place Buy " + ordType; - noBtn.innerText = "Cancel Order"; - yesBtn.addEventListener("click", ()=>{ - var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; - if (ordType === "Limit Order") { - type = OrderTypes.LimitBuy; - } else { - type = OrderTypes.StopBuy; - } - var shares = Math.floor((money-COMM) / price); - placeOrder(stock, shares, price, type, pos); - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - noBtn.addEventListener("click", ()=>{ - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); - break; - default: - console.log("ERROR: Invalid order type"); - break; - } - return false; - }); - - sellAllButton.classList.add("stock-market-input"); - sellAllButton.classList.add("a-link-button"); - sellAllButton.innerHTML = "Sell ALL"; - sellAllButton.addEventListener("click", ()=>{ - var pos = longShortSelect.options[longShortSelect.selectedIndex].text; - pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; - var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; - switch (ordType) { - case "Market Order": - if (pos === PositionTypes.Long) { - var shares = stock.playerShares; - sellStock(stock, shares); - } else { - var shares = stock.playerShortShares; - sellShort(stock, shares, null); - } - break; - case "Limit Order": - case "Stop Order": - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: 'Sell All' only works for Market Orders") - break; - default: - console.log("ERROR: Invalid order type"); - break; - } - return false; - }); - - positionTxt.setAttribute("id", tickerId + "-position-text"); - positionTxt.classList.add("stock-market-position-text"); - stock.posTxtEl = positionTxt; - - orderList.setAttribute("id", tickerId + "-order-list"); - orderList.classList.add("stock-market-order-list"); - - stockDiv.appendChild(qtyInput); - stockDiv.appendChild(longShortSelect); - stockDiv.appendChild(orderTypeSelect); - stockDiv.appendChild(buyButton); - stockDiv.appendChild(sellButton); - stockDiv.appendChild(buyMaxButton); - stockDiv.appendChild(sellAllButton); - stockDiv.appendChild(positionTxt); - stockDiv.appendChild(orderList); - - li.appendChild(hdr); - li.appendChild(stockDiv); - document.getElementById("stock-market-list").appendChild(li); - - updateStockTicker(stock, true); - updateStockPlayerPosition(stock); - updateStockOrderList(stock); -} - -function setStockTickerClickHandlers() { - var stockList = document.getElementById("stock-market-list"); - var tickerHdrs = stockList.getElementsByClassName("accordion-header"); - if (tickerHdrs == null) { - console.log("ERROR: Could not find header elements for stock tickers"); - return; - } - for (var i = 0; i < tickerHdrs.length; ++i) { - tickerHdrs[i].onclick = function() { - this.classList.toggle("active"); - - var panel = this.nextElementSibling; - if (panel.style.display === "block") { - panel.style.display = "none"; - } else { - panel.style.display = "block"; - } - } - } -} - -//'increase' argument is a boolean indicating whether the price increased or decreased -function updateStockTicker(stock, increase) { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} - if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockTicker():"); - console.log(stock); - return; - } - var tickerId = "stock-market-ticker-" + stock.symbol; - - if (stock.playerShares > 0 || stock.playerShortShares > 0) { - updateStockPlayerPosition(stock); - } - - var hdr = document.getElementById(tickerId + "-hdr"); - - if (hdr == null) { - if (!stockMarketPortfolioMode) {console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol);} - return; - } - hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2); - if (increase != null) { - increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; - } -} - -function updateStockPlayerPosition(stock) { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} - if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockPlayerPosition():"); - console.log(stock); - return; - } - var tickerId = "stock-market-ticker-" + stock.symbol; - - if (stockMarketPortfolioMode) { - if (stock.playerShares === 0 && stock.playerShortShares === 0 && - StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] && - StockMarket["Orders"][stock.symbol].length === 0) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* removeElementById */])(tickerId + "-hdr"); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* 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; - } - } - } - - if (!(stock.posTxtEl instanceof Element)) { - stock.posTxtEl = document.getElementById(tickerId + "-position-text"); - } - if (stock.posTxtEl == null) { - console.log("ERROR: Could not find stock position element for: " + stock.symbol); - return; - } - - //Calculate returns - var totalCost = stock.playerShares * stock.playerAvgPx, - gains = (stock.price - stock.playerAvgPx) * stock.playerShares, - percentageGains = gains / totalCost; - if (isNaN(percentageGains)) {percentageGains = 0;} - - var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, - shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, - shortPercentageGains = shortGains/ shortTotalCost; - if (isNaN(shortPercentageGains)) {shortPercentageGains = 0;} - - stock.posTxtEl.innerHTML = - "

Long Position: " + - "Shares in the long position will increase " + - "in value if the price of the corresponding stock increases

" + - "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShares, 0) + - "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgPx).format('$0.000a') + - " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalCost).format('$0.000a') + ")" + - "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(gains).format('$0.000a') + - " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains*100, 2) + "%)

"; - if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShortShares, 0) + - "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgShortPx).format('$0.000a') + - " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortTotalCost).format('$0.000a') + ")" + - "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortGains).format('$0.000a') + - " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shortPercentageGains*100, 2) + "%)" + - "

Orders:

"; - } - -} - -function updateStockOrderList(stock) { - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* removeElementById */])(tickerId + "-hdr"); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* 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); - }()); - - } -} - - - - -/***/ }), -/* 31 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Corporation; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Literature_js__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__utils_decimal_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__ = __webpack_require__(15); - - - - - - - - - - - - - - - -/* State */ -var companyStates = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"]; -function CorporationState() { - this.state = 0; -} - -CorporationState.prototype.nextState = function() { - if (this.state < 0 || this.state >= companyStates.length) { - this.state = 0; - } - - ++this.state; - if (this.state >= companyStates.length) { - this.state = 0; - } -} - -CorporationState.prototype.getState = function() { - return companyStates[this.state]; -} - -CorporationState.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("CorporationState", this); -} - -CorporationState.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(CorporationState, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.CorporationState = CorporationState; - -/* Constants */ -var TOTALSHARES = 1e9; //Total number of shares you have at your company -var CyclesPerMarketCycle = 75; -var CyclesPerIndustryStateCycle = CyclesPerMarketCycle / companyStates.length; -var SecsPerMarketCycle = CyclesPerMarketCycle / 5; -var Cities = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"]; -var WarehouseInitialCost = 5e9; //Initial purchase cost of warehouse -var WarehouseInitialSize = 100; -var WarehouseUpgradeBaseCost = 1e9; - -var OfficeInitialCost = 4e9; -var OfficeInitialSize = 3; -var OfficeUpgradeBaseCost = 1e9; - -var BribeThreshold = 100e12; //Money needed to be able to bribe for faction rep -var BribeToRepRatio = 1e9; //Bribe Value divided by this = rep gain - -function Material(params={}) { - this.name = params.name ? params.name : ""; - this.qty = 0; //Quantity - this.qlt = 0; //Quality, unbounded - this.dmd = 0; //Demand, 0-100? - this.dmdR = 0; //Range of possible demand - this.cmp = 0; //Competition, 0-100 - this.cmpR = 0; //Range of possible competition - this.mv = 0; //Maximum Volatility of stats - - //Markup. Determines how high of a price you can charge on the material - //compared to the market price (bCost) based on quality - //Quality is divided by this to determine markup limits - //e.g if mku is 10 and quality is 100 then you can mark up prices by 100/10 = 10 - //without consequences - this.mku = 0; - - this.buy = 0; //How much of this material is being bought per second - this.sll = 0; //How much of this material is being sold per second - this.prd = 0; //How much of this material is being produced per second - this.exp = []; //Exports of this material to another warehouse/industry - this.imp = 0; - this.bCost = 0; //$ Cost/sec to buy material - this.sCost = 0; //$ Cost/sec to sell material - - //[Whether production/sale is limited, limit amount] - this.prdman = [false, 0]; //Production for this material is manually limited - this.sllman = [false, 0]; //Sale of this material is manually limited - this.init(); -} - -Material.prototype.init = function(mats={}) { - switch(this.name) { - case "Water": - this.dmd = 75; this.dmdR = [65, 85]; - this.cmp = 50; this.cmpR = [40, 60]; - this.bCost = 1000; this.mv = 0.2; - this.mku = 6; - break; - case "Energy": - this.dmd = 90; this.dmdR = [80, 100]; - this.cmp = 80; this.cmpR = [65, 95]; - this.bCost = 1500; this.mv = 0.2; - this.mku = 6; - break; - case "Food": - this.dmd = 80; this.dmdR = [70, 90]; - this.cmp = 60; this.cmpR = [35, 85]; - this.bCost = 5000; this.mv = 1; - this.mku = 3; - break; - case "Plants": - this.dmd = 70; this.dmdR = [20, 90]; - this.cmp = 50; this.cmpR = [30, 70]; - this.bCost = 3000; this.mv = 0.6; - this.mku = 3.75; - break; - case "Metal": - this.dmd = 80; this.dmdR = [75, 85]; - this.cmp = 70; this.cmpR = [60, 80]; - this.bCost = 2650; this.mv = 1; - this.mku = 6; - break; - case "Hardware": - this.dmd = 85; this.dmdR = [80, 90]; - this.cmp = 80; this.cmpR = [65, 95]; - this.bCost = 4000; this.mv = 0.5; //Less mv bc its processed twice - this.mku = 1; - break; - case "Chemicals": - this.dmd = 55; this.dmdR = [40, 70]; - this.cmp = 60; this.cmpR = [40, 80]; - this.bCost = 6750; this.mv = 1.2; - this.mku = 2; - break; - case "Real Estate": - this.dmd = 50; this.dmdR = [5, 100]; - this.cmp = 50; this.cmpR = [25, 75]; - this.bCost = 16e3; this.mv = 1.5; //Less mv bc its processed twice - this.mku = 1.5; - break; - case "Drugs": - this.dmd = 60; this.dmdR = [45, 75]; - this.cmp = 70; this.cmpR = [40, 100]; - this.bCost = 8e3; this.mv = 1.6; - this.mku = 1; - break; - case "Robots": - this.dmd = 90; this.dmdR = [80, 100]; - this.cmp = 90; this.cmpR = [80, 100]; - this.bCost = 20e3; this.mv = 0.5; //Less mv bc its processed twice - this.mku = 1; - break; - case "AI Cores": - this.dmd = 90; this.dmdR = [80, 100]; - this.cmp = 90; this.cmpR = [80, 100]; - this.bCost = 27e3; this.mv = 0.8; //Less mv bc its processed twice - this.mku = 0.5; - break; - case "Scientific Research": - break; - default: - console.log("Invalid material type in init(): " + this.name); - break; - } -} - -//Process change in demand, competition, and buy cost of this material -Material.prototype.processMarket = function() { - //This 1st random check determines whether competition increases or decreases - //More competition = lower market price - var v = (Math.random() * this.mv) / 100; - var pv = (Math.random() * this.mv) / 300; - if (Math.random() < 0.42) { - this.cmp *= (1+v); - if (this.cmp > this.cmpR[1]) {this.cmp = this.cmpR[1]}; - this.bCost *= (1-pv); - } else { - this.cmp *= (1-v); - if (this.cmp < this.cmpR[0]) {this.cmp = this.cmpR[0];} - this.bCost *= (1+pv); - } - - //This 2nd random check determines whether demand increases or decreases - //More demand = higher market price - v = (Math.random() * this.mv) / 100; - pv = (Math.random() * this.mv) / 300; - if (Math.random() < 0.45) { - this.dmd *= (1+v); - if (this.dmd > this.dmdR[1]) {this.dmd = this.dmdR[1];} - this.bCost *= (1+pv); - } else { - this.dmd *= (1-v); - if (this.dmd < this.dmdR[0]) {this.dmd = this.dmdR[0];} - this.bCost *= (1-pv); - } -} - -Material.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Material", this); -} - -Material.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Material, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Material = Material; - -//Map of material (by name) to their sizes (how much space it takes in warehouse) -let MaterialSizes = { - Water: 0.05, - Energy: 0.01, - Food: 0.03, - Plants: 0.05, - Metal: 0.1, - Hardware: 0.06, - Chemicals: 0.05, - Drugs: 0.02, - Robots: 0.5, - "AICores": 0.1 -} - -function Product(params={}) { - this.name = params.name ? params.name : 0; - this.dmd = params.demand ? params.demand : 0; - this.cmp = params.competition ? params.competition : 0; - this.mku = params.markup ? params.markup : 0; - this.pCost = 0; //An estimate of how much money it costs to make this - this.sCost = 0; //How much this is selling for - - //Variables for creation of product - this.fin = false; //Finished being created - this.prog = 0; //0-100% created - this.createCity = params.createCity ? params.createCity : ""; // City in which the product is being created - this.designCost = params.designCost ? params.designCost : 0; - this.advCost = params.advCost ? params.advCost : 0; - - //Aggregate score for a product's 'rating' based on the other properties below - //The weighting of the other properties (performance, durability) - //differs between industries - this.rat = 0; - - this.qlt = params.quality ? params.quality : 0; - this.per = params.performance ? params.performance : 0; - this.dur = params.durability ? params.durability : 0; - this.rel = params.reliability ? params.reliability : 0; - this.aes = params.aesthetics ? params.aesthetics : 0; - this.fea = params.features ? params.features : 0; - - //Data refers to the production, sale, and quantity of the products - //These values are specific to a city - //The data is [qty, prod, sell] - this.data = { - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [0, 0, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [0, 0, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [0, 0, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [0, 0, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [0, 0, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [0, 0, 0], - } - - //Only applies for location-based products like restaurants/hospitals - this.loc = params.loc ? params.loc : 0; - - //How much space it takes in the warehouse. Not applicable for all products - this.siz = params.size ? params.size : 0; - - //Material requirements. An object that maps the name of a material to how much it requires - //to make 1 unit of the product. - this.reqMats = params.req ? params.req : {}; - - //[Whether production/sale is limited, limit amount] - this.prdman = { - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [false, 0], - } - - this.sllman = { - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [false, 0], - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [false, 0], - } -} - -//empWorkMult is a multiplier that increases progress rate based on -//productivity of employees -Product.prototype.createProduct = function(marketCycles=1, empWorkMult=1) { - if (this.fin) {return;} - this.prog += (marketCycles * .01 * empWorkMult); -} - -//'industry' is a reference to the industry that makes the product -Product.prototype.finishProduct = function(employeeProd, industry) { - this.fin = true; - - //Calculate properties - var progrMult = this.prog / 100; - - var engrRatio = employeeProd[EmployeePositions.Engineer] / employeeProd["total"], - mgmtRatio = employeeProd[EmployeePositions.Management] / employeeProd["total"], - rndRatio = employeeProd[EmployeePositions.RandD] / employeeProd["total"], - opsRatio = employeeProd[EmployeePositions.Operations] / employeeProd["total"], - busRatio = employeeProd[EmployeePositions.Business] / employeeProd["total"]; - var designMult = 1 + (Math.pow(this.designCost, 0.1) / 100); - console.log("designMult: " + designMult); - var balanceMult = (1.2 * engrRatio) + (0.9 * mgmtRatio) + (1.3 * rndRatio) + - (1.5 * opsRatio) + (busRatio); - var sciMult = 1 + (Math.pow(industry.sciResearch.qty, industry.sciFac) / 1000); - var totalMult = progrMult * balanceMult * designMult * sciMult; - - this.qlt = totalMult * ((0.10 * employeeProd[EmployeePositions.Engineer]) + - (0.05 * employeeProd[EmployeePositions.Management]) + - (0.05 * employeeProd[EmployeePositions.RandD]) + - (0.02 * employeeProd[EmployeePositions.Operations]) + - (0.02 * employeeProd[EmployeePositions.Business])); - this.per = totalMult * ((0.15 * employeeProd[EmployeePositions.Engineer]) + - (0.02 * employeeProd[EmployeePositions.Management]) + - (0.02 * employeeProd[EmployeePositions.RandD]) + - (0.02 * employeeProd[EmployeePositions.Operations]) + - (0.02 * employeeProd[EmployeePositions.Business])); - this.dur = totalMult * ((0.05 * employeeProd[EmployeePositions.Engineer]) + - (0.02 * employeeProd[EmployeePositions.Management]) + - (0.08 * employeeProd[EmployeePositions.RandD]) + - (0.05 * employeeProd[EmployeePositions.Operations]) + - (0.05 * employeeProd[EmployeePositions.Business])); - this.rel = totalMult * ((0.02 * employeeProd[EmployeePositions.Engineer]) + - (0.08 * employeeProd[EmployeePositions.Management]) + - (0.02 * employeeProd[EmployeePositions.RandD]) + - (0.05 * employeeProd[EmployeePositions.Operations]) + - (0.08 * employeeProd[EmployeePositions.Business])); - this.aes = totalMult * ((0.00 * employeeProd[EmployeePositions.Engineer]) + - (0.08 * employeeProd[EmployeePositions.Management]) + - (0.05 * employeeProd[EmployeePositions.RandD]) + - (0.02 * employeeProd[EmployeePositions.Operations]) + - (0.10 * employeeProd[EmployeePositions.Business])); - this.fea = totalMult * ((0.08 * employeeProd[EmployeePositions.Engineer]) + - (0.05 * employeeProd[EmployeePositions.Management]) + - (0.02 * employeeProd[EmployeePositions.RandD]) + - (0.05 * employeeProd[EmployeePositions.Operations]) + - (0.05 * employeeProd[EmployeePositions.Business])); - this.calculateRating(industry); - var advMult = 1 + (Math.pow(this.advCost, 0.1) / 100); - this.mku = 100 / (advMult * Math.pow((this.qlt + 0.001), 0.6) * (busRatio + mgmtRatio)); - this.dmd = industry.awareness === 0 ? 20 : Math.min(100, advMult * (100 * (industry.popularity / industry.awareness))); - this.cmp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, 70); - - //Calculate the product's required materials - //For now, just set it to be the same as the requirements to make materials - for (var matName in industry.reqMats) { - if (industry.reqMats.hasOwnProperty(matName)) { - this.reqMats[matName] = industry.reqMats[matName]; - } - } - - //Calculate the product's size - //For now, just set it to be the same size as the requirements to make materials - this.siz = 0; - for (var matName in industry.reqMats) { - this.siz += MaterialSizes[matName] * industry.reqMats[matName]; - } - - //Delete unneeded variables - delete this.prog; - delete this.createCity; - delete this.designCost; - delete this.advCost; -} - - -Product.prototype.calculateRating = function(industry) { - var weights = ProductRatingWeights[industry.type]; - if (weights == null) { - console.log("ERROR: Could not find product rating weights for: " + industry); - return; - } - this.rat = 0; - this.rat += weights.Quality ? this.qlt * weights.Quality : 0; - this.rat += weights.Performance ? this.per * weights.Performance : 0; - this.rat += weights.Durability ? this.dur * weights.Durability : 0; - this.rat += weights.Reliability ? this.rel * weights.Reliability : 0; - this.rat += weights.Aesthetics ? this.aes * weights.Aesthetics : 0; - this.rat += weights.Features ? this.fea * weights.Features : 0; -} - -Product.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Product", this); -} - -Product.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Product, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Product = Product; - -var Industries = { - Energy: "Energy", - Utilities: "Water Utilities", - Agriculture: "Agriculture", - Fishing: "Fishing", - Mining: "Mining", - Food: "Food", - Tobacco: "Tobacco", - Chemical: "Chemical", - Pharmaceutical: "Pharmaceutical", - Computer: "Computer Hardware", - Robotics: "Robotics", - Software: "Software", - Healthcare: "Healthcare", - RealEstate: "RealEstate", -} - -var IndustryStartingCosts = { - Energy: 225e9, - Utilities: 150e9, - Agriculture: 40e9, - Fishing: 80e9, - Mining: 300e9, - Food: 10e9, - Tobacco: 20e9, - Chemical: 70e9, - Pharmaceutical: 200e9, - Computer: 500e9, - Robotics: 1e12, - Software: 25e9, - Healthcare: 750e9, - RealEstate: 600e9, -} - -var IndustryDescriptions = { - Energy: "Engage in the production and distribution of energy.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Energy).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Utilities: "Distributes water and provides wastewater services.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Utilities).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Agriculture: "Cultive crops and breed livestock to produce food.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Agriculture).format("$0.000a") + "
" + - "Recommended starting Industry: YES", - Fishing: "Produce food through the breeding and processing of fish and fish products

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Fishing).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Mining: "Extract and process metals from the earth.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Mining).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Food: "Create your own restaurants all around the world.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Food).format("$0.000a") + "
" + - "Recommended starting Industry: YES", - Tobacco: "Create and distribute tobacco and tobacco-related products.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Tobacco).format("$0.000a") + "
" + - "Recommended starting Industry: YES", - Chemical: "Product industrial chemicals

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Chemical).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Pharmaceutical: "Discover, develop, and create new pharmaceutical drugs.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Pharmaceutical).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Computer: "Develop and manufacture new computer hardware and networking infrastructures.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Computer).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Robotics: "Develop and create robots.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Robotics).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - Software: "Develop computer software and create AI Cores.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Software).format("$0.000a") + "
" + - "Recommended starting Industry: YES", - Healthcare: "Create and manage hospitals.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Healthcare).format("$0.000a") + "
" + - "Recommended starting Industry: NO", - RealEstate: "Develop and manage real estate properties.

" + - "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.RealEstate).format("$0.000a") + "
" + - "Recommended starting Industry: NO", -} - -var ProductRatingWeights = { - [Industries.Food]: { - Quality: 0.7, - Durability: 0.1, - Aesthetics: 0.2, - }, - [Industries.Tobacco]: { - Quality: 0.4, - Durability: 0.2, - Reliability: 0.2, - Aesthetics: 0.2, - }, - [Industries.Pharmaceutical]: { - Quality: 0.2, - Performance: 0.2, - Durability: 0.1, - Reliability: 0.3, - Features: 0.2, - }, - [Industries.Computer]: { - Quality: 0.15, - Performance: 0.25, - Durability: 0.25, - Reliability: 0.2, - Aesthetics: 0.05, - Features: 0.1, - }, - [Industries.Robotics]: { - Quality: 0.1, - Performance: 0.2, - Durability: 0.2, - Reliability: 0.2, - Aesthetics: 0.1, - Features: 0.2, - }, - [Industries.Software]: { - Quality: 0.2, - Performance: 0.2, - Reliability: 0.2, - Durability: 0.2, - Features: 0.2, - }, - [Industries.Healthcare]: { - Quality: 0.4, - Performance: 0.1, - Durability: 0.1, - Reliability: 0.3, - Features: 0.1, - }, - [Industries.RealEstate]: { - Quality: 0.2, - Durability: 0.25, - Reliability: 0.1, - Aesthetics: 0.35, - Features: 0.1, - } -} - -//Industry upgrades -//The structure is: -// [index in array, base price, price mult, benefit mult (if applicable), name, desc] -var IndustryUpgrades = { - "0": [0, 500e3, 1, 1.05, - "Coffee", "Provide your employees with coffee, increasing their energy by 5%."], - "1": [1, 1e9, 1.05, 1.03, - "AdVert.Inc", "Hire AdVert.Inc to advertise your company. Each level of " + - "this upgrade grants your company a static increase of 4 and 1 to its awareness and " + - "popularity, respectively. It will then increase your company's awareness by 1%, and its popularity " + - "by a random percentage between 2% and 4%. These effects are increased by other upgrades " + - "that increase the power of your advertising."] -} - -var empManualAssignmentModeActive = false; -function Industry(params={}) { - this.offices = { //Maps locations to offices. 0 if no office at that location - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: new OfficeSpace({ - loc:__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12, - size:OfficeInitialSize, - }), - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: 0 - }; - - this.warehouses = { //Maps locations to warehouses. 0 if no warehouse at that location - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chonqing]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: new Warehouse({ - loc:__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12, - size: WarehouseInitialSize, - }), - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: 0, - [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: 0 - }; - - this.name = params.name ? params.name : 0; - this.type = params.type ? params.type : 0; - - this.sciResearch = new Material({name: "Scientific Research"}); - - //A map of the NAME of materials required to create produced materials to - //how many are needed to produce 1 unit of produced materials - this.reqMats = {}; - - //An array of the name of materials being produced - this.prodMats = []; - - this.products = {}; - this.makesProducts = false; - - this.awareness = 0; - this.popularity = 0; //Should always be less than awareness - this.startingCost = 0; - - /* The following are factors for how much production/other things are increased by - different factors. The production increase always has diminishing returns, - and they are all reprsented by exponentials of < 1 (e.g x ^ 0.5, x ^ 0.8) - The number for these represent the exponential. A lower number means more - diminishing returns */ - this.reFac = 0; //Real estate Factor - this.sciFac = 0; //Scientific Research Factor, affects quality - this.hwFac = 0; //Hardware factor - this.robFac = 0; //Robotics Factor - this.aiFac = 0; //AI Cores factor; - this.advFac = 0; //Advertising factor, affects sales - - this.prodMult = 0; //Production multiplier - - //Financials - this.lastCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.lastCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - - //Upgrades - var numUpgrades = Object.keys(IndustryUpgrades).length; - this.upgrades = Array(numUpgrades).fill(0); - - this.state = "START"; - this.newInd = true; - - this.init(); -} - -Industry.prototype.init = function() { - //Set the unique properties of an industry (how much its affected by real estate/scientific research, etc.) - this.startingCost = IndustryStartingCosts[this.type]; - switch (this.type) { - case Industries.Energy: - this.reFac = 0.65; - this.sciFac = 0.7; - this.robFac = 0.05; - this.aiFac = 0.3; - this.advFac = 0.07; - this.reqMats = { - "Hardware": 0.1, - "Metal": 0.25, - }; - this.prodMats = ["Energy"]; - break; - case Industries.Utilities: - case "Utilities": - this.reFac = 0.4; - this.sciFac = 0.6; - this.robFac = 0.3; - this.aiFac = 0.3; - this.advFac = 0.07; - this.reqMats = { - "Hardware": 0.1, - "Metal": 0.2, - } - this.prodMats = ["Water"]; - break; - case Industries.Agriculture: - this.reFac = 0.8; - this.sciFac = 0.5; - this.hwFac = 0.2; - this.robFac = 0.3; - this.aiFac = 0.3; - this.advFac = 0.04; - this.reqMats = { - "Water": 0.5, - "Energy": 0.5, - } - this.prodMats = ["Plants", "Food"]; - break; - case Industries.Fishing: - this.reFac = 0.15; - this.sciFac = 0.35; - this.hwFac = 0.35; - this.robFac = 0.5; - this.aiFac = 0.2; - this.advFac = 0.06; - this.reqMats = { - "Energy": 0.5, - } - this.prodMats = ["Food"]; - break; - case Industries.Mining: - this.reFac = 0.3; - this.sciFac = 0.25; - this.hwFac = 0.4; - this.robFac = 0.5; - this.aiFac = 0.5; - this.advFac = 0.04; - this.reqMats = { - "Energy": 0.8, - } - this.prodMats = ["Metal"]; - break; - case Industries.Food: - //reFac is unique for this bc it diminishes greatly per city. Handle this separately in code? - this.sciFac = 0.12; - this.hwFac = 0.15; - this.robFac = 0.3; - this.aiFac = 0.25; - this.advFac = 0.25; - this.reFac = 0.05; - this.reqMats = { - "Food": 0.5, - "Water": 0.5, - "Energy": 0.2, - } - this.makesProducts = true; - break; - case Industries.Tobacco: - this.reFac = 0.15; - this.sciFac = 0.75; - this.hwFac = 0.15; - this.robFac = 0.2; - this.aiFac = 0.15; - this.advFac = 0.2; - this.reqMats = { - "Plants": 1, - "Water": 0.2, - } - this.makesProducts = true; - break; - case Industries.Chemical: - this.reFac = 0.25; - this.sciFac = 0.75; - this.hwFac = 0.2; - this.robFac = 0.25; - this.aiFac = 0.2; - this.advFac = 0.05; - this.reqMats = { - "Plants": 1, - "Energy": 0.5, - "Water": 0.5, - } - this.prodMats = ["Chemicals"]; - break; - case Industries.Pharmaceutical: - this.reFac = 0.05; - this.sciFac = 0.8; - this.hwFac = 0.15; - this.robFac = 0.25; - this.aiFac = 0.2; - this.advFac = 0.15; - this.reqMats = { - "Chemicals": 2, - "Energy": 1, - "Water": 0.5, - } - this.prodMats = ["Drugs"]; - this.makesProducts = true; - break; - case Industries.Computer: - case "Computer": - this.reFac = 0.2; - this.sciFac = 0.65; - this.robFac = 0.4; - this.aiFac = 0.2; - this.advFac = 0.17; - this.reqMats = { - "Metal": 2.5, - "Energy": 1, - } - this.prodMats = ["Hardware"]; - this.makesProducts = true; - break; - case Industries.Robotics: - this.reFac = 0.35; - this.sciFac = 0.7; - this.aiFac = 0.4; - this.advFac = 0.2; - this.hwFac = 0.2; - this.reqMats = { - "Hardware": 5, - "Energy": 3, - } - this.prodMats = ["Robots"]; - this.makesProducts = true; - break; - case Industries.Software: - this.sciFac = 0.65; - this.advFac = 0.16; - this.hwFac = 0.25; - this.reFac = 0.1; - this.aiFac = 0.1; - this.robFac = 0.05; - this.reqMats = { - "Hardware": 0.5, - "Energy": 1, - } - this.prodMats = ["AICores"]; - this.makesProducts = true; - break; - case Industries.Healthcare: - //reFac is unique for this bc it diminishes greatly per city. Handle this separately in code? - this.sciFac = 0.75; - this.advFac = 0.1; - this.hwFac = 0.1; - this.robFac = 0.1; - this.aiFac = 0.1; - this.reqMats = { - "Robots": 10, - "AICores": 5, - "Energy": 5, - "Water": 5, - } - this.makesProducts = true; - break; - case Industries.RealEstate: - this.robFac = 0.6; - this.aiFac = 0.6; - this.advFac = 0.25; - this.sciFac = 0.05; - this.hwFac = 0.05; - this.reqMats = { - "Metal": 20, - "Energy": 10, - "Water": 10, - "Hardware": 5 - } - this.prodMats = ["RealEstate"]; - this.makesProducts = true; - break; - default: - console.log("ERR: Invalid Industry Type passed into Industry.init(): " + this.type); - return; - } -} - -Industry.prototype.getProductDescriptionText = function() { - if (!this.makesProducts) {return;} - switch (this.type) { - case Industries.Food: - return "create and manage restaurants"; - break; - case Industries.Tobacco: - return "create tobacco and tobacco-related products"; - break; - case Industries.Pharmaceutical: - return "develop new pharmaceutical drugs"; - break; - case Industries.Computer: - case "Computer": - return "create new computer hardware and networking infrastructures"; - break; - case Industries.Robotics: - return "build specialized robots and robot-related products"; - break; - case Industries.Software: - return "develop computer software"; - break; - case Industries.HealthCare: - return "build and manage hospitals"; - break; - case Industries.RealEstate: - return "develop and manage real estate properties"; - break; - default: - console.log("ERROR: Invalid industry type in Industry.getProductDescriptionText"); - return ""; - } -} - -//Calculates the values that factor into the production and properties of -//materials/products (such as quality, etc.) -Industry.prototype.calculateProductionFactors = function() { - var multSum = 0; - for (var i = 0; i < Cities.length; ++i) { - var city = Cities[i]; - var warehouse = this.warehouses[city]; - if (!(warehouse instanceof Warehouse)) { - continue; - } - - var materials = warehouse.materials, - office = this.offices[city]; - - var cityMult = Math.pow(0.002 * materials.RealEstate.qty+1, this.reFac) * - Math.pow(0.002 * materials.Hardware.qty+1, this.hwFac) * - Math.pow(0.002 * materials.Robots.qty+1, this.robFac) * - Math.pow(0.002 * materials.AICores.qty+1, this.aiFac); - multSum += Math.pow(cityMult, 0.73); - } - - multSum < 1 ? this.prodMult = 1 : this.prodMult = multSum; -} - -Industry.prototype.updateWarehouseSizeUsed = function(warehouse) { - if (warehouse instanceof Warehouse) { - //This resets the size back to 0 and then accounts for materials - warehouse.updateMaterialSizeUsed(); - } - - for (var prodName in this.products) { - if (this.products.hasOwnProperty(prodName)) { - var prod = this.products[prodName]; - warehouse.sizeUsed += (prod.data[warehouse.loc][0] * prod.siz); - if (prod.data[warehouse.loc][0] > 0 && warehouse.loc === currentCityUi) { - industryWarehouseStorageBreakdownText += (prodName + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(prod.data[warehouse.loc][0] * prod.siz, 0) + "
"); - } - } - } -} - -Industry.prototype.process = function(marketCycles=1, state, company) { - this.state = state; - - //At the start of a cycle, store and reset revenue/expenses - //Then calculate salaries and processs the markets - if (state === "START") { - if (isNaN(this.thisCycleRevenue) || isNaN(this.thisCycleExpenses)) { - console.log("ERROR: NaN in Corporation's computed revenue/expenses"); - console.log(this.thisCycleRevenue.toString()); - console.log(this.thisCycleExpenses.toString()); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Something went wrong when compting Corporation's revenue/expenses. This is a bug. Please report to game developer"); - this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - } - this.lastCycleRevenue = this.thisCycleRevenue.dividedBy(marketCycles * SecsPerMarketCycle); - this.lastCycleExpenses = this.thisCycleExpenses.dividedBy(marketCycles * SecsPerMarketCycle); - this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - - //Once you start making revenue, the player should no longer be - //considered new, and therefore no longer needs the 'tutorial' UI elements - if (this.lastCycleRevenue.gt(0)) {this.newInd = false;} - - //Process offices (and the employees in them) - var employeeSalary = 0; - for (var officeLoc in this.offices) { - if (this.offices.hasOwnProperty(officeLoc) && - this.offices[officeLoc] instanceof OfficeSpace) { - employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:company}); - } - } - this.thisCycleExpenses = this.thisCycleExpenses.plus(employeeSalary); - - //Process change in demand/competition of materials/products - this.processMaterialMarket(marketCycles); - this.processProductMarket(marketCycles); - - //Process loss of popularity - this.popularity -= (marketCycles * .0001); - this.popularity = Math.max(0, this.popularity); - - //Process Dreamsense gains - var popularityGain = company.getDreamSenseGain(), awarenessGain = popularityGain * 4; - if (popularityGain > 0) { - this.popularity += (popularityGain * marketCycles); - this.awareness += (awarenessGain * marketCycles); - } - - return; - } - - //Process production, purchase, and import/export of materials - var res = this.processMaterials(marketCycles, company); - this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); - this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); - - //Process creation, production & sale of products - res = this.processProducts(marketCycles, company); - this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); - this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); - -} - -//Process change in demand and competition for this industry's materials -Industry.prototype.processMaterialMarket = function(marketCycles=1) { - //References to prodMats and reqMats - var reqMats = this.reqMats, prodMats = this.prodMats; - - //Only 'process the market' for materials that this industry deals with - for (var i = 0; i < Cities.length; ++i) { - //If this industry has a warehouse in this city, process the market - //for every material this industry requires or produces - if (this.warehouses[Cities[i]] instanceof Warehouse) { - var wh = this.warehouses[Cities[i]]; - for (var name in reqMats) { - if (reqMats.hasOwnProperty(name)) { - wh.materials[name].processMarket(); - } - } - - //Produced materials are stored in an array - for (var foo = 0; foo < prodMats.length; ++foo) { - wh.materials[prodMats[foo]].processMarket(); - } - - //Process these twice because these boost production - wh.materials["Hardware"].processMarket(); - wh.materials["Robots"].processMarket(); - wh.materials["AICores"].processMarket(); - wh.materials["RealEstate"].processMarket(); - } - } -} - -//Process change in demand and competition for this industry's products -Industry.prototype.processProductMarket = function(marketCycles=1) { - //Demand gradually decreases, and competition gradually increases - for (var name in this.products) { - if (this.products.hasOwnProperty(name)) { - var product = this.products[name]; - var change = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(1, 3) * 0.0004; - if (this.type === Industries.Pharmaceutical || this.type === Industries.Software || - this.type === Industries.Robotics) { - change *= 3; - } - change *= marketCycles; - product.dmd -= change; - product.cmp += change; - product.cmp = Math.min(product.cmp, 99.99); - product.dmd = Math.max(product.dmd, 0.001); - } - } -} - -//Process production, purchase, and import/export of materials -Industry.prototype.processMaterials = function(marketCycles=1, company) { - var revenue = 0, expenses = 0, industry = this; - this.calculateProductionFactors(); - for (var i = 0; i < Cities.length; ++i) { - var city = Cities[i], office = this.offices[city]; - - if (this.warehouses[city] instanceof Warehouse) { - var warehouse = this.warehouses[city]; - - switch(this.state) { - - case "PURCHASE": - /* Process purchase of materials */ - for (var matName in warehouse.materials) { - if (warehouse.materials.hasOwnProperty(matName)) { - (function(matName, ind) { - var mat = warehouse.materials[matName]; - var buyAmt, maxAmt; - if (warehouse.smartSupplyEnabled && Object.keys(ind.reqMats).includes(matName)) { - //Smart supply tracker is stored as per second rate - mat.buy = ind.reqMats[matName] * warehouse.smartSupplyStore; - buyAmt = mat.buy * SecsPerMarketCycle * marketCycles; - } else { - buyAmt = (mat.buy * SecsPerMarketCycle * marketCycles); - } - - if (matName == "RealEstate") { - maxAmt = buyAmt; - } else { - maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialSizes[matName]); - } - var buyAmt = Math.min(buyAmt, maxAmt); - if (buyAmt > 0) { - mat.qty += buyAmt; - expenses += (buyAmt * mat.bCost); - } - })(matName, industry); - this.updateWarehouseSizeUsed(warehouse); - } - } //End process purchase of materials - break; - - case "PRODUCTION": - warehouse.smartSupplyStore = 0; //Reset smart supply amount - - /* Process production of materials */ - if (this.prodMats.length > 0) { - var mat = warehouse.materials[this.prodMats[0]]; - //Calculate the maximum production of this material based - //on the office's productivity - var maxProd = this.getOfficeProductivity(office) * this.prodMult * company.getProductionMultiplier(), prod; - - if (mat.prdman[0]) { - //Production is manually limited - prod = Math.min(maxProd, mat.prdman[1]); - } else { - prod = maxProd; - } - prod *= (SecsPerMarketCycle * marketCycles); //Convert production from per second to per market cycle - //Calculate net change in warehouse storage making - //the produced materials will cost - var totalMatSize = 0; - for (var tmp = 0; tmp < this.prodMats.length; ++tmp) { - totalMatSize += (MaterialSizes[this.prodMats[tmp]]); - } - for (var reqMatName in this.reqMats) { - if (this.reqMats.hasOwnProperty(reqMatName)) { - var normQty = this.reqMats[reqMatName]; - totalMatSize -= (MaterialSizes[reqMatName] * normQty); - } - } - //If not enough space in warehouse, limit the amount of produced materials - if (totalMatSize > 0) { - var maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / totalMatSize); - prod = Math.min(maxAmt, prod); - } - - //Keep track of production for smart supply (/s) - warehouse.smartSupplyStore += (prod / (SecsPerMarketCycle * marketCycles)); - - //Make sure we have enough resource to make our materials - var producableFrac = 1; - for (var reqMatName in this.reqMats) { - if (this.reqMats.hasOwnProperty(reqMatName)) { - var req = this.reqMats[reqMatName] * prod; - if (warehouse.materials[reqMatName].qty < req) { - producableFrac = Math.min(producableFrac, warehouse.materials[reqMatName].qty / req); - } - } - } - if (producableFrac <= 0) {producableFrac = 0; prod = 0;} - - //Make our materials if they are producable - if (producableFrac > 0 && prod > 0) { - for (var reqMatName in this.reqMats) { - if (this.reqMats.hasOwnProperty(reqMatName)) { - var reqMatQtyNeeded = (this.reqMats[reqMatName] * prod * producableFrac); - warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; - warehouse.materials[reqMatName].prd = 0; - warehouse.materials[reqMatName].prd -= reqMatQtyNeeded / (SecsPerMarketCycle * marketCycles); - } - } - for (var j = 0; j < this.prodMats.length; ++j) { - warehouse.materials[this.prodMats[j]].qty += (prod * producableFrac); - warehouse.materials[this.prodMats[j]].qlt = - (office.employeeProd[EmployeePositions.Engineer] / 100 + - Math.pow(this.sciResearch.qty, this.sciFac) + - Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3); - } - } else { - for (var reqMatName in this.reqMats) { - if (this.reqMats.hasOwnProperty(reqMatName)) { - warehouse.materials[reqMatName].prd = 0; - } - } - } - - //Per second - var fooProd = prod * producableFrac / (SecsPerMarketCycle * marketCycles); - for (var fooI = 0; fooI < this.prodMats.length; ++fooI) { - warehouse.materials[this.prodMats[fooI]].prd = fooProd; - } - } else { - //If this doesn't produce any materials, then it only creates - //Products. Creating products will consume materials. The - //Production of all consumed materials must be set to 0 - for (var reqMatName in this.reqMats) { - if (this.reqMats.hasOwnProperty(reqMatName)) { - warehouse.materials[reqMatName].prd = 0; - } - } - } - break; - - case "SALE": - /* Process sale of materials */ - for (var matName in warehouse.materials) { - if (warehouse.materials.hasOwnProperty(matName)) { - var mat = warehouse.materials[matName]; - if (mat.sCost < 0 || mat.sllman[0] === false) { - mat.sll = 0; - continue; - } - var mat = warehouse.materials[matName]; - - var sCost; - if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(mat.sCost)) { - sCost = mat.sCost.replace(/MP/g, mat.bCost); - sCost = eval(sCost); - } else { - sCost = mat.sCost; - } - - //Calculate how much of the material sells (per second) - var markup = 1, markupLimit = mat.qlt / mat.mku; - if (sCost > mat.bCost) { - //Penalty if difference between sCost and bCost is greater than markup limit - if ((sCost - mat.bCost) > markupLimit) { - markup = markupLimit / (sCost - mat.bCost); - } - } else if (sCost < mat.bCost) { - if (sCost <= 0) { - markup = 1e12; //Sell everything, essentially discard - } else { - //Lower prices than market increases sales - markup = mat.bCost / sCost; - } - } - //var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); - var businessFactor = this.getBusinessFactor(office); //Business employee productivity - var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity - var marketFactor = this.getMarketFactor(mat); //Competition + demand - var maxSell = (mat.qlt + .001) * marketFactor * markup * businessFactor * - company.getSalesMultiplier() * advertisingFactor; - - var sellAmt; - if (mat.sllman[1] !== -1) { - //Sell amount is manually limited - sellAmt = Math.min(maxSell, mat.sllman[1]); - } else { - sellAmt = maxSell; - } - sellAmt = (sellAmt * SecsPerMarketCycle * marketCycles); - sellAmt = Math.min(mat.qty, sellAmt); - if (sellAmt < 0) { - console.log("ERROR: sellAmt is negative"); - continue; - } - if (sellAmt && sCost >= 0) { - mat.qty -= sellAmt; - revenue += (sellAmt * sCost); - mat.sll = sellAmt / (SecsPerMarketCycle * marketCycles); - } else { - mat.sll = 0; - } - } - } //End processing of sale of materials - break; - - case "EXPORT": - for (var matName in warehouse.materials) { - if (warehouse.materials.hasOwnProperty(matName)) { - var mat = warehouse.materials[matName]; - for (var expI = 0; expI < mat.exp.length; ++expI) { - var exp = mat.exp[expI]; - var amt = exp.amt * SecsPerMarketCycle * marketCycles; - if (mat.qty <= amt) { - amt = mat.qty; - } - if (amt === 0) { - break; //None left - } - for (var foo = 0; foo < company.divisions.length; ++foo) { - if (company.divisions[foo].name === exp.ind) { - var expIndustry = company.divisions[foo]; - var expWarehouse = expIndustry.warehouses[exp.city]; - if (!(expWarehouse instanceof Warehouse)) { - console.log("ERROR: Invalid export! " + expIndustry.name + " " + exp.city); - break; - } - expWarehouse.materials[matName].qty += amt; - mat.qty -= amt; - break; - } - } - } - } - } - - break; - - case "START": - break; - default: - console.log("ERROR: Invalid state: " + this.state); - break; - } //End switch(this.state) - this.updateWarehouseSizeUsed(warehouse); - - } // End warehouse - - //Produce Scientific Research based on R&D employees - //Scientific Research can be produced without a warehouse - if (office instanceof OfficeSpace) { - this.sciResearch.qty += (.01 * Math.pow(office.employeeProd[EmployeePositions.RandD], 0.5) - * company.getScientificResearchMultiplier()); - } - } - return [revenue, expenses]; -} - -//Process production & sale of this industry's FINISHED products (including all of their stats) -Industry.prototype.processProducts = function(marketCycles=1, corporation) { - var revenue = 0, expenses = 0; - - //Create products - if (this.state === "PRODUCTION") { - for (var prodName in this.products) { - if (this.products.hasOwnProperty(prodName)) { - var prod = this.products[prodName]; - if (!prod.fin) { - var city = prod.createCity, office = this.offices[city]; - var total = office.employeeProd[EmployeePositions.Operations] + - office.employeeProd[EmployeePositions.Engineer] + - office.employeeProd[EmployeePositions.Management], ratio; - if (total === 0) { - ratio = 0; - } else { - ratio = office.employeeProd[EmployeePositions.Engineer] / total + - office.employeeProd[EmployeePositions.Operations] / total + - office.employeeProd[EmployeePositions.Management] / total; - } - prod.createProduct(marketCycles, ratio * Math.pow(total, 0.29)); - if (prod.prog >= 100) { - prod.finishProduct(office.employeeProd, this); - } - break; - } - } - } - } - - //Produce Products - for (var prodName in this.products) { - if (this.products.hasOwnProperty(prodName)) { - var prod = this.products[prodName]; - if (prod instanceof Product && prod.fin) { - revenue += this.processProduct(marketCycles, prod, corporation); - } - } - } - return [revenue, expenses]; -} - -//Processes FINISHED products -Industry.prototype.processProduct = function(marketCycles=1, product, corporation) { - var totalProfit = 0; - for (var i = 0; i < Cities.length; ++i) { - var city = Cities[i], office = this.offices[city], warehouse = this.warehouses[city]; - if (warehouse instanceof Warehouse) { - switch(this.state) { - - case "PRODUCTION": - //Calculate the maximum production of this material based - //on the office's productivity - var maxProd = this.getOfficeProductivity(office, {forProduct:true}) * - corporation.getProductionMultiplier() * this.prodMult, prod; - - //Account for whether production is manually limited - if (product.prdman[city][0]) { - prod = Math.min(maxProd, product.prdman[city][1]); - } else { - prod = maxProd; - } - prod *= (SecsPerMarketCycle * marketCycles); - - //Calculate net change in warehouse storage making the Products will cost - var netStorageSize = product.siz; - for (var reqMatName in product.reqMats) { - if (product.reqMats.hasOwnProperty(reqMatName)) { - var normQty = product.reqMats[reqMatName]; - netStorageSize -= (MaterialSizes[reqMatName] * normQty); - } - } - - //If there's not enough space in warehouse, limit the amount of Product - if (netStorageSize > 0) { - var maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / netStorageSize); - prod = Math.min(maxAmt, prod); - } - - warehouse.smartSupplyStore += (prod / (SecsPerMarketCycle * marketCycles)); - - //Make sure we have enough resources to make our Products - var producableFrac = 1; - for (var reqMatName in product.reqMats) { - if (product.reqMats.hasOwnProperty(reqMatName)) { - var req = product.reqMats[reqMatName] * prod; - if (warehouse.materials[reqMatName].qty < req) { - producableFrac = Math.min(producableFrac, warehouse.materials[reqMatName].qty / req); - } - } - } - - //Make our Products if they are producable - if (producableFrac > 0 && prod > 0) { - for (var reqMatName in product.reqMats) { - if (product.reqMats.hasOwnProperty(reqMatName)) { - var reqMatQtyNeeded = (product.reqMats[reqMatName] * prod * producableFrac); - warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; - warehouse.materials[reqMatName].prd -= reqMatQtyNeeded / (SecsPerMarketCycle * marketCycles); - } - } - //Quantity - product.data[city][0] += (prod * producableFrac); - } - - //Keep track of production Per second - product.data[city][1] = prod * producableFrac / (SecsPerMarketCycle * marketCycles); - break; - - case "SALE": - //Process sale of Products - product.pCost = 0; //Estimated production cost - for (var reqMatName in product.reqMats) { - if (product.reqMats.hasOwnProperty(reqMatName)) { - product.pCost += (product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost); - } - } - - //Since its a product, its production cost is increased for labor - product.pCost *= 3; - - var markup = 1, markupLimit = product.rat / product.mku; - if (product.sCost > product.pCost) { - if ((product.sCost - product.pCost) > markupLimit) { - markup = markupLimit / (product.sCost - product.pCost); - } - } - //var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); - var businessFactor = this.getBusinessFactor(office); //Business employee productivity - var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity - var marketFactor = this.getMarketFactor(product); //Competition + demand - 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] && product.sllman[city][1] > 0) { - //Sell amount is manually limited - sellAmt = Math.min(maxSell, product.sllman[city][1]); - } else { - sellAmt = maxSell; - } - sellAmt = sellAmt * SecsPerMarketCycle * marketCycles; - sellAmt = Math.min(product.data[city][0], sellAmt); //data[0] is qty - if (sellAmt && product.sCost) { - product.data[city][0] -= sellAmt; //data[0] is qty - totalProfit += (sellAmt * product.sCost); - product.data[city][2] = sellAmt / (SecsPerMarketCycle * marketCycles); //data[2] is sell property - } else { - product.data[city][2] = 0; //data[2] is sell property - } - break; - - case "START": - case "PURCHASE": - case "EXPORT": - break; - default: - console.log("ERROR: Invalid State: " + this.state); - break; - } //End switch(this.state) - } - } - return totalProfit; -} - -Industry.prototype.discontinueProduct = function(product, parentRefs) { - var company = parentRefs.company, industry = parentRefs.industry; - for (var productName in this.products) { - if (this.products.hasOwnProperty(productName)) { - if (product === this.products[productName]) { - delete this.products[productName]; - company.updateUIContent(); - } - } - } -} - -Industry.prototype.upgrade = function(upgrade, refs) { - var corporation = refs.corporation, division = refs.division, - office = refs.office; - var upgN = upgrade[0], basePrice = upgrade[1], priceMult = upgrade[2], - upgradeBenefit = upgrade[3]; - while (this.upgrades.length <= upgN) {this.upgrades.push(0);} - ++this.upgrades[upgN]; - - switch (upgN) { - case 0: //Coffee, 5% energy per employee - for (var i = 0; i < office.employees.length; ++i) { - office.employees[i].ene = Math.min(office.employees[i].ene * 1.05, 100); - } - break; - case 1: //AdVert.Inc, - var advMult = corporation.getAdvertisingMultiplier(); - this.awareness += (4 * advMult); - this.popularity += (1 * advMult); - this.awareness *= (1.01 * advMult); - this.popularity *= ((1 + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(2, 4) / 100) * advMult); - break; - default: - console.log("ERROR: Un-implemented function index: " + upgN); - break; - } -} - -//Returns how much of a material can be produced based of office productivity (employee stats) -Industry.prototype.getOfficeProductivity = function(office, params) { - var total = office.employeeProd[EmployeePositions.Operations] + - office.employeeProd[EmployeePositions.Engineer] + - office.employeeProd[EmployeePositions.Management], ratio; - if (total === 0) { - ratio = 0; - } else { - ratio = (office.employeeProd[EmployeePositions.Operations] / total) * - (office.employeeProd[EmployeePositions.Engineer] / total) * - (office.employeeProd[EmployeePositions.Management] / total); - ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees - } - if (params && params.forProduct) { - return ratio * Math.pow(total, 0.2); - } else { - return 2 * ratio * Math.pow(total, 0.3); - } -} - -//Returns a multiplier based on the office' 'Business' employees that affects sales -Industry.prototype.getBusinessFactor = function(office) { - var ratioMult = 1; - if (office.employeeProd["total"] > 0) { - ratioMult = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); - } - return ratioMult * Math.pow(1 + office.employeeProd[EmployeePositions.Business], 0.1); -} - -//Returns a set of multipliers based on the Industry's awareness, popularity, and advFac. This -//multiplier affects sales. The result is: -// [Total sales mult, total awareness mult, total pop mult, awareness/pop ratio mult] -Industry.prototype.getAdvertisingFactors = function() { - var awarenessFac = Math.pow(this.awareness + 1, this.advFac); - var popularityFac = Math.pow(this.popularity + 1, this.advFac); - var ratioFac = (this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01)); - var totalFac = Math.pow(awarenessFac * popularityFac * ratioFac, 0.85); - return [totalFac, awarenessFac, popularityFac, ratioFac]; -} - -//Returns a multiplier based on a materials demand and competition that affects sales -Industry.prototype.getMarketFactor = function(mat) { - return mat.dmd * (100 - mat.cmp)/100; -} - -Industry.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Industry", this); -} - -Industry.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Industry, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Industry = Industry; - -var EmployeePositions = { - Operations: "Operations", - Engineer: "Engineer", - Business: "Business", - Management: "Management", - RandD: "Research & Development", - Training:"Training", - Unassigned:"Unassigned", -} - -function Employee(params={}) { - if (!(this instanceof Employee)) { - return new Employee(params); - } - this.name = params.name ? params.name : "Bobby"; - - //Morale, happiness, and energy are 0-100 - this.mor = params.morale ? params.morale : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); - this.hap = params.happiness ? params.happiness : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); - this.ene = params.energy ? params.energy : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); - - this.age = params.age ? params.age : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(20, 50); - this.int = params.intelligence ? params.intelligence : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); - this.cha = params.charisma ? params.charisma : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); - this.exp = params.experience ? params.experience : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); - this.cre = params.creativity ? params.creativity : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); - this.eff = params.efficiency ? params.efficiency : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); - this.sal = params.salary ? params.salary : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(0.1, 5); - this.pro = 0; //Productivity, This is calculated - - this.loc = params.loc ? params.loc : ""; - this.pos = EmployeePositions.Unassigned; -} - -//Returns the amount the employee needs to be paid -Employee.prototype.process = function(marketCycles=1, office) { - var gain = 0.001 * marketCycles, - det = gain * Math.random(); - this.age += gain; - this.exp += gain; - if (this.age > 150) { - this.int -= det; - this.eff -= det; - this.cha -= det; - } - - //Training - var trainingEff = gain * Math.random(); - if (this.pos === EmployeePositions.Training) { - //To increase creativity and intelligence special upgrades are needed - this.cha += trainingEff; - this.exp += trainingEff; - this.eff += trainingEff; - } - - //Weight based on how full office is - //Too many employees = more likely to decrease energy and happiness - var officeCapacityWeight = 0.5 * (office.employees.length / office.size - 0.5); - if (Math.random() < 0.5 - officeCapacityWeight) { - this.ene += det; - this.hap += det; - } else { - this.ene -= det; - this.hap -= det; - } - if (this.ene < office.minEne) {this.ene = office.minEne;} - if (this.hap < office.minHap) {this.hap = office.minHap;} - var salary = this.sal * marketCycles * SecsPerMarketCycle; - return salary; -} - -Employee.prototype.calculateProductivity = function(corporation) { - var effCre = this.cre * corporation.getEmployeeCreMultiplier(), - effCha = this.cha * corporation.getEmployeeChaMultiplier(), - effInt = this.int * corporation.getEmployeeIntMultiplier(), - effEff = this.eff * corporation.getEmployeeEffMultiplier(); - var prodBase = this.mor * this.hap * this.ene * 1e-6, prodMult; - switch(this.pos) { - //Calculate productivity based on position. This is multipled by prodBase - //to get final value - case EmployeePositions.Operations: - prodMult = (0.6 * effInt) + (0.1 * effCha) + (this.exp) + - (0.5 * effCre) + (effEff); - break; - case EmployeePositions.Engineer: - prodMult = (effInt) + (0.1 * effCha) + (1.5 * this.exp) + - (effEff); - break; - case EmployeePositions.Business: - prodMult = (0.4 * effInt) + (effCha) + (0.5 * this.exp); - break; - case EmployeePositions.Management: - prodMult = (2 * effCha) + (this.exp) + (0.2 * effCre) + - (0.7 * effEff); - break; - case EmployeePositions.RandD: - prodMult = (1.5 * effInt) + (0.8 * this.exp) + (effCre) + - (0.5 * effEff); - break; - case EmployeePositions.Unassigned: - case EmployeePositions.Training: - prodMult = 0; - break; - default: - console.log("ERROR: Invalid employee position: " + this.pos); - break; - } - return prodBase * prodMult; -} - -//Process benefits from having an office party thrown -Employee.prototype.throwParty = function(money) { - var mult = 1 + (money / 10e6); - this.mor *= mult; - this.mor = Math.min(100, this.mor); - this.hap *= mult; - this.hap = Math.min(100, this.hap); - return mult; -} - -//'panel' is the DOM element on which to create the UI -Employee.prototype.createUI = function(panel, corporation) { - var effCre = this.cre * corporation.getEmployeeCreMultiplier(), - effCha = this.cha * corporation.getEmployeeChaMultiplier(), - effInt = this.int * corporation.getEmployeeIntMultiplier(), - effEff = this.eff * corporation.getEmployeeEffMultiplier(); - panel.style.color = "white"; - panel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - id:"cmpy-mgmt-employee-" + this.name + "-panel-text", - innerHTML:"Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.mor, 3) + "
" + - "Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.hap, 3) + "
" + - "Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.ene, 3) + "
" + - "Age: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.age, 3) + "
" + - "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effInt, 3) + "
" + - "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCha, 3) + "
" + - "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.exp, 3) + "
" + - "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCre, 3) + "
" + - "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effEff, 3) + "
" + - "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.sal).format("$0.000a") + "/ s
", - })); - - //Selector for employee position - var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {}); - for (var key in EmployeePositions) { - if (EmployeePositions.hasOwnProperty(key)) { - selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text: EmployeePositions[key], - value: EmployeePositions[key], - })); - } - } - - selector.addEventListener("change", ()=>{ - this.pos = selector.options[selector.selectedIndex].value; - }); - - //Set initial value of selector - for (var i = 0; i < selector.length; ++i) { - if (selector.options[i].value === this.pos) { - selector.selectedIndex = i; - break; - } - } - panel.appendChild(selector); -} - -Employee.prototype.updateUI = function(panel, corporation) { - var effCre = this.cre * corporation.getEmployeeCreMultiplier(), - effCha = this.cha * corporation.getEmployeeChaMultiplier(), - effInt = this.int * corporation.getEmployeeIntMultiplier(), - effEff = this.eff * corporation.getEmployeeEffMultiplier(); - if (panel == null) { - console.log("ERROR: Employee.updateUI() called with null panel"); - return; - } - var text = document.getElementById("cmpy-mgmt-employee-" + this.name + "-panel-text"); - if (text == null) { - return this.createUI(panel); - } - text.innerHTML = "Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.mor, 3) + "
" + - "Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.hap, 3) + "
" + - "Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.ene, 3) + "
" + - "Age: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.age, 3) + "
" + - "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effInt, 3) + "
" + - "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCha, 3) + "
" + - "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.exp, 3) + "
" + - "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCre, 3) + "
" + - "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effEff, 3) + "
" + - "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.sal).format("$0.000a") + "/ s
"; -} - -Employee.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Employee", this); -} - -Employee.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Employee, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Employee = Employee; - -var OfficeSpaceTiers = { - Basic: "Basic", - Enhanced: "Enhanced", - Luxurious: "Luxurious", - Extravagant: "Extravagant" -} - -function OfficeSpace(params={}) { - this.loc = params.loc ? params.loc : ""; - this.cost = params.cost ? params.cost : 1; - this.size = params.size ? params.size : 1; - this.comf = params.comfort ? params.comfort : 1; - this.beau = params.beauty ? params.beauty : 1; - this.tier = OfficeSpaceTiers.Basic; - - this.minEne = 0; //Minimum energy of employees, based on office - this.minHap = 0; //Minimum happiness of employees, based on office. - - this.employees = []; - this.employeeProd = { - [EmployeePositions.Operations]: 0, - [EmployeePositions.Engineer]: 0, - [EmployeePositions.Business]: 0, - [EmployeePositions.Management]: 0, - [EmployeePositions.RandD]: 0, - total: 0, - }; -} - -OfficeSpace.prototype.process = function(marketCycles=1, parentRefs) { - var corporation = parentRefs.corporation, industry = parentRefs.industry; - var perfMult=1; //Multiplier for employee morale/happiness/energy based on company performance - if (industry.funds < 0 && industry.lastCycleRevenue < 0) { - perfMult = Math.pow(0.99, marketCycles); - } else if (industry.funds > 0 && industry.lastCycleRevenue > 0) { - perfMult = Math.pow(1.01, marketCycles); - } - - var salaryPaid = 0; - for (var i = 0; i < this.employees.length; ++i) { - var emp = this.employees[i]; - emp.mor *= perfMult; - emp.hap *= perfMult; - emp.ene *= perfMult; - var salary = emp.process(marketCycles, this); - salaryPaid += salary; - } - this.calculateEmployeeProductivity(marketCycles, corporation); - return salaryPaid; -} - -OfficeSpace.prototype.calculateEmployeeProductivity = function(marketCycles=1, corporation) { - //Reset - for (var name in this.employeeProd) { - if (this.employeeProd.hasOwnProperty(name)) { - this.employeeProd[name] = 0; - } - } - - var total = 0; - for (var i = 0; i < this.employees.length; ++i) { - var employee = this.employees[i]; - var prod = employee.calculateProductivity(corporation); - this.employeeProd[employee.pos] += prod; - total += prod; - } - this.employeeProd["total"] = total; -} - -//Takes care of UI as well -OfficeSpace.prototype.findEmployees = function(parentRefs) { - var company = parentRefs.corporation, division = parentRefs.division; - if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;} - - //Generate three random employees (meh, decent, amazing) - var mult1 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(25, 50)/100, - mult2 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(51, 75)/100, - mult3 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(76, 100)/100; - var int = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - cha = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - exp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - cre = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - eff = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - sal = 2.2 * (int + cha + exp + cre + eff); - - var emp1 = new Employee({ - intelligence: int * mult1, - charisma: cha * mult1, - experience: exp * mult1, - creativity: cre * mult1, - efficiency: eff * mult1, - salary: sal * mult1, - }); - - var emp2 = new Employee({ - intelligence: int * mult2, - charisma: cha * mult2, - experience: exp * mult2, - creativity: cre * mult2, - efficiency: eff * mult2, - salary: sal * mult2, - }); - - var emp3 = new Employee({ - intelligence: int * mult3, - charisma: cha * mult3, - experience: exp * mult3, - creativity: cre * mult3, - efficiency: eff * mult3, - salary: sal * mult3, - }); - - var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerHTML: "Select one of the following candidates for hire:", - }); - - var createEmpDiv = function(employee, office) { - var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-find-employee-option", - innerHTML: "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.int, 1) + "
" + - "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.cha, 1) + "
" + - "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.exp, 1) + "
" + - "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.cre, 1) + "
" + - "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.eff, 1) + "
" + - "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(employee.sal).format('$0.000a') + " \ s
", - clickListener:()=>{ - office.hireEmployee(employee, parentRefs); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-hire-employee-popup"); - return false; - } - }); - return div; - }; - - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Cancel", - float:"right", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-hire-employee-popup"); - return false; - } - }); - - var elems = [text, - createEmpDiv(emp1, this), - createEmpDiv(emp2, this), - createEmpDiv(emp3, this), - cancelBtn]; - - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])("cmpy-mgmt-hire-employee-popup", elems); -} - -OfficeSpace.prototype.hireEmployee = function(employee, parentRefs) { - var company = parentRefs.corporation, division = parentRefs.division; - var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), - noBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerHTML = "Hire"; - noBtn.innerHTML = "Cancel"; - yesBtn.addEventListener("click", ()=>{ - var name = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])(); - for (var i = 0; i < this.employees.length; ++i) { - if (this.employees[i].name === name) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You already have an employee with this nickname! Please give every employee a unique nickname."); - return false; - } - } - employee.name = name; - this.employees.push(employee); - company.displayDivisionContent(division, currentCityUi); - return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - noBtn.addEventListener("click", ()=>{ - return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Give your employee a nickname!"); -} - -OfficeSpace.prototype.hireRandomEmployee = function(parentRefs) { - var company = parentRefs.corporation, division = parentRefs.division; - if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;} - - //Generate three random employees (meh, decent, amazing) - var mult = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(76, 100)/100; - var int = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - cha = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - exp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - cre = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - eff = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), - sal = 2.2 * (int + cha + exp + cre + eff); - - var emp = new Employee({ - intelligence: int * mult, - charisma: cha * mult, - experience: exp * mult, - creativity: cre * mult, - efficiency: eff * mult, - salary: sal * mult, - }); - - var name = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["d" /* generateRandomString */])(7); - - for (var i = 0; i < this.employees.length; ++i) { - if (this.employees[i].name === name) { - return this.hireRandomEmployee(parentRefs); - } - } - emp.name = name; - this.employees.push(emp); - company.displayDivisionContent(division, currentCityUi); -} - -//Finds the first unassigned employee and assigns its to the specified job -OfficeSpace.prototype.assignEmployeeToJob = function(job) { - for (var i = 0; i < this.employees.length; ++i) { - if (this.employees[i].pos === EmployeePositions.Unassigned) { - this.employees[i].pos = job; - return true; - } - } - return false; -} - -//Finds the first employee with the given job and unassigns it -OfficeSpace.prototype.unassignEmployeeFromJob = function(job) { - for (var i = 0; i < this.employees.length; ++i) { - if (this.employees[i].pos === job) { - this.employees[i].pos = EmployeePositions.Unassigned; - return true; - } - } - return false; -} - -OfficeSpace.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("OfficeSpace", this); -} - -OfficeSpace.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(OfficeSpace, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.OfficeSpace = OfficeSpace; - -function Warehouse(params={}) { - this.loc = params.loc ? params.loc : ""; - this.size = params.size ? params.size : 0; - this.level = 0; - this.sizeUsed = 0; - this.smartSupplyEnabled = false; //Whether or not smart supply is enabled - - //Stores the amount of product to be produced. Used for Smart Supply unlock. - //The production tracked by smart supply is always based on the previous cycle, - //so it will always trail the "true" production by 1 cycle - this.smartSupplyStore = 0; - - this.materials = { - Water: new Material({name: "Water"}), - Energy: new Material({name: "Energy"}), - Food: new Material({name: "Food"}), - Plants: new Material({name: "Plants"}), - Metal: new Material({name: "Metal"}), - Hardware: new Material({name: "Hardware"}), - Chemicals: new Material({name: "Chemicals"}), - Drugs: new Material({name: "Drugs"}), - Robots: new Material({name: "Robots"}), - AICores: new Material({name: "AI Cores"}), - RealEstate: new Material({name: "Real Estate"}) - } -} - -Warehouse.prototype.updateMaterialSizeUsed = function() { - this.sizeUsed = 0; - if (this.loc === currentCityUi) {industryWarehouseStorageBreakdownText = ""; } - for (var matName in this.materials) { - if (this.materials.hasOwnProperty(matName)) { - var mat = this.materials[matName]; - if (MaterialSizes.hasOwnProperty(matName)) { - this.sizeUsed += (mat.qty * MaterialSizes[matName]); - if (mat.qty > 0 && this.loc === currentCityUi) { - industryWarehouseStorageBreakdownText += (matName + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qty * MaterialSizes[matName], 0) + "
"); - } - } - } - } - if (this.sizeUsed > this.size) { - console.log("ERROR: Warehouse size used greater than capacity, something went wrong"); - } -} - -Warehouse.prototype.updateSize = function(corporation) { - //Backwards compatibility - if (this.level == null || this.level === 0) { - this.level = Math.round(this.size / 100); - } - - this.size = (this.level * 100) * corporation.getStorageMultiplier(); -} - -Warehouse.prototype.createUI = function(parentRefs) { - if (parentRefs.company == null || parentRefs.industry == null) { - console.log("ERROR: Warehouse.createUI called without parentRefs.company or parentRefs.industry"); - return; - } - var company = parentRefs.company, industry = parentRefs.industry; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehousePanel); - industryWarehouseStorageText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - display:"inline-block", class:"tooltip", - color: this.sizeUsed >= this.size ? "red" : "white", - }); - industryWarehousePanel.appendChild(industryWarehouseStorageText); - - //Upgrade warehouse size button - var upgradeCost = WarehouseUpgradeBaseCost * Math.pow(1.07, Math.round(this.size / 100) - 1); - industryWarehouseUpgradeSizeButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Upgrade Warehouse Size - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost).format('$0.000a'), - display:"inline-block", - class: company.funds.lt(upgradeCost) ? "a-link-button-inactive" : "a-link-button", - clickListener:()=>{ - //Backwards compatibility - if (this.level == null || this.level === 0) { - this.level = Math.round(this.size / 100); - } - - ++this.level; - this.updateSize(company); - company.funds = company.funds.minus(upgradeCost); - this.createUI(parentRefs); - return; - } - }); - industryWarehousePanel.appendChild(industryWarehouseUpgradeSizeButton); - - //Material requirement text - var reqText = "This Industry uses [" + Object.keys(industry.reqMats).join(", ") + - "] in order to "; - if (industry.prodMats.length > 0) { - reqText += "produce [" + industry.prodMats.join(", ") + "] "; - if (industry.makesProducts) { - reqText += " and " + industry.getProductDescriptionText(); - } - } else if (industry.makesProducts) { - reqText += industry.getProductDescriptionText(); - } - reqText += "

To get started with production, purchase your required " + - "materials or import them from another of your company's divisions.

"; - - //Material ratio text for tooltip - var reqRatioText = "The exact requirements for production are:
"; - for (var matName in industry.reqMats) { - if (industry.reqMats.hasOwnProperty(matName)) { - reqRatioText += (industry.reqMats[matName] + " " + matName + "
"); - } - } - reqRatioText += "in order to create "; - if (industry.prodMats.length > 0) { - reqRatioText += "one of each produced Material (" + industry.prodMats.join(", ") + ") "; - if (industry.makesProducts) { - reqRatioText += "or to create one of its Products"; - } - } else if (industry.makesProducts) { - reqRatioText += "one of its Products"; - } - - industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML:reqText, tooltipleft:reqRatioText - })); - - //Current state - industryWarehouseStateText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p"); - industryWarehousePanel.appendChild(industryWarehouseStateText); - - //Smart Supply Enable/Disable - if (company.unlockUpgrades[1]) { - if (this.smartSupplyEnabled == null) {this.smartSupplyEnabled = false;} - var smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox"; - industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("label", { - for:smartSupplyCheckboxId, innerText:"Enable Smart Supply", - color:"white" - })); - industrySmartSupplyCheckbox = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"checkbox", id:smartSupplyCheckboxId, margin:"3px", - changeListener:()=>{ - this.smartSupplyEnabled = industrySmartSupplyCheckbox.checked; - } - }); - industrySmartSupplyCheckbox.checked = this.smartSupplyEnabled; - industryWarehousePanel.appendChild(industrySmartSupplyCheckbox); - } - - //Materials - industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "
Materials:
", - })); - industryWarehouseMaterials = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("ul"); - industryWarehousePanel.appendChild(industryWarehouseMaterials); - - //Products - if (industry.makesProducts && Object.keys(industry.products).length > 0) { - industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "
Products:
", - })); - industryWarehouseProducts = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("ul"); - industryWarehousePanel.appendChild(industryWarehouseProducts); - } - - this.updateUI(parentRefs); -} - -Warehouse.prototype.updateUI = function(parentRefs) { - if (parentRefs.company == null || parentRefs.industry == null) { - console.log("ERROR: Warehouse.updateUI called without parentRefs.company or parentRefs.industry"); - return; - } - var company = parentRefs.company, industry = parentRefs.industry; - - //Storage text - var storageText = "Storage: " + - (this.sizedUsed >= this.size ? Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sizeUsed, 3) : Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sizeUsed, 3)) + - "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.size, 3); - if (industryWarehouseStorageBreakdownText != null && - industryWarehouseStorageBreakdownText != "") { - storageText += ("" + - industryWarehouseStorageBreakdownText + ""); - } - industryWarehouseStorageText.innerHTML = storageText; - - //Upgrade warehouse size button - var upgradeCost = WarehouseUpgradeBaseCost * Math.pow(1.07, Math.round(this.size / 100) - 1); - if (company.funds.lt(upgradeCost)) { - industryWarehouseUpgradeSizeButton.className = "a-link-button-inactive"; - } else { - industryWarehouseUpgradeSizeButton.className = "a-link-button"; - } - - //Current state - var stateText = "Current state: "; - switch(industry.state) { - case "START": - stateText += "Preparing..."; - break; - case "PURCHASE": - stateText += "Purchasing materials..."; - break; - case "PRODUCTION": - stateText += "Producing materials and/or products..."; - break; - case "SALE": - stateText += "Selling materials and/or products..."; - break; - case "EXPORT": - stateText += "Exporting materials and/or products..."; - break; - default: - console.log("ERROR: Invalid state: " + industry.state); - break; - } - industryWarehouseStateText.innerText = stateText; - - //Materials - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehouseMaterials); - for (var matName in this.materials) { - if (this.materials.hasOwnProperty(matName) && this.materials[matName] instanceof Material) { - if (Object.keys(industry.reqMats).includes(matName) || industry.prodMats.includes(matName) || - matName === "Hardware" || matName === "Robots" || matName === "AICores" || - matName === "RealEstate") { - industryWarehouseMaterials.appendChild(this.createMaterialUI(this.materials[matName], matName, parentRefs)); - } - } - } - - //Products - if (industry.makesProducts && Object.keys(industry.products).length > 0) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehouseProducts); - for (var productName in industry.products) { - if (industry.products.hasOwnProperty(productName) && industry.products[productName] instanceof Product) { - industryWarehouseProducts.appendChild(this.createProductUI(industry.products[productName], parentRefs)); - } - } - } -} - -Warehouse.prototype.createMaterialUI = function(mat, matName, parentRefs) { - if (parentRefs.company == null || parentRefs.industry == null) { - console.log("ERROR: Warehouse.createMaterialUI called without industry or company parent refs"); - return; - } - var company = parentRefs.company, industry = parentRefs.industry; - var purchasePopupId = "cmpy-mgmt-material-purchase-popup", - sellPopupid = "cmpy-mgmt-material-sell-popup"; - var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-warehouse-material-div", - }); - - var totalExport = 0; - for (var i = 0; i < mat.exp.length; ++i) { - totalExport += mat.exp[i].amt; - } - var totalGain = mat.buy + mat.prd + mat.imp - mat.sll - totalExport; - - //If Market Research upgrades are unlocked, add competition and demand info - var cmpAndDmdText = ""; - if (company.unlockUpgrades[2] === 1) { - cmpAndDmdText += "
Competition: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.cmp, 3); - } - if (company.unlockUpgrades[3] === 1) { - cmpAndDmdText += "
Demand: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.dmd, 3); - } - var innerTxt = "

" + mat.name + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qty, 3) + - "(" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalGain, 3) + "/s)" + - "Buy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.buy, 3) + - "/s
Prod: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.prd, 3) + "/s
Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + - "/s
Export: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalExport, 3) + "/s
Import: " + - Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.imp, 3) + "/s" + cmpAndDmdText + "


" + - "

MP: $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.bCost, 2) + - "Market Price: The price you would pay if " + - "you were to buy this material on the market


" + - "

Quality: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qlt, 2) + - "The quality of your material. Higher quality " + - "will lead to more sales

"; - - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: innerTxt, - id: "cmpy-mgmt-warehouse-" + matName + "-text", display:"inline-block", - })); - - var buttonPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - display:"inline-block", - }); - div.appendChild(buttonPanel); - - //Button to set purchase amount - var tutorial = industry.newInd && Object.keys(industry.reqMats).includes(mat.name) && - mat.buy === 0 && mat.imp === 0; - var buyButtonParams = { - innerText: "Buy (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.buy, 3) + ")", display:"inline-block", - class: tutorial ? "a-link-button flashing-button" : "a-link-button", - clickListener:()=>{ - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Enter the amount of " + mat.name + " you would like " + - "to purchase per second. This material's cost changes constantly" - }); - var confirmBtn; - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", value:mat.buy ? mat.buy : null, placeholder: "Purchase amount", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Confirm", class:"a-link-button", - clickListener:()=>{ - if (isNaN(input.value)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount"); - } else { - mat.buy = parseFloat(input.value); - if (isNaN(mat.buy)) {mat.buy = 0;} - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); - this.createUI(parentRefs); - return false; - } - } - }); - var clearButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Clear Purchase", class:"a-link-button", - clickListener:()=>{ - mat.buy = 0; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); - this.createUI(parentRefs); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Cancel", class:"a-link-button", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(purchasePopupId, [txt, input, confirmBtn, clearButton, cancelBtn]); - input.focus(); - } - }; - if (tutorial) { - buyButtonParams.tooltip = "Purchase your required materials to get production started!"; - } - buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", buyButtonParams)); - - //Button to manage exports - if (company.unlockUpgrades[0] === 1) { //Export unlock upgrade - function createExportPopup() { - var popupId = "cmpy-mgmt-export-popup"; - var exportTxt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Select the industry and city to export this material to, as well as " + - "how much of this material to export per second. You can set the export " + - "amount to 'MAX' to export all of the materials in this warehouse." - }); - - //Select industry and city to export to - var citySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select"); - var industrySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { - changeListener:()=>{ - var industryName = industrySelector.options[industrySelector.selectedIndex].value; - for (var foo = 0; foo < company.divisions.length; ++foo) { - if (company.divisions[foo].name == industryName) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["c" /* clearSelector */])(citySelector); - var selectedIndustry = company.divisions[foo]; - for (var cityName in company.divisions[foo].warehouses) { - if (company.divisions[foo].warehouses[cityName] instanceof Warehouse) { - citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - value:cityName, text:cityName, - })); - } - } - return; - } - } - } - }); - - for (var i = 0; i < company.divisions.length; ++i) { - industrySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text:company.divisions[i].name, value:company.divisions[i].name, - })); //End create element option - } //End for - - var currIndustry = industrySelector.options[industrySelector.selectedIndex].value; - for (var i = 0; i < company.divisions.length; ++i) { - if (company.divisions[i].name == currIndustry) { - for (var cityName in company.divisions[i].warehouses) { - if (company.divisions[i].warehouses.hasOwnProperty(cityName) && - company.divisions[i].warehouses[cityName] instanceof Warehouse) { - citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - value:cityName, text:cityName, - })); - } - } - break; - } - } - - //Select amount to export - var exportAmount = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Export amount / s" - }); - - var exportBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", innerText:"Export", - clickListener:()=>{ - var industryName = industrySelector.options[industrySelector.selectedIndex].text, - cityName = citySelector.options[citySelector.selectedIndex].text, - amt = parseFloat(exportAmount.value); - if (isNaN(amt)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount entered for export"); - return; - } - var exportObj = {ind:industryName, city:cityName, amt:amt}; - mat.exp.push(exportObj); - - //Go to the target city and increase the mat.imp attribute for the corresponding material - for (var i = 0; i < company.divisions.length; ++i) { - if (company.divisions[i].name === industryName) { - var warehouse = company.divisions[i].warehouses[cityName]; - if (warehouse instanceof Warehouse) { - warehouse.materials[matName].imp += amt; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } else { - console.log("ERROR: Target city for export does not have warehouse in specified city"); - } - } - } - console.log("ERROR: Could not find target industry/city for export"); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - - var currExportsText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Below is a list of all current exports of this material from this warehouse. " + - "Clicking on one of the exports below will REMOVE that export." - }); - var currExports = []; - for (var i = 0; i < mat.exp.length; ++i) { - (function(i, mat, currExports){ - currExports.push(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-existing-export", - innerHTML: "Industry: " + mat.exp[i].ind + "
" + - "City: " + mat.exp[i].city + "
" + - "Amount/s: " + mat.exp[i].amt, - clickListener:()=>{ - //Go to the target city and decrease the mat.imp attribute for the corresponding material - for (var j = 0; j < company.divisions.length; ++j) { - if (company.divisions[j].name === mat.exp[i].ind) { - var warehouse = company.divisions[j].warehouses[mat.exp[i].city]; - if (warehouse instanceof Warehouse) { - warehouse.materials[matName].imp -= mat.exp[i].amt; - } else { - console.log("ERROR: Target city for export does not have warehouse in specified city"); - } - } - } - mat.exp.splice(i, 1); //Remove export object - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - createExportPopup(); - } - })); - })(i, mat, currExports); - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [exportTxt, industrySelector, citySelector, exportAmount, - exportBtn, cancelBtn, currExportsText].concat(currExports)); - } - buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Export", display:"inline-block", class:"a-link-button", - clickListener:()=>{createExportPopup();} - })); - } - - buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); // Force line break - - //Button to set sell amount - var innerTextString; - if (mat.sllman[0]) { - innerTextString = (mat.sllman[1] === -1 ? "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + "/MAX)" : - "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sllman[1], 3) + ")"); - if (mat.sCost) { - if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(mat.sCost)) { - var sCost = mat.sCost.replace(/MP/g, mat.bCost); - innerTextString += " @ $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(eval(sCost), 2); - } else { - innerTextString += " @ $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sCost, 2); - } - } - } else { - innerTextString = "Sell (0.000/0.000)"; - } - - buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText: innerTextString, display:"inline-block", class:"a-link-button", - clickListener:()=>{ - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Enter the maximum amount of " + mat.name + " you would like " + - "to sell per second, as well as the price at which you would " + - "like to sell at.

" + - "If the sell amount is set to 0, then the material will not be sold. If the sell price " + - "if set to 0, then the material will be discarded

" + - "Setting the sell amount to 'MAX' will result in you always selling the " + - "maximum possible amount of the material.

" + - "When setting the sell price, you can use the 'MP' variable to designate a dynamically " + - "changing price that depends on the market price. For example, if you set the sell price " + - "to 'MP+10' then it will always be sold at $10 above the market price.", - }); - var br = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); - var confirmBtn; - var inputQty = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", marginTop:"4px", - value: mat.sllman[1] ? mat.sllman[1] : null, placeholder: "Sell amount", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - var inputPx = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", marginTop:"4px", - value: mat.sCost ? mat.sCost : null, placeholder: "Sell price", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Confirm", class:"a-link-button", margin:"6px", - clickListener:()=>{ - //Parse price - //Sanitize cost - var cost = inputPx.value.replace(/\s+/g, ''); - cost = cost.replace(/[^-()\d/*+.MP]/g, ''); - var temp = cost.replace(/MP/g, mat.bCost); - var temp = eval(temp); - if (temp == null || isNaN(temp)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field"); - return false; - } - - if (cost.includes("MP")) { - mat.sCost = cost; //Dynamically evaluated - } else { - mat.sCost = temp; - } - - //Parse quantity - if (inputQty.value === "MAX") { - mat.sllman[0] = true; - mat.sllman[1] = -1; - } else if (isNaN(inputQty.value)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell quantity field! Must be numeric or 'MAX'"); - return false; - } else { - var qty = parseFloat(inputQty.value); - if (isNaN(qty)) {qty = 0;} - if (qty === 0) { - mat.sllman[0] = false; - mat.sllman[1] = 0; - } else { - mat.sllman[0] = true; - mat.sllman[1] = qty; - } - } - - this.createUI(parentRefs); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(sellPopupid); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Cancel", class:"a-link-button", margin: "6px", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(sellPopupid); - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(sellPopupid, [txt, br, inputQty, inputPx, confirmBtn, cancelBtn]); - inputQty.focus(); - } - })); - - return div; -} - -Warehouse.prototype.createProductUI = function(product, parentRefs) { - var company = parentRefs.company, industry = parentRefs.industry, - city = currentCityUi; - var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-warehouse-product-div" - }); - - //Products being designed TODO - if (!product.fin) { - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Designing " + product.name + "...
" + - Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.prog, 2) + "% complete", - })); - return div; - } - - //Completed products - var cmpAndDmdText = ""; - if (company.unlockUpgrades[2] === 1) { - cmpAndDmdText += "
Competition: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.cmp, 3); - } - if (company.unlockUpgrades[3] === 1) { - cmpAndDmdText += "
Demand: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.dmd, 3); - } - var totalGain = product.data[city][1] - product.data[city][2]; //Production - sale - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "

" + product.name + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][0], 3) + //Quantity - "(" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalGain, 3) + "/s)" + - "Prod: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][1], 3) + "/s
" + - "Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/s


" + - "

Rating: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.rat, 3) + - "Quality: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.qlt, 3) + "
" + - "Performance: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.per, 3) + "
" + - "Durability: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.dur, 3) + "
" + - "Reliability: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.rel, 3) + "
" + - "Aesthetics: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.aes, 3) + "
" + - "Features: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.fea, 3) + - cmpAndDmdText + "


" + - "

Est. Production Cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.pCost).format("$0.000a") + - "An estimate of how much it costs to produce one unit of this product. " + - "If your sell price exceeds this by too much, people won't buy your product. The better your " + - "product is, the higher you can mark up its price.


" + - "

Est. Market Price: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.pCost + product.rat / product.mku).format("$0.000a") + - "An estimate of how much consumers are willing to pay for this product. " + - "Setting the sale price above this may result in less sales. Setting the sale price below this may result " + - "in more sales.

" - })); - var buttonPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - display:"inline-block", - }); - div.appendChild(buttonPanel); - - //Sell button - var sellInnerTextString = (product.sllman[city][1] === -1 ? "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/MAX)" : - "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.sllman[city][1], 3) + ")"); - if (product.sCost) { - sellInnerTextString += (" @ " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.sCost).format("$0.000a")); - } - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:sellInnerTextString, class:"a-link-button", display:"inline-block",margin:"6px", - clickListener:()=>{ - var popupId = "cmpy-mgmt-sell-product-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML:"Enter the maximum amount of " + product.name + " you would like " + - "to sell per second, as well as the price at which you would like to " + - "sell it at.

" + - "If the sell amount is set to 0, then the product will not be sold. If the " + - "sell price is set to 0, then the product will be discarded.

" + - "Setting the sell amount to 'MAX' will result in you always selling the " + - "maximum possible amount of the material.

", - }); - var confirmBtn; - var inputQty = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", value:product.sllman[city][1] ? product.sllman[city][1] : null, placeholder: "Sell amount", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - var inputPx = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", value: product.sCost ? product.sCost : null, placeholder: "Sell price", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Confirm", - clickListener:()=>{ - //Parse price - var cost = parseFloat(inputPx.value); - if (isNaN(cost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell price field"); - return false; - } - product.sCost = cost; - - //Parse quantity - if (inputQty.value === "MAX") { - product.sllman[city][0] = true; - product.sllman[city][1] = -1; - } else if (isNaN(inputQty.value)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell quantity field! Must be numeric"); - return false; - } else { - var qty = parseFloat(inputQty.value); - if (isNaN(qty)) {qty = 0;} - if (qty === 0) { - product.sllman[city][0] = false; - } else { - product.sllman[city][0] = true; - product.sllman[city][1] = qty; - } - } - this.createUI(parentRefs); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, inputQty, inputPx, confirmBtn, cancelBtn]); - inputQty.focus(); - } - })); - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br",{})); //force line break - - //Limit production button - var limitProductionInnerText = "Limit Production"; - if (product.prdman[city][0]) { - limitProductionInnerText += " (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.prdman[city][1], 3) + ")"; - } - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:limitProductionInnerText,display:"inline-block", - clickListener:()=>{ - var popupId = "cmpy-mgmt-limit-product-production-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Enter a limit to the amount of this product you would " + - "like to product per second. Leave the box empty to set no limit." - }); - var confirmBtn; - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Limit", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", innerText:"Limit production", margin:'6px', - clickListener:()=>{ - if (input.value === "") { - product.prdman[city][0] = false; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - var qty = parseFloat(input.value); - if (isNaN(qty)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value entered"); - return false; - } - if (qty < 0) { - product.prdman[city][0] = false; - } else { - product.prdman[city][0] = true; - product.prdman[city][1] = qty; - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", innerText:"Cancel", margin:"6px", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, input, confirmBtn, cancelBtn]); - } - })); - - //Discontinue button - div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:'a-link-button', display:"inline-block",innerText:"Discontinue", - clickListener:()=>{ - var popupId = "cmpy-mgmt-discontinue-product-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Are you sure you want to do this? Discontinuing a product " + - "removes it completely and permanently. You will no longer " + - "produce this product and all of its existing stock will be " + - "removed and left unsold", - }); - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button",innerText:"Discontinue", - clickListener:()=>{ - industry.discontinueProduct(product, parentRefs); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, confirmBtn, cancelBtn]); - } - })); - return div; -} - -Warehouse.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Warehouse", this); -} - -Warehouse.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Warehouse, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Warehouse = Warehouse; - -//Corporation Unlock Upgrades -//Upgrades for entire corporation, unlocks features, either you have it or you dont -//The structure is [index in Corporation feature upgrades array, price ] -var CorporationUnlockUpgrades = { - //Lets you export goods - "0": [0, 20e9, "Export", - "Develop infrastructure to export your materials to your other facilities. " + - "This allows you to move materials around between different divisions and cities."], - - //Lets you buy exactly however many required materials you need for production - "1": [1, 50e9, "Smart Supply", "Use advanced AI to anticipate your supply needs. " + - "This allows you to purchase exactly however many materials you need for production."], - - //Displays each material/product's demand - "2": [2, 5e9, "Market Research - Demand", - "Mine and analyze market data to determine the demand of all resources. " + - "The demand attribute, which affects sales, will be displayed for every material and product."], - - //Display's each material/product's competition - "3": [3, 5e9, "Market Data - Competition", - "Mine and analyze market data to determine how much competition there is on the market " + - "for all resources. The competition attribute, which affects sales, will be displayed for " + - "for every material and product."], - "4": [4, 10e9, "VeChain", - "Use AI and blockchain technology to identify where you can improve your supply chain systems. " + - "This upgrade will allow you to view a wide array of useful statistics about your " + - "Corporation."] -} - -//Corporation Upgrades -//Upgrades for entire corporation, levelable upgrades -//The structure is [index in Corporation upgrades array, base price, price mult, benefit mult (additive), -// name, desc] -var CorporationUpgrades = { - //Smart factories, increases production - "0": [0, 2e9, 1.07, 0.03, - "Smart Factories", "Advanced AI automatically optimizes the operation and productivity " + - "of factories. Each level of this upgrade increases your global production by 3% (additive)."], - - //Smart warehouses, increases storage size - "1": [1, 2e9, 1.07, .1, - "Smart Storage", "Advanced AI automatically optimizes your warehouse storage methods. " + - "Each level of this upgrade increases your global warehouse storage size by 10% (additive)."], - - //Advertise through dreams, passive popularity/ awareness gain - "2": [2, 8e9, 1.09, .001, - "DreamSense", "Use DreamSense LCC Technologies to advertise your corporation " + - "to consumers through their dreams. Each level of this upgrade provides a passive " + - "increase in awareness of all of your companies (divisions) by 0.004 / market cycle," + - "and in popularity by 0.001 / market cycle. A market cycle is approximately " + - "20 seconds."], - - //Makes advertising more effective - "3": [3, 4e9, 1.12, 0.005, - "Wilson Analytics", "Purchase data and analysis from Wilson, a marketing research " + - "firm. Each level of this upgrades increases the effectiveness of your " + - "advertising by 0.5% (additive)."], - - //Augmentation for employees, increases cre - "4": [4, 1e9, 1.06, 0.1, - "Nuoptimal Nootropic Injector Implants", "Purchase the Nuoptimal Nootropic " + - "Injector augmentation for your employees. Each level of this upgrade " + - "globally increases the creativity of your employees by 10% (additive)."], - - //Augmentation for employees, increases cha - "5": [5, 1e9, 1.06, 0.1, - "Speech Processor Implants", "Purchase the Speech Processor augmentation for your employees. " + - "Each level of this upgrade globally increases the charisma of your employees by 10% (additive)."], - - //Augmentation for employees, increases int - "6": [6, 1e9, 1.06, 0.1, - "Neural Accelerators", "Purchase the Neural Accelerator augmentation for your employees. " + - "Each level of this upgrade globally increases the intelligence of your employees " + - "by 10% (additive)."], - - //Augmentation for employees, increases eff - "7": [7, 1e9, 1.06, 0.1, - "FocusWires", "Purchase the FocusWire augmentation for your employees. Each level " + - "of this upgrade globally increases the efficiency of your employees by 10% (additive)."], - - //Improves sales of materials/products - "8": [8, 1e9, 1.08, 0.01, - "ABC SalesBots", "Always Be Closing. Purchase these robotic salesmen to increase the amount of " + - "materials and products you sell. Each level of this upgrade globally increases your sales " + - "by 1% (additive)."], - - //Improves scientific research rate - "9": [9, 5e9, 1.07, 0.05, - "Project Insight", "Purchase 'Project Insight', a R&D service provided by the secretive " + - "Fulcrum Technologies. Each level of this upgrade globally increases the amount of " + - "Scientific Research you produce by 5% (additive)."], -} - -function Corporation(params={}) { - this.name = params.name ? params.name : "The Corporation"; - - //A division/business sector is represented by the object: - this.divisions = []; - - //Financial stats - this.funds = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(150e9); - this.revenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.expenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.fundingRound = 0; - this.public = false; //Publicly traded - this.numShares = TOTALSHARES; - this.issuedShares = 0; - this.sharePrice = 0; - this.storedCycles = 0; - - var numUnlockUpgrades = Object.keys(CorporationUnlockUpgrades).length, - numUpgrades = Object.keys(CorporationUpgrades).length; - - this.unlockUpgrades = Array(numUnlockUpgrades).fill(0); - this.upgrades = Array(numUpgrades).fill(0); - this.upgradeMultipliers = Array(numUpgrades).fill(1); - - this.state = new CorporationState(); -} - -Corporation.prototype.getState = function() { - return this.state.getState(); -} - -Corporation.prototype.storeCycles = function(numCycles=1) { - this.storedCycles += numCycles; -} - -Corporation.prototype.process = function() { - var corp = this; - if (this.storedCycles >= CyclesPerIndustryStateCycle) { - var state = this.getState(), marketCycles=1; - this.storedCycles -= (marketCycles * CyclesPerIndustryStateCycle); - - //At the start of a new cycle, calculate profits from previous cycle - if (state === "START") { - this.revenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.expenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - this.divisions.forEach((ind)=>{ - this.revenue = this.revenue.plus(ind.lastCycleRevenue); - this.expenses = this.expenses.plus(ind.lastCycleExpenses); - }); - var profit = this.revenue.minus(this.expenses); - var cycleProfit = profit.times(marketCycles * SecsPerMarketCycle); - if (isNaN(this.funds)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("There was an error calculating your Corporations funds and they got reset to 0. " + - "This is a bug. Please report to game developer.

" + - "(Your funds have been set to $150b for the inconvenience)"); - this.funds = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(150e9); - } - this.funds = this.funds.plus(cycleProfit); - this.updateSharePrice(); - } - - this.divisions.forEach(function(ind) { - ind.process(marketCycles, state, corp); - }); - - - this.state.nextState(); - - if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage === __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.Corporation) {this.updateUIContent();} - } -} - -Corporation.prototype.determineValuation = function() { - var val, profit = (this.revenue.minus(this.expenses)).toNumber(); - if (this.public) { - val = this.funds.toNumber() + (profit * 90e3); - val *= (Math.pow(1.1, this.divisions.length)); - val = Math.max(val, 0); - } else { - val = 10e9 + Math.max(this.funds.toNumber(), 0) / 3; //Base valuation - if (profit > 0) { - val += (profit * 350e3); - val *= (Math.pow(1.1, this.divisions.length)); - } else { - val = 10e9 * Math.pow(1.1, this.divisions.length); - } - val -= (val % 1e6); //Round down to nearest millionth - } - return val * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* BitNodeMultipliers */].CorporationValuation; -} - -Corporation.prototype.getInvestment = function() { - var val = this.determineValuation(), percShares; - switch (this.fundingRound) { - case 0: //Seed - percShares = 0.10; - break; - case 1: //Series A - percShares = 0.35; - break; - case 2: //Series B - percShares = 0.25; - break; - case 3: //Series C - percShares = 0.20; - break; - case 4: - return; - } - var funding = val * percShares * 4, - investShares = Math.floor(TOTALSHARES * percShares), - yesBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["d" /* yesNoBoxGetYesButton */])(), - noBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["c" /* yesNoBoxGetNoButton */])(); - yesBtn.innerHTML = "Accept"; - noBtn.innerHML = "Reject"; - yesBtn.addEventListener("click", ()=>{ - ++this.fundingRound; - this.funds = this.funds.plus(funding); - this.numShares -= investShares; - this.displayCorporationOverviewContent(); - return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); - }); - noBtn.addEventListener("click", ()=>{ - return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); - }); - Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["b" /* yesNoBoxCreate */])("An investment firm has offered you " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(funding).format('$0.000a') + - " in funding in exchange for a " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(percShares*100).format("0.000a") + - "% stake in the company (" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(investShares).format('0.000a') + " shares).

" + - "Do you accept or reject this offer?"); -} - -Corporation.prototype.goPublic = function() { - var goPublicPopupId = "cmpy-mgmt-go-public-popup"; - var initialSharePrice = this.determineValuation() / (TOTALSHARES); - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Enter the number of shares you would like to issue " + - "for your IPO. These shares will be publicly sold " + - "and you will no longer own them. Your Corporation will receive " + - __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(initialSharePrice).format('$0.000a') + " per share " + - "(the IPO money will be deposited directly into your Corporation's funds).

" + - "Furthermore, issuing more shares now will help drive up " + - "your company's stock price in the future.

" + - "You have a total of " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.numShares).format("0.000a") + " of shares that you can issue.", - }); - var yesBtn; - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", - placeholder: "Shares to issue", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {yesBtn.click();} - } - }); - var br = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); - yesBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Go Public", - clickListener:()=>{ - var numShares = Math.round(input.value); - var initialSharePrice = this.determineValuation() / (TOTALSHARES); - if (isNaN(numShares)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for number of issued shares"); - return false; - } - if (numShares > this.numShares) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error: You don't have that many shares to issue!"); - return false; - } - this.public = true; - this.sharePrice = initialSharePrice; - this.issuedShares = numShares; - this.numShares -= numShares; - this.funds = this.funds.plus(numShares * initialSharePrice); - this.displayCorporationOverviewContent(); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(goPublicPopupId); - return false; - } - }); - var noBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(goPublicPopupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(goPublicPopupId, [txt, br, input, yesBtn, noBtn]); -} - -Corporation.prototype.updateSharePrice = function() { - var targetPrice = this.determineValuation() / (TOTALSHARES - this.issuedShares); - if (this.sharePrice <= targetPrice) { - this.sharePrice *= (1 + (Math.random() * 0.01)); - } else { - this.sharePrice *= (1 - (Math.random() * 0.01)); - } - if (this.sharePrice <= 0.01) {this.sharePrice = 0.01;} -} - -//One time upgrades that unlock new features -Corporation.prototype.unlock = function(upgrade) { - var upgN = upgrade[0], price = upgrade[1]; - while (this.unlockUpgrades.length <= upgN) { - this.unlockUpgrades.push(0); - } - if (this.funds.lt(price)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough funds to unlock this!"); - return; - } - this.unlockUpgrades[upgN] = 1; - this.funds = this.funds.minus(price); -} - -//Levelable upgrades -Corporation.prototype.upgrade = function(upgrade) { - var upgN = upgrade[0], basePrice = upgrade[1], priceMult = upgrade[2], - upgradeAmt = upgrade[3]; //Amount by which the upgrade multiplier gets increased (additive) - while (this.upgrades.length <= upgN) {this.upgrades.push(0);} - while (this.upgradeMultipliers.length <= upgN) {this.upgradeMultipliers.push(1);} - var totalCost = basePrice * Math.pow(priceMult, this.upgrades[upgN]); - if (this.funds.lt(totalCost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough funds to purchase this!"); - return; - } - ++this.upgrades[upgN]; - this.funds = this.funds.minus(totalCost); - - //Increase upgrade multiplier - this.upgradeMultipliers[upgN] = 1 + (this.upgrades[upgN] * upgradeAmt); - - //If storage size is being updated, update values in Warehouse objects - if (upgN === 1) { - for (var i = 0; i < this.divisions.length; ++i) { - var industry = this.divisions[i]; - for (var city in industry.warehouses) { - if (industry.warehouses.hasOwnProperty(city) && industry.warehouses[city] instanceof Warehouse) { - industry.warehouses[city].updateSize(this); - } - } - } - } - - this.updateCorporationOverviewContent(); -} - -Corporation.prototype.getProductionMultiplier = function() { - var mult = this.upgradeMultipliers[0]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getStorageMultiplier = function() { - var mult = this.upgradeMultipliers[1]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getDreamSenseGain = function() { - var gain = this.upgradeMultipliers[2] - 1; - return gain <= 0 ? 0 : gain; -} - -Corporation.prototype.getAdvertisingMultiplier = function() { - var mult = this.upgradeMultipliers[3]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getEmployeeCreMultiplier = function() { - var mult = this.upgradeMultipliers[4]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getEmployeeChaMultiplier = function() { - var mult = this.upgradeMultipliers[5]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getEmployeeIntMultiplier = function() { - var mult = this.upgradeMultipliers[6]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getEmployeeEffMultiplier = function() { - var mult = this.upgradeMultipliers[7]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getSalesMultiplier = function() { - var mult = this.upgradeMultipliers[8]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -Corporation.prototype.getScientificResearchMultiplier = function() { - var mult = this.upgradeMultipliers[9]; - if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} -} - -//Keep 'global' variables for DOM elements so we don't have to search -//through the DOM tree repeatedly when updating UI -var companyManagementDiv, companyManagementHeaderTabs, companyManagementPanel, - currentCityUi, - corporationUnlockUpgrades, corporationUpgrades, - - //Industry Overview Panel - industryOverviewPanel, industryOverviewText, - - //Industry Employee Panel - industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeAutohireButton, - industryEmployeeManagementUI, industryEmployeeInfo, industryIndividualEmployeeInfo, - industryOfficeUpgradeSizeButton, - - //Industry Warehouse Panel - industryWarehousePanel, industrySmartSupplyCheckbox, industryWarehouseStorageText, - industryWarehouseStorageBreakdownText, - industryWarehouseUpgradeSizeButton, industryWarehouseStateText, - industryWarehouseMaterials, industryWarehouseProducts, - headerTabs, cityTabs; -Corporation.prototype.createUI = function() { - companyManagementDiv = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"cmpy-mgmt-container", - position:"fixed", - class:"generic-menupage-container" - }); - companyManagementHeaderTabs = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {id:"cmpy-mgmt-header-tabs"}); - companyManagementDiv.appendChild(companyManagementHeaderTabs); - - //Create division/industry tabs at the top - this.updateUIHeaderTabs(); - - //Create the 'panel' that will have the actual content in the UI - companyManagementPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {id:"cmpy-mgmt-panel"}); - companyManagementDiv.appendChild(companyManagementPanel); - document.getElementById("entire-game-container").appendChild(companyManagementDiv); - - this.displayCorporationOverviewContent(); -} - -Corporation.prototype.updateUIHeaderTabs = function() { - if (companyManagementHeaderTabs) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(companyManagementHeaderTabs); - } else { - console.log("ERROR: Header tabs div has not yet been created when Corporation.updateUIHeaderTabs() is called"); - return; - } - - //Corporation overview tabs - var cmpyOverviewHdrTab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { - id:"cmpy-mgmt-company-tab", - class:"cmpy-mgmt-header-tab", - innerText:this.name, - checked:true, - clickListener:()=>{ - this.selectHeaderTab(cmpyOverviewHdrTab); - this.displayCorporationOverviewContent(); - return false; - } - }); - companyManagementHeaderTabs.appendChild(cmpyOverviewHdrTab); - - //Tabs for each division - for (var i = 0; i < this.divisions.length; ++i) { - this.createDivisionUIHeaderTab(this.divisions[i]); - } - - //Create a tab to expand into a new industry - companyManagementHeaderTabs.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { - id:'cmpy-mgmt-expand-industry-tab', - class:"cmpy-mgmt-header-tab", - innerText:"Expand into new Industry", - clickListener: ()=>{ - if (document.getElementById("cmpy-mgmt-expand-industry-popup") != null) {return;} - - var container = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"popup-box-container", - id:"cmpy-mgmt-expand-industry-popup", - }); - var content = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"popup-box-content"}); - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Create a new division to expand into a new industry:", - }); - var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { - class:"cmpy-mgmt-industry-select" - }); - var industryDescription = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); - var yesBtn; - var nameInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"text", - id:"cmpy-mgmt-expand-industry-name-input", - color:"white", - backgroundColor:"black", - display:"block", - maxLength: 30, - pattern:"[a-zA-Z0-9-_]", - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {yesBtn.click();} - } - }); - var nameLabel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("label", { - for:"cmpy-mgmt-expand-industry-name-input", - innerText:"Division name: " - }); - yesBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { - class:"popup-box-button", - innerText:"Create Division", - clickListener: ()=>{ - var ind = selector.options[selector.selectedIndex].value, - newDivisionName = nameInput.value; - - for (var i = 0; i < this.divisions.length; ++i) { - if (this.divisions[i].name === newDivisionName) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("This name is already in use!"); - return false; - } - } - if (this.funds.lt(IndustryStartingCosts[ind])) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Not enough money to create a new division in this industry"); - } else if (newDivisionName === "") { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("New division must have a name!"); - } else { - this.funds = this.funds.minus(IndustryStartingCosts[ind]); - var newInd = new Industry({ - name:newDivisionName, - type:ind, - }); - this.divisions.push(newInd); - this.updateUIHeaderTabs(); - this.selectHeaderTab(headerTabs[headerTabs.length-2]); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-expand-industry-popup"); - this.displayDivisionContent(newInd, __WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12); - } - return false; - } - }); - var noBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { - class:"popup-box-button", - innerText:"Cancel", - clickListener: function() { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-expand-industry-popup"); - return false; - } - }); - - //Make an object to keep track of what industries you're already in - var ownedIndustries = {} - for (var i = 0; i < this.divisions.length; ++i) { - ownedIndustries[this.divisions[i].type] = true; - } - - //Add industry types to selector - //Have Agriculture be first as recommended option - if (!ownedIndustries["Agriculture"]) { - selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text:Industries["Agriculture"], value:"Agriculture" - })); - } - - for (var key in Industries) { - if (key !== "Agriculture" && Industries.hasOwnProperty(key) && !ownedIndustries[key]) { - var ind = Industries[key]; - selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text: ind,value:key, - })); - } - } - - //Initial Industry Description - var ind = selector.options[selector.selectedIndex].value; - industryDescription.innerHTML = (IndustryDescriptions[ind] + "

"); - - //Change the industry description text based on selected option - selector.addEventListener("change", function() { - var ind = selector.options[selector.selectedIndex].value; - industryDescription.innerHTML = IndustryDescriptions[ind] + "

"; - }); - - //Add to DOM - content.appendChild(txt); - content.appendChild(selector); - content.appendChild(industryDescription); - content.appendChild(nameLabel); - content.appendChild(nameInput); - content.appendChild(noBtn); - content.appendChild(yesBtn); - container.appendChild(content); - document.getElementById("entire-game-container").appendChild(container); - container.style.display = "block"; - return false; - } - })); - - headerTabs = companyManagementDiv.getElementsByClassName("cmpy-mgmt-header-tab"); -} - -//Updates UI to display which header tab is selected -Corporation.prototype.selectHeaderTab = function(currentTab) { - if (currentTab == null) {return;} - for (var i = 0; i < headerTabs.length; ++i) { - headerTabs[i].className = "cmpy-mgmt-header-tab"; - } - currentTab.className = "cmpy-mgmt-header-tab current"; -} - -Corporation.prototype.createDivisionUIHeaderTab = function(division) { - var tabId = "cmpy-mgmt-" + division.name + "-tab"; - var tab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { - id:tabId, - class:"cmpy-mgmt-header-tab", - innerText:division.name, - clickListener:()=>{ - this.selectHeaderTab(tab); - this.displayDivisionContent(division, __WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12); - return false; - } - }); - companyManagementHeaderTabs.appendChild(tab); -} - -Corporation.prototype.clearUIPanel = function() { - while(companyManagementPanel.firstChild) { - companyManagementPanel.removeChild(companyManagementPanel.firstChild); - } -} - -Corporation.prototype.updateUIContent = function() { - //Check which of the header tab buttons is checked - if (headerTabs == null) { - console.log("ERROR: headerTabs is null in Corporation.updateUIContent()"); - return; - } - for (var i = 0; i < headerTabs.length; ++i) { - if (headerTabs[i].classList.contains("current")) { - if (i === 0) { - //Corporation overview - this.updateCorporationOverviewContent(); - } else { - //Division - this.updateDivisionContent(this.divisions[i-1]); - } - return; - } - } -} - -Corporation.prototype.displayCorporationOverviewContent = function() { - this.clearUIPanel(); - companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - id:"cmpy-mgmt-overview-text", - })); - if (headerTabs && headerTabs.length >= 1) { - this.selectHeaderTab(headerTabs[0]); - } - - //Check if player has Corporation Handbook - var homeComp = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].getHomeComputer(), hasHandbook = false, - handbookFn = "corporation-management-handbook.lit"; - for (var i = 0; i < homeComp.messages.length; ++i) { - if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(homeComp.messages[i]) && homeComp.messages[i] === handbookFn) { - hasHandbook = true; - break; - } - } - - companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Getting Started Guide", display:"inline-block", - tooltip:"Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " + - "This is a .lit file that guides you through the beginning of setting up a Corporation and " + - "provides some tips/pointers for helping you get started with managing it.", - clickListener:()=>{ - if (!hasHandbook) {homeComp.messages.push(handbookFn);} - Object(__WEBPACK_IMPORTED_MODULE_3__Literature_js__["b" /* showLiterature */])(handbookFn); - return false; - } - })); - - //Investors - if (this.public) { - //Sell share buttons - var sellShares = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Sell Shares", display:"inline-block", - tooltip:"Sell your shares in the company. This is the only way to " + - "profit from your business venture.", - clickListener:()=>{ - var popupId = "cmpy-mgmt-sell-shares-popup"; - var currentStockPrice = this.sharePrice; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Enter the number of shares you would like to sell. The money from " + - "selling your shares will go directly to you (NOT your Corporation). " + - "The current price of your " + - "company's stock is " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(currentStockPrice).format("$0.000a"), - }); - var profitIndicator = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Shares to sell", margin:"5px", - inputListener: ()=> { - var numShares = Math.round(input.value); - if (isNaN(numShares) || numShares <= 0) { - profitIndicator.innerText = "ERROR: Invalid value entered for number of shares to sell" - } else if (numShares > this.numShares) { - profitIndicator.innerText = "You don't have this many shares to sell!"; - } else { - profitIndicator.innerText = "Sell " + numShares + " shares for a total of " + - __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(numShares * currentStockPrice).format('$0.000a'); - } - } - }); - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Sell shares", display:"inline-block", - clickListener:()=>{ - var shares = Math.round(input.value); - if (isNaN(shares) || shares <= 0) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value for number of shares"); - } else if (shares > this.numShares) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You don't have this many shares to sell"); - } else { - this.numShares -= shares; - if (isNaN(this.issuedShares)) { - console.log("ERROR: Corporation issuedShares is NaN: " + this.issuedShares); - console.log("Converting to number now"); - var res = parseInt(this.issuedShares); - if (isNaN(res)) { - this.issuedShares = 0; - } else { - this.issuedShares = res; - } - } - this.issuedShares += shares; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(shares * this.sharePrice); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Cancel", display:"inline-block", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, profitIndicator, input, confirmBtn, cancelBtn]); - } - }); - - //Buyback shares button - var buybackShares = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Buyback shares", display:"inline-block", - tooltip:"Buy back shares you that previously issued or sold at market price.", - clickListener:()=>{ - var popupId = "cmpy-mgmt-buyback-shares-popup"; - var currentStockPrice = this.sharePrice; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML: "Enter the number of shares you would like to buy back at market price. To purchase " + - "these shares, you must use your own money (NOT your Corporation's funds). " + - "The current price of your " + - "company's stock is " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(currentStockPrice).format("$0.000a") + - ". Your company currently has " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.issuedShares, 3) + " outstanding stock shares", - }); - var costIndicator = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Shares to buyback", margin:"5px", - inputListener: ()=> { - var numShares = Math.round(input.value); - //TODO add conditional for if player doesn't have enough money - if (isNaN(numShares) || numShares <= 0) { - costIndicator.innerText = "ERROR: Invalid value entered for number of shares to buyback" - } else if (numShares > this.issuedShares) { - costIndicator.innerText = "There are not this many shares available to buy back. " + - "There are only " + this.issuedShares + " outstanding shares."; - } else { - console.log("here"); - costIndicator.innerText = "Purchase " + numShares + " shares for a total of " + - __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(numShares * currentStockPrice).format('$0.000a'); - } - } - }); - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Buy shares", display:"inline-block", - clickListener:()=>{ - var shares = Math.round(input.value); - var tempStockPrice = this.sharePrice; - if (isNaN(shares) || shares <= 0) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value for number of shares"); - } else if (shares > this.issuedShares) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: There are not this many oustanding shares to buy back"); - } else if (shares * tempStockPrice > __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have enough money to purchase this many shares (you need " + - __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(shares * tempStockPrice).format("$0.000a") + ")"); - } else { - this.numShares += shares; - if (isNaN(this.issuedShares)) { - console.log("ERROR: Corporation issuedShares is NaN: " + this.issuedShares); - console.log("Converting to number now"); - var res = parseInt(this.issuedShares); - if (isNaN(res)) { - this.issuedShares = 0; - } else { - this.issuedShares = res; - } - } - this.issuedShares -= shares; - __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(shares * tempStockPrice); - //TODO REMOVE from Player money - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - } - return false; - - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Cancel", - display:"inline-block", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, costIndicator, input, confirmBtn, cancelBtn]); - } - }); - - companyManagementPanel.appendChild(sellShares); - companyManagementPanel.appendChild(buybackShares); - - //If your Corporation is big enough, buy faction influence through bribes - var canBribe = this.determineValuation() >= BribeThreshold; - var bribeFactions = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: canBribe ? "a-link-button" : "a-link-button-inactive", - innerText:"Bribe Factions", display:"inline-block", - tooltip:canBribe - ? "Use your Corporations power and influence to bribe Faction leaders in exchange for reputation" - : "Your Corporation is not powerful enough to bribe Faction leaders", - clickListener:()=>{ - var popupId = "cmpy-mgmt-bribe-factions-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"You can use Corporation funds or stock shares to bribe Faction Leaders in exchange for faction reputation" - }); - var factionSelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {margin:"3px"}); - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].factions.length; ++i) { - var facName = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].factions[i]; - factionSelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text:facName, value:facName - })); - } - var repGainText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p"); - var stockSharesInput; - var moneyInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Corporation funds", margin:"5px", - inputListener:()=>{ - var money = moneyInput.value == null || moneyInput.value == "" ? 0 : parseFloat(moneyInput.value); - var stockPrice = this.sharePrice; - var stockShares = stockSharesInput.value == null || stockSharesInput.value == "" ? 0 : Math.round(parseFloat(stockSharesInput.value)); - if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { - repGainText.innerText = "ERROR: Invalid value(s) entered"; - } else if (this.funds.lt(money)) { - repGainText.innerText = "ERROR: You do not have this much money to bribe with"; - } else if (this.stockShares > this.numShares) { - repGainText.innerText = "ERROR: You do not have this many shares to bribe with"; - } else { - - var totalAmount = Number(money) + (stockShares * stockPrice); - var repGain = totalAmount / BribeToRepRatio; - repGainText.innerText = "You will gain " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + - " reputation with " + - factionSelector.options[factionSelector.selectedIndex].value + - " with this bribe"; - } - } - }); - stockSharesInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", placeholder:"Stock Shares", margin: "5px", - inputListener:()=>{ - var money = moneyInput.value == null || moneyInput.value == "" ? 0 : moneyInput.value; - var stockPrice = this.sharePrice; - var stockShares = stockSharesInput.value == null || stockSharesInput.value == "" ? 0 : Math.round(stockSharesInput.value); - if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { - repGainText.innerText = "ERROR: Invalid value(s) entered"; - } else if (this.funds.lt(money)) { - repGainText.innerText = "ERROR: You do not have this much money to bribe with"; - } else if (this.stockShares > this.numShares) { - repGainText.innerText = "ERROR: You do not have this many shares to bribe with"; - } else { - var totalAmount = money + (stockShares * stockPrice); - var repGain = totalAmount / BribeToRepRatio; - console.log("repGain: " + repGain); - repGainText.innerText = "You will gain " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + - " reputation with " + - factionSelector.options[factionSelector.selectedIndex].value + - " with this bribe"; - } - } - }); - var confirmButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Bribe", display:"inline-block", - clickListener:()=>{ - var money = moneyInput.value == null || moneyInput.value == "" ? 0 : parseFloat(moneyInput.value); - var stockPrice = this.sharePrice; - var stockShares = stockSharesInput.value == null || stockSharesInput.value == ""? 0 : Math.round(parseFloat(stockSharesInput.value)); - var fac = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][factionSelector.options[factionSelector.selectedIndex].value]; - if (fac == null) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You must select a faction to bribe"); - return false; - } - if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value(s) entered"); - } else if (this.funds.lt(money)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have this much money to bribe with"); - } else if (this.stockShares > this.numShares) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have this many shares to bribe with"); - } else { - var totalAmount = money + (stockShares * stockPrice); - var repGain = totalAmount / BribeToRepRatio; - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You gained " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + - " reputation with " + fac.name + " by bribing them."); - fac.playerReputation += repGain; - this.funds = this.funds.minus(money); - this.numShares -= stockShares; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - } - }); - var cancelButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Cancel", display:"inline-block", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, factionSelector, repGainText, - moneyInput, stockSharesInput, confirmButton, cancelButton]); - } - }); - companyManagementPanel.appendChild(bribeFactions); - } else { - var findInvestors = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: this.fundingRound >= 4 ? "a-link-button-inactive" : "a-link-button tooltip", - innerText: "Find Investors", - display:"inline-block", - clickListener:()=>{ - this.getInvestment(); - } - }); - if (this.fundingRound < 4) { - var findInvestorsTooltip = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { - class:"tooltiptext", - innerText:"Search for private investors who will give you startup funding in exchange " + - "for equity (stock shares) in your company" - }); - findInvestors.appendChild(findInvestorsTooltip); - } - - var goPublic = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button tooltip", - innerText:"Go Public", - display:"inline-block", - clickListener:()=>{ - this.goPublic(); - return false; - } - }); - var goPublicTooltip = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { - class:"tooltiptext", - innerText: "Become a publicly traded and owned entity. Going public involves " + - "issuing shares for an IPO. Once you are a public company, " + - "your shares will be traded on the stock market." - }); - goPublic.appendChild(goPublicTooltip); - - companyManagementPanel.appendChild(findInvestors); - companyManagementPanel.appendChild(goPublic); - } - - //Update overview text - this.updateCorporationOverviewContent(); - - //Don't show upgrades if player hasn't opened any divisions - if (this.divisions.length <= 0) {return; } - //Corporation Upgrades - var upgradeContainer = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-upgrade-container", - }); - upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerText:"Unlocks", margin:"6px", padding:"6px", - })); - - //Unlock upgrades - var corp = this; - var numUnlockUpgrades = Object.keys(CorporationUnlockUpgrades).length, - numUpgrades = Object.keys(CorporationUpgrades).length; - if (this.unlockUpgrades == null || this.upgrades == null) { //Backwards compatibility - this.unlockUpgrades = Array(numUnlockUpgrades).fill(0); - this.upgrades = Array(numUpgrades).fill(0); - } - while (this.unlockUpgrades.length < numUnlockUpgrades) {this.unlockUpgrades.push(0);} - while (this.upgrades.length < numUpgrades) {this.upgrades.push(0);} - while (this.upgradeMultipliers < numUpgrades) {this.upgradeMultipliers.push(1);} - - for (var i = 0; i < numUnlockUpgrades; ++i) { - (function(i, corp) { - if (corp.unlockUpgrades[i] === 0) { - var upgrade = CorporationUnlockUpgrades[i.toString()]; - if (upgrade == null) { - console.log("ERROR: Could not find upgrade index " + i); - return; - } - - upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-upgrade-div", width:"45%", - innerHTML:upgrade[2] + " - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgrade[1]).format("$0.000a"), - tooltip: upgrade[3], - clickListener:()=>{ - if (corp.funds.lt(upgrade[1])) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); - } else { - corp.unlock(upgrade); - corp.displayCorporationOverviewContent(); - } - } - })); - } - })(i, corp); - } - - //Levelable upgrades - upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { - innerText:"Upgrades", margin:"6px", padding:"6px", - })); - - for (var i = 0; i < numUpgrades; ++i) { - (function(i, corp) { - var upgrade = CorporationUpgrades[i.toString()]; - if (upgrade == null) { - console.log("ERROR: Could not find levelable upgrade index " + i); - return; - } - - var baseCost = upgrade[1], priceMult = upgrade[2]; - var cost = baseCost * Math.pow(priceMult, corp.upgrades[i]); - upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-upgrade-div", width:"45%", - innerHTML:upgrade[4] + " - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(cost).format("$0.000a"), - tooltip:upgrade[5], - clickListener:()=>{ - if (corp.funds.lt(cost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); - } else { - corp.upgrade(upgrade); - corp.displayCorporationOverviewContent(); - } - } - })); - })(i, corp); - } - - companyManagementPanel.appendChild(upgradeContainer); -} - -Corporation.prototype.updateCorporationOverviewContent = function() { - var p = document.getElementById("cmpy-mgmt-overview-text"); - if (p == null) { - console.log("WARNING: Could not find overview text elemtn in updateCorporationOverviewContent()"); - return; - } - var totalFunds = this.funds, - totalRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0), - totalExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); - - var profit = this.revenue.minus(this.expenses).toNumber(), - profitStr = profit >= 0 ? __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(profit).format("$0.000a") : "-" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(-1 * profit).format("$0.000a"); - - var txt = "Total Funds: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(totalFunds.toNumber()).format('$0.000a') + "
" + - "Total Revenue: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.revenue.toNumber()).format("$0.000a") + " / s
" + - "Total Expenses: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.expenses.toNumber()).format("$0.000a") + "/ s
" + - "Total Profits: " + profitStr + " / s
" + - "Publicly Traded: " + (this.public ? "Yes" : "No") + "
" + - "Owned Stock Shares: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.numShares).format('0.000a') + "
" + - "Stock Price: " + (this.public ? "$" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sharePrice, 2) : "N/A") + "

"; - - var prodMult = this.getProductionMultiplier(), - storageMult = this.getStorageMultiplier(), - advMult = this.getAdvertisingMultiplier(), - empCreMult = this.getEmployeeCreMultiplier(), - empChaMult = this.getEmployeeChaMultiplier(), - empIntMult = this.getEmployeeIntMultiplier(), - empEffMult = this.getEmployeeEffMultiplier(), - salesMult = this.getSalesMultiplier(), - sciResMult = this.getScientificResearchMultiplier(); - if (prodMult > 1) {txt += "Production Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(prodMult, 3) + "
";} - if (storageMult > 1) {txt += "Storage Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(storageMult, 3) + "
";} - if (advMult > 1) {txt += "Advertising Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(advMult, 3) + "
";} - if (empCreMult > 1) {txt += "Empl. Creativity Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empCreMult, 3) + "
";} - if (empChaMult > 1) {txt += "Empl. Charisma Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empChaMult, 3) + "
";} - if (empIntMult > 1) {txt += "Empl. Intelligence Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empIntMult, 3) + "
";} - if (empEffMult > 1) {txt += "Empl. Efficiency Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empEffMult, 3) + "
";} - if (salesMult > 1) {txt += "Sales Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(salesMult, 3) + "
";} - if (sciResMult > 1) {txt += "Scientific Research Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(sciResMult, 3) + "
";} - p.innerHTML = txt; -} - -Corporation.prototype.displayDivisionContent = function(division, city) { - this.clearUIPanel(); - currentCityUi = city; - - //Add the city tabs on the left - for (var cityName in division.offices) { - if (division.offices[cityName] instanceof OfficeSpace) { - this.createCityUITab(cityName, division); - } - } - cityTabs = companyManagementPanel.getElementsByClassName("cmpy-mgmt-city-tab"); - if (cityTabs.length > 0) { - this.selectCityTab(document.getElementById("cmpy-mgmt-city-" + city + "-tab"), city); - } - - //Expand into new City button - companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { - class:"cmpy-mgmt-city-tab", innerText:"Expand into new City", display:"inline-block", - clickListener:()=>{ - var popupId = "cmpy-mgmt-expand-city-popup"; - var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText: "Would you like to expand into a new city by opening an office? " + - "This would cost " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(OfficeInitialCost).format('$0.000a'), - }); - var citySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {margin:"5px"}); - for (var cityName in division.offices) { - if (division.offices.hasOwnProperty(cityName)) { - if (!(division.offices[cityName] instanceof OfficeSpace)) { - citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - text: cityName, - value: cityName - })); - } - } - } - - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Confirm", class:"a-link-button", display:"inline-block", margin:"3px", - clickListener:()=>{ - var city = citySelector.options[citySelector.selectedIndex].value; - if (this.funds.lt(OfficeInitialCost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to open a new office!"); - } else { - this.funds = this.funds.minus(OfficeInitialCost); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Opened a new office in " + city + "!"); - division.offices[city] = new OfficeSpace({ - loc:city, - size:OfficeInitialSize, - }); - this.displayDivisionContent(division, city); - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Cancel", class:"a-link-button", display:"inline-block", margin:"3px", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }) - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [text, citySelector, confirmBtn, cancelBtn]); - return false; - } - })); - companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); // Force line break - - //Get office object - var office = division.offices[currentCityUi]; - if (!(office instanceof OfficeSpace)) { - console.log("ERROR: Current city for UI does not have an office space"); - return; - } - - //Left and right panels - var leftPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"cmpy-mgmt-industry-left-panel"}); - var rightPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"cmpy-mgmt-industry-right-panel"}); - companyManagementPanel.appendChild(leftPanel); - companyManagementPanel.appendChild(rightPanel); - - //Different sections (Overview, Employee/Office, and Warehouse) - industryOverviewPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"cmpy-mgmt-industry-overview-panel", class:"cmpy-mgmt-industry-overview-panel" - }); - leftPanel.appendChild(industryOverviewPanel); - - industryEmployeePanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"cmpy-mgmt-employee-panel", class:"cmpy-mgmt-employee-panel" - }); - leftPanel.appendChild(industryEmployeePanel); - - industryWarehousePanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - id:"cmpy-mgmt-warehouse-panel", class:"cmpy-mgmt-warehouse-panel" - }); - rightPanel.appendChild(industryWarehousePanel); - - //Industry overview text - industryOverviewText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); - industryOverviewPanel.appendChild(industryOverviewText); - industryOverviewPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - //Industry overview Purchases & Upgrades - var numUpgrades = Object.keys(IndustryUpgrades).length; - while (division.upgrades.length < numUpgrades) {division.upgrades.push(0);} //Backwards compatibility - - var industryOverviewUpgrades = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {}); - industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("u", { - innerText:"Purchases & Upgrades", margin:"2px", padding:"2px", - fontSize:"14px", - })); - industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - for (var i = 0; i < numUpgrades; ++i) { - (function(i, corp, division, office) { - var upgrade = IndustryUpgrades[i.toString()]; - if (upgrade == null) { - console.log("ERROR: Could not find levelable upgrade index: " + i); - return; - } - - var baseCost = upgrade[1], priceMult = upgrade[2], cost = 0; - switch(i) { - case 0: //Coffee, cost is static per employee - cost = office.employees.length * baseCost; - break; - default: - cost = baseCost * Math.pow(priceMult, division.upgrades[i]); - break; - } - industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - class:"cmpy-mgmt-upgrade-div", display:"inline-block", - innerHTML:upgrade[4] + ' - ' + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(cost).format("$0.000a"), - tooltip:upgrade[5], - clickListener:()=>{ - if (corp.funds.lt(cost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); - } else { - corp.funds = corp.funds.minus(cost); - division.upgrade(upgrade, { - corporation:corp, - office:office, - }); - corp.displayDivisionContent(division, city); - } - } - })); - industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - })(i, this, division, office); - } - - - industryOverviewPanel.appendChild(industryOverviewUpgrades); - - //Industry Overview 'Create Product' button if applicable - if (division.makesProducts) { - //Get the text on the button based on Industry type - var createProductButtonText, createProductPopupText; - switch(division.type) { - case Industries.Food: - createProductButtonText = "Build Restaurant"; - createProductPopupText = "Build and manage a new restaurant!" - break; - case Industries.Tobacco: - createProductButtonText = "Create Product"; - createProductPopupText = "Create a new tobacco product!"; - break; - case Industries.Pharmaceutical: - createProductButtonText = "Create Drug"; - createProductPopupText = "Design and develop a new pharmaceutical drug!"; - break; - case Industries.Computer: - case "Computer": - createProductButtonText = "Create Product"; - createProductPopupText = "Design and manufacture a new computer hardware product!"; - break; - case Industries.Robotics: - createProductButtonText = "Design Robot"; - createProductPopupText = "Design and create a new robot or robotic system!"; - break; - case Industries.Software: - createProductButtonText = "Develop Software"; - createProductPopupText = "Develop a new piece of software!"; - break; - case Industries.HealthCare: - createProductButtonText = "Build Hospital"; - createProductPopupText = "Build and manage a new hospital!"; - break; - case Industries.RealEstate: - createProductButtonText = "Develop Property"; - createProductPopupText = "Develop a new piece of real estate property!"; - break; - default: - createProductButtonText = "Create Product"; - return ""; - } - createProductPopupText += "

To begin developing a product, " + - "first choose the city in which it will be designed. The stats of your employees " + - "in the selected city affect the properties of the finished product, such as its " + - "quality, performance, and durability.

" + - "You can also choose to invest money in the design and marketing of " + - "the product. Investing money in its design will result in a superior product. " + - "Investing money in marketing the product will help the product's sales."; - - //Create the button - industryOverviewPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:createProductButtonText, margin:"6px", display:"inline-block", - clickListener:()=>{ - var popupId = "cmpy-mgmt-create-product-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML:createProductPopupText, - }); - var designCity = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {}); - for (var cityName in division.offices) { - if (division.offices[cityName] instanceof OfficeSpace) { - designCity.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { - value:cityName, - text:cityName - })); - } - } - var foo = "Product Name"; - if (division.type === Industries.Food) { - foo = "Restaurant Name"; - } else if (division.type === Industries.Healthcare) { - foo = "Hospital Name"; - } else if (division.type === Industries.RealEstate) { - foo = "Property Name"; - } - var productNameInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - placeholder:foo, - }); - var lineBreak1 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br",{}); - var designInvestInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", - placeholder:"Design investment" - }); - var marketingInvestInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", - placeholder:"Marketing investment" - }); - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Develop Product", - clickListener:()=>{ - if (designInvestInput.value == null) {designInvestInput.value = 0;} - if (marketingInvestInput.value == null) {marketingInvestInput.value = 0;} - var designInvest = parseFloat(designInvestInput.value), - marketingInvest = parseFloat(marketingInvestInput.value); - if (productNameInput.value == null || productNameInput.value === "") { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must specify a name for your product!"); - } else if (isNaN(designInvest)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for design investment"); - } else if (isNaN(marketingInvest)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for marketing investment"); - } else if (this.funds.lt(designInvest + marketingInvest)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to make this large of an investment"); - } else { - var product = new Product({ - name:productNameInput.value.replace(/[<>]/g, ''), //Sanitize for HTMl elements - createCity:designCity.options[designCity.selectedIndex].value, - designCost: designInvest, - advCost: marketingInvest, - }); - this.funds = this.funds.minus(designInvest + marketingInvest); - division.products[product.name] = product; - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - } - //this.updateUIContent(); - this.displayDivisionContent(division, city); - return false; - } - }) - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }) - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, designCity, productNameInput, lineBreak1, - designInvestInput, marketingInvestInput, confirmBtn, cancelBtn]); - } - })); - } - - //Employee and Office Panel - industryEmployeeText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - id: "cmpy-mgmt-employee-p", - display:"block", - innerHTML: "

Office Space


" + - "Type: " + office.tier + "
" + - "Comfort: " + office.comf + "
" + - "Beauty: " + office.beau + "
" + - "Size: " + office.employees.length + " / " + office.size + " employees", - }); - industryEmployeePanel.appendChild(industryEmployeeText); - - //Hire Employee button - if (office.employees.length === 0) { - industryEmployeeHireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button",display:"inline-block", - innerText:"Hire Employee", fontSize:"13px", - tooltip:"You'll need to hire some employees to get your operations started! " + - "It's recommended to have at least one employee in every position", - clickListener:()=>{ - office.findEmployees({corporation:this, division:division}); - return false; - } - }); - //industryEmployeeHireButton.classList.add("flashing-button"); - } else { - industryEmployeeHireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button",display:"inline-block", - innerText:"Hire Employee", fontSize:"13px", - clickListener:()=>{ - office.findEmployees({corporation:this, division:division}); - return false; - } - }); - } - industryEmployeePanel.appendChild(industryEmployeeHireButton); - - //Autohire Employee button - industryEmployeeAutohireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", - innerText:"Autohire Employee", fontSize:"13px", - tooltip:"Automatically hires an employee and gives him/her a random name", - clickListener:()=>{ - office.hireRandomEmployee({corporation:this, division:division}); - return false; - } - }); - industryEmployeePanel.appendChild(industryEmployeeAutohireButton); - - //Upgrade Office Size button - industryEmployeePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - industryOfficeUpgradeSizeButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Upgrade size", - display:"inline-block", margin:"6px", fontSize:"13px", - tooltip:"Upgrade the office's size so that it can hold more employees!", - clickListener:()=>{ - var popupId = "cmpy-mgmt-upgrade-office-size-popup"; - var initialPriceMult = Math.round(office.size / OfficeInitialSize); - var upgradeCost = OfficeInitialCost * Math.pow(1.07, initialPriceMult); - - //Calculate cost to upgrade size by 15 employees - var mult = 0; - for (var i = 0; i < 5; ++i) { - mult += (Math.pow(1.07, initialPriceMult + i)); - } - var upgradeCost15 = OfficeInitialCost * mult; - - //Calculate max upgrade size and cost - var maxMult = (this.funds.dividedBy(OfficeInitialCost)).toNumber(); - var maxNum = 1; - mult = Math.pow(1.07, initialPriceMult); - while(maxNum < 50) { //Hard cap of 50x (extra 150 employees) - if (mult >= maxMult) {break;} - var multIncrease = Math.pow(1.07, initialPriceMult + maxNum); - if (mult + multIncrease > maxMult) { - break; - } else { - mult += multIncrease; - } - ++maxNum; - } - - var upgradeCostMax = OfficeInitialCost * mult; - - var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Increase the size of your office space to fit additional employees!" - }); - var text2 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {innerText: "Upgrade size: "}); - - var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: this.funds.lt(upgradeCost) ? "a-link-button-inactive" : "a-link-button", - display:"inline-block", margin:"4px", innerText:"by 3", - tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost).format("$0.000a"), - clickListener:()=>{ - if (this.funds.lt(upgradeCost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); - } else { - office.size += OfficeInitialSize; - this.funds = this.funds.minus(upgradeCost); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); - this.updateUIContent(); - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var confirmBtn15 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: this.funds.lt(upgradeCost15) ? "a-link-button-inactive" : "a-link-button", - display:"inline-block", margin:"4px", innerText:"by 15", - tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost15).format("$0.000a"), - clickListener:()=>{ - if (this.funds.lt(upgradeCost15)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); - } else { - office.size += (OfficeInitialSize * 5); - this.funds = this.funds.minus(upgradeCost15); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); - this.updateUIContent(); - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var confirmBtnMax = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:this.funds.lt(upgradeCostMax) ? "a-link-button-inactive" : "a-link-button", - display:"inline-block", margin:"4px", innerText:"by MAX (" + maxNum*OfficeInitialSize + ")", - tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCostMax).format("$0.000a"), - clickListener:()=>{ - if (this.funds.lt(upgradeCostMax)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); - } else { - office.size += (OfficeInitialSize * maxNum); - this.funds = this.funds.minus(upgradeCostMax); - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); - this.updateUIContent(); - } - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", innerText:"Cancel", display:"inline-block", margin:"4px", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }) - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [text, text2, confirmBtn, confirmBtn15, confirmBtnMax, cancelBtn]); - return false; - } - }); - industryEmployeePanel.appendChild(industryOfficeUpgradeSizeButton); - - //Throw Office Party - industryEmployeePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", innerText:"Throw Party", - fontSize:"13px", - tooltip:"Throw an office party to increase your employee's morale and happiness", - clickListener:()=>{ - var popupId = "cmpy-mgmt-throw-office-party-popup"; - var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Enter the amount of money you would like to spend PER EMPLOYEE " + - "on this office party" - }); - var totalCostTxt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Throwing this party will cost a total of $0" - }); - var confirmBtn; - var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { - type:"number", margin:"5px", placeholder:"$ / employee", - inputListener:()=>{ - if (isNaN(input.value) || input.value < 0) { - totalCostTxt.innerText = "Invalid value entered!" - } else { - var totalCost = input.value * office.employees.length; - totalCostTxt.innerText = "Throwing this party will cost a total of " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(totalCost).format('$0.000a'); - } - }, - onkeyup:(e)=>{ - e.preventDefault(); - if (e.keyCode === 13) {confirmBtn.click();} - } - }); - confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - display:"inline-block", - innerText:"Throw Party", - clickListener:()=>{ - if (isNaN(input.value) || input.value < 0) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value entered"); - } else { - var totalCost = input.value * office.employees.length; - if (this.funds.lt(totalCost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to throw this party!"); - } else { - this.funds = this.funds.minus(totalCost); - var mult; - for (var fooit = 0; fooit < office.employees.length; ++fooit) { - mult = office.employees[fooit].throwParty(input.value); - } - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You threw a party for the office! The morale and happiness " + - "of each employee increased by " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])((mult-1) * 100, 2) + "%."); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - } - } - return false; - } - }); - var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", - display:"inline-block", - innerText:"Cancel", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); - return false; - } - }); - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, totalCostTxt, input, confirmBtn, cancelBtn]); - } - })); - - industryEmployeeManagementUI = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {}); - industryEmployeeInfo = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {margin:"4px", padding:"4px"}); - if (empManualAssignmentModeActive) { - //Employees manually assigned - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", margin:"4px", - innerText:"Switch to Auto Mode", - tooltip:"Switch to Automatic Assignment Mode, which will automatically " + - "assign employees to your selected jobs. You simply have to select " + - "the number of assignments for each job", - clickListener:()=>{ - empManualAssignmentModeActive = false; - this.displayDivisionContent(division, city); - } - })); - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - industryIndividualEmployeeInfo = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {margin:"4px", padding:"4px"}); - var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { - color: "white", backgroundColor:"black", margin:"4px", padding:"4px", - changeListener:()=>{ - var name = selector.options[selector.selectedIndex].text; - for (var i = 0; i < office.employees.length; ++i) { - if (office.employees[i].name === name) { - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryIndividualEmployeeInfo); - office.employees[i].createUI(industryIndividualEmployeeInfo, this); - return; - } - } - console.log("ERROR: Employee in selector could not be found"); - } - }); - - for (var i = 0; i < office.employees.length; ++i) { - selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", {text:office.employees[i].name})); - } - - selector.selectedIndex = -1; - - industryEmployeeManagementUI.appendChild(industryEmployeeInfo); - industryEmployeeManagementUI.appendChild(selector); - industryEmployeeManagementUI.appendChild(industryIndividualEmployeeInfo); - } else { - //Player only manages the number of each occupation, not who gets what job - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class:"a-link-button", display:"inline-block", margin:"4px", - innerText:"Switch to Manual Mode", - tooltip:"Switch to Manual Assignment Mode, which allows you to " + - "specify which employees should get which jobs", - clickListener:()=>{ - empManualAssignmentModeActive = true; - this.displayDivisionContent(division, city); - } - })); - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - var opCount = 0, engCount = 0, busCount = 0, - mgmtCount = 0, rndCount = 0, unassignedCount = 0, - trainingCount = 0; - for (var i = 0; i < office.employees.length; ++i) { - switch (office.employees[i].pos) { - case EmployeePositions.Operations: - ++opCount; break; - case EmployeePositions.Engineer: - ++engCount; break; - case EmployeePositions.Business: - ++busCount; break; - case EmployeePositions.Management: - ++mgmtCount; break; - case EmployeePositions.RandD: - ++rndCount; break; - case EmployeePositions.Unassigned: - ++unassignedCount; break; - case EmployeePositions.Training: - ++trainingCount; break; - default: - console.log("ERROR: Unrecognized employee position: " + office.employees[i].pos); - break; - } - } - - //Unassigned employee count display - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - display:"inline-block", - innerText:"Unassigned Employees: " + unassignedCount, - })); - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - //General display of employee information (avg morale, avg energy, etc.) - industryEmployeeManagementUI.appendChild(industryEmployeeInfo); - industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - - var positions = [EmployeePositions.Operations, EmployeePositions.Engineer, - EmployeePositions.Business, EmployeePositions.Management, - EmployeePositions.RandD, EmployeePositions.Training]; - var descriptions = ["Manages supply chain operations. Improves production.", //Operations - "Develops and maintains products and production systems. Improves production.", //Engineer - "Handles sales and finances. Improves sales.", //Business - "Leads and oversees employees and office operations. Improves production.", //Management - "Research new innovative ways to improve the company. Generates Scientific Research", //RandD - "Set employee to training, which will increase some of their stats. Employees in training do not affect any company operations."] //Training - var counts = [opCount, engCount, busCount, mgmtCount, rndCount, trainingCount]; - for (var i = 0; i < positions.length; ++i) { - (function(corp, i) { - var info = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h2", { - display:"inline-block", width:"40%", fontSize:"15px", - innerText: positions[i] + "(" + counts[i] + ")", - tooltipleft: descriptions[i] - }); - var plusBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: unassignedCount > 0 ? "a-link-button" : "a-link-button-inactive", - display:"inline-block", innerText:"+", - clickListener:()=>{ - office.assignEmployeeToJob(positions[i]); - corp.displayDivisionContent(division, city); - } - }); - var minusBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - class: counts[i] > 0 ? "a-link-button" : "a-link-button-inactive", - display:"inline-block", innerText:"-", - clickListener:()=>{ - office.unassignEmployeeFromJob(positions[i]); - corp.displayDivisionContent(division, city); - } - }); - var newline = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); - industryEmployeeManagementUI.appendChild(info); - industryEmployeeManagementUI.appendChild(plusBtn); - industryEmployeeManagementUI.appendChild(minusBtn); - industryEmployeeManagementUI.appendChild(newline); - })(this, i); - } - } - industryEmployeePanel.appendChild(industryEmployeeManagementUI); - - //Warehouse Panel - var warehouse = division.warehouses[currentCityUi]; - if (warehouse instanceof Warehouse) { - warehouse.createUI({industry:division, company: this}); - } else { - industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { - innerText:"Purchase Warehouse ($5b)", - class: "a-link-button", - clickListener:()=>{ - if (this.funds.lt(WarehouseInitialCost)) { - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough funds to do this!"); - } else { - division.warehouses[currentCityUi] = new Warehouse({ - loc:currentCityUi, - size:WarehouseInitialSize, - }); - this.funds = this.funds.minus(WarehouseInitialCost); - this.displayDivisionContent(division, currentCityUi); - } - return false; - } - })); - } - this.updateDivisionContent(division); -} - -Corporation.prototype.updateDivisionContent = function(division) { - if (!(division instanceof Industry)) { - console.log("ERROR: Invalid 'division' argument in Corporation.updateDivisionContent"); - return; - } - var vechain = (this.unlockUpgrades[4] === 1); - //Industry Overview Text - var profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber(), - profitStr = profit >= 0 ? __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(profit).format("$0.000a") : "-" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(-1 * profit).format("$0.000a"); - var advertisingInfo = ""; - if (vechain) { - var advertisingFactors = division.getAdvertisingFactors(); - var awarenessFac = advertisingFactors[1]; - var popularityFac = advertisingFactors[2]; - var ratioFac = advertisingFactors[3]; - var totalAdvertisingFac = advertisingFactors[0]; - advertisingInfo = - "

Advertising Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalAdvertisingFac, 3) + - "Total multiplier for this industry's sales due to its awareness and popularity
" + - "Awareness Bonus: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(awarenessFac, 0.85), 3) + "
" + - "Popularity Bonus: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(popularityFac, 0.85), 3) + "
" + - "Ratio Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(ratioFac, 0.85), 3) + "


" - - } - - Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryOverviewText); - industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerHTML:"Industry: " + division.type + " (Corp Funds: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.funds.toNumber()).format("$0.000a") + ")

" + - "Awareness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.awareness, 3) + "
" + - "Popularity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.popularity, 3) + "
" + - advertisingInfo + "
" + - "Revenue: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s
" + - "Expenses: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s
" + - "Profit: " + profitStr + " / s

" - })); - industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - marginTop:"2px", - innerText:"Production Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.prodMult, 2), - tooltip:"Production gain from owning production-boosting materials " + - "such as hardware, Robots, AI Cores, and Real Estate" - })); - industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { - innerText:"?", class:"help-tip", - clickListener:()=>{ - Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Owning Hardware, Robots, AI Cores, and Real Estate " + - "can boost your Industry's production. The effect these " + - "materials have on your production varies between Industries. " + - "For example, Real Estate may be very effective for some Industries, " + - "but ineffective for others.

" + - "This division's production multiplier is calculated by summing " + - "the individual production multiplier of each of its office locations. " + - "This production multiplier is applied to each office. Therefore, it is " + - "beneficial to expand into new cities as this can greatly increase the " + - "production multiplier of your entire Division." - ) - } - })); - industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br")); - industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - display:"inline-block", - innerText:"Scientific Research: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.sciResearch.qty, 3), - tooltip:"Scientific Research increases the quality of the materials and " + - "products that you produce." - })); - - //Office and Employee List - var office = division.offices[currentCityUi]; - industryEmployeeText.innerHTML = - "

Office Space


" + - "Type: " + office.tier + "
" + - "Comfort: " + office.comf + "
" + - "Beauty: " + office.beau + "
" + - "Size: " + office.employees.length + " / " + office.size + " employees"; - if (office.employees.length >= office.size) { - industryEmployeeHireButton.className = "a-link-button-inactive"; - industryEmployeeAutohireButton.className = "a-link-button-inactive tooltip"; - } else if (office.employees.length === 0) { - industryEmployeeHireButton.className = "a-link-button tooltip flashing-button"; - industryEmployeeAutohireButton.className = "a-link-button tooltip"; - } else { - industryEmployeeHireButton.className = "a-link-button"; - industryEmployeeAutohireButton.className = "a-link-button tooltip"; - } - - //Employee Overview stats - //Calculate average morale, happiness, and energy - var totalMorale = 0, totalHappiness = 0, totalEnergy = 0, - avgMorale = 0, avgHappiness = 0, avgEnergy = 0; - for (var i = 0; i < office.employees.length; ++i) { - totalMorale += office.employees[i].mor; - totalHappiness += office.employees[i].hap; - totalEnergy += office.employees[i].ene; - } - if (office.employees.length > 0) { - avgMorale = totalMorale / office.employees.length; - avgHappiness = totalHappiness / office.employees.length; - avgEnergy = totalEnergy / office.employees.length; - } - industryEmployeeInfo.innerHTML = - "Avg Employee Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgMorale, 3) + "
" + - "Avg Employee Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgHappiness, 3) + "
" + - "Avg Employee Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgEnergy, 3); - if (vechain) { //VeChain - Statistics - industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Material Production: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText:"Product Production: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); - industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { - innerText: "Business Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.getBusinessFactor(office), 3), - tooltip: "The effect this office's 'Business' employees has on boosting sales" - })); - } - - //Warehouse - var warehouse = division.warehouses[currentCityUi]; - if (warehouse instanceof Warehouse) { - warehouse.updateUI({industry:division, company:this}); - } -} - -Corporation.prototype.createCityUITab = function(city, division) { - var tab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { - id:"cmpy-mgmt-city-" + city + "-tab", - class:"cmpy-mgmt-city-tab", - innerText:city, - clickListener:()=>{ - this.selectCityTab(tab, city); - this.displayDivisionContent(division, city); - return false; - } - }); - companyManagementPanel.appendChild(tab); -} - -Corporation.prototype.selectCityTab = function(activeTab, city) { - if (activeTab == null) { - activeTab = document.getElementById("cmpy-mgmt-city-" + city + "-tab"); - if (activeTab == null) {return;} - } - for (var i = 0; i < cityTabs.length; ++i) { - cityTabs[i].className = "cmpy-mgmt-city-tab"; - } - activeTab.className = "cmpy-mgmt-city-tab current"; -} - -Corporation.prototype.clearUI = function() { - //Delete everything - if (companyManagementDiv != null) {Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(companyManagementDiv.id);} - - //Reset global DOM variables - companyManagementDiv = null; - companyManagementPanel = null; - currentCityUi = null; - - corporationUnlockUpgrades = null; - corporationUpgrades = null; - - industryOverviewPanel = null; - industryOverviewText = null; - - industryEmployeePanel = null; - industryEmployeeText = null; - industryEmployeeHireButton = null; - industryEmployeeAutohireButton = null; - industryEmployeeManagementUI = null; - industryEmployeeInfo = null; - industryIndividualEmployeeInfo = null; - - industryOfficeUpgradeSizeButton = null; - - industryWarehousePanel = null; - industrySmartSupplyCheckbox = null; - industryWarehouseStorageText = null; - industryWarehouseUpgradeSizeButton = null; - industryWarehouseStateText = null; - industryWarehouseMaterials = null; - industryWarehouseProducts = null; - - companyManagementHeaderTabs = null; - headerTabs = null; - cityTabs = null; - - document.getElementById("character-overview-wrapper").style.visibility = "visible"; -} - -Corporation.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Corporation", this); -} - -Corporation.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Corporation, value.data); -} - -__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Corporation = Corporation; - - - - -/***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return commitShopliftCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return commitRobStoreCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return commitMugCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return commitLarcenyCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return commitDealDrugsCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return commitBondForgeryCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return commitTraffickArmsCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return commitHomicideCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return commitGrandTheftAutoCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return commitKidnapCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return commitAssassinationCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return commitHeistCrime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return determineCrimeSuccess; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return determineCrimeChanceShoplift; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return determineCrimeChanceRobStore; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return determineCrimeChanceMug; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return determineCrimeChanceLarceny; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return determineCrimeChanceDealDrugs; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return determineCrimeChanceBondForgery; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return determineCrimeChanceTraffickArms; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return determineCrimeChanceHomicide; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return determineCrimeChanceGrandTheftAuto; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return determineCrimeChanceKidnap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return determineCrimeChanceAssassination; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return determineCrimeChanceHeist; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__ = __webpack_require__(1); - - - - -/* Crimes.js */ -function commitShopliftCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeShoplift; - var time = 2000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 0, 0, 2/div, 2/div, 0, 15000/div, time, singParams); //$7500/s, 1 exp/s - return time; -} - -function commitRobStoreCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeRobStore; - var time = 60000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(30/div, 0, 0, 45/div, 45/div, 0, 400000/div, time, singParams); //$6666,6/2, 0.5exp/s, 0.75exp/s - return time; -} - -function commitMugCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeMug; - var time = 4000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 3/div, 3/div, 3/div, 3/div, 0, 36000/div, time, singParams); //$9000/s, .66 exp/s - return time; -} - -function commitLarcenyCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeLarceny; - var time = 90000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(45/div, 0, 0, 60/div, 60/div, 0, 800000/div, time, singParams) // $8888.88/s, .5 exp/s, .66 exp/s - return time; -} - -function commitDealDrugsCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeDrugs; - var time = 10000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 0, 0, 5/div, 5/div, 10/div, 120000/div, time, singParams); //$12000/s, .5 exp/s, 1 exp/s - return time; -} - -function commitBondForgeryCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeBondForgery; - var time = 300000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(100/div, 0, 0, 150/div, 0, 15/div, 4500000/div, time, singParams); //$15000/s, 0.33 hack exp/s, .5 dex exp/s, .05 cha exp - return time; -} - -function commitTraffickArmsCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeTraffickArms; - var time = 40000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 20/div, 20/div, 20/div, 20/div, 40/div, 600000/div, time, singParams); //$15000/s, .5 combat exp/s, 1 cha exp/s - return time; -} - -function commitHomicideCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHomicide; - var time = 3000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 2/div, 2/div, 2/div, 2/div, 0, 45000/div, time, singParams); //$15000/s, 0.66 combat exp/s - return time; -} - -function commitGrandTheftAutoCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeGrandTheftAuto; - var time = 80000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 20/div, 20/div, 20/div, 80/div, 40/div, 1600000/div, time, singParams); //$20000/s, .25 exp/s, 1 exp/s, .5 exp/s - return time; -} - -function commitKidnapCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeKidnap; - var time = 120000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 80/div, 80/div, 80/div, 80/div, 80/div, 3600000/div, time, singParams); //$30000/s. .66 exp/s - return time; -} - -function commitAssassinationCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeAssassination; - var time = 300000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 300/div, 300/div, 300/div, 300/div, 0, 12000000/div, time, singParams); //$40000/s, 1 exp/s - return time; -} - -function commitHeistCrime(div=1, singParams=null) { - if (div <= 0) {div = 1;} - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHeist; - var time = 600000; - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(450/div, 450/div, 450/div, 450/div, 450/div, 450/div, 120000000/div, time, singParams); //$200000/s, .75exp/s - return time; -} - -function determineCrimeSuccess(crime, moneyGained) { - var chance = 0; - switch (crime) { - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeShoplift: - chance = determineCrimeChanceShoplift(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeRobStore: - chance = determineCrimeChanceRobStore(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeMug: - chance = determineCrimeChanceMug(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeLarceny: - chance = determineCrimeChanceLarceny(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeDrugs: - chance = determineCrimeChanceDealDrugs(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeBondForgery: - chance = determineCrimeChanceBondForgery(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeTraffickArms: - chance = determineCrimeChanceTraffickArms(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHomicide: - chance = determineCrimeChanceHomicide(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeGrandTheftAuto: - chance = determineCrimeChanceGrandTheftAuto(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeKidnap: - chance = determineCrimeChanceKidnap(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeAssassination: - chance = determineCrimeChanceAssassination(); - break; - case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHeist: - chance = determineCrimeChanceHeist(); - break; - default: - console.log(crime); - Object(__WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERR: Unrecognized crime type. This is probably a bug please contact the developer"); - return; - } - - if (Math.random() <= chance) { - //Success - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].gainMoney(moneyGained); - return true; - } else { - //Failure - return false; - } -} - -let intWgt = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceCrimeWeight; -let maxLvl = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].MaxSkillLevel; - -function determineCrimeChanceShoplift() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 20; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceRobStore() { - var chance = (0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + - 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - 1 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 5; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceMug() { - var chance = (1.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + - 1.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 5; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceLarceny() { - var chance = (0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 3; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceDealDrugs() { - var chance = (3*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + - 2*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceBondForgery() { - var chance = (0.1*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + - 2.5*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - 2*intWgt*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceTraffickArms() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 2; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceHomicide() { - var chance = (2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + - 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceGrandTheftAuto() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - 4 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 8; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceKidnap() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 5; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceAssassination() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 8; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - -function determineCrimeChanceHeist() { - var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + - intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 18; - chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; - return Math.min(chance, 1); -} - - - - -/***/ }), -/* 33 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return iTutorialSteps; }); -/* unused harmony export iTutorialEnd */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return iTutorialStart; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return iTutorialNextStep; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return currITutorialStep; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return iTutorialIsRunning; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__ = __webpack_require__(2); - - - - - -/* InteractiveTutorial.js */ -let iTutorialSteps = { - Start: "Start", - GoToCharacterPage: "Click on the Character page menu link", - CharacterPage: "Introduction to Character page", - CharacterGoToTerminalPage: "Click on the Terminal link", - TerminalIntro: "Introduction to terminal interface", - TerminalHelp: "Using the help command to display all options in terminal", - TerminalLs: "Use the ls command to show all programs/scripts. Right now we have NUKE.exe", - TerminalScan: "Using the scan command to display all available connections", - TerminalScanAnalyze1: "Use the scan-analyze command to show hacking related information", - TerminalScanAnalyze2: "Use the scan-analyze command with a depth of 3", - TerminalConnect: "Using the telnet/connect command to connect to another server", - TerminalAnalyze: "Use the analyze command to display details about this server", - TerminalNuke: "Use the NUKE Program to gain root access to a server", - TerminalManualHack: "Use the hack command to manually hack a server", - TerminalHackingMechanics: "Briefly explain hacking mechanics", - TerminalCreateScript: "Create a script using nano", - TerminalTypeScript: "This occurs in the Script Editor page...type the script then save and close", - TerminalFree: "Use the free command to check RAM", - TerminalRunScript: "Use the run command to run a script", - TerminalGoToActiveScriptsPage: "Go to the ActiveScriptsPage", - ActiveScriptsPage: "Introduction to the Active Scripts Page", - ActiveScriptsToTerminal: "Go from Active Scripts Page Back to Terminal", - TerminalTailScript: "Use the tail command to show a script's logs", - GoToHacknetNodesPage: "Go to the Hacknet Nodes page", - HacknetNodesIntroduction: "Introduction to Hacknet Nodesm and have user purchase one", - HacknetNodesGoToWorldPage: "Go to the world page", - WorldDescription: "Tell the user to explore..theres a lot of different stuff to do out there", - TutorialPageInfo: "The tutorial page contains a lot of info on different subjects", - End: "End", -} - -var currITutorialStep = iTutorialSteps.Start; -var iTutorialIsRunning = false; - -function iTutorialStart() { - //Don't autosave during this interactive tutorial - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].Counters.autoSaveCounter = 999000000000; - console.log("Interactive Tutorial started"); - currITutorialStep = iTutorialSteps.Start; - iTutorialIsRunning = true; - - document.getElementById("interactive-tutorial-container").style.display = "block"; - - iTutorialEvaluateStep(); - - //Exit tutorial button - var exitButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-exit"); - exitButton.addEventListener("click", function() { - iTutorialEnd(); - return false; - }); - - //Back button - var backButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-back"); - backButton.style.display = "none"; - backButton.addEventListener("click", function() { - iTutorialPrevStep(); - return false; - }); -} - -function iTutorialEvaluateStep() { - if (!iTutorialIsRunning) {console.log("Interactive Tutorial not running"); return;} - switch(currITutorialStep) { - case iTutorialSteps.Start: - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); - - iTutorialSetText("Welcome to Bitburner, a cyberpunk-themed incremental RPG! " + - "The game takes place in a dark, dystopian future...The year is 2077...

" + - "This tutorial will show you the basics of the game. " + - "You may skip the tutorial at any time."); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.GoToCharacterPage: - iTutorialSetText("Let's start by heading to the Stats page. Click the 'Stats' tab on " + - "the main navigation menu (left-hand side of the screen)"); - - //No next button - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "none"; - - //Flash Character tab - document.getElementById("stats-menu-link").setAttribute("class", "flashing-button"); - - //Initialize everything necessary to open the "Character" page - var charaterMainMenuButton = document.getElementById("stats-menu-link"); - charaterMainMenuButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadCharacterContent(); - iTutorialNextStep(); //Opening the character page will go to the next step - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stats-menu-link"); - return false; - }); - break; - case iTutorialSteps.CharacterPage: - iTutorialSetText("The Stats page shows a lot of important information about your progress, " + - "such as your skills, money, and bonuses/multipliers. ") - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.CharacterGoToTerminalPage: - iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " + - "main navigation menu."); - //No next button - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "none"; - - document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); - - //Initialize everything necessary to open the 'Terminal' Page - var terminalMainMenuButton = document.getElementById("terminal-menu-link"); - terminalMainMenuButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); - return false; - }); - break; - case iTutorialSteps.TerminalIntro: - iTutorialSetText("The Terminal is used to interface with your home computer as well as " + - "all of the other machines around the world."); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.TerminalHelp: - iTutorialSetText("Let's try it out. Start by entering the 'help' command into the Terminal " + - "(Don't forget to press Enter after typing the command)"); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "none"; - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalLs: - iTutorialSetText("The 'help' command displays a list of all available Terminal commands, how to use them, " + - "and a description of what they do.

Let's try another command. Enter the 'ls' command"); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalScan: - iTutorialSetText("'ls' is a basic command that shows all of the contents (programs/scripts) " + - "on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " + - "We'll get to what this does later.

Using your home computer's terminal, you can connect " + - "to other machines throughout the world. Let's do that now by first entering " + - "the 'scan' command. "); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalScanAnalyze1: - iTutorialSetText("The 'scan' command shows all available network connections. In other words, " + - "it displays a list of all servers that can be connected to from your " + - "current machine. A server is identified by either its IP or its hostname.

" + - "That's great and all, but there's so many servers. Which one should you go to? " + - "The 'scan-analyze' command gives some more detailed information about servers on the " + - "network. Try it now"); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalScanAnalyze2: - iTutorialSetText("You just ran 'scan-analyze' with a depth of one. This command shows more detailed " + - "information about each server that you can connect to (servers that are a distance of " + - "one node away).

It is also possible to run 'scan-analyze' with " + - "a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.") - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalConnect: - iTutorialSetText("Now you can see information about all servers that are up to two nodes away, as well " + - "as figure out how to navigate to those servers through the network. You can only connect to " + - "a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " + - "the ip or the hostname, but dont use both.

" + - "From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is " + - "only one node away. Let's connect so it now using: 'connect foodnstuff'"); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalAnalyze: - iTutorialSetText("You are now connected to another machine! What can you do now? You can hack it!

In the year 2077, currency has " + - "become digital and decentralized. People and corporations store their money " + - "on servers and computers. Using your hacking abilities, you can hack servers " + - "to steal money and gain experience.

" + - "Before you try to hack a server, you should run diagnostics using the 'analyze' command"); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalNuke: - iTutorialSetText("When the 'analyze' command finishes running it will show useful information " + - "about hacking the server.

For this server, the required hacking skill is only 1, " + - "which means you can hack it right now. However, in order to hack a server " + - "you must first gain root access. The 'NUKE.exe' program that we saw earlier on your " + - "home computer is a virus that will grant you root access to a machine if there are enough " + - "open ports.

The 'analyze' results shows that there do not need to be any open ports " + - "on this machine for the NUKE virus to work, so go ahead and run the virus using the " + - "'run NUKE.exe' command."); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalManualHack: - iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " + - "Try doing that now."); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalHackingMechanics: - iTutorialSetText("You are now attempting to hack the server. Note that performing a hack takes time and " + - "only has a certain percentage chance " + - "of success. This time and success chance is determined by a variety of factors, including " + - "your hacking skill and the server's security level.

" + - "If your attempt to hack the server is successful, you will steal a certain percentage " + - "of the server's total money. This percentage is affected by your hacking skill and " + - "the server's security level.

The amount of money on a server is not limitless. So, if " + - "you constantly hack a server and deplete its money, then you will encounter " + - "diminishing returns in your hacking."); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.TerminalCreateScript: - iTutorialSetText("Hacking is the core mechanic of the game and is necessary for progressing. However, " + - "you don't want to be hacking manually the entire time. You can automate your hacking " + - "by writing scripts!

To create a new script or edit an existing one, you can use the 'nano' " + - "command. Scripts must end with the '.script' extension. Let's make a script now by " + - "entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c" + - " will end a command like hack early)"); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "none"; - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalTypeScript: - iTutorialSetText("This is the script editor. You can use it to program your scripts. Scripts are " + - "written in the Netscript language, a programming language created for " + - "this game. There are details about the Netscript language in the documentation, which " + - "can be accessed in the 'Tutorial' tab on the main navigation menu. I highly suggest you check " + - "it out after this tutorial. For now, just copy " + - "and paste the following code into the script editor:

" + - "while(true) {
" + - "  hack('foodnstuff');
" + - "}

" + - "For anyone with basic programming experience, this code should be straightforward. " + - "This script will continuously hack the 'foodnstuff' server.

" + - "To save and close the script editor, press the button in the bottom left, or press ctrl + b."); - //next step triggered in saveAndCloseScriptEditor() (Script.js) - break; - case iTutorialSteps.TerminalFree: - iTutorialSetText("Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " + - "run on any machine which you have root access to. Different servers have different " + - "amounts of RAM. You can also purchase more RAM for your home server.

To check how much " + - "RAM is available on this machine, enter the 'free' command."); - //next step triggered by terminal commmand - break; - case iTutorialSteps.TerminalRunScript: - iTutorialSetText("We have 16GB of free RAM on this machine, which is enough to run our " + - "script. Let's run our script using 'run foodnstuff.script'."); - //next step triggered by terminal commmand - break; - case iTutorialSteps.TerminalGoToActiveScriptsPage: - iTutorialSetText("Your script is now running! The script might take a few seconds to 'fully start up'. " + - "Your scripts will continuously run in the background and will automatically stop if " + - "the code ever completes (the 'foodnstuff.script' will never complete because it " + - "runs an infinite loop).

These scripts can passively earn you income and hacking experience. " + - "Your scripts will also earn money and experience while you are offline, although at a " + - "much slower rate.

" + - "Let's check out some statistics for our running scripts by clicking the " + - "'Active Scripts' link in the main navigation menu."); - document.getElementById("active-scripts-menu-link").setAttribute("class", "flashing-button"); - var activeScriptsMainMenuButton = document.getElementById("active-scripts-menu-link"); - activeScriptsMainMenuButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadActiveScriptsContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("active-scripts-menu-link"); - return false; - }); - break; - case iTutorialSteps.ActiveScriptsPage: - iTutorialSetText("This page displays stats/information about all of your scripts that are " + - "running across every existing server. You can use this to gauge how well " + - "your scripts are doing. Let's go back to the Terminal now using the 'Terminal'" + - "link."); - document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); - //Initialize everything necessary to open the 'Terminal' Page - var terminalMainMenuButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); - terminalMainMenuButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); - return false; - }); - break; - case iTutorialSteps.ActiveScriptsToTerminal: - iTutorialSetText("One last thing about scripts, each active script contains logs that detail " + - "what it's doing. We can check these logs using the 'tail' command. Do that " + - "now for the script we just ran by typing 'tail foodnstuff.script'"); - //next step triggered by terminal command - break; - case iTutorialSteps.TerminalTailScript: - iTutorialSetText("The log for this script won't show much right now (it might show nothing at all) because it " + - "just started running...but check back again in a few minutes!

" + - "This pretty much covers the basics of hacking. To learn more about writing " + - "scripts using the Netscript language, select the 'Tutorial' link in the " + - "main navigation menu to look at the documentation. For now, let's move on " + - "to something else!"); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.GoToHacknetNodesPage: - iTutorialSetText("Hacking is not the only way to earn money. One other way to passively " + - "earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " + - "the 'Hacknet Nodes' page through the main navigation menu now."); - document.getElementById("hacknet-nodes-menu-link").setAttribute("class", "flashing-button"); - var hacknetNodesButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hacknet-nodes-menu-link"); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "none"; - hacknetNodesButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadHacknetNodesContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hacknet-nodes-menu-link"); - return false; - }); - break; - case iTutorialSteps.HacknetNodesIntroduction: - iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " + - "existing ones. Let's purchase a new one now."); - //Next step triggered by purchaseHacknet() (HacknetNode.js) - break; - case iTutorialSteps.HacknetNodesGoToWorldPage: - iTutorialSetText("You just purchased a Hacknet Node! This Hacknet Node will passively " + - "earn you money over time, both online and offline. When you get enough " + - " money, you can upgrade " + - "your newly-purchased Hacknet Node below.

" + - "Let's go to the 'City' page through the main navigation menu."); - document.getElementById("city-menu-link").setAttribute("class", "flashing-button"); - var worldButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("city-menu-link"); - worldButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadWorldContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("city-menu-link"); - return false; - }); - break; - case iTutorialSteps.WorldDescription: - iTutorialSetText("This page lists all of the different locations you can currently " + - "travel to. Each location has something that you can do. " + - "There's a lot of content out in the world, make sure " + - "you explore and discover!

" + - "Lastly, click on the 'Tutorial' link in the main navigation menu."); - document.getElementById("tutorial-menu-link").setAttribute("class", "flashing-button"); - var tutorialButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("tutorial-menu-link"); - tutorialButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTutorialContent(); - iTutorialNextStep(); - Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("tutorial-menu-link"); - return false; - }); - break; - - case iTutorialSteps.TutorialPageInfo: - iTutorialSetText("This page contains a lot of different documentation about the game's " + - "content and mechanics. I know it's a lot, but I highly suggest you read " + - "(or at least skim) through this before you start playing. That's the end of the tutorial. " + - "Hope you enjoy the game!"); - var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); - next.style.display = "inline-block"; - next.innerHTML = "Finish Tutorial"; - - var backButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-back"); - backButton.style.display = "none"; - - next.addEventListener("click", function() { - iTutorialNextStep(); - return false; - }); - break; - case iTutorialSteps.End: - iTutorialEnd(); - break; - default: - throw new Error("Invalid tutorial step"); - } -} - -//Go to the next step and evaluate it -function iTutorialNextStep() { - switch(currITutorialStep) { - case iTutorialSteps.Start: - currITutorialStep = iTutorialSteps.GoToCharacterPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.GoToCharacterPage: - document.getElementById("stats-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.CharacterPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.CharacterPage: - currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.CharacterGoToTerminalPage: - document.getElementById("terminal-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.TerminalIntro; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalIntro: - currITutorialStep = iTutorialSteps.TerminalHelp; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalHelp: - currITutorialStep = iTutorialSteps.TerminalLs; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalLs: - currITutorialStep = iTutorialSteps.TerminalScan; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalScan: - currITutorialStep = iTutorialSteps.TerminalScanAnalyze1; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalScanAnalyze1: - currITutorialStep = iTutorialSteps.TerminalScanAnalyze2; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalScanAnalyze2: - currITutorialStep = iTutorialSteps.TerminalConnect; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalConnect: - currITutorialStep = iTutorialSteps.TerminalAnalyze; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalAnalyze: - currITutorialStep = iTutorialSteps.TerminalNuke; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalNuke: - currITutorialStep = iTutorialSteps.TerminalManualHack; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalManualHack: - currITutorialStep = iTutorialSteps.TerminalHackingMechanics; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalHackingMechanics: - currITutorialStep = iTutorialSteps.TerminalCreateScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalCreateScript: - currITutorialStep = iTutorialSteps.TerminalTypeScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalTypeScript: - currITutorialStep = iTutorialSteps.TerminalFree; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalFree: - currITutorialStep = iTutorialSteps.TerminalRunScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalRunScript: - currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalGoToActiveScriptsPage: - document.getElementById("active-scripts-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.ActiveScriptsPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.ActiveScriptsPage: - document.getElementById("terminal-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.ActiveScriptsToTerminal: - currITutorialStep = iTutorialSteps.TerminalTailScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalTailScript: - currITutorialStep = iTutorialSteps.GoToHacknetNodesPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.GoToHacknetNodesPage: - document.getElementById("hacknet-nodes-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.HacknetNodesIntroduction; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.HacknetNodesIntroduction: - currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.HacknetNodesGoToWorldPage: - document.getElementById("city-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.WorldDescription; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.WorldDescription: - document.getElementById("tutorial-menu-link").removeAttribute("class"); - currITutorialStep = iTutorialSteps.TutorialPageInfo; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TutorialPageInfo: - currITutorialStep = iTutorialSteps.End; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.End: - break; - default: - throw new Error("Invalid tutorial step"); - } -} - -//Go to previous step and evaluate -function iTutorialPrevStep() { - switch(currITutorialStep) { - case iTutorialSteps.Start: - currITutorialStep = iTutorialSteps.Start; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.GoToCharacterPage: - currITutorialStep = iTutorialSteps.Start; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.CharacterPage: - currITutorialStep = iTutorialSteps.GoToCharacterPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.CharacterGoToTerminalPage: - currITutorialStep = iTutorialSteps.CharacterPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalIntro: - currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalHelp: - currITutorialStep = iTutorialSteps.TerminalIntro; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalLs: - currITutorialStep = iTutorialSteps.TerminalHelp; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalScan: - currITutorialStep = iTutorialSteps.TerminalLs; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalConnect: - currITutorialStep = iTutorialSteps.TerminalScan; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalAnalyze: - currITutorialStep = iTutorialSteps.TerminalConnect; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalNuke: - currITutorialStep = iTutorialSteps.TerminalAnalyze; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalManualHack: - currITutorialStep = iTutorialSteps.TerminalNuke; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalHackingMechanics: - currITutorialStep = iTutorialSteps.TerminalManualHack; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalCreateScript: - currITutorialStep = iTutorialSteps.TerminalManualHack; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalTypeScript: - currITutorialStep = iTutorialSteps.TerminalCreateScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalFree: - currITutorialStep = iTutorialSteps.TerminalTypeScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalRunScript: - currITutorialStep = iTutorialSteps.TerminalFree; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalGoToActiveScriptsPage: - currITutorialStep = iTutorialSteps.TerminalRunScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.ActiveScriptsPage: - currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.ActiveScriptsToTerminal: - currITutorialStep = iTutorialSteps.ActiveScriptsPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TerminalTailScript: - currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.GoToHacknetNodesPage: - currITutorialStep = iTutorialSteps.TerminalTailScript; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.HacknetNodesIntroduction: - currITutorialStep = iTutorialSteps.GoToHacknetNodesPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.HacknetNodesGoToWorldPage: - currITutorialStep = iTutorialSteps.HacknetNodesIntroduction; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.WorldDescription: - currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.TutorialPageInfo: - currITutorialStep = iTutorialSteps.WorldDescription; - iTutorialEvaluateStep(); - break; - case iTutorialSteps.End: - break; - default: - throw new Error("Invalid tutorial step"); - } -} - -function iTutorialEnd() { - //Re-enable auto save - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].Counters.autoSaveCounter = 300; - console.log("Ending interactive tutorial"); - __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].init(); - currITutorialStep = iTutorialSteps.End; - iTutorialIsRunning = false; - document.getElementById("interactive-tutorial-container").style.display = "none"; - Object(__WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__["a" /* dialogBoxCreate */])("If you are new to the game, the following links may be useful for you!

" + - "Getting Started Guide" + - "Wiki

" + - "The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. " + - "To read it, go to Terminal and enter

cat hackers-starting-handbook.lit"); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().messages.push("hackers-starting-handbook.lit"); -} - -function iTutorialSetText(txt) { - var textBox = document.getElementById("interactive-tutorial-text"); - if (textBox == null) {throw new Error("Could not find text box"); return;} - textBox.innerHTML = txt; - textBox.parentElement.scrollTop = 0; // this resets scroll position -} - - - - -/***/ }), -/* 34 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return makeRuntimeRejectMsg; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return netscriptDelay; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return runScriptFromScript; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return scriptCalculateHackingChance; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return scriptCalculateHackingTime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return scriptCalculateExpGain; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return scriptCalculatePercentMoneyHacked; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return scriptCalculateGrowTime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return scriptCalculateWeakenTime; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return evaluate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isScriptErrorMessage; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return killNetscriptDelay; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return evaluateImport; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(35); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Script_js__ = __webpack_require__(22); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(39); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__ = __webpack_require__(5); - - - - - - - - - - - - - - -var Promise = __webpack_require__(69); - -Promise.config({ - warnings: false, - longStackTraces: false, - cancellation: true, - monitoring: false -}); -/* Evaluator - * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser - * - * Returns a promise - */ -function evaluate(exp, workerScript) { - return Promise.delay(__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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)); - } - if (env.stopFlag) {return Promise.reject(workerScript);} +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return FconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createFconf; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return parseFconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return loadFconf; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_acorn_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__utils_acorn_js__); + + +var FconfSettings = { + ENABLE_BASH_HOTKEYS: false +} + +var FconfComments = { + ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" + + "new Terminal shortcuts and features that more closely resemble\n" + + "a real Bash-style shell. Note that when this mode is enabled,\n" + + "the default browser shortcuts are overriden by the new Bash\n" + + "shortcuts.\n\n" + + "To see a full list of the Terminal shortcuts that this enables, see:\n" + + "http://bitburner.readthedocs.io/en/latest/shortcuts.html", +} + +//Parse Fconf settings from the config text +//Throws an exception if parsing fails +function parseFconfSettings(config) { + var ast = Object(__WEBPACK_IMPORTED_MODULE_0__utils_acorn_js__["parse"])(config, {sourceType:"module"}); + var queue = []; + queue.push(ast); + while (queue.length != 0) { + var exp = queue.shift(); 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(e)) { - workerScript.errorMessage = e; - return Promise.reject(workerScript); - } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]) { - return Promise.reject(e); - } else { - return Promise.reject(workerScript); + for (var i = 0; i < exp.body.length; ++i) { + if (exp.body[i] instanceof __WEBPACK_IMPORTED_MODULE_0__utils_acorn_js__["Node"]) { + queue.push(exp.body[i]); } - }); - 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 __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(e)) { - return Promise.reject(makeRuntimeRejectMsg(workerScript, e)); - } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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)); - } - } - } - }); - }); - 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 "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)); - } + var setting, value; + if (exp.left != null && exp.left.name != null) { + setting = exp.left.name; } else { - return Promise.reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier", exp)); + break; } - 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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); + if (exp.right != null && exp.right.raw != null) { + value = exp.right.raw; } 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 Promise.reject(makeRuntimeRejectMsg(workerScript)) - 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 == true && exp.operator === "||") { - return Promise.resolve(true); - } - if (expLeft == false && exp.operator === "&&") { - return Promise.resolve(false); - } - 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": - return Promise.resolve(expLeft>expRight); - break; - case ">=": - return Promise.resolve(expLeft>=expRight); - break; - case "+": - return Promise.resolve(expLeft+expRight); - break; - case "-": - return Promise.resolve(expLeft-expRight); - break; - case "*": - return Promise.resolve(expLeft*expRight); - break; - case "/": - if (expRight === 0) { - return Promise.reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero")); - } else { - return Promise.resolve(expLeft/expRight); - } - break; - case "%": - return Promise.resolve(expLeft%expRight); - break; - case "in": - return Promise.resolve(expLeft in expRight); - break; - case "instanceof": - return Promise.resolve(expLeft instanceof expRight); - break; - case "||": - return Promise.resolve(expLeft || expRight); - break; - case "&&": - return Promise.resolve(expLeft && expRight); - break; - default: - return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unsupported operator: " + exp.operator)); - } - }); - }); -} - -function evalUnary(exp, workerScript){ - var env = workerScript.env; - if (env.stopFlag) {return Promise.reject(workerScript);} - return evaluate(exp.argument, workerScript).then(function(res) { - if (exp.operator == "!") { - return Promise.resolve(!res); - } else if (exp.operator == "-") { - if (isNaN(res)) { - return Promise.resolve(res); - } else { - return Promise.resolve(-1 * res); - } - } else { - return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator)); - } - }); -} - -//Takes in a MemberExpression that should represent a Netscript array (possible multidimensional) -//The return value is an array of the form: -// [0th index (leftmost), array name, 1st index, 2nd index, ...] -function getArrayElement(exp, workerScript) { - var indices = []; - return evaluate(exp.property, workerScript).then(function(idx) { - if (isNaN(idx)) { - return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx)); - } else { - if (exp.object.name === undefined && exp.object.object) { - return getArrayElement(exp.object, workerScript).then(function(res) { - res.push(idx); - indices = res; - return Promise.resolve(indices); - }).catch(function(e) { - return Promise.reject(e); - }); - } else { - indices.push(idx); - indices.push(exp.object.name); - return Promise.resolve(indices); - } - } - }); -} - -function evalAssignment(exp, workerScript) { - var env = workerScript.env; - if (env.stopFlag) {return Promise.reject(workerScript);} - - if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") { - return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left))); - } - - 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 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 evaluateImport(exp, workerScript, checkingRam=false) { - //When its checking RAM, it exports an array of nodes for each imported function - var ramCheckRes = []; - - var env = workerScript.env; - if (env.stopFlag) { - if (checkingRam) {return ramCheckRes;} - return Promise.reject(workerScript); - } - - //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); - } - } - - //Get the code - var server = Object(__WEBPACK_IMPORTED_MODULE_5__Server_js__["e" /* 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)); - } - - //Create the AST - try { - var ast = Object(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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; } + parseFconfSetting(setting, value); break; default: break; } - for (var prop in node) { - if (node.hasOwnProperty(prop)) { - if (node[prop] instanceof __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["Node"]) { - queue.push(node[prop]); + for (var prop in exp) { + if (exp.hasOwnProperty(prop)) { + if (exp[prop] instanceof __WEBPACK_IMPORTED_MODULE_0__utils_acorn_js__["Node"]) { + queue.push(exp[prop]); } } } } - if (!checkingRam) {workerScript.scriptRef.log("Imported functions from " + scriptName);} - if (checkingRam) {return ramCheckRes;} - return Promise.resolve(true); } -function killNetscriptDelay(workerScript) { - if (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__Script_js__["d" /* 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(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* 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 - workerScript.scriptRef.log("Running script: " + scriptname + " on " + server.hostname + " with " + threads + " threads and args: " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__["j" /* printArray */])(args) + ". May take a few seconds to start up..."); - var runningScriptObj = new __WEBPACK_IMPORTED_MODULE_7__Script_js__["b" /* RunningScript */](script, args); - runningScriptObj.threads = threads; - server.runningScripts.push(runningScriptObj); //Push onto runningScripts - Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["g" /* isString */])(msg)) {return false;} - let splitMsg = msg.split("|"); - if (splitMsg.length != 4){ - return false; - } - var ip = splitMsg[1]; - if (!Object(__WEBPACK_IMPORTED_MODULE_10__utils_IPAddress_js__["c" /* 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 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill) + (0.2 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence); - var skillChance = (skillMult - server.requiredHackingSkill) / skillMult; - var chance = skillChance * difficultyMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var hackingTime = 5 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_exp_mult * 0.3 + 3) * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* 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 = (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill - (server.requiredHackingSkill - 1)) / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill; - var percentMoneyHacked = difficultyMult * skillMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_money_mult / 240; - if (percentMoneyHacked < 0) {return 0;} - if (percentMoneyHacked > 1) {return 1;} - return percentMoneyHacked * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var growTime = 16 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); - var weakenTime = 20 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds - return weakenTime * 1000; -} - - - - -/***/ }), -/* 35 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Environment; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HacknetNode_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__NetscriptPort_js__ = __webpack_require__(38); - - - - -/* 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(__WEBPACK_IMPORTED_MODULE_1__NetscriptFunctions_js__["a" /* NetscriptFunctions */])(workerScript); - } - this.parent = parent; - this.stopFlag = false; -} -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 __WEBPACK_IMPORTED_MODULE_0__HacknetNode_js__["a" /* HacknetNode */]) { - throw new Error("Cannot assign a Hacknet Node handle to a new value"); - } - if (res[idx[idx.length-1]] instanceof __WEBPACK_IMPORTED_MODULE_2__NetscriptPort_js__["a" /* 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; - } -}; - - - - -/***/ }), -/* 36 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return prestigeAugmentation; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return prestigeSourceFile; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Company_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__engine_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Gang_js__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Location_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Message_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__ = __webpack_require__(23); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__StockMarket_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Terminal_js__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_17__utils_decimal_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__utils_DialogBox_js__ = __webpack_require__(1); - - - - - - - - - - - - - - - - - - - - - -//Prestige by purchasing augmentation -function prestigeAugmentation() { - Object(__WEBPACK_IMPORTED_MODULE_2__BitNode_js__["c" /* initBitNodeMultipliers */])(); - - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].prestigeAugmentation(); - - //Delete all Worker Scripts objects - Object(__WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__["e" /* prestigeWorkerScripts */])(); - - var homeComp = __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].getHomeComputer(); - //Delete all servers except home computer - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["h" /* prestigeAllServers */])(); - - //Delete Special Server IPs - Object(__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["e" /* prestigeSpecialServerIps */])(); //Must be done before initForeignServers() - - //Reset home computer (only the programs) and add to AllServers - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["a" /* AddToAllServers */])(homeComp); - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["i" /* prestigeHomeComputer */])(homeComp); - - if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].Neurolink) && - __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].Neurolink].owned) { - homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); - homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); - } - if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].CashRoot) && - __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].CashRoot].owned) { - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].setMoney(new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(1000000)); - homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); - } - - //Re-create foreign servers - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["f" /* initForeignServers */])(); - - //Darkweb is purchase-able - document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); - - //Gain favor for Companies - for (var member in __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */]) { - if (__WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */].hasOwnProperty(member)) { - __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */][member].gainFavor(); - } - } - - //Gain favor for factions - for (var member in __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */]) { - if (__WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */].hasOwnProperty(member)) { - __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][member].gainFavor(); - } - } - - //Stop a Terminal action if there is onerror - if (__WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress) { - __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress = false; - __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].finishAction(true); - } - - //Re-initialize things - This will update any changes - Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["f" /* initFactions */])(); //Factions must be initialized before augmentations - Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["g" /* initAugmentations */])(); //Calls reapplyAllAugmentations() and resets Player multipliers - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].reapplyAllSourceFiles(); - Object(__WEBPACK_IMPORTED_MODULE_3__Company_js__["h" /* initCompanies */])(); - - //Clear terminal - $("#terminal tr:not(:last)").remove(); - Object(__WEBPACK_IMPORTED_MODULE_16__Terminal_js__["c" /* postNetburnerText */])(); - - //Messages - Object(__WEBPACK_IMPORTED_MODULE_9__Message_js__["d" /* initMessages */])(); - - //Reset Stock market - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["g" /* initStockMarket */])(); - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["i" /* initSymbolToStockMap */])(); - } - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["m" /* setStockMarketContentCreated */])(false); - var stockMarketList = document.getElementById("stock-market-list"); - while(stockMarketList.firstChild) { - stockMarketList.removeChild(stockMarketList.firstChild); - } - - //Gang, in BitNode 2 - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN == 2 && __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].inGang()) { - var faction = __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gang.facName]; - if (faction instanceof __WEBPACK_IMPORTED_MODULE_6__Faction_js__["a" /* Faction */]) { - Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["h" /* joinFaction */])(faction); - } - } - - //BitNode 8: Ghost of Wall Street - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 8) {__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].money = new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(100e6);} - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 8 || __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__["e" /* hasWallStreetSF */]) { - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount = true; - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasTixApiAccess = true; - } - - var mainMenu = document.getElementById("mainmenu-container"); - mainMenu.style.visibility = "visible"; - __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].resetTerminalInput(); - __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"].loadTerminalContent(); - - //Red Pill - if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].TheRedPill) && - __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].TheRedPill].owned) { - var WorldDaemon = __WEBPACK_IMPORTED_MODULE_13__Server_js__["b" /* AllServers */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["a" /* SpecialServerIps */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["b" /* SpecialServerNames */].WorldDaemon]]; - var DaedalusServer = __WEBPACK_IMPORTED_MODULE_13__Server_js__["b" /* AllServers */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["a" /* SpecialServerIps */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["b" /* SpecialServerNames */].DaedalusServer]]; - if (WorldDaemon && DaedalusServer) { - WorldDaemon.serversOnNetwork.push(DaedalusServer.ip); - DaedalusServer.serversOnNetwork.push(WorldDaemon.ip); - } - } -} - - -//Prestige by destroying Bit Node and gaining a Source File -function prestigeSourceFile() { - Object(__WEBPACK_IMPORTED_MODULE_2__BitNode_js__["c" /* initBitNodeMultipliers */])(); - - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].prestigeSourceFile(); - Object(__WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__["e" /* prestigeWorkerScripts */])(); //Delete all Worker Scripts objects - - var homeComp = __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].getHomeComputer(); - - //Delete all servers except home computer - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["h" /* prestigeAllServers */])(); //Must be done before initForeignServers() - - //Delete Special Server IPs - Object(__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["e" /* prestigeSpecialServerIps */])(); - - //Reset home computer (only the programs) and add to AllServers - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["a" /* AddToAllServers */])(homeComp); - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["i" /* prestigeHomeComputer */])(homeComp); - - //Re-create foreign servers - Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["f" /* initForeignServers */])(); - - var srcFile1Owned = false; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].sourceFiles.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].sourceFiles[i].n == 1) { - srcFile1Owned = true; - } - } - if (srcFile1Owned) { - homeComp.setMaxRam(32); - } else { - homeComp.setMaxRam(8); - } - homeComp.cpuCores = 1; - - //Darkweb is purchase-able - document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); - - //Reset favor for Companies - for (var member in __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */]) { - if (__WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */].hasOwnProperty(member)) { - __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */][member].favor = 0; - } - } - - //Reset favor for factions - for (var member in __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */]) { - if (__WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */].hasOwnProperty(member)) { - __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][member].favor = 0; - } - } - - //Stop a Terminal action if there is one - if (__WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress) { - __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress = false; - __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].finishAction(true); - } - - //Delete all Augmentations - for (var name in __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */]) { - if (__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */].hasOwnProperty(name)) { - delete __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; - } - } - - //Re-initialize things - This will update any changes - Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["f" /* initFactions */])(); //Factions must be initialized before augmentations - Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["g" /* initAugmentations */])(); //Calls reapplyAllAugmentations() and resets Player multipliers - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].reapplyAllSourceFiles(); - Object(__WEBPACK_IMPORTED_MODULE_3__Company_js__["h" /* initCompanies */])(); - - //Clear terminal - $("#terminal tr:not(:last)").remove(); - Object(__WEBPACK_IMPORTED_MODULE_16__Terminal_js__["c" /* postNetburnerText */])(); - - //Messages - Object(__WEBPACK_IMPORTED_MODULE_9__Message_js__["d" /* initMessages */])(); - - var mainMenu = document.getElementById("mainmenu-container"); - mainMenu.style.visibility = "visible"; - __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].resetTerminalInput(); - __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"].loadTerminalContent(); - - //Reinitialize Bit Node flags - Object(__WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__["f" /* initSingularitySFFlags */])(); - - //Reset Stock market, gang, and corporation - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["g" /* initStockMarket */])(); - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["i" /* initSymbolToStockMap */])(); - } - Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["m" /* setStockMarketContentCreated */])(false); - var stockMarketList = document.getElementById("stock-market-list"); - while(stockMarketList.firstChild) { - stockMarketList.removeChild(stockMarketList.firstChild); - } - - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gang = null; - Object(__WEBPACK_IMPORTED_MODULE_7__Gang_js__["c" /* deleteGangDisplayContent */])(); - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].corporation = null; - - //BitNode 3: Corporatocracy - if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 3) { - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].money = new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(150e9); - homeComp.messages.push("corporation-management-handbook.lit"); - Object(__WEBPACK_IMPORTED_MODULE_18__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You received a copy of the Corporation Management Handbook on your home computer. " + - "Read it if you need help getting started with Corporations!"); - } - - //Gain int exp - __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gainIntelligenceExp(5); -} - - - -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) - -/***/ }), -/* 37 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SourceFiles; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return PlayerOwnedSourceFile; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return applySourceFile; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initSourceFiles; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); - - - -/* SourceFile.js */ -//Each SourceFile corresponds to a BitNode with the same number -function SourceFile(number, info="") { - var bitnodeKey = "BitNode" + number; - var bitnode = __WEBPACK_IMPORTED_MODULE_1__BitNode_js__["b" /* BitNodes */][bitnodeKey]; - if (bitnode == null) { - throw new Error("Invalid Bit Node for this Source File"); - } - - this.n = number; - this.name = "Source-File " + number + ": " + bitnode.name; - this.lvl = 1; - this.info = info; - this.owned = false; -} - -let SourceFiles = {}; -function initSourceFiles() { - SourceFiles = {}; - SourceFiles["SourceFile1"] = new SourceFile(1, "This Source-File lets the player start with 32GB of RAM on his/her " + - "home computer. It also increases all of the player's multipliers by:

" + - "Level 1: 16%
" + - "Level 2: 24%
" + - "Level 3: 28%"); - SourceFiles["SourceFile2"] = new SourceFile(2, "This Source-File increases the player's crime success rate, crime money, and charisma " + - "multipliers by:

" + - "Level 1: 20%
" + - "Level 2: 30%
" + - "Level 3: 35%"); - SourceFiles["SourceFile3"] = new SourceFile(3,"This Source-File lets you create corporations on other BitNodes (although " + - "some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by:
" + - "Level 1: 8%
" + - "Level 2: 12%
" + - "Level 3: 14%"); - SourceFiles["SourceFile4"] = new SourceFile(4, "This Source-File lets you access and use the Singularity Functions in every BitNode. Every " + - "level of this Source-File opens up more of the Singularity Functions you can use."); - SourceFiles["SourceFile5"] = new SourceFile(5, "This Source-File grants a special new stat called Intelligence. Intelligence " + - "is unique because it is permanent and persistent (it never gets reset back to 1). However, " + - "gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't " + - "know when you gain experience and how much). Higher Intelligence levels will boost your production " + - "for many actions in the game. In addition, this Source-File will unlock the getBitNodeMultipliers() " + - "Netscript function, and will raise all of your hacking-related multipliers by:

" + - "Level 1: 4%
" + - "Level 2: 6%
" + - "Level 3: 7%"); - SourceFiles["SourceFile6"] = new SourceFile(6); - SourceFiles["SourceFile7"] = new SourceFile(7); - SourceFiles["SourceFile8"] = new SourceFile(8, "This Source-File grants the following benefits:

" + - "Level 1: Permanent access to WSE and TIX API
" + - "Level 2: Ability to short stocks in other BitNodes
" + - "Level 3: Ability to use limit/stop orders in other BitNodes

" + - "This Source-File also increases your hacking growth multipliers by: " + - "
Level 1: 8%
Level 2: 12%
Level 3: 14%"); - SourceFiles["SourceFile9"] = new SourceFile(9); - SourceFiles["SourceFile10"] = new SourceFile(10); - SourceFiles["SourceFile11"] = new SourceFile(11, "This Source-File makes it so that company favor increases BOTH the player's salary and reputation gain rate " + - "at that company by 1% per favor (rather than just the reputation gain). This Source-File also " + - " increases the player's company salary and reputation gain multipliers by:

" + - "Level 1: 24%
" + - "Level 2: 36%
" + - "Level 3: 42%
"); - SourceFiles["SourceFile12"] = new SourceFile(12); -} - -function PlayerOwnedSourceFile(number, level) { - this.n = number; - this.lvl = level; -} - -//Takes in a PlayerOwnedSourceFile as the "srcFile" argument -function applySourceFile(srcFile) { - var srcFileKey = "SourceFile" + srcFile.n; - var sourceFileObject = SourceFiles[srcFileKey]; - if (sourceFileObject == null) { - console.log("ERROR: Invalid source file number: " + srcFile.n); +function parseFconfSetting(setting, value) { + setting = String(setting); + value = String(value); + if (setting == null || value == null || FconfSettings[setting] == null) { + console.log("WARNING: Invalid .fconf setting: " + setting); return; } - switch(srcFile.n) { - case 1: // The Source Genesis - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (16 / (Math.pow(2, i))); + //Needed to convert entered value to boolean/strings accordingly + switch(setting) { + case "ENABLE_BASH_HOTKEYS": + var value = value.toLowerCase(); + if (value === "1" || value === "true" || value === "y") { + value = true; + } else { + value = false; } - var incMult = 1 + (mult / 100); - var decMult = 1 - (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_chance_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_speed_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].strength_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].defense_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].dexterity_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].agility_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].strength_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].defense_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].dexterity_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].agility_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_exp_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].company_rep_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].faction_rep_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_success_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= decMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_ram_cost_mult *= decMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_core_cost_mult *= decMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= decMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; - break; - case 2: //Rise of the Underworld - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (20 / (Math.pow(2, i))); - } - var incMult = 1 + (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_success_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; - break; - case 3: //Corporatocracy - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (8 / (Math.pow(2, i))); - } - var incMult = 1 + (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; - break; - case 4: //The Singularity - //No effects, just gives access to Singularity functions - break; - case 5: //Artificial Intelligence - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (4 / (Math.pow(2, i))); - } - var incMult = 1 + (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_chance_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_speed_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_exp_mult *= incMult; - break; - case 8: //Ghost of Wall Street - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (8 / (Math.pow(2, i))); - } - var incMult = 1 + (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; - break; - case 11: //The Big Crash - var mult = 0; - for (var i = 0; i < srcFile.lvl; ++i) { - mult += (24 / (Math.pow(2, i))); - } - var incMult = 1 + (mult / 100); - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; - __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].company_rep_mult *= incMult; + FconfSettings[setting] = value; break; default: - console.log("ERROR: Invalid source file number: " + srcFile.n); break; } + return; +} - sourceFileObject.owned = true; +//Create the .fconf file text from the settings +function createFconf() { + var res = ""; + for (var setting in FconfSettings) { + if (FconfSettings.hasOwnProperty(setting)) { + //Setting comments (description) + var comment = FconfComments[setting]; + if (comment == null) {continue;} + var comment = comment.split("\n"); + for (var i = 0; i < comment.length; ++i) { + res += ("//" + comment[i] + "\n"); + } + + var value = 0; + if (FconfSettings[setting] === true) { + value = "1"; + } else if (FconfSettings[setting] === false) { + value = "0"; + } else { + value = String(FconfSettings[setting]); + } + res += (setting + "=" + value + "\n"); + } + } + return res; +} + +function loadFconf(saveString) { + FconfSettings = JSON.parse(saveString); } /***/ }), -/* 38 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NetscriptPort; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Settings_js__ = __webpack_require__(12); - - -function NetscriptPort() { - this.data = []; -} - -NetscriptPort.prototype.write = function(data) { - this.data.push(data); - if (this.data.length > __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* Settings */].MaxPortCapacity) { - return this.data.shift(); - } - return null; -} - -NetscriptPort.prototype.tryWrite = function(data) { - if (this.data.length >= __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* 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 == __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* Settings */].MaxPortCapacity; -} - -NetscriptPort.prototype.empty = function() { - return this.data.length === 0; -} - -NetscriptPort.prototype.clear = function() { - this.data.length = 0; -} - - - - -/***/ }), -/* 39 */ +/* 40 */ /***/ (function(module, exports, __webpack_require__) { /* @@ -52558,90 +44152,6946 @@ Object.defineProperty(exports, '__esModule', { value: true }); }))); -/***/ }), -/* 40 */ -/***/ (function(module, exports) { - -var g; - -// This works in non-strict mode -g = (function() { - return this; -})(); - -try { - // This works if eval is allowed (see CSP) - g = g || Function("return this")() || (1,eval)("this"); -} catch(e) { - // This works if the window reference is available - if(typeof window === "object") - g = window; -} - -// g can still be undefined, but nothing to do about it... -// We return undefined, instead of nothing here, so it's -// easier to handle this case. if(!global) { ...} - -module.exports = g; - - /***/ }), /* 41 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return gameOptionsBoxOpen; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return gameOptionsBoxClose; }); -/* GameOptions.js */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return iTutorialSteps; }); +/* unused harmony export iTutorialEnd */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return iTutorialStart; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return iTutorialNextStep; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return currITutorialStep; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return iTutorialIsRunning; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__ = __webpack_require__(2); -//Close box when clicking outside -$(document).click(function(event) { - if (gameOptionsOpened) { - if ( $(event.target).closest(".game-options-box").get(0) == null ) { - gameOptionsBoxClose(); + + + + +/* InteractiveTutorial.js */ +let iTutorialSteps = { + Start: "Start", + GoToCharacterPage: "Click on the Character page menu link", + CharacterPage: "Introduction to Character page", + CharacterGoToTerminalPage: "Click on the Terminal link", + TerminalIntro: "Introduction to terminal interface", + TerminalHelp: "Using the help command to display all options in terminal", + TerminalLs: "Use the ls command to show all programs/scripts. Right now we have NUKE.exe", + TerminalScan: "Using the scan command to display all available connections", + TerminalScanAnalyze1: "Use the scan-analyze command to show hacking related information", + TerminalScanAnalyze2: "Use the scan-analyze command with a depth of 3", + TerminalConnect: "Using the telnet/connect command to connect to another server", + TerminalAnalyze: "Use the analyze command to display details about this server", + TerminalNuke: "Use the NUKE Program to gain root access to a server", + TerminalManualHack: "Use the hack command to manually hack a server", + TerminalHackingMechanics: "Briefly explain hacking mechanics", + TerminalCreateScript: "Create a script using nano", + TerminalTypeScript: "This occurs in the Script Editor page...type the script then save and close", + TerminalFree: "Use the free command to check RAM", + TerminalRunScript: "Use the run command to run a script", + TerminalGoToActiveScriptsPage: "Go to the ActiveScriptsPage", + ActiveScriptsPage: "Introduction to the Active Scripts Page", + ActiveScriptsToTerminal: "Go from Active Scripts Page Back to Terminal", + TerminalTailScript: "Use the tail command to show a script's logs", + GoToHacknetNodesPage: "Go to the Hacknet Nodes page", + HacknetNodesIntroduction: "Introduction to Hacknet Nodesm and have user purchase one", + HacknetNodesGoToWorldPage: "Go to the world page", + WorldDescription: "Tell the user to explore..theres a lot of different stuff to do out there", + TutorialPageInfo: "The tutorial page contains a lot of info on different subjects", + End: "End", +} + +var currITutorialStep = iTutorialSteps.Start; +var iTutorialIsRunning = false; + +function iTutorialStart() { + //Don't autosave during this interactive tutorial + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].Counters.autoSaveCounter = 999000000000; + console.log("Interactive Tutorial started"); + currITutorialStep = iTutorialSteps.Start; + iTutorialIsRunning = true; + + document.getElementById("interactive-tutorial-container").style.display = "block"; + + iTutorialEvaluateStep(); + + //Exit tutorial button + var exitButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-exit"); + exitButton.addEventListener("click", function() { + iTutorialEnd(); + return false; + }); + + //Back button + var backButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-back"); + backButton.style.display = "none"; + backButton.addEventListener("click", function() { + iTutorialPrevStep(); + return false; + }); +} + +function iTutorialEvaluateStep() { + if (!iTutorialIsRunning) {console.log("Interactive Tutorial not running"); return;} + switch(currITutorialStep) { + case iTutorialSteps.Start: + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); + + iTutorialSetText("Welcome to Bitburner, a cyberpunk-themed incremental RPG! " + + "The game takes place in a dark, dystopian future...The year is 2077...

" + + "This tutorial will show you the basics of the game. " + + "You may skip the tutorial at any time."); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.GoToCharacterPage: + iTutorialSetText("Let's start by heading to the Stats page. Click the 'Stats' tab on " + + "the main navigation menu (left-hand side of the screen)"); + + //No next button + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "none"; + + //Flash Character tab + document.getElementById("stats-menu-link").setAttribute("class", "flashing-button"); + + //Initialize everything necessary to open the "Character" page + var charaterMainMenuButton = document.getElementById("stats-menu-link"); + charaterMainMenuButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadCharacterContent(); + iTutorialNextStep(); //Opening the character page will go to the next step + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stats-menu-link"); + return false; + }); + break; + case iTutorialSteps.CharacterPage: + iTutorialSetText("The Stats page shows a lot of important information about your progress, " + + "such as your skills, money, and bonuses/multipliers. ") + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.CharacterGoToTerminalPage: + iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " + + "main navigation menu."); + //No next button + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "none"; + + document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); + + //Initialize everything necessary to open the 'Terminal' Page + var terminalMainMenuButton = document.getElementById("terminal-menu-link"); + terminalMainMenuButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); + return false; + }); + break; + case iTutorialSteps.TerminalIntro: + iTutorialSetText("The Terminal is used to interface with your home computer as well as " + + "all of the other machines around the world."); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.TerminalHelp: + iTutorialSetText("Let's try it out. Start by entering the 'help' command into the Terminal " + + "(Don't forget to press Enter after typing the command)"); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "none"; + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalLs: + iTutorialSetText("The 'help' command displays a list of all available Terminal commands, how to use them, " + + "and a description of what they do.

Let's try another command. Enter the 'ls' command"); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalScan: + iTutorialSetText("'ls' is a basic command that shows all of the contents (programs/scripts) " + + "on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " + + "We'll get to what this does later.

Using your home computer's terminal, you can connect " + + "to other machines throughout the world. Let's do that now by first entering " + + "the 'scan' command. "); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalScanAnalyze1: + iTutorialSetText("The 'scan' command shows all available network connections. In other words, " + + "it displays a list of all servers that can be connected to from your " + + "current machine. A server is identified by either its IP or its hostname.

" + + "That's great and all, but there's so many servers. Which one should you go to? " + + "The 'scan-analyze' command gives some more detailed information about servers on the " + + "network. Try it now"); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalScanAnalyze2: + iTutorialSetText("You just ran 'scan-analyze' with a depth of one. This command shows more detailed " + + "information about each server that you can connect to (servers that are a distance of " + + "one node away).

It is also possible to run 'scan-analyze' with " + + "a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.") + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalConnect: + iTutorialSetText("Now you can see information about all servers that are up to two nodes away, as well " + + "as figure out how to navigate to those servers through the network. You can only connect to " + + "a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " + + "the ip or the hostname, but dont use both.

" + + "From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is " + + "only one node away. Let's connect so it now using: 'connect foodnstuff'"); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalAnalyze: + iTutorialSetText("You are now connected to another machine! What can you do now? You can hack it!

In the year 2077, currency has " + + "become digital and decentralized. People and corporations store their money " + + "on servers and computers. Using your hacking abilities, you can hack servers " + + "to steal money and gain experience.

" + + "Before you try to hack a server, you should run diagnostics using the 'analyze' command"); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalNuke: + iTutorialSetText("When the 'analyze' command finishes running it will show useful information " + + "about hacking the server.

For this server, the required hacking skill is only 1, " + + "which means you can hack it right now. However, in order to hack a server " + + "you must first gain root access. The 'NUKE.exe' program that we saw earlier on your " + + "home computer is a virus that will grant you root access to a machine if there are enough " + + "open ports.

The 'analyze' results shows that there do not need to be any open ports " + + "on this machine for the NUKE virus to work, so go ahead and run the virus using the " + + "'run NUKE.exe' command."); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalManualHack: + iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " + + "Try doing that now."); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalHackingMechanics: + iTutorialSetText("You are now attempting to hack the server. Note that performing a hack takes time and " + + "only has a certain percentage chance " + + "of success. This time and success chance is determined by a variety of factors, including " + + "your hacking skill and the server's security level.

" + + "If your attempt to hack the server is successful, you will steal a certain percentage " + + "of the server's total money. This percentage is affected by your hacking skill and " + + "the server's security level.

The amount of money on a server is not limitless. So, if " + + "you constantly hack a server and deplete its money, then you will encounter " + + "diminishing returns in your hacking."); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.TerminalCreateScript: + iTutorialSetText("Hacking is the core mechanic of the game and is necessary for progressing. However, " + + "you don't want to be hacking manually the entire time. You can automate your hacking " + + "by writing scripts!

To create a new script or edit an existing one, you can use the 'nano' " + + "command. Scripts must end with the '.script' extension. Let's make a script now by " + + "entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c" + + " will end a command like hack early)"); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "none"; + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalTypeScript: + iTutorialSetText("This is the script editor. You can use it to program your scripts. Scripts are " + + "written in the Netscript language, a programming language created for " + + "this game. There are details about the Netscript language in the documentation, which " + + "can be accessed in the 'Tutorial' tab on the main navigation menu. I highly suggest you check " + + "it out after this tutorial. For now, just copy " + + "and paste the following code into the script editor:

" + + "while(true) {
" + + "  hack('foodnstuff');
" + + "}

" + + "For anyone with basic programming experience, this code should be straightforward. " + + "This script will continuously hack the 'foodnstuff' server.

" + + "To save and close the script editor, press the button in the bottom left, or press ctrl + b."); + //next step triggered in saveAndCloseScriptEditor() (Script.js) + break; + case iTutorialSteps.TerminalFree: + iTutorialSetText("Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " + + "run on any machine which you have root access to. Different servers have different " + + "amounts of RAM. You can also purchase more RAM for your home server.

To check how much " + + "RAM is available on this machine, enter the 'free' command."); + //next step triggered by terminal commmand + break; + case iTutorialSteps.TerminalRunScript: + iTutorialSetText("We have 16GB of free RAM on this machine, which is enough to run our " + + "script. Let's run our script using 'run foodnstuff.script'."); + //next step triggered by terminal commmand + break; + case iTutorialSteps.TerminalGoToActiveScriptsPage: + iTutorialSetText("Your script is now running! The script might take a few seconds to 'fully start up'. " + + "Your scripts will continuously run in the background and will automatically stop if " + + "the code ever completes (the 'foodnstuff.script' will never complete because it " + + "runs an infinite loop).

These scripts can passively earn you income and hacking experience. " + + "Your scripts will also earn money and experience while you are offline, although at a " + + "much slower rate.

" + + "Let's check out some statistics for our running scripts by clicking the " + + "'Active Scripts' link in the main navigation menu."); + document.getElementById("active-scripts-menu-link").setAttribute("class", "flashing-button"); + var activeScriptsMainMenuButton = document.getElementById("active-scripts-menu-link"); + activeScriptsMainMenuButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadActiveScriptsContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("active-scripts-menu-link"); + return false; + }); + break; + case iTutorialSteps.ActiveScriptsPage: + iTutorialSetText("This page displays stats/information about all of your scripts that are " + + "running across every existing server. You can use this to gauge how well " + + "your scripts are doing. Let's go back to the Terminal now using the 'Terminal'" + + "link."); + document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); + //Initialize everything necessary to open the 'Terminal' Page + var terminalMainMenuButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); + terminalMainMenuButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTerminalContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("terminal-menu-link"); + return false; + }); + break; + case iTutorialSteps.ActiveScriptsToTerminal: + iTutorialSetText("One last thing about scripts, each active script contains logs that detail " + + "what it's doing. We can check these logs using the 'tail' command. Do that " + + "now for the script we just ran by typing 'tail foodnstuff.script'"); + //next step triggered by terminal command + break; + case iTutorialSteps.TerminalTailScript: + iTutorialSetText("The log for this script won't show much right now (it might show nothing at all) because it " + + "just started running...but check back again in a few minutes!

" + + "This pretty much covers the basics of hacking. To learn more about writing " + + "scripts using the Netscript language, select the 'Tutorial' link in the " + + "main navigation menu to look at the documentation. For now, let's move on " + + "to something else!"); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.GoToHacknetNodesPage: + iTutorialSetText("Hacking is not the only way to earn money. One other way to passively " + + "earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " + + "the 'Hacknet Nodes' page through the main navigation menu now."); + document.getElementById("hacknet-nodes-menu-link").setAttribute("class", "flashing-button"); + var hacknetNodesButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hacknet-nodes-menu-link"); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "none"; + hacknetNodesButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadHacknetNodesContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("hacknet-nodes-menu-link"); + return false; + }); + break; + case iTutorialSteps.HacknetNodesIntroduction: + iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " + + "existing ones. Let's purchase a new one now."); + //Next step triggered by purchaseHacknet() (HacknetNode.js) + break; + case iTutorialSteps.HacknetNodesGoToWorldPage: + iTutorialSetText("You just purchased a Hacknet Node! This Hacknet Node will passively " + + "earn you money over time, both online and offline. When you get enough " + + " money, you can upgrade " + + "your newly-purchased Hacknet Node below.

" + + "Let's go to the 'City' page through the main navigation menu."); + document.getElementById("city-menu-link").setAttribute("class", "flashing-button"); + var worldButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("city-menu-link"); + worldButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadWorldContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("city-menu-link"); + return false; + }); + break; + case iTutorialSteps.WorldDescription: + iTutorialSetText("This page lists all of the different locations you can currently " + + "travel to. Each location has something that you can do. " + + "There's a lot of content out in the world, make sure " + + "you explore and discover!

" + + "Lastly, click on the 'Tutorial' link in the main navigation menu."); + document.getElementById("tutorial-menu-link").setAttribute("class", "flashing-button"); + var tutorialButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("tutorial-menu-link"); + tutorialButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].loadTutorialContent(); + iTutorialNextStep(); + Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("tutorial-menu-link"); + return false; + }); + break; + + case iTutorialSteps.TutorialPageInfo: + iTutorialSetText("This page contains a lot of different documentation about the game's " + + "content and mechanics. I know it's a lot, but I highly suggest you read " + + "(or at least skim) through this before you start playing. That's the end of the tutorial. " + + "Hope you enjoy the game!"); + var next = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-next"); + next.style.display = "inline-block"; + next.innerHTML = "Finish Tutorial"; + + var backButton = Object(__WEBPACK_IMPORTED_MODULE_3__utils_HelperFunctions_js__["b" /* clearEventListeners */])("interactive-tutorial-back"); + backButton.style.display = "none"; + + next.addEventListener("click", function() { + iTutorialNextStep(); + return false; + }); + break; + case iTutorialSteps.End: + iTutorialEnd(); + break; + default: + throw new Error("Invalid tutorial step"); + } +} + +//Go to the next step and evaluate it +function iTutorialNextStep() { + switch(currITutorialStep) { + case iTutorialSteps.Start: + currITutorialStep = iTutorialSteps.GoToCharacterPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.GoToCharacterPage: + document.getElementById("stats-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.CharacterPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.CharacterPage: + currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.CharacterGoToTerminalPage: + document.getElementById("terminal-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.TerminalIntro; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalIntro: + currITutorialStep = iTutorialSteps.TerminalHelp; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalHelp: + currITutorialStep = iTutorialSteps.TerminalLs; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalLs: + currITutorialStep = iTutorialSteps.TerminalScan; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalScan: + currITutorialStep = iTutorialSteps.TerminalScanAnalyze1; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalScanAnalyze1: + currITutorialStep = iTutorialSteps.TerminalScanAnalyze2; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalScanAnalyze2: + currITutorialStep = iTutorialSteps.TerminalConnect; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalConnect: + currITutorialStep = iTutorialSteps.TerminalAnalyze; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalAnalyze: + currITutorialStep = iTutorialSteps.TerminalNuke; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalNuke: + currITutorialStep = iTutorialSteps.TerminalManualHack; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalManualHack: + currITutorialStep = iTutorialSteps.TerminalHackingMechanics; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalHackingMechanics: + currITutorialStep = iTutorialSteps.TerminalCreateScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalCreateScript: + currITutorialStep = iTutorialSteps.TerminalTypeScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalTypeScript: + currITutorialStep = iTutorialSteps.TerminalFree; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalFree: + currITutorialStep = iTutorialSteps.TerminalRunScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalRunScript: + currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalGoToActiveScriptsPage: + document.getElementById("active-scripts-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.ActiveScriptsPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.ActiveScriptsPage: + document.getElementById("terminal-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.ActiveScriptsToTerminal: + currITutorialStep = iTutorialSteps.TerminalTailScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalTailScript: + currITutorialStep = iTutorialSteps.GoToHacknetNodesPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.GoToHacknetNodesPage: + document.getElementById("hacknet-nodes-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.HacknetNodesIntroduction; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.HacknetNodesIntroduction: + currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.HacknetNodesGoToWorldPage: + document.getElementById("city-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.WorldDescription; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.WorldDescription: + document.getElementById("tutorial-menu-link").removeAttribute("class"); + currITutorialStep = iTutorialSteps.TutorialPageInfo; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TutorialPageInfo: + currITutorialStep = iTutorialSteps.End; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.End: + break; + default: + throw new Error("Invalid tutorial step"); + } +} + +//Go to previous step and evaluate +function iTutorialPrevStep() { + switch(currITutorialStep) { + case iTutorialSteps.Start: + currITutorialStep = iTutorialSteps.Start; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.GoToCharacterPage: + currITutorialStep = iTutorialSteps.Start; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.CharacterPage: + currITutorialStep = iTutorialSteps.GoToCharacterPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.CharacterGoToTerminalPage: + currITutorialStep = iTutorialSteps.CharacterPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalIntro: + currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalHelp: + currITutorialStep = iTutorialSteps.TerminalIntro; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalLs: + currITutorialStep = iTutorialSteps.TerminalHelp; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalScan: + currITutorialStep = iTutorialSteps.TerminalLs; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalConnect: + currITutorialStep = iTutorialSteps.TerminalScan; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalAnalyze: + currITutorialStep = iTutorialSteps.TerminalConnect; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalNuke: + currITutorialStep = iTutorialSteps.TerminalAnalyze; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalManualHack: + currITutorialStep = iTutorialSteps.TerminalNuke; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalHackingMechanics: + currITutorialStep = iTutorialSteps.TerminalManualHack; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalCreateScript: + currITutorialStep = iTutorialSteps.TerminalManualHack; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalTypeScript: + currITutorialStep = iTutorialSteps.TerminalCreateScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalFree: + currITutorialStep = iTutorialSteps.TerminalTypeScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalRunScript: + currITutorialStep = iTutorialSteps.TerminalFree; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalGoToActiveScriptsPage: + currITutorialStep = iTutorialSteps.TerminalRunScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.ActiveScriptsPage: + currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.ActiveScriptsToTerminal: + currITutorialStep = iTutorialSteps.ActiveScriptsPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TerminalTailScript: + currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.GoToHacknetNodesPage: + currITutorialStep = iTutorialSteps.TerminalTailScript; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.HacknetNodesIntroduction: + currITutorialStep = iTutorialSteps.GoToHacknetNodesPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.HacknetNodesGoToWorldPage: + currITutorialStep = iTutorialSteps.HacknetNodesIntroduction; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.WorldDescription: + currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.TutorialPageInfo: + currITutorialStep = iTutorialSteps.WorldDescription; + iTutorialEvaluateStep(); + break; + case iTutorialSteps.End: + break; + default: + throw new Error("Invalid tutorial step"); + } +} + +function iTutorialEnd() { + //Re-enable auto save + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].Counters.autoSaveCounter = 300; + console.log("Ending interactive tutorial"); + __WEBPACK_IMPORTED_MODULE_0__engine_js__["Engine"].init(); + currITutorialStep = iTutorialSteps.End; + iTutorialIsRunning = false; + document.getElementById("interactive-tutorial-container").style.display = "none"; + Object(__WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__["a" /* dialogBoxCreate */])("If you are new to the game, the following links may be useful for you!

" + + "Getting Started Guide" + + "Wiki

" + + "The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. " + + "To read it, go to Terminal and enter

cat hackers-starting-handbook.lit"); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().messages.push("hackers-starting-handbook.lit"); +} + +function iTutorialSetText(txt) { + var textBox = document.getElementById("interactive-tutorial-text"); + if (textBox == null) {throw new Error("Could not find text box"); return;} + textBox.innerHTML = txt; + textBox.parentElement.scrollTop = 0; // this resets scroll position +} + + + + +/***/ }), +/* 42 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return makeRuntimeRejectMsg; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return netscriptDelay; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return runScriptFromScript; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return scriptCalculateHackingChance; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return scriptCalculateHackingTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return scriptCalculateExpGain; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return scriptCalculatePercentMoneyHacked; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return scriptCalculateGrowTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return scriptCalculateWeakenTime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return evaluate; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isScriptErrorMessage; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return killNetscriptDelay; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return evaluateImport; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptEnvironment_js__ = __webpack_require__(57); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Script_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__ = __webpack_require__(40); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__ = __webpack_require__(6); + + + + + + + + + + + + + + +var Promise = __webpack_require__(177); + +Promise.config({ + warnings: false, + longStackTraces: false, + cancellation: true, + monitoring: false +}); +/* Evaluator + * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser + * + * Returns a promise + */ +function evaluate(exp, workerScript) { + return Promise.delay(__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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)); + } + 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(e)) { + workerScript.errorMessage = e; + return Promise.reject(workerScript); + } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]) { + return Promise.reject(e); + } else { + 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 __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(e)) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, e)); + } else if (e instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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)); + } + } + } + }); + }); + 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 "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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 Promise.reject(makeRuntimeRejectMsg(workerScript)) + 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 == true && exp.operator === "||") { + return Promise.resolve(true); + } + if (expLeft == false && exp.operator === "&&") { + return Promise.resolve(false); + } + 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": + return Promise.resolve(expLeft>expRight); + break; + case ">=": + return Promise.resolve(expLeft>=expRight); + break; + case "+": + return Promise.resolve(expLeft+expRight); + break; + case "-": + return Promise.resolve(expLeft-expRight); + break; + case "*": + return Promise.resolve(expLeft*expRight); + break; + case "/": + if (expRight === 0) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero")); + } else { + return Promise.resolve(expLeft/expRight); + } + break; + case "%": + return Promise.resolve(expLeft%expRight); + break; + case "in": + return Promise.resolve(expLeft in expRight); + break; + case "instanceof": + return Promise.resolve(expLeft instanceof expRight); + break; + case "||": + return Promise.resolve(expLeft || expRight); + break; + case "&&": + return Promise.resolve(expLeft && expRight); + break; + default: + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unsupported operator: " + exp.operator)); + } + }); + }); +} + +function evalUnary(exp, workerScript){ + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + return evaluate(exp.argument, workerScript).then(function(res) { + if (exp.operator == "!") { + return Promise.resolve(!res); + } else if (exp.operator == "-") { + if (isNaN(res)) { + return Promise.resolve(res); + } else { + return Promise.resolve(-1 * res); + } + } else { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator)); + } + }); +} + +//Takes in a MemberExpression that should represent a Netscript array (possible multidimensional) +//The return value is an array of the form: +// [0th index (leftmost), array name, 1st index, 2nd index, ...] +function getArrayElement(exp, workerScript) { + var indices = []; + return evaluate(exp.property, workerScript).then(function(idx) { + if (isNaN(idx)) { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx)); + } else { + if (exp.object.name === undefined && exp.object.object) { + return getArrayElement(exp.object, workerScript).then(function(res) { + res.push(idx); + indices = res; + return Promise.resolve(indices); + }).catch(function(e) { + return Promise.reject(e); + }); + } else { + indices.push(idx); + indices.push(exp.object.name); + return Promise.resolve(indices); + } + } + }); +} + +function evalAssignment(exp, workerScript) { + var env = workerScript.env; + if (env.stopFlag) {return Promise.reject(workerScript);} + + if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") { + return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left))); + } + + 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 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__Settings_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 evaluateImport(exp, workerScript, checkingRam=false) { + //When its checking RAM, it exports an array of nodes for each imported function + var ramCheckRes = []; + + var env = workerScript.env; + if (env.stopFlag) { + if (checkingRam) {return ramCheckRes;} + return Promise.reject(workerScript); + } + + //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); + } + } + + //Get the code + var server = Object(__WEBPACK_IMPORTED_MODULE_5__Server_js__["e" /* 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)); + } + + //Create the AST + try { + var ast = Object(__WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_8__utils_acorn_js__["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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__Script_js__["d" /* 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(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* 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 + workerScript.scriptRef.log("Running script: " + scriptname + " on " + server.hostname + " with " + threads + " threads and args: " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_HelperFunctions_js__["j" /* printArray */])(args) + ". May take a few seconds to start up..."); + var runningScriptObj = new __WEBPACK_IMPORTED_MODULE_7__Script_js__["b" /* RunningScript */](script, args); + runningScriptObj.threads = threads; + server.runningScripts.push(runningScriptObj); //Push onto runningScripts + Object(__WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(msg)) {return false;} + let splitMsg = msg.split("|"); + if (splitMsg.length != 4){ + return false; + } + var ip = splitMsg[1]; + if (!Object(__WEBPACK_IMPORTED_MODULE_10__utils_IPAddress_js__["c" /* 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 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill) + (0.2 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence); + var skillChance = (skillMult - server.requiredHackingSkill) / skillMult; + var chance = skillChance * difficultyMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var hackingTime = 5 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_exp_mult * 0.3 + 3) * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* 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 = (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill - (server.requiredHackingSkill - 1)) / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill; + var percentMoneyHacked = difficultyMult * skillMult * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_money_mult / 240; + if (percentMoneyHacked < 0) {return 0;} + if (percentMoneyHacked > 1) {return 1;} + return percentMoneyHacked * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var growTime = 16 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* 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) / (__WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_skill + 50 + (0.1 * __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].intelligence)); + var weakenTime = 20 * skillFactor / __WEBPACK_IMPORTED_MODULE_2__Player_js__["a" /* Player */].hacking_speed_mult; //This is in seconds + return weakenTime * 1000; +} + + + + +/***/ }), +/* 43 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* unused harmony export hacknetNodesInit */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HacknetNode; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return purchaseHacknet; }); +/* unused harmony export updateTotalHacknetProduction */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getCostOfNextHacknetNode; }); +/* unused harmony export updateHacknetNodesMultiplierButtons */ +/* unused harmony export getMaxNumberLevelUpgrades */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return displayHacknetNodesContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return updateHacknetNodesContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return processAllHacknetNodeEarnings; }); +/* unused harmony export getHacknetNode */ +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__ = __webpack_require__(41); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__ = __webpack_require__(6); + + + + + + + + + + +/* HacknetNode.js */ +function hacknetNodesInit() { + var mult1x = document.getElementById("hacknet-nodes-1x-multiplier"); + mult1x.addEventListener("click", function() { + hacknetNodePurchaseMultiplier = 1; + updateHacknetNodesMultiplierButtons(); + updateHacknetNodesContent(); + return false; + }); + var mult5x = document.getElementById("hacknet-nodes-5x-multiplier"); + mult5x.addEventListener("click", function() { + hacknetNodePurchaseMultiplier = 5; + updateHacknetNodesMultiplierButtons(); + updateHacknetNodesContent(); + return false; + }); + var mult10x = document.getElementById("hacknet-nodes-10x-multiplier"); + mult10x.addEventListener("click", function() { + hacknetNodePurchaseMultiplier = 10; + updateHacknetNodesMultiplierButtons(); + updateHacknetNodesContent(); + return false; + }); + var multMax = document.getElementById("hacknet-nodes-max-multiplier"); + multMax.addEventListener("click", function() { + hacknetNodePurchaseMultiplier = 0; + updateHacknetNodesMultiplierButtons(); + updateHacknetNodesContent(); + return false; + }); +} +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 = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMoneyGainPerLevel; + + this.moneyGainRatePerSecond = (this.level * gainPerLevel) * + Math.pow(1.035, this.ram-1) * + ((this.cores + 5) / 6) * + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_money_mult * + __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* BitNodeMultipliers */].HacknetNodeMoney; + if (isNaN(this.moneyGainRatePerSecond)) { + this.moneyGainRatePerSecond = 0; + Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeLevelMult; + var totalMultiplier = 0; //Summed + var currLevel = this.level; + for (var i = 0; i < levels; ++i) { + totalMultiplier += Math.pow(mult, currLevel); + ++currLevel; + } + return __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNode / 2 * totalMultiplier * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 > __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel) { + var diff = Math.max(0, __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - this.level); + return this.purchaseLevelUpgrade(diff); + } + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); + this.level += levels; + this.updateMoneyGainRate(); + return true; +} + +//Wrapper function for Netscript +HacknetNode.prototype.upgradeLevel = function(levels=1) { + return this.purchaseLevelUpgrade(levels); +} + +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 * __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHacknetNode; + var mult = Math.pow(__WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeRamMult, numUpgrades); + return baseCost * mult * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} + if (this.ram >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxRam) {return false;} + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); + this.ram *= 2; //Ram is always doubled + this.updateMoneyGainRate(); + return true; +} + +//Wrapper function for Netscript +HacknetNode.prototype.upgradeRam = function() { + return this.purchaseRamUpgrade(); +} + +HacknetNode.prototype.calculateCoreUpgradeCost = function() { + var coreBaseCost = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNodeCore; + var mult = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeUpgradeCoreMult; + return coreBaseCost * Math.pow(mult, this.cores-1) * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknet_node_core_cost_mult; +} + +//Wrapper function for Netscript +HacknetNode.prototype.getCoreUpgradeCost = function() { + return this.calculateCoreUpgradeCost(); +} + +HacknetNode.prototype.purchaseCoreUpgrade = function() { + var cost = this.calculateCoreUpgradeCost(); + if (isNaN(cost)) {return false;} + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) {return false;} + if (this.cores >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxCores) {return false;} + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["b" /* Generic_toJSON */])("HacknetNode", this); +} + +HacknetNode.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(HacknetNode, value.data); +} + +__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["c" /* Reviver */].constructors.HacknetNode = HacknetNode; + + +function purchaseHacknet() { + /* INTERACTIVE TUTORIAL */ + if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["b" /* iTutorialIsRunning */]) { + if (__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["a" /* currITutorialStep */] == __WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["e" /* iTutorialSteps */].HacknetNodesIntroduction) { + Object(__WEBPACK_IMPORTED_MODULE_3__InteractiveTutorial_js__["c" /* iTutorialNextStep */])(); + } else { + return; + } + } + + /* END INTERACTIVE TUTORIAL */ + + var cost = getCostOfNextHacknetNode(); + if (isNaN(cost)) {throw new Error("Cost is NaN"); return;} + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; + var name = "hacknet-node-" + numOwned; + var node = new HacknetNode(name); + node.updateMoneyGainRate(); + + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(cost); + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.push(node); + + displayHacknetNodesContent(); + updateTotalHacknetProduction(); + return numOwned; +} + +//Calculates the total production from all HacknetNodes +function updateTotalHacknetProduction() { + var total = 0; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { + total += __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i].moneyGainRatePerSecond; + } + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].totalHacknetNodeProduction = total; +} + +function getCostOfNextHacknetNode() { + //Cost increases exponentially based on how many you own + var numOwned = __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; + var mult = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodePurchaseNextMult; + return __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].BaseCostForHacknetNode * Math.pow(mult, numOwned) * __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(1))) {return 0;} + var min = 1; + var max = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel-1; + var levelsToMax = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - nodeObj.level; + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) { + return levelsToMax; + } + + while (min <= max) { + var curr = (min + max) / 2 | 0; + if (curr != __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel && + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(curr)) && + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(curr+1))) { + return Math.min(levelsToMax, curr); + } else if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(nodeObj.calculateLevelUpgradeCost(curr))) { + max = curr - 1; + } else if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gt(nodeObj.calculateLevelUpgradeCost(curr))) { + min = curr + 1; + } else { + return Math.min(levelsToMax, curr); + } + } +} + +//Creates Hacknet Node DOM elements when the page is opened +function displayHacknetNodesContent() { + //Update Hacknet Nodes button + var newPurchaseButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["b" /* 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 < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { + createHacknetNodeDomElement(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* 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 = document.getElementById("hacknet-nodes-purchase-button"); + purchaseButton.innerHTML = "Purchase Hacknet Node - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2); + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(cost)) { + purchaseButton.setAttribute("class", "a-link-button-inactive"); + } else { + purchaseButton.setAttribute("class", "a-link-button"); + } + + //Update player's money + var moneyElem = document.getElementById("hacknet-nodes-money"); + moneyElem.innerHTML = "Money: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.toNumber(), 2) + "
" + + "Total production from all Hacknet Nodes: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].totalHacknetNodeProduction, 2) + " / second"; + + //Update information in each owned hacknet node + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { + updateHacknetNodeDomElement(__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]); + } +} + +//Creates a single Hacknet Node DOM element +function createHacknetNodeDomElement(nodeObj) { + var nodeName = nodeObj.name; + + var listItem = document.createElement("li"); + listItem.setAttribute("class", "hacknet-node"); + + var span = document.createElement("span"); + span.style.display = "inline"; + + var buttonDiv = document.createElement("div"); + buttonDiv.setAttribute("class", "hacknet-node-button-div"); + + //Text + var txt = document.createElement("p"); + //txt.setAttribute("id", "hacknet-node-text-" + nodeName); + txt.id = "hacknet-node-text-" + nodeName; + + //Upgrade buttons + var upgradeLevelButton = document.createElement("a"); + var upgradeRamButton = document.createElement("a"); + var upgradeCoreButton = document.createElement("a"); + + //upgradeLevelButton.setAttribute("id", "hacknet-node-upgrade-level-" + nodeName); + upgradeLevelButton.id = "hacknet-node-upgrade-level-" + nodeName; + upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); + upgradeLevelButton.addEventListener("click", function() { + var numUpgrades = hacknetNodePurchaseMultiplier; + if (hacknetNodePurchaseMultiplier == 0) { + numUpgrades = getMaxNumberLevelUpgrades(nodeObj); + } + nodeObj.purchaseLevelUpgrade(numUpgrades); + updateHacknetNodesContent(); + return false; + }); + //upgradeRamButton.setAttribute("id", "hacknet-node-upgrade-ram-" + nodeName); + upgradeRamButton.id = "hacknet-node-upgrade-ram-" + nodeName; + upgradeRamButton.setAttribute("class", "a-link-button-inactive"); + upgradeRamButton.addEventListener("click", function() { + nodeObj.purchaseRamUpgrade(); + updateHacknetNodesContent(); + return false; + }); + //upgradeCoreButton.setAttribute("id", "hacknet-node-upgrade-core-" + nodeName); + upgradeCoreButton.id = "hacknet-node-upgrade-core-" + nodeName; + upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); + upgradeCoreButton.addEventListener("click", function() { + nodeObj.purchaseCoreUpgrade(); + updateHacknetNodesContent(); + return false; + }); + + //Put all the components together in the li element + span.appendChild(txt); + buttonDiv.appendChild(upgradeLevelButton); + buttonDiv.appendChild(upgradeRamButton); + buttonDiv.appendChild(upgradeCoreButton); + span.appendChild(buttonDiv); + listItem.appendChild(span); + + document.getElementById("hacknet-nodes-list").appendChild(listItem); + + //Set the text and stuff inside the DOM element + updateHacknetNodeDomElement(nodeObj); +} + +//Updates information on a single hacknet node DOM element +function updateHacknetNodeDomElement(nodeObj) { + var nodeName = nodeObj.name; + var txt = document.getElementById("hacknet-node-text-" + nodeName); + if (txt == null) {throw new Error("Cannot find text element");} + txt.innerHTML = "Node name: " + nodeName + "
" + + "Production: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.totalMoneyGenerated, 2) + + " ($" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.moneyGainRatePerSecond, 2) + " / second)
" + + "Level: " + nodeObj.level + "
" + + "RAM: " + nodeObj.ram + "GB
" + + "Cores: " + nodeObj.cores; + + //Upgrade level + var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName); + if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");} + if (nodeObj.level >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel) { + upgradeLevelButton.innerHTML = "MAX LEVEL"; + upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); + } else { + var multiplier = 0; + if (hacknetNodePurchaseMultiplier == 0) { + //Max + multiplier = getMaxNumberLevelUpgrades(nodeObj); + } else { + var levelsToMax = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxLevel - nodeObj.level; + multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier); + } + + var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier); + upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier + + " - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeLevelCost, 2); + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeLevelCost)) { + upgradeLevelButton.setAttribute("class", "a-link-button-inactive"); + } else { + upgradeLevelButton.setAttribute("class", "a-link-button"); + } + } + + //Upgrade RAM + var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName); + if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");} + if (nodeObj.ram >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxRam) { + upgradeRamButton.innerHTML = "MAX RAM"; + upgradeRamButton.setAttribute("class", "a-link-button-inactive"); + } else { + var upgradeRamCost = nodeObj.calculateRamUpgradeCost(); + upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeRamCost, 2); + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeRamCost)) { + upgradeRamButton.setAttribute("class", "a-link-button-inactive"); + } else { + upgradeRamButton.setAttribute("class", "a-link-button"); + } + } + + //Upgrade Cores + var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName); + if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");} + if (nodeObj.cores >= __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].HacknetNodeMaxCores) { + upgradeCoreButton.innerHTML = "MAX CORES"; + upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); + } else { + var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost(); + upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(upgradeCoreCost, 2); + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(upgradeCoreCost)) { + upgradeCoreButton.setAttribute("class", "a-link-button-inactive"); + } else { + upgradeCoreButton.setAttribute("class", "a-link-button"); + } + } +} + +function processAllHacknetNodeEarnings(numCycles) { + var total = 0; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { + total += processSingleHacknetNodeEarnings(numCycles, __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]); + } + return total; +} + +function processSingleHacknetNodeEarnings(numCycles, nodeObj) { + var cyclesPerSecond = 1000 / __WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"]._idleSpeed; + var earningPerCycle = nodeObj.moneyGainRatePerSecond / cyclesPerSecond; + if (isNaN(earningPerCycle)) { + console.log("ERROR: Hacknet Node Calculated earnings is NaN"); + earningPerCycle = 0; + } + var totalEarnings = numCycles * earningPerCycle; + nodeObj.totalMoneyGenerated += totalEarnings; + nodeObj.onlineTimeSeconds += (numCycles * (__WEBPACK_IMPORTED_MODULE_2__engine_js__["Engine"]._idleSpeed / 1000)); + __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].gainMoney(totalEarnings); + return totalEarnings; +} + +function getHacknetNode(name) { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i].name == name) { + return __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hacknetNodes[i]; + } + } + return null; +} + + + + +/***/ }), +/* 44 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HackingMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return inMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return setInMission; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return currMission; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb__ = __webpack_require__(122); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_jsplumb___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7_jsplumb__); + + + + + + + + + +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 gameOptionsOpened = false; -function gameOptionsBoxInit() { - //Menu link button - document.getElementById("options-menu-link").addEventListener("click", function() { - gameOptionsBoxOpen(); - return false; - }); - - //Close button - var closeButton = document.getElementById("game-options-close-button"); - closeButton.addEventListener("click", function() { - gameOptionsBoxClose(); - return false; - }); -}; - -document.addEventListener("DOMContentLoaded", gameOptionsBoxInit, false); - -function gameOptionsBoxClose() { - gameOptionsOpened = false; - var box = document.getElementById("game-options-container"); - box.style.display = "none"; +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 } -function gameOptionsBoxOpen() { - var box = document.getElementById("game-options-container"); - box.style.display = "block"; - setTimeout(function() { - gameOptionsOpened = true; - }, 500); +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 / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToDiffConversion + 1; + console.log("difficulty: " + this.difficulty); + this.reward = 250 + (rep / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionRepToRewardConversion); +} + +HackingMission.prototype.init = function() { + //Create Header DOM + this.createPageDom(); + + //Create player starting nodes + var home = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].getHomeComputer() + for (var i = 0; i < home.cpuCores; ++i) { + var stats = { + atk: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 7.5) + 30, + def: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill / 20), + hp: (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1)); + var numDatabases = Math.min(10, Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(1, Math.round(this.difficulty / 3) + 1)); + var totalNodes = numNodes + numFirewalls + numDatabases; + var xlimit = 7 - Math.floor(totalNodes / 8); + var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.8 + (this.difficulty / 5), 10); + for (var i = 0; i < numNodes; ++i) { + var stats = { + atk: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(80, 86), + def: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(5, 10), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 20), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(30, 55), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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 * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; + var headerText = document.createElement("p"); + headerText.innerHTML = "You are about to start a hacking mission! You will gain " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + + "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + + "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.playerAtk, 1) + "
" + + "Player Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.enemyAtk, 1) + "
" + + "Enemy Defense: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, 2); + var randMult = Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["a" /* addOffset */])(0.85 + (this.difficulty / 2), 15); + switch (type) { + case 0: //Spam + var stats = { + atk: 0, + def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(15, 45), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(200, 225) + } + node = new Node(NodeTypes.Spam, stats); + break; + case 1: //Transfer + var stats = { + atk: 0, + def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(15, 45), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(250, 275) + } + node = new Node(NodeTypes.Transfer, stats); + break; + case 2: //Shield + default: + var stats = { + atk: 0, + def: averageAttack * 1.1 + Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* getRandomInt */])(30, 70), + hp: randMult * Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-cpu-node"); + break; + case NodeTypes.Firewall: + txt = "Firewall
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-firewall-node"); + break; + case NodeTypes.Database: + txt = "Database
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-database-node"); + break; + case NodeTypes.Spam: + txt = "Spam
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-spam-node"); + break; + case NodeTypes.Transfer: + txt = "Transfer
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-transfer-node"); + break; + case NodeTypes.Shield: + default: + txt = "Shield
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + nodeDiv.classList.add("hack-mission-shield-node"); + break; + } + + txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + + "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Firewall: + txt = "Firewall
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Database: + txt = "Database
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Spam: + txt = "Spam
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Transfer: + txt = "Transfer
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + case NodeTypes.Shield: + default: + txt = "Shield
" + "HP: " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.hp, 1); + break; + } + + txt += "
Atk: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(nodeObj.atk, 1) + + "
Def: " + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* 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 * __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionDifficultyToHacking; + switch(nodeObj.action) { + case NodeActions.Attack: + if (targetNode == null) {break;} + if (nodeObj.conn == null) {break;} + var dmg = this.calculateAttackDamage(atk, def, plyr ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 ? __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill : enmyHacking); + targetNode.atk -= (eff/5 * numCycles); + calcStats = true; + break; + case NodeActions.Fortify: + var eff = this.calculateFortifyEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_skill); + nodeObj.def += (eff/5 * numCycles); + calcStats = true; + break; + case NodeActions.Overflow: + var eff = this.calculateOverflowEffect(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 += __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].HackingMissionTransferAttackIncrease; + }); + this.configurePlayerNodeElement(targetNode.el); + } else { + swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode); + this.enemyCores.forEach(function(node) { + node.atk *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 *= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["h" /* 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: " + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult); + var gain = this.reward * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * favorMult; + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Mission won! You earned " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gain, 3) + " reputation with " + this.faction.name); + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gainIntelligenceExp(this.difficulty * __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceHackingMissionBaseExpGain); + this.faction.playerReputation += gain; + } else { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* 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"; + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadFactionContent(); + Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["c" /* displayFactionContent */])(this.faction.name); } -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), -/* 42 */ +/* 45 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Gang; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return displayGangContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateGangContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadAllGangs; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllGangs; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return resetGangs; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return deleteGangDisplayContent; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__ = __webpack_require__(15); + + + + + + + + + + + +/* Gang.js */ +//Switch between territory and management screen with 1 and 2 +$(document).keydown(function(event) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.Gang && !__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["e" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["l" /* 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, __WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* Reviver */]); +} + +//Power is an estimate of a gang's ability to gain/defend territory +let gangStoredPowerCycles = 0; +function processAllGangPowerGains(numCycles=1) { + if (!__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} + gangStoredPowerCycles += numCycles; + if (gangStoredPowerCycles < 150) {return;} + var playerGangName = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName; + for (var name in AllGangs) { + if (AllGangs.hasOwnProperty(name)) { + if (name == playerGangName) { + AllGangs[name].power += __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 (!__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} + gangStoredTerritoryCycles += numCycles; + if (gangStoredTerritoryCycles < __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].GangTerritoryUpdateTimer) {return;} + + for (var i = 0; i < GangNames.length; ++i) { + var other = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, GangNames.length-1); + while(other == i) { + other = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["h" /* 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 -= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][this.facName]; + if (!(fac instanceof __WEBPACK_IMPORTED_MODULE_2__Faction_js__["a" /* Faction */])) { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* 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 += ((__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].faction_rep_mult * gain * favorMult) / __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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)) { + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Gang", this); +} + +Gang.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Gang, value.data); +} + +__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* Reviver */].constructors.Gang = Gang; + +/*** Gang Member object ***/ +function GangMember(name) { + this.name = name; + this.task = GangMemberTasks["Unassigned"]; //GangMemberTask object + this.city = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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) { + return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1); +} + +GangMember.prototype.updateSkillLevels = function() { + this.hack = Math.floor(this.calculateSkill(this.hack_exp) * this.hack_mult); + this.str = Math.floor(this.calculateSkill(this.str_exp) * this.str_mult); + this.def = Math.floor(this.calculateSkill(this.def_exp) * this.def_mult); + this.dex = Math.floor(this.calculateSkill(this.dex_exp) * this.dex_mult); + this.agi = Math.floor(this.calculateSkill(this.agi_exp) * this.agi_mult); + this.cha = Math.floor(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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; + if (territoryMult <= 0) {return 0;} + var respectMult = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; + if (territoryMult <= 0) {return 0;} + var respectMult = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMember", this); +} + +GangMember.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMember, value.data); +} + +__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMemberTask", this); +} + +GangMemberTask.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMemberTask, value.data); +} + +__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["b" /* Generic_toJSON */])("GangMemberUpgrade", this); +} + +GangMemberUpgrade.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(GangMemberUpgrade, value.data); +} + +__WEBPACK_IMPORTED_MODULE_5__utils_JSONReviver_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["l" /* removeElement */])(gangMemberUpgradeBoxElements[i]); + } + gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter]; + + var filter = gangMemberUpgradeBoxFilter.value.toString(); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name.indexOf(filter) > -1 || __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].task.name.indexOf(filter) > -1) { + var newPanel = createGangMemberUpgradePanel(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i]); + gangMemberUpgradeBoxContent.appendChild(newPanel); + gangMemberUpgradeBoxElements.push(newPanel); + } + } + } else { + //New popup + gangMemberUpgradeBoxFilter = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name.indexOf(filter) > -1 || __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].task.name.indexOf(filter) > -1) { + gangMemberUpgradeBoxElements.push(createGangMemberUpgradePanel(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i])); + } + } + + gangMemberUpgradeBox = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["g" /* createPopup */])(boxId, gangMemberUpgradeBoxElements); + gangMemberUpgradeBoxContent = document.getElementById(boxId + "-content"); + gangMemberUpgradeBoxOpened = true; + } +} + +//Create upgrade panels for each individual Gang Member +function createGangMemberUpgradePanel(memberObj) { + var container = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + border:"1px solid white", + }); + + var header = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:memberObj.name + " (" + memberObj.task.name + ")" + }); + container.appendChild(header); + + var text = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("pre", { + fontSize:"14px", display: "inline-block", width:"20%", + innerText: + "Hack: " + memberObj.hack + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.hack_mult, 2) + ")\n" + + "Str: " + memberObj.str + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.str_mult, 2) + ")\n" + + "Def: " + memberObj.def + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.def_mult, 2) + ")\n" + + "Dex: " + memberObj.dex + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.dex_mult, 2) + ")\n" + + "Agi: " + memberObj.agi + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.agi_mult, 2) + ")\n" + + "Cha: " + memberObj.cha + " (x" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); + var armorDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); + var vehicleDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", {width:"20%", display:"inline-block",}); + var rootkitDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:upg.name + " - " + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(upg.cost).format("$0.000a"), + class:"a-link-button", margin:"2px", padding:"2px", display:"block", + fontSize:"12px", + tooltip:upg.desc, + clickListener:()=>{ + if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].money.lt(upg.cost)) {return false;} + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"gang-container", class:"generic-menupage-container", + }); + + //Get variables + var facName = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName, + members = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members, + wanted = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted, + respect = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect; + + //Back button + gangContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Back", + clickListener:()=>{ + __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].loadFactionContent(); + Object(__WEBPACK_IMPORTED_MODULE_2__Faction_js__["c" /* displayFactionContent */])(facName); + return false; + } + })); + + //Buttons to switch between panels + managementButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + display:"block", id:"gang-management-subpage", + }); + + var lowerWantedTask = ""; + if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.isHackingGang) { + lowerWantedTask = "Ethical Hacking"; + } else { + lowerWantedTask = "Vigilante Justice"; + } + gangDesc = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", {id:"gang-info", width:"70%"}); + gangManagementSubpage.appendChild(gangInfo); + + gangRecruitMemberButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerHTML = "Recruit Gang Member"; + noBtn.innerHTML = "Cancel"; + yesBtn.addEventListener("click", ()=>{ + var name = Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])(); + if (name === "") { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must enter a name for your Gang member!"); + } else { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { + if (name == __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i].name) { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You already have a gang member with this name!"); + return false; + } + } + var member = new GangMember(name); + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.push(member); + createGangMemberDisplayElement(member); + updateGangContent(); + } + Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_9__utils_YesNoBox_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + gangExpandAllButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", placeholder:"Filter gang members", margin:"5px", padding:"5px", + onkeyup:()=>{ + displayGangMemberList(); + } + }); + gangManageEquipmentButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("ul", {id:"gang-member-list"}); + displayGangMemberList(); + gangManagementSubpage.appendChild(gangMemberList); + + //Subpage for seeing gang territory information + gangTerritorySubpage = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"gang-territory-subpage", display:"none" + }); + + //Info text for territory page + gangTerritoryDescText = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("fieldset", {width:"50%", display:"inline-block"}); + + gangTerritoryInfoText = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(gangMemberList); + var members = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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 || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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]; + if (gangname == __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName) { + gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gangTerritoryInfo.power, 6) + "): " + + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(100*gangTerritoryInfo.territory, 2) + "%

"); + } else { + gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gangTerritoryInfo.power, 6) + "): " + + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(100*gangTerritoryInfo.territory, 2) + "%

"); + } + } + } + } else { + //Update information for overall gang + if (gangInfo instanceof Element) { + var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName]; + var rep; + if (!(faction instanceof __WEBPACK_IMPORTED_MODULE_2__Faction_js__["a" /* Faction */])) { + rep = "ERROR"; + } else { + rep = faction.playerReputation; + } + Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(gangInfo); + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Respect + display:"inline-block", + innerText:"Respect: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect, 6) + + " (" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Wanted level + display:"inline-block", + innerText:"Wanted Level: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted, 6) + + " (" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + var wantedPenalty = (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect) / (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.respect + __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.wanted); + wantedPenalty = (1 - wantedPenalty) * 100; + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Wanted Level multiplier + display:"inline-block", + innerText:"Wanted Level Penalty: -" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(wantedPenalty, 2) + "%", + tooltip:"Penalty for respect and money gain rates due to Wanted Level" + })); + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Money gain rate + display:"inline-block", + innerText:"Money gain rate: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.moneyGainRate, 2) + + " / sec", + })); + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + var territoryMult = AllGangs[__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName].territory; + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Territory multiplier + display:"inline-block", + innerText:"Territory: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(territoryMult * 100, 3) + "%", + tooltip:"The percentage of total territory your Gang controls" + })); + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", { //Faction reputation + display:"inline-block", + innerText:"Faction reputation: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(rep, 3) + })); + gangInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + } else { + console.log("ERROR: gang-info DOM element DNE"); + } + + //Toggle the 'Recruit member button' if valid + var numMembers = __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; + var repCost = 0; + if (numMembers > 0) { + var repCost = Math.pow(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].GangRecruitCostMultiplier, numMembers); + } + var faction = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.facName]; + if (faction == null) { + Object(__WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Could not find your gang's faction. This is probably a bug please report to dev"); + return; + } + var btn = gangRecruitMemberButton; + if (numMembers >= __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repCost, 2) + " Faction reputation needed to recruit next member"; + } + + //Update information for each gang member + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members.length; ++i) { + updateGangMemberDisplayElement(__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].gang.members[i]); + } + } +} + +//Takes in a GangMember object +function createGangMemberDisplayElement(memberObj) { + if (!gangContentCreated || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].inGang()) {return;} + var name = memberObj.name; + + var accordion = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["e" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id: name + "gang-member-stats", class: "gang-member-info-div", + width:"30%", display:"inline" + }); + var statsP = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id: name + "gang-member-task", class:"gang-member-info-div", + width:"30%", display:"inline" + }); + var taskSelector = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("select", { + color:"white", backgroundColor:"black", + id:name + "gang-member-task-selector" + }); + + var tasks = null; + if (__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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; + } + } + taskSelector.selectedIndex = taskIndex; + } + + var gainInfo = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("p", {id:name + "gang-member-gain-info"}); + taskDiv.appendChild(taskSelector); + taskDiv.appendChild(gainInfo); + + //Panel for Description of task + var taskDescDiv = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:name + "gang-member-task-desc", class:"gang-member-info-div", + width:"30%", display:"inline" + }); + + var taskDescP = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["f" /* 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 || !__WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.hack, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.hack_exp).format('(0.00a)') + " exp)
" + + "Strength: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.str, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.str_exp).format('(0.00a)') + " exp)
" + + "Defense: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.def, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.def_exp).format('(0.00a)') + " exp)
" + + "Dexterity: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.dex, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.dex_exp).format('(0.00a)') + " exp)
" + + "Agility: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.agi, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.agi_exp).format('(0.00a)') + " exp)
" + + "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(memberObj.cha, 0) + " (" + __WEBPACK_IMPORTED_MODULE_7__utils_numeral_min_js___default()(memberObj.cha_exp).format('(0.00a)') + " exp)
"; + } + + var gainInfo = document.getElementById(name + "gang-member-gain-info"); + if (gainInfo) { + gainInfo.innerHTML = + "Money: $" + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateMoneyGain(), 2) + " / sec
" + + "Respect: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateRespectGain(), 6) + " / sec
" + + "Wanted Level: " + Object(__WEBPACK_IMPORTED_MODULE_8__utils_StringHelperFunctions_js__["c" /* formatNumber */])(5*memberObj.calculateWantedLevelGain(), 6) + " / sec
"; + } +} + +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 deleteGangDisplayContent() { + if (gangContainer != null) {Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["m" /* removeElementById */])(gangContainer.id);} + + gangContentCreated = false; + gangContainer = null; + managementButton = null; + territoryButton = null; + + //Subpages + gangManagementSubpage = null; + gangTerritorySubpage = null; + + //Gang Management Elements + gangDesc = null; + gangInfo = null; + gangRecruitMemberButton = null; + gangRecruitRequirementText = null; + gangExpandAllButton = null; + gangCollapseAllButton = null; + gangMemberFilter = null; + gangManageEquipmentButton = null; + gangMemberList = null; + + //Gang Equipment Upgrade Elements + gangMemberUpgradeBox = null; + gangMemberUpgradeBoxContent = null; + gangMemberUpgradeBoxFilter = null; + gangMemberUpgradeBoxElements = null; +} + + + +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) + +/***/ }), +/* 46 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return StockMarket; }); +/* unused harmony export StockSymbols */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return SymbolToStockMap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return initStockSymbols; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return initStockMarket; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return initSymbolToStockMap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return stockMarketCycle; }); +/* unused harmony export buyStock */ +/* unused harmony export sellStock */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return shortStock; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return sellShort; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return updateStockPrices; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return displayStockMarketContent; }); +/* unused harmony export updateStockTicker */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return updateStockPlayerPosition; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return loadStockMarket; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return setStockMarketContentCreated; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return placeOrder; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return cancelOrder; }); +/* unused harmony export Order */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return OrderTypes; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return PositionTypes; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__ = __webpack_require__(15); + + + + + + + + + + + + + + +/* StockMarket.js */ +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(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Stock", this); +} + +Stock.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Stock, value.data); +} + +__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* 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 + " @ " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___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(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Order", this); +} + +Order.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Order, value.data); +} + +__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* 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, __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* Reviver */]); + } +} + +function initStockSymbols() { + //Stocks for companies at which you can work + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumECorp] = "ECP"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12MegaCorp] = "MGCP"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12BladeIndustries] = "BLD"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumClarkeIncorporated] = "CLRK"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniTekIncorporated] = "OMTK"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FourSigma] = "FSIG"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingKuaiGongInternational] = "KGI"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumFulcrumTechnologies] = "FLCM"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaStormTechnologies] = "STM"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoDefComm] = "DCOMM"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenHeliosLabs] = "HLS"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoVitaLife] = "VITA"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12IcarusMicrosystems] = "ICRS"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12UniversalEnergy] = "UNV"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumAeroCorp] = "AERO"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniaCybersystems] = "OMN"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingSolarisSpaceSystems] = "SLRS"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoGlobalPharmaceuticals] = "GPH"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaNovaMedical] = "NVMD"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumWatchdogSecurity] = "WDS"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp] = "LXO"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction] = "RHOC"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises] = "APHE"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities] = "SYSC"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek] = "CTK"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies] = "NTLK"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaOmegaSoftware] = "OMGA"; + StockSymbols[__WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* 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 = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumECorp; + var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); + StockMarket[ecorp] = ecorpStk; + + var megacorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12MegaCorp; + var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(25000, 33000)); + StockMarket[megacorp] = megacorpStk; + + var blade = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12BladeIndustries; + var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(15000, 22000)); + StockMarket[blade] = bladeStk; + + var clarke = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumClarkeIncorporated; + var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(15000, 20000)); + StockMarket[clarke] = clarkeStk; + + var omnitek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniTekIncorporated; + var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(35000, 40000)); + StockMarket[omnitek] = omnitekStk; + + var foursigma = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FourSigma; + var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(60000, 70000)); + StockMarket[foursigma] = foursigmaStk; + + var kuaigong = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingKuaiGongInternational; + var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 24000)); + StockMarket[kuaigong] = kuaigongStk; + + var fulcrum = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumFulcrumTechnologies; + var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(30000, 35000)); + StockMarket[fulcrum] = fulcrumStk; + + var storm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaStormTechnologies; + var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(21000, 24000)); + StockMarket[storm] = stormStk; + + var defcomm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoDefComm; + var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 15000)); + StockMarket[defcomm] = defcommStk; + + var helios = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenHeliosLabs; + var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(12000, 16000)); + StockMarket[helios] = heliosStk; + + var vitalife = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoVitaLife; + var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 12000)); + StockMarket[vitalife] = vitalifeStk; + + var icarus = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12IcarusMicrosystems; + var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(16000, 20000)); + StockMarket[icarus] = icarusStk; + + var universalenergy = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12UniversalEnergy; + var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); + StockMarket[universalenergy] = universalenergyStk; + + var aerocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumAeroCorp; + var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(10000, 15000)); + StockMarket[aerocorp] = aerocorpStk; + + var omnia = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniaCybersystems; + var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(9000, 12000)); + StockMarket[omnia] = omniaStk; + + var solaris = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingSolarisSpaceSystems; + var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); + StockMarket[solaris] = solarisStk; + + var globalpharm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoGlobalPharmaceuticals; + var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); + StockMarket[globalpharm] = globalpharmStk; + + var nova = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaNovaMedical; + var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(18000, 24000)); + StockMarket[nova] = novaStk; + + var watchdog = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumWatchdogSecurity; + var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); + StockMarket[watchdog] = watchdogStk; + + var lexocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp; + var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); + StockMarket[lexocorp] = lexocorpStk; + + var rho = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction; + var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(3000, 6000)); + StockMarket[rho] = rhoStk; + + var alpha = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises; + var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(5000, 7500)); + StockMarket[alpha] = alphaStk; + + var syscore = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities; + var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(4000, 7000)) + StockMarket[syscore] = syscoreStk; + + var computek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek; + var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 5000)); + StockMarket[computek] = computekStk; + + var netlink = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies; + var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 4000)); + StockMarket[netlink] = netlinkStk; + + var omega = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaOmegaSoftware; + var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(3000, 6000)); + StockMarket[omega] = omegaStk; + + var fns = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FoodNStuff; + var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(1000, 4000)); + StockMarket[fns] = fnsStk; + + var sigmacosm = "Sigma Cosmetics"; + var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(2000, 3000)); + StockMarket[sigmacosm] = sigmacosmStk; + + var joesguns = "Joes Guns"; + var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(500, 1000)); + StockMarket[joesguns] = joesgunsStk; + + var catalyst = "Catalyst Ventures"; + var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(500, 1000)); + StockMarket[catalyst] = catalystStk; + + var microdyne = "Microdyne Technologies"; + var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* getRandomInt */])(20000, 25000)); + StockMarket[microdyne] = microdyneStk; + + var titanlabs = "Titan Laboratories"; + var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["h" /* 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() { + console.log("Cycling the Stock Market"); + 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this. You need $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString() + "."); + return false; + } + + var origTotal = stock.playerShares * stock.playerAvgPx; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); + var newTotal = origTotal + totalPrice; + stock.playerShares += shares; + stock.playerAvgPx = newTotal / stock.playerShares; + updateStockPlayerPosition(stock); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(gains); + stock.playerShares -= shares; + if (stock.playerShares == 0) { + stock.playerAvgPx = 0; + } + updateStockPlayerPosition(stock); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + + "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); + return true; +} + +//Returns true if successful and false otherwise +function shortStock(stock, shares, workerScript=null) { + var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); + if (stock == null || isNaN(shares) || shares < 0) { + if (tixApi) { + workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + if (tixApi) { + workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " + + "money to purchase this short position. You need " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)')); + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this short position. You need $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + "."); + } + + return false; + } + + var origTotal = stock.playerShortShares * stock.playerAvgShortPx; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. Paid " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)') + " in commission fees."); + } + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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 __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); + if (stock == null || isNaN(shares) || shares < 0) { + if (tixApi) { + workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* 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) - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; + if (isNaN(profit)) {profit = 0;} + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(origCost + profit); + if (tixApi) { + workerScript.scriptRef.onlineMoneyMade += profit; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* 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 " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " + + "a total of " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(origCost + profit).format('($0.000a)')); + } + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold your short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + + "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* 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;} + } + + 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 (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["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 = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; +function displayStockMarketContent() { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = false;} + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = false;} + + //Purchase WSE Account button + var wseAccountButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-account"); + wseAccountButton.innerText = "Buy WSE Account - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost, 2).toString(); + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost)) { + wseAccountButton.setAttribute("class", "a-link-button"); + } else { + wseAccountButton.setAttribute("class", "a-link-button-inactive"); + } + wseAccountButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = true; + initStockMarket(); + initSymbolToStockMap(); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost); + displayStockMarketContent(); + return false; + }); + + //Purchase TIX API Access account + var tixApiAccessButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-tix-api"); + tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost, 2).toString(); + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost)) { + tixApiAccessButton.setAttribute("class", "a-link-button"); + } else { + tixApiAccessButton.setAttribute("class", "a-link-button-inactive"); + } + tixApiAccessButton.addEventListener("click", function() { + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = true; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost); + displayStockMarketContent(); + return false; + }); + + var stockList = document.getElementById("stock-market-list"); + if (stockList == null) {return;} + + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { + stockMarketContentCreated = false; + while (stockList.firstChild) { + stockList.removeChild(stockList.firstChild); + } + return; + } + + //Create stock market content if you have an account + if (!stockMarketContentCreated && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { + console.log("Creating Stock Market UI"); + document.getElementById("stock-market-commission").innerHTML = + "Commission Fees: Every transaction you make has a $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])(txt); + return false; + }); + + //Switch to Portfolio Mode Button + var modeBtn = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-expand-tickers"), + collapseBtn = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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 (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* 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 " + + " || (4734 && event.keyCode<40) " + + " || (event.keyCode==46) )"); + + longShortSelect.classList.add("stock-market-input"); + longShortSelect.setAttribute("id", tickerId + "-pos-selector"); + var longOpt = document.createElement("option"); + longOpt.text = "Long"; + longShortSelect.add(longOpt); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* wallStreetSFLvl */] >= 2)) { + var shortOpt = document.createElement("option"); + shortOpt.text = "Short"; + longShortSelect.add(shortOpt); + } + + orderTypeSelect.classList.add("stock-market-input"); + orderTypeSelect.setAttribute("id", tickerId + "-order-selector"); + var marketOpt = document.createElement("option"); + marketOpt.text = "Market Order"; + orderTypeSelect.add(marketOpt); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* wallStreetSFLvl */] >= 3)) { + var limitOpt = document.createElement("option"); + limitOpt.text = "Limit Order"; + orderTypeSelect.add(limitOpt); + var stopOpt = document.createElement("option"); + stopOpt.text = "Stop Order"; + orderTypeSelect.add(stopOpt); + } + + buyButton.classList.add("stock-market-input"); + buyButton.classList.add("a-link-button"); + buyButton.innerHTML = "Buy"; + buyButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Buy " + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitBuy; + } else { + type = OrderTypes.StopBuy; + } + placeOrder(stock, shares, price, type, pos); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + sellButton.classList.add("stock-market-input"); + sellButton.classList.add("a-link-button"); + sellButton.innerHTML = "Sell"; + sellButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + pos === PositionTypes.Long ? sellStock(stock, shares) : sellShort(stock, shares, null); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Sell " + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitSell; + } else { + type = OrderTypes.StopSell; + } + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + placeOrder(stock, shares, price, type, pos); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + buyMaxButton.classList.add("stock-market-input"); + buyMaxButton.classList.add("a-link-button"); + buyMaxButton.innerHTML = "Buy MAX"; + buyMaxButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var money = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.toNumber(); + switch (ordType) { + case "Market Order": + var shares = Math.floor((money - COMM) / stock.price); + pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Buy " + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitBuy; + } else { + type = OrderTypes.StopBuy; + } + var shares = Math.floor((money-COMM) / price); + placeOrder(stock, shares, price, type, pos); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + sellAllButton.classList.add("stock-market-input"); + sellAllButton.classList.add("a-link-button"); + sellAllButton.innerHTML = "Sell ALL"; + sellAllButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + switch (ordType) { + case "Market Order": + if (pos === PositionTypes.Long) { + var shares = stock.playerShares; + sellStock(stock, shares); + } else { + var shares = stock.playerShortShares; + sellShort(stock, shares, null); + } + break; + case "Limit Order": + case "Stop Order": + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: 'Sell All' only works for Market Orders") + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + positionTxt.setAttribute("id", tickerId + "-position-text"); + positionTxt.classList.add("stock-market-position-text"); + stock.posTxtEl = positionTxt; + + orderList.setAttribute("id", tickerId + "-order-list"); + orderList.classList.add("stock-market-order-list"); + + stockDiv.appendChild(qtyInput); + stockDiv.appendChild(longShortSelect); + stockDiv.appendChild(orderTypeSelect); + stockDiv.appendChild(buyButton); + stockDiv.appendChild(sellButton); + stockDiv.appendChild(buyMaxButton); + stockDiv.appendChild(sellAllButton); + stockDiv.appendChild(positionTxt); + stockDiv.appendChild(orderList); + + li.appendChild(hdr); + li.appendChild(stockDiv); + document.getElementById("stock-market-list").appendChild(li); + + updateStockTicker(stock, true); + updateStockPlayerPosition(stock); + updateStockOrderList(stock); +} + +function setStockTickerClickHandlers() { + var stockList = document.getElementById("stock-market-list"); + var tickerHdrs = stockList.getElementsByClassName("accordion-header"); + if (tickerHdrs == null) { + console.log("ERROR: Could not find header elements for stock tickers"); + return; + } + for (var i = 0; i < tickerHdrs.length; ++i) { + tickerHdrs[i].onclick = function() { + this.classList.toggle("active"); + + var panel = this.nextElementSibling; + if (panel.style.display === "block") { + panel.style.display = "none"; + } else { + panel.style.display = "block"; + } + } + } +} + +//'increase' argument is a boolean indicating whether the price increased or decreased +function updateStockTicker(stock, increase) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockTicker():"); + console.log(stock); + return; + } + var tickerId = "stock-market-ticker-" + stock.symbol; + + if (stock.playerShares > 0 || stock.playerShortShares > 0) { + updateStockPlayerPosition(stock); + } + + var hdr = document.getElementById(tickerId + "-hdr"); + + if (hdr == null) { + if (!stockMarketPortfolioMode) {console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol);} + return; + } + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2); + if (increase != null) { + increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + } +} + +function updateStockPlayerPosition(stock) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockPlayerPosition():"); + console.log(stock); + return; + } + var tickerId = "stock-market-ticker-" + stock.symbol; + + if (stockMarketPortfolioMode) { + if (stock.playerShares === 0 && stock.playerShortShares === 0 && + StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] && + StockMarket["Orders"][stock.symbol].length === 0) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* removeElementById */])(tickerId + "-hdr"); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* 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; + } + } + } + + if (!(stock.posTxtEl instanceof Element)) { + stock.posTxtEl = document.getElementById(tickerId + "-position-text"); + } + if (stock.posTxtEl == null) { + console.log("ERROR: Could not find stock position element for: " + stock.symbol); + return; + } + + //Calculate returns + var totalCost = stock.playerShares * stock.playerAvgPx, + gains = (stock.price - stock.playerAvgPx) * stock.playerShares, + percentageGains = gains / totalCost; + if (isNaN(percentageGains)) {percentageGains = 0;} + + var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, + shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, + shortPercentageGains = shortGains/ shortTotalCost; + if (isNaN(shortPercentageGains)) {shortPercentageGains = 0;} + + stock.posTxtEl.innerHTML = + "

Long Position: " + + "Shares in the long position will increase " + + "in value if the price of the corresponding stock increases

" + + "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShares, 0) + + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgPx).format('$0.000a') + + " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalCost).format('$0.000a') + ")" + + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(gains).format('$0.000a') + + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains*100, 2) + "%)

"; + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["e" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["g" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShortShares, 0) + + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgShortPx).format('$0.000a') + + " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortTotalCost).format('$0.000a') + ")" + + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortGains).format('$0.000a') + + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shortPercentageGains*100, 2) + "%)" + + "

Orders:

"; + } + +} + +function updateStockOrderList(stock) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["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(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* removeElementById */])(tickerId + "-hdr"); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["m" /* 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(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* 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); + }()); + + } +} + + + + +/***/ }), +/* 47 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SourceFiles; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return PlayerOwnedSourceFile; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return applySourceFile; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initSourceFiles; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(8); + + + +/* SourceFile.js */ +//Each SourceFile corresponds to a BitNode with the same number +function SourceFile(number, info="") { + var bitnodeKey = "BitNode" + number; + var bitnode = __WEBPACK_IMPORTED_MODULE_1__BitNode_js__["b" /* BitNodes */][bitnodeKey]; + if (bitnode == null) { + throw new Error("Invalid Bit Node for this Source File"); + } + + this.n = number; + this.name = "Source-File " + number + ": " + bitnode.name; + this.lvl = 1; + this.info = info; + this.owned = false; +} + +let SourceFiles = {}; +function initSourceFiles() { + SourceFiles = {}; + SourceFiles["SourceFile1"] = new SourceFile(1, "This Source-File lets the player start with 32GB of RAM on his/her " + + "home computer. It also increases all of the player's multipliers by:

" + + "Level 1: 16%
" + + "Level 2: 24%
" + + "Level 3: 28%"); + SourceFiles["SourceFile2"] = new SourceFile(2, "This Source-File increases the player's crime success rate, crime money, and charisma " + + "multipliers by:

" + + "Level 1: 20%
" + + "Level 2: 30%
" + + "Level 3: 35%"); + SourceFiles["SourceFile3"] = new SourceFile(3,"This Source-File lets you create corporations on other BitNodes (although " + + "some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by:
" + + "Level 1: 8%
" + + "Level 2: 12%
" + + "Level 3: 14%"); + SourceFiles["SourceFile4"] = new SourceFile(4, "This Source-File lets you access and use the Singularity Functions in every BitNode. Every " + + "level of this Source-File opens up more of the Singularity Functions you can use."); + SourceFiles["SourceFile5"] = new SourceFile(5, "This Source-File grants a special new stat called Intelligence. Intelligence " + + "is unique because it is permanent and persistent (it never gets reset back to 1). However, " + + "gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't " + + "know when you gain experience and how much). Higher Intelligence levels will boost your production " + + "for many actions in the game. In addition, this Source-File will unlock the getBitNodeMultipliers() " + + "Netscript function, and will raise all of your hacking-related multipliers by:

" + + "Level 1: 4%
" + + "Level 2: 6%
" + + "Level 3: 7%"); + SourceFiles["SourceFile6"] = new SourceFile(6); + SourceFiles["SourceFile7"] = new SourceFile(7); + SourceFiles["SourceFile8"] = new SourceFile(8, "This Source-File grants the following benefits:

" + + "Level 1: Permanent access to WSE and TIX API
" + + "Level 2: Ability to short stocks in other BitNodes
" + + "Level 3: Ability to use limit/stop orders in other BitNodes

" + + "This Source-File also increases your hacking growth multipliers by: " + + "
Level 1: 8%
Level 2: 12%
Level 3: 14%"); + SourceFiles["SourceFile9"] = new SourceFile(9); + SourceFiles["SourceFile10"] = new SourceFile(10); + SourceFiles["SourceFile11"] = new SourceFile(11, "This Source-File makes it so that company favor increases BOTH the player's salary and reputation gain rate " + + "at that company by 1% per favor (rather than just the reputation gain). This Source-File also " + + " increases the player's company salary and reputation gain multipliers by:

" + + "Level 1: 24%
" + + "Level 2: 36%
" + + "Level 3: 42%
"); + SourceFiles["SourceFile12"] = new SourceFile(12); +} + +function PlayerOwnedSourceFile(number, level) { + this.n = number; + this.lvl = level; +} + +//Takes in a PlayerOwnedSourceFile as the "srcFile" argument +function applySourceFile(srcFile) { + var srcFileKey = "SourceFile" + srcFile.n; + var sourceFileObject = SourceFiles[srcFileKey]; + if (sourceFileObject == null) { + console.log("ERROR: Invalid source file number: " + srcFile.n); + return; + } + + switch(srcFile.n) { + case 1: // The Source Genesis + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (16 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + var decMult = 1 - (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_chance_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_speed_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].strength_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].defense_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].dexterity_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].agility_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].strength_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].defense_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].dexterity_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].agility_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_exp_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].company_rep_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].faction_rep_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_success_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_purchase_cost_mult *= decMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_ram_cost_mult *= decMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_core_cost_mult *= decMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacknet_node_level_cost_mult *= decMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; + break; + case 2: //Rise of the Underworld + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (20 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].crime_success_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; + break; + case 3: //Corporatocracy + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (8 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].charisma_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; + break; + case 4: //The Singularity + //No effects, just gives access to Singularity functions + break; + case 5: //Artificial Intelligence + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (4 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_chance_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_speed_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_exp_mult *= incMult; + break; + case 8: //Ghost of Wall Street + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (8 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; + break; + case 11: //The Big Crash + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (24 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].work_money_mult *= incMult; + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].company_rep_mult *= incMult; + break; + default: + console.log("ERROR: Invalid source file number: " + srcFile.n); + break; + } + + sourceFileObject.owned = true; +} + + + + +/***/ }), +/* 48 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process) { + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(35))) + +/***/ }), +/* 49 */ +/***/ (function(module, exports, __webpack_require__) { + +/* eslint-disable node/no-deprecated-api */ +var buffer = __webpack_require__(34) +var Buffer = buffer.Buffer + +// alternative to using Object.keys for old browsers +function copyProps (src, dst) { + for (var key in src) { + dst[key] = src[key] + } +} +if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) { + module.exports = buffer +} else { + // Copy properties from require('buffer') + copyProps(buffer, exports) + exports.Buffer = SafeBuffer +} + +function SafeBuffer (arg, encodingOrOffset, length) { + return Buffer(arg, encodingOrOffset, length) +} + +// Copy static methods from Buffer +copyProps(Buffer, SafeBuffer) + +SafeBuffer.from = function (arg, encodingOrOffset, length) { + if (typeof arg === 'number') { + throw new TypeError('Argument must not be a number') + } + return Buffer(arg, encodingOrOffset, length) +} + +SafeBuffer.alloc = function (size, fill, encoding) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + var buf = Buffer(size) + if (fill !== undefined) { + if (typeof encoding === 'string') { + buf.fill(fill, encoding) + } else { + buf.fill(fill) + } + } else { + buf.fill(0) + } + return buf +} + +SafeBuffer.allocUnsafe = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return Buffer(size) +} + +SafeBuffer.allocUnsafeSlow = function (size) { + if (typeof size !== 'number') { + throw new TypeError('Argument must be a number') + } + return buffer.SlowBuffer(size) +} + + +/***/ }), +/* 50 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer) { + +module.exports = { + /** + * True if this is running in Nodejs, will be undefined in a browser. + * In a browser, browserify won't include this file and the whole module + * will be resolved an empty object. + */ + isNode : typeof Buffer !== "undefined", + /** + * Create a new nodejs Buffer from an existing content. + * @param {Object} data the data to pass to the constructor. + * @param {String} encoding the encoding to use. + * @return {Buffer} a new Buffer. + */ + newBufferFrom: function(data, encoding) { + // XXX We can't use `Buffer.from` which comes from `Uint8Array.from` + // in nodejs v4 (< v.4.5). It's not the expected implementation (and + // has a different signature). + // see https://github.com/nodejs/node/issues/8053 + // A condition on nodejs' version won't solve the issue as we don't + // control the Buffer polyfills that may or may not be used. + return new Buffer(data, encoding); + }, + /** + * Create a new nodejs Buffer with the specified size. + * @param {Integer} size the size of the buffer. + * @return {Buffer} a new Buffer. + */ + allocBuffer: function (size) { + if (Buffer.alloc) { + return Buffer.alloc(size); + } else { + return new Buffer(size); + } + }, + /** + * Find out if an object is a Buffer. + * @param {Object} b the object to test. + * @return {Boolean} true if the object is a Buffer, false otherwise. + */ + isBuffer : function(b){ + return Buffer.isBuffer(b); + }, + + isStream : function (obj) { + return obj && + typeof obj.on === "function" && + typeof obj.pause === "function" && + typeof obj.resume === "function"; + } +}; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34).Buffer)) + +/***/ }), +/* 51 */ +/***/ (function(module, exports) { + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global = module.exports = typeof window != 'undefined' && window.Math == Math + ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); +if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef + +/***/ }), +/* 52 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52649,7 +51099,7 @@ function gameOptionsBoxOpen() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return logBoxUpdateText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return logBoxOpened; }); /* unused harmony export logBoxCurrentScript */ -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_NetscriptWorker_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__HelperFunctions_js__ = __webpack_require__(2); @@ -52719,10 +51169,4946 @@ function logBoxUpdateText() { -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), -/* 43 */ +/* 53 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Corporation; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Literature_js__ = __webpack_require__(54); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6__utils_decimal_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__ = __webpack_require__(9); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__ = __webpack_require__(15); + + + + + + + + + + + + + + + +/* State */ +var companyStates = ["START", "PURCHASE", "PRODUCTION", "SALE", "EXPORT"]; +function CorporationState() { + this.state = 0; +} + +CorporationState.prototype.nextState = function() { + if (this.state < 0 || this.state >= companyStates.length) { + this.state = 0; + } + + ++this.state; + if (this.state >= companyStates.length) { + this.state = 0; + } +} + +CorporationState.prototype.getState = function() { + return companyStates[this.state]; +} + +CorporationState.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("CorporationState", this); +} + +CorporationState.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(CorporationState, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.CorporationState = CorporationState; + +/* Constants */ +var TOTALSHARES = 1e9; //Total number of shares you have at your company +var CyclesPerMarketCycle = 75; +var CyclesPerIndustryStateCycle = CyclesPerMarketCycle / companyStates.length; +var SecsPerMarketCycle = CyclesPerMarketCycle / 5; +var Cities = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"]; +var WarehouseInitialCost = 5e9; //Initial purchase cost of warehouse +var WarehouseInitialSize = 100; +var WarehouseUpgradeBaseCost = 1e9; + +var OfficeInitialCost = 4e9; +var OfficeInitialSize = 3; +var OfficeUpgradeBaseCost = 1e9; + +var BribeThreshold = 100e12; //Money needed to be able to bribe for faction rep +var BribeToRepRatio = 1e9; //Bribe Value divided by this = rep gain + +var ProductProductionCostRatio = 5; //Ratio of material cost of a product to its production cost + +function Material(params={}) { + this.name = params.name ? params.name : ""; + this.qty = 0; //Quantity + this.qlt = 0; //Quality, unbounded + this.dmd = 0; //Demand, 0-100? + this.dmdR = 0; //Range of possible demand + this.cmp = 0; //Competition, 0-100 + this.cmpR = 0; //Range of possible competition + this.mv = 0; //Maximum Volatility of stats + + //Markup. Determines how high of a price you can charge on the material + //compared to the market price (bCost) based on quality + //Quality is divided by this to determine markup limits + //e.g if mku is 10 and quality is 100 then you can mark up prices by 100/10 = 10 + //without consequences + this.mku = 0; + + this.buy = 0; //How much of this material is being bought per second + this.sll = 0; //How much of this material is being sold per second + this.prd = 0; //How much of this material is being produced per second + this.exp = []; //Exports of this material to another warehouse/industry + this.totalExp = 0; //Total export amount for last cycle + this.imp = 0; + this.bCost = 0; //$ Cost/sec to buy material + this.sCost = 0; //$ Cost/sec to sell material + + //[Whether production/sale is limited, limit amount] + this.prdman = [false, 0]; //Production for this material is manually limited + this.sllman = [false, 0]; //Sale of this material is manually limited + this.init(); +} + +Material.prototype.init = function(mats={}) { + switch(this.name) { + case "Water": + this.dmd = 75; this.dmdR = [65, 85]; + this.cmp = 50; this.cmpR = [40, 60]; + this.bCost = 1000; this.mv = 0.2; + this.mku = 6; + break; + case "Energy": + this.dmd = 90; this.dmdR = [80, 100]; + this.cmp = 80; this.cmpR = [65, 95]; + this.bCost = 1500; this.mv = 0.2; + this.mku = 6; + break; + case "Food": + this.dmd = 80; this.dmdR = [70, 90]; + this.cmp = 60; this.cmpR = [35, 85]; + this.bCost = 5000; this.mv = 1; + this.mku = 3; + break; + case "Plants": + this.dmd = 70; this.dmdR = [20, 90]; + this.cmp = 50; this.cmpR = [30, 70]; + this.bCost = 3000; this.mv = 0.6; + this.mku = 3.75; + break; + case "Metal": + this.dmd = 80; this.dmdR = [75, 85]; + this.cmp = 70; this.cmpR = [60, 80]; + this.bCost = 2650; this.mv = 1; + this.mku = 6; + break; + case "Hardware": + this.dmd = 85; this.dmdR = [80, 90]; + this.cmp = 80; this.cmpR = [65, 95]; + this.bCost = 4000; this.mv = 0.5; //Less mv bc its processed twice + this.mku = 1; + break; + case "Chemicals": + this.dmd = 55; this.dmdR = [40, 70]; + this.cmp = 60; this.cmpR = [40, 80]; + this.bCost = 6750; this.mv = 1.2; + this.mku = 2; + break; + case "Real Estate": + this.dmd = 50; this.dmdR = [5, 100]; + this.cmp = 50; this.cmpR = [25, 75]; + this.bCost = 16e3; this.mv = 1.5; //Less mv bc its processed twice + this.mku = 1.5; + break; + case "Drugs": + this.dmd = 60; this.dmdR = [45, 75]; + this.cmp = 70; this.cmpR = [40, 100]; + this.bCost = 8e3; this.mv = 1.6; + this.mku = 1; + break; + case "Robots": + this.dmd = 90; this.dmdR = [80, 100]; + this.cmp = 90; this.cmpR = [80, 100]; + this.bCost = 20e3; this.mv = 0.5; //Less mv bc its processed twice + this.mku = 1; + break; + case "AI Cores": + this.dmd = 90; this.dmdR = [80, 100]; + this.cmp = 90; this.cmpR = [80, 100]; + this.bCost = 27e3; this.mv = 0.8; //Less mv bc its processed twice + this.mku = 0.5; + break; + case "Scientific Research": + break; + default: + console.log("Invalid material type in init(): " + this.name); + break; + } +} + +//Process change in demand, competition, and buy cost of this material +Material.prototype.processMarket = function() { + //This 1st random check determines whether competition increases or decreases + //More competition = lower market price + var v = (Math.random() * this.mv) / 100; + var pv = (Math.random() * this.mv) / 300; + if (Math.random() < 0.42) { + this.cmp *= (1+v); + if (this.cmp > this.cmpR[1]) {this.cmp = this.cmpR[1]}; + this.bCost *= (1-pv); + } else { + this.cmp *= (1-v); + if (this.cmp < this.cmpR[0]) {this.cmp = this.cmpR[0];} + this.bCost *= (1+pv); + } + + //This 2nd random check determines whether demand increases or decreases + //More demand = higher market price + v = (Math.random() * this.mv) / 100; + pv = (Math.random() * this.mv) / 300; + if (Math.random() < 0.45) { + this.dmd *= (1+v); + if (this.dmd > this.dmdR[1]) {this.dmd = this.dmdR[1];} + this.bCost *= (1+pv); + } else { + this.dmd *= (1-v); + if (this.dmd < this.dmdR[0]) {this.dmd = this.dmdR[0];} + this.bCost *= (1-pv); + } +} + +Material.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Material", this); +} + +Material.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Material, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Material = Material; + +//Map of material (by name) to their sizes (how much space it takes in warehouse) +let MaterialSizes = { + Water: 0.05, + Energy: 0.01, + Food: 0.03, + Plants: 0.05, + Metal: 0.1, + Hardware: 0.06, + Chemicals: 0.05, + Drugs: 0.02, + Robots: 0.5, + "AICores": 0.1 +} + +function Product(params={}) { + this.name = params.name ? params.name : 0; + this.dmd = params.demand ? params.demand : 0; + this.cmp = params.competition ? params.competition : 0; + this.mku = params.markup ? params.markup : 0; + this.pCost = 0; //An estimate of how much money it costs to make this + this.sCost = 0; //How much this is selling for + + //Variables for creation of product + this.fin = false; //Finished being created + this.prog = 0; //0-100% created + this.createCity = params.createCity ? params.createCity : ""; // City in which the product is being created + this.designCost = params.designCost ? params.designCost : 0; + this.advCost = params.advCost ? params.advCost : 0; + + //Aggregate score for a product's 'rating' based on the other properties below + //The weighting of the other properties (performance, durability) + //differs between industries + this.rat = 0; + + this.qlt = params.quality ? params.quality : 0; + this.per = params.performance ? params.performance : 0; + this.dur = params.durability ? params.durability : 0; + this.rel = params.reliability ? params.reliability : 0; + this.aes = params.aesthetics ? params.aesthetics : 0; + this.fea = params.features ? params.features : 0; + + //Data refers to the production, sale, and quantity of the products + //These values are specific to a city + //The data is [qty, prod, sell] + this.data = { + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [0, 0, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [0, 0, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [0, 0, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [0, 0, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [0, 0, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [0, 0, 0], + } + + //Only applies for location-based products like restaurants/hospitals + this.loc = params.loc ? params.loc : 0; + + //How much space it takes in the warehouse. Not applicable for all products + this.siz = params.size ? params.size : 0; + + //Material requirements. An object that maps the name of a material to how much it requires + //to make 1 unit of the product. + this.reqMats = params.req ? params.req : {}; + + //[Whether production/sale is limited, limit amount] + this.prdman = { + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [false, 0], + } + + this.sllman = { + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: [false, 0], + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: [false, 0], + } +} + +//empWorkMult is a multiplier that increases progress rate based on +//productivity of employees +Product.prototype.createProduct = function(marketCycles=1, empWorkMult=1) { + if (this.fin) {return;} + this.prog += (marketCycles * .01 * empWorkMult); +} + +//'industry' is a reference to the industry that makes the product +Product.prototype.finishProduct = function(employeeProd, industry) { + this.fin = true; + + //Calculate properties + var progrMult = this.prog / 100; + + var engrRatio = employeeProd[EmployeePositions.Engineer] / employeeProd["total"], + mgmtRatio = employeeProd[EmployeePositions.Management] / employeeProd["total"], + rndRatio = employeeProd[EmployeePositions.RandD] / employeeProd["total"], + opsRatio = employeeProd[EmployeePositions.Operations] / employeeProd["total"], + busRatio = employeeProd[EmployeePositions.Business] / employeeProd["total"]; + var designMult = 1 + (Math.pow(this.designCost, 0.1) / 100); + console.log("designMult: " + designMult); + var balanceMult = (1.2 * engrRatio) + (0.9 * mgmtRatio) + (1.3 * rndRatio) + + (1.5 * opsRatio) + (busRatio); + var sciMult = 1 + (Math.pow(industry.sciResearch.qty, industry.sciFac) / 800); + var totalMult = progrMult * balanceMult * designMult * sciMult; + + this.qlt = totalMult * ((0.10 * employeeProd[EmployeePositions.Engineer]) + + (0.05 * employeeProd[EmployeePositions.Management]) + + (0.05 * employeeProd[EmployeePositions.RandD]) + + (0.02 * employeeProd[EmployeePositions.Operations]) + + (0.02 * employeeProd[EmployeePositions.Business])); + this.per = totalMult * ((0.15 * employeeProd[EmployeePositions.Engineer]) + + (0.02 * employeeProd[EmployeePositions.Management]) + + (0.02 * employeeProd[EmployeePositions.RandD]) + + (0.02 * employeeProd[EmployeePositions.Operations]) + + (0.02 * employeeProd[EmployeePositions.Business])); + this.dur = totalMult * ((0.05 * employeeProd[EmployeePositions.Engineer]) + + (0.02 * employeeProd[EmployeePositions.Management]) + + (0.08 * employeeProd[EmployeePositions.RandD]) + + (0.05 * employeeProd[EmployeePositions.Operations]) + + (0.05 * employeeProd[EmployeePositions.Business])); + this.rel = totalMult * ((0.02 * employeeProd[EmployeePositions.Engineer]) + + (0.08 * employeeProd[EmployeePositions.Management]) + + (0.02 * employeeProd[EmployeePositions.RandD]) + + (0.05 * employeeProd[EmployeePositions.Operations]) + + (0.08 * employeeProd[EmployeePositions.Business])); + this.aes = totalMult * ((0.00 * employeeProd[EmployeePositions.Engineer]) + + (0.08 * employeeProd[EmployeePositions.Management]) + + (0.05 * employeeProd[EmployeePositions.RandD]) + + (0.02 * employeeProd[EmployeePositions.Operations]) + + (0.10 * employeeProd[EmployeePositions.Business])); + this.fea = totalMult * ((0.08 * employeeProd[EmployeePositions.Engineer]) + + (0.05 * employeeProd[EmployeePositions.Management]) + + (0.02 * employeeProd[EmployeePositions.RandD]) + + (0.05 * employeeProd[EmployeePositions.Operations]) + + (0.05 * employeeProd[EmployeePositions.Business])); + this.calculateRating(industry); + var advMult = 1 + (Math.pow(this.advCost, 0.1) / 100); + this.mku = 100 / (advMult * Math.pow((this.qlt + 0.001), 0.65) * (busRatio + mgmtRatio)); + this.dmd = industry.awareness === 0 ? 20 : Math.min(100, advMult * (100 * (industry.popularity / industry.awareness))); + this.cmp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(0, 70); + + //Calculate the product's required materials + //For now, just set it to be the same as the requirements to make materials + for (var matName in industry.reqMats) { + if (industry.reqMats.hasOwnProperty(matName)) { + this.reqMats[matName] = industry.reqMats[matName]; + } + } + + //Calculate the product's size + //For now, just set it to be the same size as the requirements to make materials + this.siz = 0; + for (var matName in industry.reqMats) { + this.siz += MaterialSizes[matName] * industry.reqMats[matName]; + } + + //Delete unneeded variables + delete this.prog; + delete this.createCity; + delete this.designCost; + delete this.advCost; +} + + +Product.prototype.calculateRating = function(industry) { + var weights = ProductRatingWeights[industry.type]; + if (weights == null) { + console.log("ERROR: Could not find product rating weights for: " + industry); + return; + } + this.rat = 0; + this.rat += weights.Quality ? this.qlt * weights.Quality : 0; + this.rat += weights.Performance ? this.per * weights.Performance : 0; + this.rat += weights.Durability ? this.dur * weights.Durability : 0; + this.rat += weights.Reliability ? this.rel * weights.Reliability : 0; + this.rat += weights.Aesthetics ? this.aes * weights.Aesthetics : 0; + this.rat += weights.Features ? this.fea * weights.Features : 0; +} + +Product.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Product", this); +} + +Product.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Product, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Product = Product; + +var Industries = { + Energy: "Energy", + Utilities: "Water Utilities", + Agriculture: "Agriculture", + Fishing: "Fishing", + Mining: "Mining", + Food: "Food", + Tobacco: "Tobacco", + Chemical: "Chemical", + Pharmaceutical: "Pharmaceutical", + Computer: "Computer Hardware", + Robotics: "Robotics", + Software: "Software", + Healthcare: "Healthcare", + RealEstate: "RealEstate", +} + +var IndustryStartingCosts = { + Energy: 225e9, + Utilities: 150e9, + Agriculture: 40e9, + Fishing: 80e9, + Mining: 300e9, + Food: 10e9, + Tobacco: 20e9, + Chemical: 70e9, + Pharmaceutical: 200e9, + Computer: 500e9, + Robotics: 1e12, + Software: 25e9, + Healthcare: 750e9, + RealEstate: 600e9, +} + +var IndustryDescriptions = { + Energy: "Engage in the production and distribution of energy.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Energy).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Utilities: "Distributes water and provides wastewater services.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Utilities).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Agriculture: "Cultive crops and breed livestock to produce food.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Agriculture).format("$0.000a") + "
" + + "Recommended starting Industry: YES", + Fishing: "Produce food through the breeding and processing of fish and fish products

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Fishing).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Mining: "Extract and process metals from the earth.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Mining).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Food: "Create your own restaurants all around the world.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Food).format("$0.000a") + "
" + + "Recommended starting Industry: YES", + Tobacco: "Create and distribute tobacco and tobacco-related products.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Tobacco).format("$0.000a") + "
" + + "Recommended starting Industry: YES", + Chemical: "Product industrial chemicals

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Chemical).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Pharmaceutical: "Discover, develop, and create new pharmaceutical drugs.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Pharmaceutical).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Computer: "Develop and manufacture new computer hardware and networking infrastructures.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Computer).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Robotics: "Develop and create robots.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Robotics).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + Software: "Develop computer software and create AI Cores.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Software).format("$0.000a") + "
" + + "Recommended starting Industry: YES", + Healthcare: "Create and manage hospitals.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.Healthcare).format("$0.000a") + "
" + + "Recommended starting Industry: NO", + RealEstate: "Develop and manage real estate properties.

" + + "Starting cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(IndustryStartingCosts.RealEstate).format("$0.000a") + "
" + + "Recommended starting Industry: NO", +} + +var ProductRatingWeights = { + [Industries.Food]: { + Quality: 0.7, + Durability: 0.1, + Aesthetics: 0.2, + }, + [Industries.Tobacco]: { + Quality: 0.4, + Durability: 0.2, + Reliability: 0.2, + Aesthetics: 0.2, + }, + [Industries.Pharmaceutical]: { + Quality: 0.2, + Performance: 0.2, + Durability: 0.1, + Reliability: 0.3, + Features: 0.2, + }, + [Industries.Computer]: { + Quality: 0.15, + Performance: 0.25, + Durability: 0.25, + Reliability: 0.2, + Aesthetics: 0.05, + Features: 0.1, + }, + "Computer" : { //Repeat + Quality: 0.15, + Performance: 0.25, + Durability: 0.25, + Reliability: 0.2, + Aesthetics: 0.05, + Features: 0.1, + }, + [Industries.Robotics]: { + Quality: 0.1, + Performance: 0.2, + Durability: 0.2, + Reliability: 0.2, + Aesthetics: 0.1, + Features: 0.2, + }, + [Industries.Software]: { + Quality: 0.2, + Performance: 0.2, + Reliability: 0.2, + Durability: 0.2, + Features: 0.2, + }, + [Industries.Healthcare]: { + Quality: 0.4, + Performance: 0.1, + Durability: 0.1, + Reliability: 0.3, + Features: 0.1, + }, + [Industries.RealEstate]: { + Quality: 0.2, + Durability: 0.25, + Reliability: 0.1, + Aesthetics: 0.35, + Features: 0.1, + } +} + +//Industry upgrades +//The structure is: +// [index in array, base price, price mult, benefit mult (if applicable), name, desc] +var IndustryUpgrades = { + "0": [0, 500e3, 1, 1.05, + "Coffee", "Provide your employees with coffee, increasing their energy by 5%."], + "1": [1, 1e9, 1.06, 1.03, + "AdVert.Inc", "Hire AdVert.Inc to advertise your company. Each level of " + + "this upgrade grants your company a static increase of 3 and 1 to its awareness and " + + "popularity, respectively. It will then increase your company's awareness by 1%, and its popularity " + + "by a random percentage between 1% and 3%. These effects are increased by other upgrades " + + "that increase the power of your advertising."] +} + +var empManualAssignmentModeActive = false; +function Industry(params={}) { + this.offices = { //Maps locations to offices. 0 if no office at that location + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chongqing]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: new OfficeSpace({ + loc:__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12, + size:OfficeInitialSize, + }), + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: 0 + }; + + this.warehouses = { //Maps locations to warehouses. 0 if no warehouse at that location + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Aevum]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Chonqing]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12]: new Warehouse({ + loc:__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12, + size: WarehouseInitialSize, + }), + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].NewTokyo]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Ishima]: 0, + [__WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Volhaven]: 0 + }; + + this.name = params.name ? params.name : 0; + this.type = params.type ? params.type : 0; + + this.sciResearch = new Material({name: "Scientific Research"}); + + //A map of the NAME of materials required to create produced materials to + //how many are needed to produce 1 unit of produced materials + this.reqMats = {}; + + //An array of the name of materials being produced + this.prodMats = []; + + this.products = {}; + this.makesProducts = false; + + this.awareness = 0; + this.popularity = 0; //Should always be less than awareness + this.startingCost = 0; + + /* The following are factors for how much production/other things are increased by + different factors. The production increase always has diminishing returns, + and they are all reprsented by exponentials of < 1 (e.g x ^ 0.5, x ^ 0.8) + The number for these represent the exponential. A lower number means more + diminishing returns */ + this.reFac = 0; //Real estate Factor + this.sciFac = 0; //Scientific Research Factor, affects quality + this.hwFac = 0; //Hardware factor + this.robFac = 0; //Robotics Factor + this.aiFac = 0; //AI Cores factor; + this.advFac = 0; //Advertising factor, affects sales + + this.prodMult = 0; //Production multiplier + + //Financials + this.lastCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.lastCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + + //Upgrades + var numUpgrades = Object.keys(IndustryUpgrades).length; + this.upgrades = Array(numUpgrades).fill(0); + + this.state = "START"; + this.newInd = true; + + this.init(); +} + +Industry.prototype.init = function() { + //Set the unique properties of an industry (how much its affected by real estate/scientific research, etc.) + this.startingCost = IndustryStartingCosts[this.type]; + switch (this.type) { + case Industries.Energy: + this.reFac = 0.65; + this.sciFac = 0.7; + this.robFac = 0.05; + this.aiFac = 0.3; + this.advFac = 0.08; + this.reqMats = { + "Hardware": 0.1, + "Metal": 0.2, + }; + this.prodMats = ["Energy"]; + break; + case Industries.Utilities: + case "Utilities": + this.reFac = 0.5; + this.sciFac = 0.6; + this.robFac = 0.4; + this.aiFac = 0.4; + this.advFac = 0.08; + this.reqMats = { + "Hardware": 0.1, + "Metal": 0.1, + } + this.prodMats = ["Water"]; + break; + case Industries.Agriculture: + this.reFac = 0.75; + this.sciFac = 0.5; + this.hwFac = 0.2; + this.robFac = 0.3; + this.aiFac = 0.3; + this.advFac = 0.04; + this.reqMats = { + "Water": 0.5, + "Energy": 0.5, + } + this.prodMats = ["Plants", "Food"]; + break; + case Industries.Fishing: + this.reFac = 0.15; + this.sciFac = 0.35; + this.hwFac = 0.35; + this.robFac = 0.5; + this.aiFac = 0.2; + this.advFac = 0.08; + this.reqMats = { + "Energy": 0.5, + } + this.prodMats = ["Food"]; + break; + case Industries.Mining: + this.reFac = 0.3; + this.sciFac = 0.26; + this.hwFac = 0.4; + this.robFac = 0.45; + this.aiFac = 0.45; + this.advFac = 0.06; + this.reqMats = { + "Energy": 0.8, + } + this.prodMats = ["Metal"]; + break; + case Industries.Food: + //reFac is unique for this bc it diminishes greatly per city. Handle this separately in code? + this.sciFac = 0.12; + this.hwFac = 0.15; + this.robFac = 0.3; + this.aiFac = 0.25; + this.advFac = 0.25; + this.reFac = 0.05; + this.reqMats = { + "Food": 0.5, + "Water": 0.5, + "Energy": 0.2, + } + this.makesProducts = true; + break; + case Industries.Tobacco: + this.reFac = 0.15; + this.sciFac = 0.75; + this.hwFac = 0.15; + this.robFac = 0.2; + this.aiFac = 0.15; + this.advFac = 0.2; + this.reqMats = { + "Plants": 1, + "Water": 0.2, + } + this.makesProducts = true; + break; + case Industries.Chemical: + this.reFac = 0.25; + this.sciFac = 0.75; + this.hwFac = 0.2; + this.robFac = 0.25; + this.aiFac = 0.2; + this.advFac = 0.07; + this.reqMats = { + "Plants": 1, + "Energy": 0.5, + "Water": 0.5, + } + this.prodMats = ["Chemicals"]; + break; + case Industries.Pharmaceutical: + this.reFac = 0.05; + this.sciFac = 0.8; + this.hwFac = 0.15; + this.robFac = 0.25; + this.aiFac = 0.2; + this.advFac = 0.16; + this.reqMats = { + "Chemicals": 2, + "Energy": 1, + "Water": 0.5, + } + this.prodMats = ["Drugs"]; + this.makesProducts = true; + break; + case Industries.Computer: + case "Computer": + this.reFac = 0.2; + this.sciFac = 0.62; + this.robFac = 0.36; + this.aiFac = 0.19; + this.advFac = 0.17; + this.reqMats = { + "Metal": 2.5, + "Energy": 1, + } + this.prodMats = ["Hardware"]; + this.makesProducts = true; + break; + case Industries.Robotics: + this.reFac = 0.32; + this.sciFac = 0.65; + this.aiFac = 0.36; + this.advFac = 0.18; + this.hwFac = 0.19; + this.reqMats = { + "Hardware": 5, + "Energy": 3, + } + this.prodMats = ["Robots"]; + this.makesProducts = true; + break; + case Industries.Software: + this.sciFac = 0.62; + this.advFac = 0.16; + this.hwFac = 0.25; + this.reFac = 0.1; + this.aiFac = 0.1; + this.robFac = 0.05; + this.reqMats = { + "Hardware": 0.5, + "Energy": 1, + } + this.prodMats = ["AICores"]; + this.makesProducts = true; + break; + case Industries.Healthcare: + this.reFac = 0.1; + this.sciFac = 0.75; + this.advFac = 0.11; + this.hwFac = 0.1; + this.robFac = 0.1; + this.aiFac = 0.1; + this.reqMats = { + "Robots": 10, + "AICores": 5, + "Energy": 5, + "Water": 5, + } + this.makesProducts = true; + break; + case Industries.RealEstate: + this.robFac = 0.6; + this.aiFac = 0.6; + this.advFac = 0.25; + this.sciFac = 0.05; + this.hwFac = 0.05; + this.reqMats = { + "Metal": 20, + "Energy": 10, + "Water": 10, + "Hardware": 5 + } + this.prodMats = ["RealEstate"]; + this.makesProducts = true; + break; + default: + console.log("ERR: Invalid Industry Type passed into Industry.init(): " + this.type); + return; + } +} + +Industry.prototype.getProductDescriptionText = function() { + if (!this.makesProducts) {return;} + switch (this.type) { + case Industries.Food: + return "create and manage restaurants"; + break; + case Industries.Tobacco: + return "create tobacco and tobacco-related products"; + break; + case Industries.Pharmaceutical: + return "develop new pharmaceutical drugs"; + break; + case Industries.Computer: + case "Computer": + return "create new computer hardware and networking infrastructures"; + break; + case Industries.Robotics: + return "build specialized robots and robot-related products"; + break; + case Industries.Software: + return "develop computer software"; + break; + case Industries.HealthCare: + return "build and manage hospitals"; + break; + case Industries.RealEstate: + return "develop and manage real estate properties"; + break; + default: + console.log("ERROR: Invalid industry type in Industry.getProductDescriptionText"); + return ""; + } +} + +//Calculates the values that factor into the production and properties of +//materials/products (such as quality, etc.) +Industry.prototype.calculateProductionFactors = function() { + var multSum = 0; + for (var i = 0; i < Cities.length; ++i) { + var city = Cities[i]; + var warehouse = this.warehouses[city]; + if (!(warehouse instanceof Warehouse)) { + continue; + } + + var materials = warehouse.materials, + office = this.offices[city]; + + var cityMult = Math.pow(0.002 * materials.RealEstate.qty+1, this.reFac) * + Math.pow(0.002 * materials.Hardware.qty+1, this.hwFac) * + Math.pow(0.002 * materials.Robots.qty+1, this.robFac) * + Math.pow(0.002 * materials.AICores.qty+1, this.aiFac); + multSum += Math.pow(cityMult, 0.73); + } + + multSum < 1 ? this.prodMult = 1 : this.prodMult = multSum; +} + +Industry.prototype.updateWarehouseSizeUsed = function(warehouse) { + if (warehouse instanceof Warehouse) { + //This resets the size back to 0 and then accounts for materials + warehouse.updateMaterialSizeUsed(); + } + + for (var prodName in this.products) { + if (this.products.hasOwnProperty(prodName)) { + 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(prod.data[warehouse.loc][0] * prod.siz, 0) + "
"); + } + } + } +} + +Industry.prototype.process = function(marketCycles=1, state, company) { + this.state = state; + + //At the start of a cycle, store and reset revenue/expenses + //Then calculate salaries and processs the markets + if (state === "START") { + if (isNaN(this.thisCycleRevenue) || isNaN(this.thisCycleExpenses)) { + console.log("ERROR: NaN in Corporation's computed revenue/expenses"); + console.log(this.thisCycleRevenue.toString()); + console.log(this.thisCycleExpenses.toString()); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Something went wrong when compting Corporation's revenue/expenses. This is a bug. Please report to game developer"); + this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + } + this.lastCycleRevenue = this.thisCycleRevenue.dividedBy(marketCycles * SecsPerMarketCycle); + this.lastCycleExpenses = this.thisCycleExpenses.dividedBy(marketCycles * SecsPerMarketCycle); + this.thisCycleRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.thisCycleExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + + //Once you start making revenue, the player should no longer be + //considered new, and therefore no longer needs the 'tutorial' UI elements + if (this.lastCycleRevenue.gt(0)) {this.newInd = false;} + + //Process offices (and the employees in them) + var employeeSalary = 0; + for (var officeLoc in this.offices) { + if (this.offices.hasOwnProperty(officeLoc) && + this.offices[officeLoc] instanceof OfficeSpace) { + employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:company}); + } + } + this.thisCycleExpenses = this.thisCycleExpenses.plus(employeeSalary); + + //Process change in demand/competition of materials/products + this.processMaterialMarket(marketCycles); + this.processProductMarket(marketCycles); + + //Process loss of popularity + this.popularity -= (marketCycles * .0001); + this.popularity = Math.max(0, this.popularity); + + //Process Dreamsense gains + var popularityGain = company.getDreamSenseGain(), awarenessGain = popularityGain * 4; + if (popularityGain > 0) { + this.popularity += (popularityGain * marketCycles); + this.awareness += (awarenessGain * marketCycles); + } + + return; + } + + //Process production, purchase, and import/export of materials + var res = this.processMaterials(marketCycles, company); + this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); + this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); + + //Process creation, production & sale of products + res = this.processProducts(marketCycles, company); + this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); + this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); + +} + +//Process change in demand and competition for this industry's materials +Industry.prototype.processMaterialMarket = function(marketCycles=1) { + //References to prodMats and reqMats + var reqMats = this.reqMats, prodMats = this.prodMats; + + //Only 'process the market' for materials that this industry deals with + for (var i = 0; i < Cities.length; ++i) { + //If this industry has a warehouse in this city, process the market + //for every material this industry requires or produces + if (this.warehouses[Cities[i]] instanceof Warehouse) { + var wh = this.warehouses[Cities[i]]; + for (var name in reqMats) { + if (reqMats.hasOwnProperty(name)) { + wh.materials[name].processMarket(); + } + } + + //Produced materials are stored in an array + for (var foo = 0; foo < prodMats.length; ++foo) { + wh.materials[prodMats[foo]].processMarket(); + } + + //Process these twice because these boost production + wh.materials["Hardware"].processMarket(); + wh.materials["Robots"].processMarket(); + wh.materials["AICores"].processMarket(); + wh.materials["RealEstate"].processMarket(); + } + } +} + +//Process change in demand and competition for this industry's products +Industry.prototype.processProductMarket = function(marketCycles=1) { + //Demand gradually decreases, and competition gradually increases + for (var name in this.products) { + if (this.products.hasOwnProperty(name)) { + var product = this.products[name]; + var change = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(1, 3) * 0.0004; + if (this.type === Industries.Pharmaceutical || this.type === Industries.Software || + this.type === Industries.Robotics) { + change *= 3; + } + change *= marketCycles; + product.dmd -= change; + product.cmp += change; + product.cmp = Math.min(product.cmp, 99.99); + product.dmd = Math.max(product.dmd, 0.001); + } + } +} + +//Process production, purchase, and import/export of materials +Industry.prototype.processMaterials = function(marketCycles=1, company) { + var revenue = 0, expenses = 0, industry = this; + this.calculateProductionFactors(); + + //At the start of the export state, set the imports of everything to 0 + if (this.state === "EXPORT") { + for (var i = 0; i < Cities.length; ++i) { + var city = Cities[i], office = this.offices[city]; + if (!(this.warehouses[city] instanceof Warehouse)) { + continue; + } + var warehouse = this.warehouses[city]; + for (var matName in warehouse.materials) { + if (warehouse.materials.hasOwnProperty(matName)) { + var mat = warehouse.materials[matName]; + mat.imp = 0; + } + } + } + } + + for (var i = 0; i < Cities.length; ++i) { + var city = Cities[i], office = this.offices[city]; + + if (this.warehouses[city] instanceof Warehouse) { + var warehouse = this.warehouses[city]; + + switch(this.state) { + + case "PURCHASE": + /* Process purchase of materials */ + for (var matName in warehouse.materials) { + if (warehouse.materials.hasOwnProperty(matName)) { + (function(matName, ind) { + var mat = warehouse.materials[matName]; + var buyAmt, maxAmt; + if (warehouse.smartSupplyEnabled && Object.keys(ind.reqMats).includes(matName)) { + //Smart supply tracker is stored as per second rate + mat.buy = ind.reqMats[matName] * warehouse.smartSupplyStore; + buyAmt = mat.buy * SecsPerMarketCycle * marketCycles; + } else { + buyAmt = (mat.buy * SecsPerMarketCycle * marketCycles); + } + + if (matName == "RealEstate") { + maxAmt = buyAmt; + } else { + maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / MaterialSizes[matName]); + } + var buyAmt = Math.min(buyAmt, maxAmt); + if (buyAmt > 0) { + mat.qty += buyAmt; + expenses += (buyAmt * mat.bCost); + } + })(matName, industry); + this.updateWarehouseSizeUsed(warehouse); + } + } //End process purchase of materials + break; + + case "PRODUCTION": + warehouse.smartSupplyStore = 0; //Reset smart supply amount + + /* Process production of materials */ + if (this.prodMats.length > 0) { + var mat = warehouse.materials[this.prodMats[0]]; + //Calculate the maximum production of this material based + //on the office's productivity + var maxProd = this.getOfficeProductivity(office) * this.prodMult * company.getProductionMultiplier(), prod; + + if (mat.prdman[0]) { + //Production is manually limited + prod = Math.min(maxProd, mat.prdman[1]); + } else { + prod = maxProd; + } + prod *= (SecsPerMarketCycle * marketCycles); //Convert production from per second to per market cycle + //Calculate net change in warehouse storage making + //the produced materials will cost + var totalMatSize = 0; + for (var tmp = 0; tmp < this.prodMats.length; ++tmp) { + totalMatSize += (MaterialSizes[this.prodMats[tmp]]); + } + for (var reqMatName in this.reqMats) { + if (this.reqMats.hasOwnProperty(reqMatName)) { + var normQty = this.reqMats[reqMatName]; + totalMatSize -= (MaterialSizes[reqMatName] * normQty); + } + } + //If not enough space in warehouse, limit the amount of produced materials + if (totalMatSize > 0) { + var maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / totalMatSize); + prod = Math.min(maxAmt, prod); + } + + if (prod < 0) {prod = 0;} + + //Keep track of production for smart supply (/s) + warehouse.smartSupplyStore += (prod / (SecsPerMarketCycle * marketCycles)); + + //Make sure we have enough resource to make our materials + var producableFrac = 1; + for (var reqMatName in this.reqMats) { + if (this.reqMats.hasOwnProperty(reqMatName)) { + var req = this.reqMats[reqMatName] * prod; + if (warehouse.materials[reqMatName].qty < req) { + producableFrac = Math.min(producableFrac, warehouse.materials[reqMatName].qty / req); + } + } + } + if (producableFrac <= 0) {producableFrac = 0; prod = 0;} + + //Make our materials if they are producable + if (producableFrac > 0 && prod > 0) { + for (var reqMatName in this.reqMats) { + if (this.reqMats.hasOwnProperty(reqMatName)) { + var reqMatQtyNeeded = (this.reqMats[reqMatName] * prod * producableFrac); + warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; + warehouse.materials[reqMatName].prd = 0; + warehouse.materials[reqMatName].prd -= reqMatQtyNeeded / (SecsPerMarketCycle * marketCycles); + } + } + for (var j = 0; j < this.prodMats.length; ++j) { + warehouse.materials[this.prodMats[j]].qty += (prod * producableFrac); + warehouse.materials[this.prodMats[j]].qlt = + (office.employeeProd[EmployeePositions.Engineer] / 100 + + Math.pow(this.sciResearch.qty, this.sciFac) + + Math.pow(warehouse.materials["AICores"].qty, this.aiFac) / 10e3); + } + } else { + for (var reqMatName in this.reqMats) { + if (this.reqMats.hasOwnProperty(reqMatName)) { + warehouse.materials[reqMatName].prd = 0; + } + } + } + + //Per second + var fooProd = prod * producableFrac / (SecsPerMarketCycle * marketCycles); + for (var fooI = 0; fooI < this.prodMats.length; ++fooI) { + warehouse.materials[this.prodMats[fooI]].prd = fooProd; + } + } else { + //If this doesn't produce any materials, then it only creates + //Products. Creating products will consume materials. The + //Production of all consumed materials must be set to 0 + for (var reqMatName in this.reqMats) { + if (this.reqMats.hasOwnProperty(reqMatName)) { + warehouse.materials[reqMatName].prd = 0; + } + } + } + break; + + case "SALE": + /* Process sale of materials */ + for (var matName in warehouse.materials) { + if (warehouse.materials.hasOwnProperty(matName)) { + var mat = warehouse.materials[matName]; + if (mat.sCost < 0 || mat.sllman[0] === false) { + mat.sll = 0; + continue; + } + var mat = warehouse.materials[matName]; + + var sCost; + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(mat.sCost)) { + sCost = mat.sCost.replace(/MP/g, mat.bCost); + sCost = eval(sCost); + } else { + sCost = mat.sCost; + } + + //Calculate how much of the material sells (per second) + var markup = 1, markupLimit = mat.qlt / mat.mku; + if (sCost > mat.bCost) { + //Penalty if difference between sCost and bCost is greater than markup limit + if ((sCost - mat.bCost) > markupLimit) { + markup = markupLimit / (sCost - mat.bCost); + } + } else if (sCost < mat.bCost) { + if (sCost <= 0) { + markup = 1e12; //Sell everything, essentially discard + } else { + //Lower prices than market increases sales + markup = mat.bCost / sCost; + } + } + //var businessFactor = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); + var businessFactor = this.getBusinessFactor(office); //Business employee productivity + var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity + var marketFactor = this.getMarketFactor(mat); //Competition + demand + var maxSell = (mat.qlt + .001) * marketFactor * markup * businessFactor * + company.getSalesMultiplier() * advertisingFactor; + + var sellAmt; + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(mat.sllman[1])) { + //Dynamically evaluated + var tmp = mat.sllman[1].replace(/MAX/g, maxSell); + tmp = tmp.replace(/PROD/g, mat.prd); + try { + sellAmt = eval(tmp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error evaluating your sell amount for material " + mat.name + + " in " + this.name + "'s " + city + " office. The sell amount " + + "is being set to zero"); + sellAmt = 0; + } + sellAmt = Math.min(maxSell, sellAmt); + } else if (mat.sllman[1] === -1) { + //Backwards compatibility, -1 = MAX + sellAmt = maxSell; + } else { + //Player's input value is just a number + sellAmt = Math.min(maxSell, mat.sllman[1]); + } + + sellAmt = (sellAmt * SecsPerMarketCycle * marketCycles); + sellAmt = Math.min(mat.qty, sellAmt); + if (sellAmt < 0) { + console.log("sellAmt calculated to be negative"); + mat.sll = 0; + continue; + } + if (sellAmt && sCost >= 0) { + mat.qty -= sellAmt; + revenue += (sellAmt * sCost); + mat.sll = sellAmt / (SecsPerMarketCycle * marketCycles); + } else { + mat.sll = 0; + } + } + } //End processing of sale of materials + break; + + case "EXPORT": + for (var matName in warehouse.materials) { + if (warehouse.materials.hasOwnProperty(matName)) { + var mat = warehouse.materials[matName]; + mat.totalExp = 0; //Reset export + for (var expI = 0; expI < mat.exp.length; ++expI) { + var exp = mat.exp[expI]; + var amt = exp.amt.replace(/MAX/g, mat.qty / (SecsPerMarketCycle * marketCycles)); + try { + amt = eval(amt); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Calculating export for " + mat.name + " in " + + this.name + "'s " + city + " division failed with " + + "error: " + e); + continue; + } + if (isNaN(amt)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error calculating export amount for " + mat.name + " in " + + this.name + "'s " + city + " division."); + continue; + } + amt = amt * SecsPerMarketCycle * marketCycles; + + if (mat.qty < amt) { + amt = mat.qty; + } + if (amt === 0) { + break; //None left + } + for (var foo = 0; foo < company.divisions.length; ++foo) { + if (company.divisions[foo].name === exp.ind) { + var expIndustry = company.divisions[foo]; + var expWarehouse = expIndustry.warehouses[exp.city]; + if (!(expWarehouse instanceof Warehouse)) { + console.log("ERROR: Invalid export! " + expIndustry.name + " " + exp.city); + break; + } + + //Make sure theres enough space in warehouse + if (expWarehouse.sizeUsed >= expWarehouse.size) { + return; //Warehouse at capacity + } else { + var maxAmt = Math.floor((expWarehouse.size - expWarehouse.sizeUsed) / MaterialSizes[matName]); + amt = Math.min(maxAmt, amt); + } + expWarehouse.materials[matName].imp += (amt / (SecsPerMarketCycle * marketCycles)); + expWarehouse.materials[matName].qty += amt; + expWarehouse.materials[matName].qlt = mat.qlt; + mat.qty -= amt; + mat.totalExp += amt; + expIndustry.updateWarehouseSizeUsed(expWarehouse); + break; + } + } + } + //totalExp should be per second + mat.totalExp /= (SecsPerMarketCycle * marketCycles); + } + } + + break; + + case "START": + break; + default: + console.log("ERROR: Invalid state: " + this.state); + break; + } //End switch(this.state) + this.updateWarehouseSizeUsed(warehouse); + + } // End warehouse + + //Produce Scientific Research based on R&D employees + //Scientific Research can be produced without a warehouse + if (office instanceof OfficeSpace) { + this.sciResearch.qty += (.005 * Math.pow(office.employeeProd[EmployeePositions.RandD], 0.5) + * company.getScientificResearchMultiplier()); + } + } + return [revenue, expenses]; +} + +//Process production & sale of this industry's FINISHED products (including all of their stats) +Industry.prototype.processProducts = function(marketCycles=1, corporation) { + var revenue = 0, expenses = 0; + + //Create products + if (this.state === "PRODUCTION") { + for (var prodName in this.products) { + if (this.products.hasOwnProperty(prodName)) { + var prod = this.products[prodName]; + if (!prod.fin) { + var city = prod.createCity, office = this.offices[city]; + var total = office.employeeProd[EmployeePositions.Operations] + + office.employeeProd[EmployeePositions.Engineer] + + office.employeeProd[EmployeePositions.Management], ratio; + if (total === 0) { + ratio = 0; + } else { + ratio = office.employeeProd[EmployeePositions.Engineer] / total + + office.employeeProd[EmployeePositions.Operations] / total + + office.employeeProd[EmployeePositions.Management] / total; + } + prod.createProduct(marketCycles, ratio * Math.pow(total, 0.29)); + if (prod.prog >= 100) { + prod.finishProduct(office.employeeProd, this); + } + break; + } + } + } + } + + //Produce Products + for (var prodName in this.products) { + if (this.products.hasOwnProperty(prodName)) { + var prod = this.products[prodName]; + if (prod instanceof Product && prod.fin) { + revenue += this.processProduct(marketCycles, prod, corporation); + } + } + } + return [revenue, expenses]; +} + +//Processes FINISHED products +Industry.prototype.processProduct = function(marketCycles=1, product, corporation) { + var totalProfit = 0; + for (var i = 0; i < Cities.length; ++i) { + var city = Cities[i], office = this.offices[city], warehouse = this.warehouses[city]; + if (warehouse instanceof Warehouse) { + switch(this.state) { + + case "PRODUCTION": + //Calculate the maximum production of this material based + //on the office's productivity + var maxProd = this.getOfficeProductivity(office, {forProduct:true}) * + corporation.getProductionMultiplier() * this.prodMult, prod; + + //Account for whether production is manually limited + if (product.prdman[city][0]) { + prod = Math.min(maxProd, product.prdman[city][1]); + } else { + prod = maxProd; + } + prod *= (SecsPerMarketCycle * marketCycles); + + //Calculate net change in warehouse storage making the Products will cost + var netStorageSize = product.siz; + for (var reqMatName in product.reqMats) { + if (product.reqMats.hasOwnProperty(reqMatName)) { + var normQty = product.reqMats[reqMatName]; + netStorageSize -= (MaterialSizes[reqMatName] * normQty); + } + } + + //If there's not enough space in warehouse, limit the amount of Product + if (netStorageSize > 0) { + var maxAmt = Math.floor((warehouse.size - warehouse.sizeUsed) / netStorageSize); + prod = Math.min(maxAmt, prod); + } + + warehouse.smartSupplyStore += (prod / (SecsPerMarketCycle * marketCycles)); + + //Make sure we have enough resources to make our Products + var producableFrac = 1; + for (var reqMatName in product.reqMats) { + if (product.reqMats.hasOwnProperty(reqMatName)) { + var req = product.reqMats[reqMatName] * prod; + if (warehouse.materials[reqMatName].qty < req) { + producableFrac = Math.min(producableFrac, warehouse.materials[reqMatName].qty / req); + } + } + } + + //Make our Products if they are producable + if (producableFrac > 0 && prod > 0) { + for (var reqMatName in product.reqMats) { + if (product.reqMats.hasOwnProperty(reqMatName)) { + var reqMatQtyNeeded = (product.reqMats[reqMatName] * prod * producableFrac); + warehouse.materials[reqMatName].qty -= reqMatQtyNeeded; + warehouse.materials[reqMatName].prd -= reqMatQtyNeeded / (SecsPerMarketCycle * marketCycles); + } + } + //Quantity + product.data[city][0] += (prod * producableFrac); + } + + //Keep track of production Per second + product.data[city][1] = prod * producableFrac / (SecsPerMarketCycle * marketCycles); + break; + + case "SALE": + //Process sale of Products + product.pCost = 0; //Estimated production cost + for (var reqMatName in product.reqMats) { + if (product.reqMats.hasOwnProperty(reqMatName)) { + product.pCost += (product.reqMats[reqMatName] * warehouse.materials[reqMatName].bCost); + } + } + + //Since its a product, its production cost is increased for labor + product.pCost *= ProductProductionCostRatio; + + //Calculate Sale Cost (sCost), which could be dynamically evaluated + var sCost; + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(product.sCost)) { + sCost = product.sCost.replace(/MP/g, product.pCost + product.rat / product.mku); + sCost = eval(sCost); + } else { + sCost = product.sCost; + } + + var markup = 1, markupLimit = product.rat / product.mku; + if (sCost > product.pCost) { + if ((sCost - product.pCost) > markupLimit) { + markup = markupLimit / (sCost - product.pCost); + } + } + var businessFactor = this.getBusinessFactor(office); //Business employee productivity + var advertisingFactor = this.getAdvertisingFactors()[0]; //Awareness + popularity + var marketFactor = this.getMarketFactor(product); //Competition + demand + 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(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* 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]); + try { + tmp = eval(tmp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error evaluating your sell price expression for " + product.name + + " in " + this.name + "'s " + city + " office. Sell price is being set to MAX"); + tmp = maxSell; + } + sellAmt = Math.min(maxSell, tmp); + } else if (product.sllman[city][0] && product.sllman[city][1] > 0) { + //Sell amount is manually limited + sellAmt = Math.min(maxSell, product.sllman[city][1]); + } else { + //Backwards compatibility, -1 = 0 + sellAmt = maxSell; + } + sellAmt = sellAmt * SecsPerMarketCycle * marketCycles; + sellAmt = Math.min(product.data[city][0], sellAmt); //data[0] is qty + if (sellAmt && sCost) { + product.data[city][0] -= sellAmt; //data[0] is qty + totalProfit += (sellAmt * sCost); + product.data[city][2] = sellAmt / (SecsPerMarketCycle * marketCycles); //data[2] is sell property + } else { + product.data[city][2] = 0; //data[2] is sell property + } + break; + + case "START": + case "PURCHASE": + case "EXPORT": + break; + default: + console.log("ERROR: Invalid State: " + this.state); + break; + } //End switch(this.state) + } + } + return totalProfit; +} + +Industry.prototype.discontinueProduct = function(product, parentRefs) { + var company = parentRefs.company, industry = parentRefs.industry; + for (var productName in this.products) { + if (this.products.hasOwnProperty(productName)) { + if (product === this.products[productName]) { + delete this.products[productName]; + company.updateUIContent(); + } + } + } +} + +Industry.prototype.upgrade = function(upgrade, refs) { + var corporation = refs.corporation, division = refs.division, + office = refs.office; + var upgN = upgrade[0], basePrice = upgrade[1], priceMult = upgrade[2], + upgradeBenefit = upgrade[3]; + while (this.upgrades.length <= upgN) {this.upgrades.push(0);} + ++this.upgrades[upgN]; + + switch (upgN) { + case 0: //Coffee, 5% energy per employee + for (var i = 0; i < office.employees.length; ++i) { + office.employees[i].ene = Math.min(office.employees[i].ene * 1.05, 100); + } + break; + case 1: //AdVert.Inc, + var advMult = corporation.getAdvertisingMultiplier(); + this.awareness += (3 * advMult); + this.popularity += (1 * advMult); + this.awareness *= (1.01 * advMult); + this.popularity *= ((1 + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(1, 3) / 100) * advMult); + break; + default: + console.log("ERROR: Un-implemented function index: " + upgN); + break; + } +} + +//Returns how much of a material can be produced based of office productivity (employee stats) +Industry.prototype.getOfficeProductivity = function(office, params) { + var total = office.employeeProd[EmployeePositions.Operations] + + office.employeeProd[EmployeePositions.Engineer] + + office.employeeProd[EmployeePositions.Management], ratio; + if (total === 0) { + ratio = 0; + } else { + ratio = (office.employeeProd[EmployeePositions.Operations] / total) * + (office.employeeProd[EmployeePositions.Engineer] / total) * + (office.employeeProd[EmployeePositions.Management] / total); + ratio = Math.max(0.01, ratio); //Minimum ratio value if you have employees + } + if (params && params.forProduct) { + return ratio * Math.pow(total, 0.2); + } else { + return 2 * ratio * Math.pow(total, 0.3); + } +} + +//Returns a multiplier based on the office' 'Business' employees that affects sales +Industry.prototype.getBusinessFactor = function(office) { + var ratioMult = 1; + if (office.employeeProd["total"] > 0) { + ratioMult = 1 + (office.employeeProd[EmployeePositions.Business] / office.employeeProd["total"]); + } + return ratioMult * Math.pow(1 + office.employeeProd[EmployeePositions.Business], 0.15); +} + +//Returns a set of multipliers based on the Industry's awareness, popularity, and advFac. This +//multiplier affects sales. The result is: +// [Total sales mult, total awareness mult, total pop mult, awareness/pop ratio mult] +Industry.prototype.getAdvertisingFactors = function() { + var awarenessFac = Math.pow(this.awareness + 1, this.advFac); + var popularityFac = Math.pow(this.popularity + 1, this.advFac); + var ratioFac = (this.awareness === 0 ? 0.01 : Math.max((this.popularity + .001) / this.awareness, 0.01)); + var totalFac = Math.pow(awarenessFac * popularityFac * ratioFac, 0.85); + return [totalFac, awarenessFac, popularityFac, ratioFac]; +} + +//Returns a multiplier based on a materials demand and competition that affects sales +Industry.prototype.getMarketFactor = function(mat) { + return mat.dmd * (100 - mat.cmp)/100; +} + +Industry.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Industry", this); +} + +Industry.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Industry, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Industry = Industry; + +var EmployeePositions = { + Operations: "Operations", + Engineer: "Engineer", + Business: "Business", + Management: "Management", + RandD: "Research & Development", + Training:"Training", + Unassigned:"Unassigned", +} + +function Employee(params={}) { + if (!(this instanceof Employee)) { + return new Employee(params); + } + this.name = params.name ? params.name : "Bobby"; + + //Morale, happiness, and energy are 0-100 + this.mor = params.morale ? params.morale : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); + this.hap = params.happiness ? params.happiness : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); + this.ene = params.energy ? params.energy : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100); + + this.age = params.age ? params.age : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(20, 50); + this.int = params.intelligence ? params.intelligence : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); + this.cha = params.charisma ? params.charisma : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); + this.exp = params.experience ? params.experience : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); + this.cre = params.creativity ? params.creativity : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); + this.eff = params.efficiency ? params.efficiency : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(10, 50); + this.sal = params.salary ? params.salary : Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(0.1, 5); + this.pro = 0; //Productivity, This is calculated + + this.loc = params.loc ? params.loc : ""; + this.pos = EmployeePositions.Unassigned; +} + +//Returns the amount the employee needs to be paid +Employee.prototype.process = function(marketCycles=1, office) { + var gain = 0.001 * marketCycles, + det = gain * Math.random(); + this.age += gain; + this.exp += gain; + if (this.age > 150) { + this.int -= det; + this.eff -= det; + this.cha -= det; + } + + //Training + var trainingEff = gain * Math.random(); + if (this.pos === EmployeePositions.Training) { + //To increase creativity and intelligence special upgrades are needed + this.cha += trainingEff; + this.exp += trainingEff; + this.eff += trainingEff; + } + + //Weight based on how full office is + //Too many employees = more likely to decrease energy and happiness + var officeCapacityWeight = 0.5 * (office.employees.length / office.size - 0.5); + if (Math.random() < 0.5 - officeCapacityWeight) { + this.ene += det; + this.hap += det; + } else { + this.ene -= det; + this.hap -= det; + } + if (this.ene < office.minEne) {this.ene = office.minEne;} + if (this.hap < office.minHap) {this.hap = office.minHap;} + var salary = this.sal * marketCycles * SecsPerMarketCycle; + return salary; +} + +Employee.prototype.calculateProductivity = function(corporation) { + var effCre = this.cre * corporation.getEmployeeCreMultiplier(), + effCha = this.cha * corporation.getEmployeeChaMultiplier(), + effInt = this.int * corporation.getEmployeeIntMultiplier(), + effEff = this.eff * corporation.getEmployeeEffMultiplier(); + var prodBase = this.mor * this.hap * this.ene * 1e-6, prodMult; + switch(this.pos) { + //Calculate productivity based on position. This is multipled by prodBase + //to get final value + case EmployeePositions.Operations: + prodMult = (0.6 * effInt) + (0.1 * effCha) + (this.exp) + + (0.5 * effCre) + (effEff); + break; + case EmployeePositions.Engineer: + prodMult = (effInt) + (0.1 * effCha) + (1.5 * this.exp) + + (effEff); + break; + case EmployeePositions.Business: + prodMult = (0.4 * effInt) + (effCha) + (0.5 * this.exp); + break; + case EmployeePositions.Management: + prodMult = (2 * effCha) + (this.exp) + (0.2 * effCre) + + (0.7 * effEff); + break; + case EmployeePositions.RandD: + prodMult = (1.5 * effInt) + (0.8 * this.exp) + (effCre) + + (0.5 * effEff); + break; + case EmployeePositions.Unassigned: + case EmployeePositions.Training: + prodMult = 0; + break; + default: + console.log("ERROR: Invalid employee position: " + this.pos); + break; + } + return prodBase * prodMult; +} + +//Process benefits from having an office party thrown +Employee.prototype.throwParty = function(money) { + var mult = 1 + (money / 10e6); + this.mor *= mult; + this.mor = Math.min(100, this.mor); + this.hap *= mult; + this.hap = Math.min(100, this.hap); + return mult; +} + +//'panel' is the DOM element on which to create the UI +Employee.prototype.createUI = function(panel, corporation) { + var effCre = this.cre * corporation.getEmployeeCreMultiplier(), + effCha = this.cha * corporation.getEmployeeChaMultiplier(), + effInt = this.int * corporation.getEmployeeIntMultiplier(), + effEff = this.eff * corporation.getEmployeeEffMultiplier(); + panel.style.color = "white"; + panel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + id:"cmpy-mgmt-employee-" + this.name + "-panel-text", + innerHTML:"Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.mor, 3) + "
" + + "Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.hap, 3) + "
" + + "Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.ene, 3) + "
" + + "Age: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.age, 3) + "
" + + "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effInt, 3) + "
" + + "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCha, 3) + "
" + + "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.exp, 3) + "
" + + "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCre, 3) + "
" + + "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effEff, 3) + "
" + + "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.sal).format("$0.000a") + "/ s
", + })); + + //Selector for employee position + var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {}); + for (var key in EmployeePositions) { + if (EmployeePositions.hasOwnProperty(key)) { + selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text: EmployeePositions[key], + value: EmployeePositions[key], + })); + } + } + + selector.addEventListener("change", ()=>{ + this.pos = selector.options[selector.selectedIndex].value; + }); + + //Set initial value of selector + for (var i = 0; i < selector.length; ++i) { + if (selector.options[i].value === this.pos) { + selector.selectedIndex = i; + break; + } + } + panel.appendChild(selector); +} + +Employee.prototype.updateUI = function(panel, corporation) { + var effCre = this.cre * corporation.getEmployeeCreMultiplier(), + effCha = this.cha * corporation.getEmployeeChaMultiplier(), + effInt = this.int * corporation.getEmployeeIntMultiplier(), + effEff = this.eff * corporation.getEmployeeEffMultiplier(); + if (panel == null) { + console.log("ERROR: Employee.updateUI() called with null panel"); + return; + } + var text = document.getElementById("cmpy-mgmt-employee-" + this.name + "-panel-text"); + if (text == null) { + return this.createUI(panel); + } + text.innerHTML = "Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.mor, 3) + "
" + + "Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.hap, 3) + "
" + + "Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.ene, 3) + "
" + + "Age: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.age, 3) + "
" + + "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effInt, 3) + "
" + + "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCha, 3) + "
" + + "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.exp, 3) + "
" + + "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effCre, 3) + "
" + + "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(effEff, 3) + "
" + + "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.sal).format("$0.000a") + "/ s
"; +} + +Employee.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Employee", this); +} + +Employee.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Employee, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Employee = Employee; + +var OfficeSpaceTiers = { + Basic: "Basic", + Enhanced: "Enhanced", + Luxurious: "Luxurious", + Extravagant: "Extravagant" +} + +function OfficeSpace(params={}) { + this.loc = params.loc ? params.loc : ""; + this.cost = params.cost ? params.cost : 1; + this.size = params.size ? params.size : 1; + this.comf = params.comfort ? params.comfort : 1; + this.beau = params.beauty ? params.beauty : 1; + this.tier = OfficeSpaceTiers.Basic; + + this.minEne = 0; //Minimum energy of employees, based on office + this.minHap = 0; //Minimum happiness of employees, based on office. + + this.employees = []; + this.employeeProd = { + [EmployeePositions.Operations]: 0, + [EmployeePositions.Engineer]: 0, + [EmployeePositions.Business]: 0, + [EmployeePositions.Management]: 0, + [EmployeePositions.RandD]: 0, + total: 0, + }; +} + +OfficeSpace.prototype.process = function(marketCycles=1, parentRefs) { + var corporation = parentRefs.corporation, industry = parentRefs.industry; + var perfMult=1; //Multiplier for employee morale/happiness/energy based on company performance + if (industry.funds < 0 && industry.lastCycleRevenue < 0) { + perfMult = Math.pow(0.99, marketCycles); + } else if (industry.funds > 0 && industry.lastCycleRevenue > 0) { + perfMult = Math.pow(1.01, marketCycles); + } + + var salaryPaid = 0; + for (var i = 0; i < this.employees.length; ++i) { + var emp = this.employees[i]; + emp.mor *= perfMult; + emp.hap *= perfMult; + emp.ene *= perfMult; + var salary = emp.process(marketCycles, this); + salaryPaid += salary; + } + this.calculateEmployeeProductivity(marketCycles, corporation); + return salaryPaid; +} + +OfficeSpace.prototype.calculateEmployeeProductivity = function(marketCycles=1, corporation) { + //Reset + for (var name in this.employeeProd) { + if (this.employeeProd.hasOwnProperty(name)) { + this.employeeProd[name] = 0; + } + } + + var total = 0; + for (var i = 0; i < this.employees.length; ++i) { + var employee = this.employees[i]; + var prod = employee.calculateProductivity(corporation); + this.employeeProd[employee.pos] += prod; + total += prod; + } + this.employeeProd["total"] = total; +} + +//Takes care of UI as well +OfficeSpace.prototype.findEmployees = function(parentRefs) { + var company = parentRefs.corporation, division = parentRefs.division; + if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;} + + //Generate three random employees (meh, decent, amazing) + var mult1 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(25, 50)/100, + mult2 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(51, 75)/100, + mult3 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(76, 100)/100; + var int = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + cha = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + exp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + cre = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + eff = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + sal = 2.2 * (int + cha + exp + cre + eff); + + var emp1 = new Employee({ + intelligence: int * mult1, + charisma: cha * mult1, + experience: exp * mult1, + creativity: cre * mult1, + efficiency: eff * mult1, + salary: sal * mult1, + }); + + var emp2 = new Employee({ + intelligence: int * mult2, + charisma: cha * mult2, + experience: exp * mult2, + creativity: cre * mult2, + efficiency: eff * mult2, + salary: sal * mult2, + }); + + var emp3 = new Employee({ + intelligence: int * mult3, + charisma: cha * mult3, + experience: exp * mult3, + creativity: cre * mult3, + efficiency: eff * mult3, + salary: sal * mult3, + }); + + var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerHTML: "Select one of the following candidates for hire:", + }); + + var createEmpDiv = function(employee, office) { + var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-find-employee-option", + innerHTML: "Intelligence: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.int, 1) + "
" + + "Charisma: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.cha, 1) + "
" + + "Experience: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.exp, 1) + "
" + + "Creativity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.cre, 1) + "
" + + "Efficiency: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(employee.eff, 1) + "
" + + "Salary: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(employee.sal).format('$0.000a') + " \ s
", + clickListener:()=>{ + office.hireEmployee(employee, parentRefs); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-hire-employee-popup"); + return false; + } + }); + return div; + }; + + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Cancel", + float:"right", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-hire-employee-popup"); + return false; + } + }); + + var elems = [text, + createEmpDiv(emp1, this), + createEmpDiv(emp2, this), + createEmpDiv(emp3, this), + cancelBtn]; + + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])("cmpy-mgmt-hire-employee-popup", elems); +} + +OfficeSpace.prototype.hireEmployee = function(employee, parentRefs) { + var company = parentRefs.corporation, division = parentRefs.division; + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerHTML = "Hire"; + noBtn.innerHTML = "Cancel"; + yesBtn.addEventListener("click", ()=>{ + var name = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])(); + for (var i = 0; i < this.employees.length; ++i) { + if (this.employees[i].name === name) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You already have an employee with this nickname! Please give every employee a unique nickname."); + return false; + } + } + employee.name = name; + this.employees.push(employee); + company.displayDivisionContent(division, currentCityUi); + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Give your employee a nickname!"); +} + +OfficeSpace.prototype.hireRandomEmployee = function(parentRefs) { + var company = parentRefs.corporation, division = parentRefs.division; + if (document.getElementById("cmpy-mgmt-hire-employee-popup") != null) {return;} + + //Generate three random employees (meh, decent, amazing) + var mult = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(76, 100)/100; + var int = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + cha = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + exp = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + cre = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + eff = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["h" /* getRandomInt */])(50, 100), + sal = 2.2 * (int + cha + exp + cre + eff); + + var emp = new Employee({ + intelligence: int * mult, + charisma: cha * mult, + experience: exp * mult, + creativity: cre * mult, + efficiency: eff * mult, + salary: sal * mult, + }); + + var name = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["d" /* generateRandomString */])(7); + + for (var i = 0; i < this.employees.length; ++i) { + if (this.employees[i].name === name) { + return this.hireRandomEmployee(parentRefs); + } + } + emp.name = name; + this.employees.push(emp); + company.displayDivisionContent(division, currentCityUi); +} + +//Finds the first unassigned employee and assigns its to the specified job +OfficeSpace.prototype.assignEmployeeToJob = function(job) { + for (var i = 0; i < this.employees.length; ++i) { + if (this.employees[i].pos === EmployeePositions.Unassigned) { + this.employees[i].pos = job; + return true; + } + } + return false; +} + +//Finds the first employee with the given job and unassigns it +OfficeSpace.prototype.unassignEmployeeFromJob = function(job) { + for (var i = 0; i < this.employees.length; ++i) { + if (this.employees[i].pos === job) { + this.employees[i].pos = EmployeePositions.Unassigned; + return true; + } + } + return false; +} + +OfficeSpace.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("OfficeSpace", this); +} + +OfficeSpace.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(OfficeSpace, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.OfficeSpace = OfficeSpace; + +function Warehouse(params={}) { + this.loc = params.loc ? params.loc : ""; + this.size = params.size ? params.size : 0; + this.level = 0; + this.sizeUsed = 0; + this.smartSupplyEnabled = false; //Whether or not smart supply is enabled + this.breakdown = ""; + + //Stores the amount of product to be produced. Used for Smart Supply unlock. + //The production tracked by smart supply is always based on the previous cycle, + //so it will always trail the "true" production by 1 cycle + this.smartSupplyStore = 0; + + this.materials = { + Water: new Material({name: "Water"}), + Energy: new Material({name: "Energy"}), + Food: new Material({name: "Food"}), + Plants: new Material({name: "Plants"}), + Metal: new Material({name: "Metal"}), + Hardware: new Material({name: "Hardware"}), + Chemicals: new Material({name: "Chemicals"}), + Drugs: new Material({name: "Drugs"}), + Robots: new Material({name: "Robots"}), + AICores: new Material({name: "AI Cores"}), + RealEstate: new Material({name: "Real Estate"}) + } +} + +Warehouse.prototype.updateMaterialSizeUsed = function() { + this.sizeUsed = 0; + this.breakdown = ""; + for (var matName in this.materials) { + if (this.materials.hasOwnProperty(matName)) { + var mat = this.materials[matName]; + if (MaterialSizes.hasOwnProperty(matName)) { + this.sizeUsed += (mat.qty * MaterialSizes[matName]); + if (mat.qty > 0) { + this.breakdown += (matName + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qty * MaterialSizes[matName], 0) + "
"); + } + } + } + } + if (this.sizeUsed > this.size) { + console.log("ERROR: Warehouse size used greater than capacity, something went wrong"); + } +} + +Warehouse.prototype.updateSize = function(corporation) { + //Backwards compatibility + if (this.level == null || this.level === 0) { + this.level = Math.round(this.size / 100); + } + + this.size = (this.level * 100) * corporation.getStorageMultiplier(); +} + +Warehouse.prototype.createUI = function(parentRefs) { + if (parentRefs.company == null || parentRefs.industry == null) { + console.log("ERROR: Warehouse.createUI called without parentRefs.company or parentRefs.industry"); + return; + } + var company = parentRefs.company, industry = parentRefs.industry; + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehousePanel); + industryWarehouseStorageText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + display:"inline-block", class:"tooltip", + color: this.sizeUsed >= this.size ? "red" : "white", + }); + industryWarehousePanel.appendChild(industryWarehouseStorageText); + + //Upgrade warehouse size button + var upgradeCost = WarehouseUpgradeBaseCost * Math.pow(1.07, this.level+1); + industryWarehouseUpgradeSizeButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Upgrade Warehouse Size - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost).format('$0.000a'), + display:"inline-block", + class: company.funds.lt(upgradeCost) ? "a-link-button-inactive" : "a-link-button", + clickListener:()=>{ + //Backwards compatibility + if (this.level == null || this.level === 0) { + this.level = Math.round(this.size / 100); + } + + ++this.level; + this.updateSize(company); + company.funds = company.funds.minus(upgradeCost); + this.createUI(parentRefs); + return; + } + }); + industryWarehousePanel.appendChild(industryWarehouseUpgradeSizeButton); + + //Material requirement text + var reqText = "This Industry uses [" + Object.keys(industry.reqMats).join(", ") + + "] in order to "; + if (industry.prodMats.length > 0) { + reqText += "produce [" + industry.prodMats.join(", ") + "] "; + if (industry.makesProducts) { + reqText += " and " + industry.getProductDescriptionText(); + } + } else if (industry.makesProducts) { + reqText += industry.getProductDescriptionText(); + } + reqText += "

To get started with production, purchase your required " + + "materials or import them from another of your company's divisions.

"; + + //Material ratio text for tooltip + var reqRatioText = "The exact requirements for production are:
"; + for (var matName in industry.reqMats) { + if (industry.reqMats.hasOwnProperty(matName)) { + reqRatioText += (industry.reqMats[matName] + " " + matName + "
"); + } + } + reqRatioText += "in order to create "; + if (industry.prodMats.length > 0) { + reqRatioText += "one of each produced Material (" + industry.prodMats.join(", ") + ") "; + if (industry.makesProducts) { + reqRatioText += "or to create one of its Products"; + } + } else if (industry.makesProducts) { + reqRatioText += "one of its Products"; + } + + industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML:reqText, tooltipleft:reqRatioText + })); + + //Current state + industryWarehouseStateText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p"); + industryWarehousePanel.appendChild(industryWarehouseStateText); + + //Smart Supply Enable/Disable + if (company.unlockUpgrades[1]) { + if (this.smartSupplyEnabled == null) {this.smartSupplyEnabled = false;} + var smartSupplyCheckboxId = "cmpy-mgmt-smart-supply-checkbox"; + industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("label", { + for:smartSupplyCheckboxId, innerText:"Enable Smart Supply", + color:"white" + })); + industrySmartSupplyCheckbox = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"checkbox", id:smartSupplyCheckboxId, margin:"3px", + changeListener:()=>{ + this.smartSupplyEnabled = industrySmartSupplyCheckbox.checked; + } + }); + industrySmartSupplyCheckbox.checked = this.smartSupplyEnabled; + industryWarehousePanel.appendChild(industrySmartSupplyCheckbox); + } + + //Materials + industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "
Materials:
", + })); + industryWarehouseMaterials = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("ul"); + industryWarehousePanel.appendChild(industryWarehouseMaterials); + + //Products + if (industry.makesProducts && Object.keys(industry.products).length > 0) { + industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "
Products:
", + })); + industryWarehouseProducts = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("ul"); + industryWarehousePanel.appendChild(industryWarehouseProducts); + } + + this.updateUI(parentRefs); +} + +Warehouse.prototype.updateUI = function(parentRefs) { + if (parentRefs.company == null || parentRefs.industry == null) { + console.log("ERROR: Warehouse.updateUI called without parentRefs.company or parentRefs.industry"); + return; + } + var company = parentRefs.company, industry = parentRefs.industry; + + //Storage text + var storageText = "Storage: " + + (this.sizedUsed >= this.size ? Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sizeUsed, 3) : Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sizeUsed, 3)) + + "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.size, 3); + if (this.breakdown != null && this.breakdown != "") { + storageText += ("" + + this.breakdown + ""); + } + industryWarehouseStorageText.innerHTML = storageText; + + //Upgrade warehouse size button + var upgradeCost = WarehouseUpgradeBaseCost * Math.pow(1.07, this.level+1); + if (company.funds.lt(upgradeCost)) { + industryWarehouseUpgradeSizeButton.className = "a-link-button-inactive"; + } else { + industryWarehouseUpgradeSizeButton.className = "a-link-button"; + } + + //Current state + var stateText = "Current state: "; + switch(industry.state) { + case "START": + stateText += "Preparing..."; + break; + case "PURCHASE": + stateText += "Purchasing materials..."; + break; + case "PRODUCTION": + stateText += "Producing materials and/or products..."; + break; + case "SALE": + stateText += "Selling materials and/or products..."; + break; + case "EXPORT": + stateText += "Exporting materials and/or products..."; + break; + default: + console.log("ERROR: Invalid state: " + industry.state); + break; + } + industryWarehouseStateText.innerText = stateText; + + //Materials + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehouseMaterials); + for (var matName in this.materials) { + if (this.materials.hasOwnProperty(matName) && this.materials[matName] instanceof Material) { + if (Object.keys(industry.reqMats).includes(matName) || industry.prodMats.includes(matName) || + matName === "Hardware" || matName === "Robots" || matName === "AICores" || + matName === "RealEstate") { + industryWarehouseMaterials.appendChild(this.createMaterialUI(this.materials[matName], matName, parentRefs)); + } + } + } + + //Products + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryWarehouseProducts); + if (industry.makesProducts && Object.keys(industry.products).length > 0) { + for (var productName in industry.products) { + if (industry.products.hasOwnProperty(productName) && industry.products[productName] instanceof Product) { + industryWarehouseProducts.appendChild(this.createProductUI(industry.products[productName], parentRefs)); + } + } + } +} + +Warehouse.prototype.createMaterialUI = function(mat, matName, parentRefs) { + if (parentRefs.company == null || parentRefs.industry == null) { + console.log("ERROR: Warehouse.createMaterialUI called without industry or company parent refs"); + return; + } + var company = parentRefs.company, industry = parentRefs.industry; + var purchasePopupId = "cmpy-mgmt-material-purchase-popup", + sellPopupid = "cmpy-mgmt-material-sell-popup"; + var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-warehouse-material-div", + }); + + var totalGain = mat.buy + mat.prd + mat.imp - mat.sll - mat.totalExp; + + //If Market Research upgrades are unlocked, add competition and demand info + var cmpAndDmdText = ""; + if (company.unlockUpgrades[2] === 1) { + cmpAndDmdText += "
Competition: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.cmp, 3); + } + if (company.unlockUpgrades[3] === 1) { + cmpAndDmdText += "
Demand: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.dmd, 3); + } + var innerTxt = "

" + mat.name + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qty, 3) + + "(" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalGain, 3) + "/s)" + + "Buy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.buy, 3) + + "/s
Prod: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.prd, 3) + "/s
Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + + "/s
Export: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.totalExp, 3) + "/s
Import: " + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.imp, 3) + "/s" + cmpAndDmdText + "


" + + "

MP: $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.bCost, 2) + + "Market Price: The price you would pay if " + + "you were to buy this material on the market


" + + "

Quality: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.qlt, 2) + + "The quality of your material. Higher quality " + + "will lead to more sales

"; + + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: innerTxt, + id: "cmpy-mgmt-warehouse-" + matName + "-text", display:"inline-block", + })); + + var buttonPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + display:"inline-block", + }); + div.appendChild(buttonPanel); + + //Button to set purchase amount + var tutorial = industry.newInd && Object.keys(industry.reqMats).includes(mat.name) && + mat.buy === 0 && mat.imp === 0; + var buyButtonParams = { + innerText: "Buy (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.buy, 3) + ")", display:"inline-block", + class: tutorial ? "a-link-button flashing-button" : "a-link-button", + clickListener:()=>{ + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Enter the amount of " + mat.name + " you would like " + + "to purchase per second. This material's cost changes constantly" + }); + var confirmBtn; + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", value:mat.buy ? mat.buy : null, placeholder: "Purchase amount", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Confirm", class:"a-link-button", + clickListener:()=>{ + if (isNaN(input.value)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount"); + } else { + mat.buy = parseFloat(input.value); + if (isNaN(mat.buy)) {mat.buy = 0;} + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); + this.createUI(parentRefs); + return false; + } + } + }); + var clearButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Clear Purchase", class:"a-link-button", + clickListener:()=>{ + mat.buy = 0; + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); + this.createUI(parentRefs); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Cancel", class:"a-link-button", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(purchasePopupId); + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(purchasePopupId, [txt, input, confirmBtn, clearButton, cancelBtn]); + input.focus(); + } + }; + if (tutorial) { + buyButtonParams.tooltip = "Purchase your required materials to get production started!"; + } + buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", buyButtonParams)); + + //Button to manage exports + if (company.unlockUpgrades[0] === 1) { //Export unlock upgrade + function createExportPopup() { + var popupId = "cmpy-mgmt-export-popup"; + var exportTxt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Select the industry and city to export this material to, as well as " + + "how much of this material to export per second. You can set the export " + + "amount to 'MAX' to export all of the materials in this warehouse." + }); + + //Select industry and city to export to + var citySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select"); + var industrySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { + changeListener:()=>{ + var industryName = industrySelector.options[industrySelector.selectedIndex].value; + for (var foo = 0; foo < company.divisions.length; ++foo) { + if (company.divisions[foo].name == industryName) { + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["c" /* clearSelector */])(citySelector); + var selectedIndustry = company.divisions[foo]; + for (var cityName in company.divisions[foo].warehouses) { + if (company.divisions[foo].warehouses[cityName] instanceof Warehouse) { + citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + value:cityName, text:cityName, + })); + } + } + return; + } + } + } + }); + + for (var i = 0; i < company.divisions.length; ++i) { + industrySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text:company.divisions[i].name, value:company.divisions[i].name, + })); //End create element option + } //End for + + var currIndustry = industrySelector.options[industrySelector.selectedIndex].value; + for (var i = 0; i < company.divisions.length; ++i) { + if (company.divisions[i].name == currIndustry) { + for (var cityName in company.divisions[i].warehouses) { + if (company.divisions[i].warehouses.hasOwnProperty(cityName) && + company.divisions[i].warehouses[cityName] instanceof Warehouse) { + citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + value:cityName, text:cityName, + })); + } + } + break; + } + } + + //Select amount to export + var exportAmount = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + placeholder:"Export amount / s" + }); + + var exportBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Export", + clickListener:()=>{ + var industryName = industrySelector.options[industrySelector.selectedIndex].text, + cityName = citySelector.options[citySelector.selectedIndex].text, + amt = exportAmount.value; + //Sanitize amt + var sanitizedAmt = amt.replace(/\s+/g, ''); + sanitizedAmt = sanitizedAmt.replace(/[^-()\d/*+.MAX]/g, ''); + var temp = sanitizedAmt.replace(/MAX/g, 1); + try { + temp = eval(temp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid expression entered for export amount: " + e); + return false; + } + + if (temp == null || isNaN(temp)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid amount entered for export"); + return; + } + var exportObj = {ind:industryName, city:cityName, amt:sanitizedAmt}; + mat.exp.push(exportObj); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + + var currExportsText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Below is a list of all current exports of this material from this warehouse. " + + "Clicking on one of the exports below will REMOVE that export." + }); + var currExports = []; + for (var i = 0; i < mat.exp.length; ++i) { + (function(i, mat, currExports){ + currExports.push(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-existing-export", + innerHTML: "Industry: " + mat.exp[i].ind + "
" + + "City: " + mat.exp[i].city + "
" + + "Amount/s: " + mat.exp[i].amt, + clickListener:()=>{ + mat.exp.splice(i, 1); //Remove export object + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + createExportPopup(); + } + })); + })(i, mat, currExports); + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [exportTxt, industrySelector, citySelector, exportAmount, + exportBtn, cancelBtn, currExportsText].concat(currExports)); + } + buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Export", display:"inline-block", class:"a-link-button", + clickListener:()=>{createExportPopup();} + })); + } + + buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); // Force line break + + //Button to set sell amount + var innerTextString; + if (mat.sllman[0]) { + innerTextString = (mat.sllman[1] === -1 ? "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + "/MAX)" : + "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sll, 3) + "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sllman[1], 3) + ")"); + if (mat.sCost) { + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(mat.sCost)) { + var sCost = mat.sCost.replace(/MP/g, mat.bCost); + innerTextString += " @ $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(eval(sCost), 2); + } else { + innerTextString += " @ $" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(mat.sCost, 2); + } + } + } else { + innerTextString = "Sell (0.000/0.000)"; + } + + buttonPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText: innerTextString, display:"inline-block", class:"a-link-button", + clickListener:()=>{ + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Enter the maximum amount of " + mat.name + " you would like " + + "to sell per second, as well as the price at which you would " + + "like to sell at.

" + + "If the sell amount is set to 0, then the material will not be sold. If the sell price " + + "if set to 0, then the material will be discarded

" + + "Setting the sell amount to 'MAX' will result in you always selling the " + + "maximum possible amount of the material.

" + + "When setting the sell amount, you can use the 'PROD' variable to designate a dynamically " + + "changing amount that depends on your production. For example, if you set the sell amount " + + "to 'PROD-5' then you will always sell 5 less of the material than you produce.

" + + "When setting the sell price, you can use the 'MP' variable to designate a dynamically " + + "changing price that depends on the market price. For example, if you set the sell price " + + "to 'MP+10' then it will always be sold at $10 above the market price.", + }); + var br = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); + var confirmBtn; + var inputQty = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", marginTop:"4px", + value: mat.sllman[1] ? mat.sllman[1] : null, placeholder: "Sell amount", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + var inputPx = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", marginTop:"4px", + value: mat.sCost ? mat.sCost : null, placeholder: "Sell price", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Confirm", class:"a-link-button", margin:"6px", + clickListener:()=>{ + //Parse price + var cost = inputPx.value.replace(/\s+/g, ''); + cost = cost.replace(/[^-()\d/*+.MP]/g, ''); //Sanitize cost + var temp = cost.replace(/MP/g, mat.bCost); + try { + temp = eval(temp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field: " + e); + return false; + } + + if (temp == null || isNaN(temp)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field"); + return false; + } + + if (cost.includes("MP")) { + mat.sCost = cost; //Dynamically evaluated + } else { + mat.sCost = temp; + } + + //Parse quantity + if (inputQty.value.includes("MAX") || inputQty.value.includes("PROD")) { + var qty = inputQty.value.replace(/\s+/g, ''); + qty = qty.replace(/[^-()\d/*+.MAXPROD]/g, ''); + var temp = qty.replace(/MAX/g, 1); + temp = temp.replace(/PROD/g, 1); + try { + temp = eval(temp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field: " + e); + return false; + } + + if (temp == null || isNaN(temp)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field"); + return false; + } + + mat.sllman[0] = true; + mat.sllman[1] = qty; //Use sanitized input + } else if (isNaN(inputQty.value)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell quantity field! Must be numeric or 'MAX'"); + return false; + } else { + var qty = parseFloat(inputQty.value); + if (isNaN(qty)) {qty = 0;} + if (qty === 0) { + mat.sllman[0] = false; + mat.sllman[1] = 0; + } else { + mat.sllman[0] = true; + mat.sllman[1] = qty; + } + } + + this.createUI(parentRefs); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(sellPopupid); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Cancel", class:"a-link-button", margin: "6px", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(sellPopupid); + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(sellPopupid, [txt, br, inputQty, inputPx, confirmBtn, cancelBtn]); + inputQty.focus(); + } + })); + + return div; +} + +Warehouse.prototype.createProductUI = function(product, parentRefs) { + var company = parentRefs.company, industry = parentRefs.industry, + city = currentCityUi; + var div = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-warehouse-product-div" + }); + + //Products being designed TODO + if (!product.fin) { + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Designing " + product.name + "...
" + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.prog, 2) + "% complete", + })); + return div; + } + + //Completed products + var cmpAndDmdText = ""; + if (company.unlockUpgrades[2] === 1) { + cmpAndDmdText += "
Competition: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.cmp, 3); + } + if (company.unlockUpgrades[3] === 1) { + cmpAndDmdText += "
Demand: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.dmd, 3); + } + var totalGain = product.data[city][1] - product.data[city][2]; //Production - sale + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "

" + product.name + ": " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][0], 3) + //Quantity + "(" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalGain, 3) + "/s)" + + "Prod: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][1], 3) + "/s
" + + "Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/s


" + + "

Rating: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.rat, 3) + + "Quality: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.qlt, 3) + "
" + + "Performance: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.per, 3) + "
" + + "Durability: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.dur, 3) + "
" + + "Reliability: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.rel, 3) + "
" + + "Aesthetics: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.aes, 3) + "
" + + "Features: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.fea, 3) + + cmpAndDmdText + "


" + + "

Est. Production Cost: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.pCost / ProductProductionCostRatio).format("$0.000a") + + "An estimate of the material cost it takes to create this Product.


" + + "

Est. Market Price: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.pCost + product.rat / product.mku).format("$0.000a") + + "An estimate of how much consumers are willing to pay for this product. " + + "Setting the sale price above this may result in less sales. Setting the sale price below this may result " + + "in more sales.

" + })); + var buttonPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + display:"inline-block", + }); + div.appendChild(buttonPanel); + + //Sell button + var sellInnerTextString = (product.sllman[city][1] === -1 ? "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/MAX)" : + "Sell (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.sllman[city][1], 3) + ")"); + if (product.sCost) { + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(product.sCost)) { + sellInnerTextString += (" @ " + product.sCost); + } else { + sellInnerTextString += (" @ " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(product.sCost).format("$0.000a")); + } + } + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:sellInnerTextString, class:"a-link-button", display:"inline-block",margin:"6px", + clickListener:()=>{ + var popupId = "cmpy-mgmt-sell-product-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML:"Enter the maximum amount of " + product.name + " you would like " + + "to sell per second, as well as the price at which you would like to " + + "sell it at.

" + + "If the sell amount is set to 0, then the product will not be sold. If the " + + "sell price is set to 0, then the product will be discarded.

" + + "Setting the sell amount to 'MAX' will result in you always selling the " + + "maximum possible amount of the material.

" + + "When setting the sell amount, you can use the 'PROD' variable to designate a " + + "dynamically changing amount that depends on your production. For example, " + + "if you set the sell amount to 'PROD-1' then you will always sell 1 less of " + + "the material than you produce.

" + + "When setting the sell price, you can use the 'MP' variable to set a " + + "dynamically changing price that depends on the Product's estimated " + + "market price. For example, if you set it to 'MP*5' then it " + + "will always be sold at five times the estimated market price.", + }); + var confirmBtn; + var inputQty = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", value:product.sllman[city][1] ? product.sllman[city][1] : null, placeholder: "Sell amount", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + var inputPx = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", value: product.sCost ? product.sCost : null, placeholder: "Sell price", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Confirm", + clickListener:()=>{ + //Parse price + if (inputPx.value.includes("MP")) { + //Dynamically evaluated quantity. First test to make sure its valid + //Sanitize input, then replace dynamic variables with arbitrary numbers + var price = inputPx.value.replace(/\s+/g, ''); + price = price.replace(/[^-()\d/*+.MP]/g, ''); + var temp = price.replace(/MP/g, 1); + try { + temp = eval(temp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell quantity field: " + e); + return false; + } + if (temp == null || isNaN(temp)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell quantity field."); + return false; + } + product.sCost = price; //Use sanitized price + } else { + var cost = parseFloat(inputPx.value); + if (isNaN(cost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell price field"); + return false; + } + product.sCost = cost; + } + + //Parse quantity + if (inputQty.value.includes("MAX") || inputQty.value.includes("PROD")) { + //Dynamically evaluated quantity. First test to make sure its valid + var qty = inputQty.value.replace(/\s+/g, ''); + qty = qty.replace(/[^-()\d/*+.MAXPROD]/g, ''); + var temp = qty.replace(/MAX/g, 1); + temp = temp.replace(/PROD/g, 1); + try { + temp = eval(temp); + } catch(e) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field: " + e); + return false; + } + + if (temp == null || isNaN(temp)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value or expression for sell price field"); + return false; + } + product.sllman[city][0] = true; + product.sllman[city][1] = qty; //Use sanitized input + } else if (isNaN(inputQty.value)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for sell quantity field! Must be numeric"); + return false; + } else { + var qty = parseFloat(inputQty.value); + if (isNaN(qty)) {qty = 0;} + if (qty === 0) { + product.sllman[city][0] = false; + } else { + product.sllman[city][0] = true; + product.sllman[city][1] = qty; + } + } + this.createUI(parentRefs); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, inputQty, inputPx, confirmBtn, cancelBtn]); + inputQty.focus(); + } + })); + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br",{})); //force line break + + //Limit production button + var limitProductionInnerText = "Limit Production"; + if (product.prdman[city][0]) { + limitProductionInnerText += " (" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.prdman[city][1], 3) + ")"; + } + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:limitProductionInnerText,display:"inline-block", + clickListener:()=>{ + var popupId = "cmpy-mgmt-limit-product-production-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Enter a limit to the amount of this product you would " + + "like to product per second. Leave the box empty to set no limit." + }); + var confirmBtn; + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", placeholder:"Limit", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Limit production", margin:'6px', + clickListener:()=>{ + if (input.value === "") { + product.prdman[city][0] = false; + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + var qty = parseFloat(input.value); + if (isNaN(qty)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value entered"); + return false; + } + if (qty < 0) { + product.prdman[city][0] = false; + } else { + product.prdman[city][0] = true; + product.prdman[city][1] = qty; + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Cancel", margin:"6px", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, input, confirmBtn, cancelBtn]); + } + })); + + //Discontinue button + div.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:'a-link-button', display:"inline-block",innerText:"Discontinue", + clickListener:()=>{ + var popupId = "cmpy-mgmt-discontinue-product-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Are you sure you want to do this? Discontinuing a product " + + "removes it completely and permanently. You will no longer " + + "produce this product and all of its existing stock will be " + + "removed and left unsold", + }); + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button",innerText:"Discontinue", + clickListener:()=>{ + industry.discontinueProduct(product, parentRefs); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, confirmBtn, cancelBtn]); + } + })); + return div; +} + +Warehouse.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Warehouse", this); +} + +Warehouse.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Warehouse, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Warehouse = Warehouse; + +//Corporation Unlock Upgrades +//Upgrades for entire corporation, unlocks features, either you have it or you dont +//The structure is [index in Corporation feature upgrades array, price ] +var CorporationUnlockUpgrades = { + //Lets you export goods + "0": [0, 20e9, "Export", + "Develop infrastructure to export your materials to your other facilities. " + + "This allows you to move materials around between different divisions and cities."], + + //Lets you buy exactly however many required materials you need for production + "1": [1, 50e9, "Smart Supply", "Use advanced AI to anticipate your supply needs. " + + "This allows you to purchase exactly however many materials you need for production."], + + //Displays each material/product's demand + "2": [2, 5e9, "Market Research - Demand", + "Mine and analyze market data to determine the demand of all resources. " + + "The demand attribute, which affects sales, will be displayed for every material and product."], + + //Display's each material/product's competition + "3": [3, 5e9, "Market Data - Competition", + "Mine and analyze market data to determine how much competition there is on the market " + + "for all resources. The competition attribute, which affects sales, will be displayed for " + + "for every material and product."], + "4": [4, 10e9, "VeChain", + "Use AI and blockchain technology to identify where you can improve your supply chain systems. " + + "This upgrade will allow you to view a wide array of useful statistics about your " + + "Corporation."] +} + +//Corporation Upgrades +//Upgrades for entire corporation, levelable upgrades +//The structure is [index in Corporation upgrades array, base price, price mult, benefit mult (additive), +// name, desc] +var CorporationUpgrades = { + //Smart factories, increases production + "0": [0, 2e9, 1.07, 0.03, + "Smart Factories", "Advanced AI automatically optimizes the operation and productivity " + + "of factories. Each level of this upgrade increases your global production by 3% (additive)."], + + //Smart warehouses, increases storage size + "1": [1, 2e9, 1.07, .1, + "Smart Storage", "Advanced AI automatically optimizes your warehouse storage methods. " + + "Each level of this upgrade increases your global warehouse storage size by 10% (additive)."], + + //Advertise through dreams, passive popularity/ awareness gain + "2": [2, 8e9, 1.09, .001, + "DreamSense", "Use DreamSense LCC Technologies to advertise your corporation " + + "to consumers through their dreams. Each level of this upgrade provides a passive " + + "increase in awareness of all of your companies (divisions) by 0.004 / market cycle," + + "and in popularity by 0.001 / market cycle. A market cycle is approximately " + + "20 seconds."], + + //Makes advertising more effective + "3": [3, 4e9, 1.12, 0.005, + "Wilson Analytics", "Purchase data and analysis from Wilson, a marketing research " + + "firm. Each level of this upgrades increases the effectiveness of your " + + "advertising by 0.5% (additive)."], + + //Augmentation for employees, increases cre + "4": [4, 1e9, 1.06, 0.1, + "Nuoptimal Nootropic Injector Implants", "Purchase the Nuoptimal Nootropic " + + "Injector augmentation for your employees. Each level of this upgrade " + + "globally increases the creativity of your employees by 10% (additive)."], + + //Augmentation for employees, increases cha + "5": [5, 1e9, 1.06, 0.1, + "Speech Processor Implants", "Purchase the Speech Processor augmentation for your employees. " + + "Each level of this upgrade globally increases the charisma of your employees by 10% (additive)."], + + //Augmentation for employees, increases int + "6": [6, 1e9, 1.06, 0.1, + "Neural Accelerators", "Purchase the Neural Accelerator augmentation for your employees. " + + "Each level of this upgrade globally increases the intelligence of your employees " + + "by 10% (additive)."], + + //Augmentation for employees, increases eff + "7": [7, 1e9, 1.06, 0.1, + "FocusWires", "Purchase the FocusWire augmentation for your employees. Each level " + + "of this upgrade globally increases the efficiency of your employees by 10% (additive)."], + + //Improves sales of materials/products + "8": [8, 1e9, 1.08, 0.01, + "ABC SalesBots", "Always Be Closing. Purchase these robotic salesmen to increase the amount of " + + "materials and products you sell. Each level of this upgrade globally increases your sales " + + "by 1% (additive)."], + + //Improves scientific research rate + "9": [9, 5e9, 1.07, 0.05, + "Project Insight", "Purchase 'Project Insight', a R&D service provided by the secretive " + + "Fulcrum Technologies. Each level of this upgrade globally increases the amount of " + + "Scientific Research you produce by 5% (additive)."], +} + +function Corporation(params={}) { + this.name = params.name ? params.name : "The Corporation"; + + //A division/business sector is represented by the object: + this.divisions = []; + + //Financial stats + this.funds = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(150e9); + this.revenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.expenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.fundingRound = 0; + this.public = false; //Publicly traded + this.numShares = TOTALSHARES; + this.issuedShares = 0; + this.sharePrice = 0; + this.storedCycles = 0; + + var numUnlockUpgrades = Object.keys(CorporationUnlockUpgrades).length, + numUpgrades = Object.keys(CorporationUpgrades).length; + + this.unlockUpgrades = Array(numUnlockUpgrades).fill(0); + this.upgrades = Array(numUpgrades).fill(0); + this.upgradeMultipliers = Array(numUpgrades).fill(1); + + this.state = new CorporationState(); +} + +Corporation.prototype.getState = function() { + return this.state.getState(); +} + +Corporation.prototype.storeCycles = function(numCycles=1) { + this.storedCycles += numCycles; +} + +Corporation.prototype.process = function() { + var corp = this; + if (this.storedCycles >= CyclesPerIndustryStateCycle) { + var state = this.getState(), marketCycles=1; + this.storedCycles -= (marketCycles * CyclesPerIndustryStateCycle); + + //At the start of a new cycle, calculate profits from previous cycle + if (state === "START") { + this.revenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.expenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + this.divisions.forEach((ind)=>{ + this.revenue = this.revenue.plus(ind.lastCycleRevenue); + this.expenses = this.expenses.plus(ind.lastCycleExpenses); + }); + var profit = this.revenue.minus(this.expenses); + var cycleProfit = profit.times(marketCycles * SecsPerMarketCycle); + if (isNaN(this.funds)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("There was an error calculating your Corporations funds and they got reset to 0. " + + "This is a bug. Please report to game developer.

" + + "(Your funds have been set to $150b for the inconvenience)"); + this.funds = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(150e9); + } + this.funds = this.funds.plus(cycleProfit); + this.updateSharePrice(); + } + + this.divisions.forEach(function(ind) { + ind.process(marketCycles, state, corp); + }); + + + this.state.nextState(); + + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage === __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.Corporation) {this.updateUIContent();} + } +} + +Corporation.prototype.determineValuation = function() { + var val, profit = (this.revenue.minus(this.expenses)).toNumber(); + if (this.public) { + val = this.funds.toNumber() + (profit * 85e3); + val *= (Math.pow(1.1, this.divisions.length)); + val = Math.max(val, 0); + } else { + val = 10e9 + Math.max(this.funds.toNumber(), 0) / 3; //Base valuation + if (profit > 0) { + val += (profit * 320e3); + val *= (Math.pow(1.1, this.divisions.length)); + } else { + val = 10e9 * Math.pow(1.1, this.divisions.length); + } + val -= (val % 1e6); //Round down to nearest millionth + } + return val * __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["a" /* BitNodeMultipliers */].CorporationValuation; +} + +Corporation.prototype.getInvestment = function() { + var val = this.determineValuation(), percShares; + switch (this.fundingRound) { + case 0: //Seed + percShares = 0.10; + break; + case 1: //Series A + percShares = 0.35; + break; + case 2: //Series B + percShares = 0.25; + break; + case 3: //Series C + percShares = 0.20; + break; + case 4: + return; + } + var funding = val * percShares * 4, + investShares = Math.floor(TOTALSHARES * percShares), + yesBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["d" /* yesNoBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["c" /* yesNoBoxGetNoButton */])(); + yesBtn.innerHTML = "Accept"; + noBtn.innerHML = "Reject"; + yesBtn.addEventListener("click", ()=>{ + ++this.fundingRound; + this.funds = this.funds.plus(funding); + this.numShares -= investShares; + this.displayCorporationOverviewContent(); + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); + }); + noBtn.addEventListener("click", ()=>{ + return Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["a" /* yesNoBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_12__utils_YesNoBox_js__["b" /* yesNoBoxCreate */])("An investment firm has offered you " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(funding).format('$0.000a') + + " in funding in exchange for a " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(percShares*100).format("0.000a") + + "% stake in the company (" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(investShares).format('0.000a') + " shares).

" + + "Do you accept or reject this offer?"); +} + +Corporation.prototype.goPublic = function() { + var goPublicPopupId = "cmpy-mgmt-go-public-popup"; + var initialSharePrice = this.determineValuation() / (TOTALSHARES); + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Enter the number of shares you would like to issue " + + "for your IPO. These shares will be publicly sold " + + "and you will no longer own them. Your Corporation will receive " + + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(initialSharePrice).format('$0.000a') + " per share " + + "(the IPO money will be deposited directly into your Corporation's funds).

" + + "Furthermore, issuing more shares now will help drive up " + + "your company's stock price in the future.

" + + "You have a total of " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.numShares).format("0.000a") + " of shares that you can issue.", + }); + var yesBtn; + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", + placeholder: "Shares to issue", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {yesBtn.click();} + } + }); + var br = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); + yesBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Go Public", + clickListener:()=>{ + var numShares = Math.round(input.value); + var initialSharePrice = this.determineValuation() / (TOTALSHARES); + if (isNaN(numShares)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for number of issued shares"); + return false; + } + if (numShares > this.numShares) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Error: You don't have that many shares to issue!"); + return false; + } + this.public = true; + this.sharePrice = initialSharePrice; + this.issuedShares = numShares; + this.numShares -= numShares; + this.funds = this.funds.plus(numShares * initialSharePrice); + this.displayCorporationOverviewContent(); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(goPublicPopupId); + return false; + } + }); + var noBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(goPublicPopupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(goPublicPopupId, [txt, br, input, yesBtn, noBtn]); +} + +Corporation.prototype.updateSharePrice = function() { + var targetPrice = this.determineValuation() / (TOTALSHARES - this.issuedShares); + if (this.sharePrice <= targetPrice) { + this.sharePrice *= (1 + (Math.random() * 0.01)); + } else { + this.sharePrice *= (1 - (Math.random() * 0.01)); + } + if (this.sharePrice <= 0.01) {this.sharePrice = 0.01;} +} + +//One time upgrades that unlock new features +Corporation.prototype.unlock = function(upgrade) { + var upgN = upgrade[0], price = upgrade[1]; + while (this.unlockUpgrades.length <= upgN) { + this.unlockUpgrades.push(0); + } + if (this.funds.lt(price)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough funds to unlock this!"); + return; + } + this.unlockUpgrades[upgN] = 1; + this.funds = this.funds.minus(price); +} + +//Levelable upgrades +Corporation.prototype.upgrade = function(upgrade) { + var upgN = upgrade[0], basePrice = upgrade[1], priceMult = upgrade[2], + upgradeAmt = upgrade[3]; //Amount by which the upgrade multiplier gets increased (additive) + while (this.upgrades.length <= upgN) {this.upgrades.push(0);} + while (this.upgradeMultipliers.length <= upgN) {this.upgradeMultipliers.push(1);} + var totalCost = basePrice * Math.pow(priceMult, this.upgrades[upgN]); + if (this.funds.lt(totalCost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough funds to purchase this!"); + return; + } + ++this.upgrades[upgN]; + this.funds = this.funds.minus(totalCost); + + //Increase upgrade multiplier + this.upgradeMultipliers[upgN] = 1 + (this.upgrades[upgN] * upgradeAmt); + + //If storage size is being updated, update values in Warehouse objects + if (upgN === 1) { + for (var i = 0; i < this.divisions.length; ++i) { + var industry = this.divisions[i]; + for (var city in industry.warehouses) { + if (industry.warehouses.hasOwnProperty(city) && industry.warehouses[city] instanceof Warehouse) { + industry.warehouses[city].updateSize(this); + } + } + } + } + + this.updateCorporationOverviewContent(); +} + +Corporation.prototype.getProductionMultiplier = function() { + var mult = this.upgradeMultipliers[0]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getStorageMultiplier = function() { + var mult = this.upgradeMultipliers[1]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getDreamSenseGain = function() { + var gain = this.upgradeMultipliers[2] - 1; + return gain <= 0 ? 0 : gain; +} + +Corporation.prototype.getAdvertisingMultiplier = function() { + var mult = this.upgradeMultipliers[3]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getEmployeeCreMultiplier = function() { + var mult = this.upgradeMultipliers[4]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getEmployeeChaMultiplier = function() { + var mult = this.upgradeMultipliers[5]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getEmployeeIntMultiplier = function() { + var mult = this.upgradeMultipliers[6]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getEmployeeEffMultiplier = function() { + var mult = this.upgradeMultipliers[7]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getSalesMultiplier = function() { + var mult = this.upgradeMultipliers[8]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +Corporation.prototype.getScientificResearchMultiplier = function() { + var mult = this.upgradeMultipliers[9]; + if (isNaN(mult) || mult < 1) {return 1;} else {return mult;} +} + +//Keep 'global' variables for DOM elements so we don't have to search +//through the DOM tree repeatedly when updating UI +var companyManagementDiv, companyManagementHeaderTabs, companyManagementPanel, + currentCityUi, + corporationUnlockUpgrades, corporationUpgrades, + + //Industry Overview Panel + industryOverviewPanel, industryOverviewText, + + //Industry Employee Panel + industryEmployeePanel, industryEmployeeText, industryEmployeeHireButton, industryEmployeeAutohireButton, + industryEmployeeManagementUI, industryEmployeeInfo, industryIndividualEmployeeInfo, + industryOfficeUpgradeSizeButton, + + //Industry Warehouse Panel + industryWarehousePanel, industrySmartSupplyCheckbox, industryWarehouseStorageText, + industryWarehouseUpgradeSizeButton, industryWarehouseStateText, + industryWarehouseMaterials, industryWarehouseProducts, + headerTabs, cityTabs; +Corporation.prototype.createUI = function() { + companyManagementDiv = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"cmpy-mgmt-container", + position:"fixed", + class:"generic-menupage-container" + }); + companyManagementHeaderTabs = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {id:"cmpy-mgmt-header-tabs"}); + companyManagementDiv.appendChild(companyManagementHeaderTabs); + + //Create division/industry tabs at the top + this.updateUIHeaderTabs(); + + //Create the 'panel' that will have the actual content in the UI + companyManagementPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {id:"cmpy-mgmt-panel"}); + companyManagementDiv.appendChild(companyManagementPanel); + document.getElementById("entire-game-container").appendChild(companyManagementDiv); + + this.displayCorporationOverviewContent(); +} + +Corporation.prototype.updateUIHeaderTabs = function() { + if (companyManagementHeaderTabs) { + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(companyManagementHeaderTabs); + } else { + console.log("ERROR: Header tabs div has not yet been created when Corporation.updateUIHeaderTabs() is called"); + return; + } + + //Corporation overview tabs + var cmpyOverviewHdrTab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { + id:"cmpy-mgmt-company-tab", + class:"cmpy-mgmt-header-tab", + innerText:this.name, + checked:true, + clickListener:()=>{ + this.selectHeaderTab(cmpyOverviewHdrTab); + this.displayCorporationOverviewContent(); + return false; + } + }); + companyManagementHeaderTabs.appendChild(cmpyOverviewHdrTab); + + //Tabs for each division + for (var i = 0; i < this.divisions.length; ++i) { + this.createDivisionUIHeaderTab(this.divisions[i]); + } + + //Create a tab to expand into a new industry + companyManagementHeaderTabs.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { + id:'cmpy-mgmt-expand-industry-tab', + class:"cmpy-mgmt-header-tab", + innerText:"Expand into new Industry", + clickListener: ()=>{ + if (document.getElementById("cmpy-mgmt-expand-industry-popup") != null) {return;} + + var container = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"popup-box-container", + id:"cmpy-mgmt-expand-industry-popup", + }); + var content = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"popup-box-content"}); + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Create a new division to expand into a new industry:", + }); + var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { + class:"cmpy-mgmt-industry-select" + }); + var industryDescription = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); + var yesBtn; + var nameInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"text", + id:"cmpy-mgmt-expand-industry-name-input", + color:"white", + backgroundColor:"black", + display:"block", + maxLength: 30, + pattern:"[a-zA-Z0-9-_]", + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {yesBtn.click();} + } + }); + var nameLabel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("label", { + for:"cmpy-mgmt-expand-industry-name-input", + innerText:"Division name: " + }); + yesBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { + class:"popup-box-button", + innerText:"Create Division", + clickListener: ()=>{ + var ind = selector.options[selector.selectedIndex].value, + newDivisionName = nameInput.value; + + for (var i = 0; i < this.divisions.length; ++i) { + if (this.divisions[i].name === newDivisionName) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("This name is already in use!"); + return false; + } + } + if (this.funds.lt(IndustryStartingCosts[ind])) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Not enough money to create a new division in this industry"); + } else if (newDivisionName === "") { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("New division must have a name!"); + } else { + this.funds = this.funds.minus(IndustryStartingCosts[ind]); + var newInd = new Industry({ + name:newDivisionName, + type:ind, + }); + this.divisions.push(newInd); + this.updateUIHeaderTabs(); + this.selectHeaderTab(headerTabs[headerTabs.length-2]); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-expand-industry-popup"); + this.displayDivisionContent(newInd, __WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12); + } + return false; + } + }); + var noBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { + class:"popup-box-button", + innerText:"Cancel", + clickListener: function() { + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])("cmpy-mgmt-expand-industry-popup"); + return false; + } + }); + + //Make an object to keep track of what industries you're already in + var ownedIndustries = {} + for (var i = 0; i < this.divisions.length; ++i) { + ownedIndustries[this.divisions[i].type] = true; + } + + //Add industry types to selector + //Have Agriculture be first as recommended option + if (!ownedIndustries["Agriculture"]) { + selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text:Industries["Agriculture"], value:"Agriculture" + })); + } + + for (var key in Industries) { + if (key !== "Agriculture" && Industries.hasOwnProperty(key) && !ownedIndustries[key]) { + var ind = Industries[key]; + selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text: ind,value:key, + })); + } + } + + //Initial Industry Description + var ind = selector.options[selector.selectedIndex].value; + industryDescription.innerHTML = (IndustryDescriptions[ind] + "

"); + + //Change the industry description text based on selected option + selector.addEventListener("change", function() { + var ind = selector.options[selector.selectedIndex].value; + industryDescription.innerHTML = IndustryDescriptions[ind] + "

"; + }); + + //Add to DOM + content.appendChild(txt); + content.appendChild(selector); + content.appendChild(industryDescription); + content.appendChild(nameLabel); + content.appendChild(nameInput); + content.appendChild(noBtn); + content.appendChild(yesBtn); + container.appendChild(content); + document.getElementById("entire-game-container").appendChild(container); + container.style.display = "block"; + return false; + } + })); + + headerTabs = companyManagementDiv.getElementsByClassName("cmpy-mgmt-header-tab"); +} + +//Updates UI to display which header tab is selected +Corporation.prototype.selectHeaderTab = function(currentTab) { + if (currentTab == null) {return;} + for (var i = 0; i < headerTabs.length; ++i) { + headerTabs[i].className = "cmpy-mgmt-header-tab"; + } + currentTab.className = "cmpy-mgmt-header-tab current"; +} + +Corporation.prototype.createDivisionUIHeaderTab = function(division) { + var tabId = "cmpy-mgmt-" + division.name + "-tab"; + var tab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { + id:tabId, + class:"cmpy-mgmt-header-tab", + innerText:division.name, + clickListener:()=>{ + this.selectHeaderTab(tab); + this.displayDivisionContent(division, __WEBPACK_IMPORTED_MODULE_4__Location_js__["a" /* Locations */].Sector12); + return false; + } + }); + companyManagementHeaderTabs.appendChild(tab); +} + +Corporation.prototype.clearUIPanel = function() { + while(companyManagementPanel.firstChild) { + companyManagementPanel.removeChild(companyManagementPanel.firstChild); + } +} + +Corporation.prototype.updateUIContent = function() { + //Check which of the header tab buttons is checked + if (headerTabs == null) { + console.log("ERROR: headerTabs is null in Corporation.updateUIContent()"); + return; + } + for (var i = 0; i < headerTabs.length; ++i) { + if (headerTabs[i].classList.contains("current")) { + if (i === 0) { + //Corporation overview + this.updateCorporationOverviewContent(); + } else { + //Division + this.updateDivisionContent(this.divisions[i-1]); + } + return; + } + } +} + +Corporation.prototype.displayCorporationOverviewContent = function() { + this.clearUIPanel(); + companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + id:"cmpy-mgmt-overview-text", + })); + if (headerTabs && headerTabs.length >= 1) { + this.selectHeaderTab(headerTabs[0]); + } + + //Check if player has Corporation Handbook + var homeComp = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].getHomeComputer(), hasHandbook = false, + handbookFn = "corporation-management-handbook.lit"; + for (var i = 0; i < homeComp.messages.length; ++i) { + if (Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["f" /* isString */])(homeComp.messages[i]) && homeComp.messages[i] === handbookFn) { + hasHandbook = true; + break; + } + } + + companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Getting Started Guide", display:"inline-block", + tooltip:"Get a copy of and read 'The Complete Handbook for Creating a Successful Corporation.' " + + "This is a .lit file that guides you through the beginning of setting up a Corporation and " + + "provides some tips/pointers for helping you get started with managing it.", + clickListener:()=>{ + if (!hasHandbook) {homeComp.messages.push(handbookFn);} + Object(__WEBPACK_IMPORTED_MODULE_3__Literature_js__["b" /* showLiterature */])(handbookFn); + return false; + } + })); + + //Investors + if (this.public) { + //Sell share buttons + var sellShares = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Sell Shares", display:"inline-block", + tooltip:"Sell your shares in the company. This is the only way to " + + "profit from your business venture.", + clickListener:()=>{ + var popupId = "cmpy-mgmt-sell-shares-popup"; + var currentStockPrice = this.sharePrice; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Enter the number of shares you would like to sell. The money from " + + "selling your shares will go directly to you (NOT your Corporation). " + + "The current price of your " + + "company's stock is " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(currentStockPrice).format("$0.000a"), + }); + var profitIndicator = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", placeholder:"Shares to sell", margin:"5px", + inputListener: ()=> { + var numShares = Math.round(input.value); + if (isNaN(numShares) || numShares <= 0) { + profitIndicator.innerText = "ERROR: Invalid value entered for number of shares to sell" + } else if (numShares > this.numShares) { + profitIndicator.innerText = "You don't have this many shares to sell!"; + } else { + profitIndicator.innerText = "Sell " + numShares + " shares for a total of " + + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(numShares * currentStockPrice).format('$0.000a'); + } + } + }); + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Sell shares", display:"inline-block", + clickListener:()=>{ + var shares = Math.round(input.value); + if (isNaN(shares) || shares <= 0) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value for number of shares"); + } else if (shares > this.numShares) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You don't have this many shares to sell"); + } else { + this.numShares -= shares; + if (isNaN(this.issuedShares)) { + console.log("ERROR: Corporation issuedShares is NaN: " + this.issuedShares); + console.log("Converting to number now"); + var res = parseInt(this.issuedShares); + if (isNaN(res)) { + this.issuedShares = 0; + } else { + this.issuedShares = res; + } + } + this.issuedShares += shares; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(shares * this.sharePrice); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Cancel", display:"inline-block", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, profitIndicator, input, confirmBtn, cancelBtn]); + } + }); + + //Buyback shares button + var buybackShares = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Buyback shares", display:"inline-block", + tooltip:"Buy back shares you that previously issued or sold at market price.", + clickListener:()=>{ + var popupId = "cmpy-mgmt-buyback-shares-popup"; + var currentStockPrice = this.sharePrice; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML: "Enter the number of shares you would like to buy back at market price. To purchase " + + "these shares, you must use your own money (NOT your Corporation's funds). " + + "The current price of your " + + "company's stock is " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(currentStockPrice).format("$0.000a") + + ". Your company currently has " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.issuedShares, 3) + " outstanding stock shares", + }); + var costIndicator = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", placeholder:"Shares to buyback", margin:"5px", + inputListener: ()=> { + var numShares = Math.round(input.value); + //TODO add conditional for if player doesn't have enough money + if (isNaN(numShares) || numShares <= 0) { + costIndicator.innerText = "ERROR: Invalid value entered for number of shares to buyback" + } else if (numShares > this.issuedShares) { + costIndicator.innerText = "There are not this many shares available to buy back. " + + "There are only " + this.issuedShares + " outstanding shares."; + } else { + console.log("here"); + costIndicator.innerText = "Purchase " + numShares + " shares for a total of " + + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(numShares * currentStockPrice).format('$0.000a'); + } + } + }); + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Buy shares", display:"inline-block", + clickListener:()=>{ + var shares = Math.round(input.value); + var tempStockPrice = this.sharePrice; + if (isNaN(shares) || shares <= 0) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value for number of shares"); + } else if (shares > this.issuedShares) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: There are not this many oustanding shares to buy back"); + } else if (shares * tempStockPrice > __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have enough money to purchase this many shares (you need " + + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(shares * tempStockPrice).format("$0.000a") + ")"); + } else { + this.numShares += shares; + if (isNaN(this.issuedShares)) { + console.log("ERROR: Corporation issuedShares is NaN: " + this.issuedShares); + console.log("Converting to number now"); + var res = parseInt(this.issuedShares); + if (isNaN(res)) { + this.issuedShares = 0; + } else { + this.issuedShares = res; + } + } + this.issuedShares -= shares; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(shares * tempStockPrice); + //TODO REMOVE from Player money + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + } + return false; + + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Cancel", + display:"inline-block", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, costIndicator, input, confirmBtn, cancelBtn]); + } + }); + + companyManagementPanel.appendChild(sellShares); + companyManagementPanel.appendChild(buybackShares); + + //If your Corporation is big enough, buy faction influence through bribes + var canBribe = this.determineValuation() >= BribeThreshold; + var bribeFactions = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: canBribe ? "a-link-button" : "a-link-button-inactive", + innerText:"Bribe Factions", display:"inline-block", + tooltip:canBribe + ? "Use your Corporations power and influence to bribe Faction leaders in exchange for reputation" + : "Your Corporation is not powerful enough to bribe Faction leaders", + clickListener:()=>{ + var popupId = "cmpy-mgmt-bribe-factions-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"You can use Corporation funds or stock shares to bribe Faction Leaders in exchange for faction reputation" + }); + var factionSelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {margin:"3px"}); + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].factions.length; ++i) { + var facName = __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].factions[i]; + factionSelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text:facName, value:facName + })); + } + var repGainText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p"); + var stockSharesInput; + var moneyInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", placeholder:"Corporation funds", margin:"5px", + inputListener:()=>{ + var money = moneyInput.value == null || moneyInput.value == "" ? 0 : parseFloat(moneyInput.value); + var stockPrice = this.sharePrice; + var stockShares = stockSharesInput.value == null || stockSharesInput.value == "" ? 0 : Math.round(parseFloat(stockSharesInput.value)); + if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { + repGainText.innerText = "ERROR: Invalid value(s) entered"; + } else if (this.funds.lt(money)) { + repGainText.innerText = "ERROR: You do not have this much money to bribe with"; + } else if (this.stockShares > this.numShares) { + repGainText.innerText = "ERROR: You do not have this many shares to bribe with"; + } else { + + var totalAmount = Number(money) + (stockShares * stockPrice); + var repGain = totalAmount / BribeToRepRatio; + repGainText.innerText = "You will gain " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + + " reputation with " + + factionSelector.options[factionSelector.selectedIndex].value + + " with this bribe"; + } + } + }); + stockSharesInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", placeholder:"Stock Shares", margin: "5px", + inputListener:()=>{ + var money = moneyInput.value == null || moneyInput.value == "" ? 0 : parseFloat(moneyInput.value); + var stockPrice = this.sharePrice; + var stockShares = stockSharesInput.value == null || stockSharesInput.value == "" ? 0 : Math.round(stockSharesInput.value); + if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { + repGainText.innerText = "ERROR: Invalid value(s) entered"; + } else if (this.funds.lt(money)) { + repGainText.innerText = "ERROR: You do not have this much money to bribe with"; + } else if (this.stockShares > this.numShares) { + repGainText.innerText = "ERROR: You do not have this many shares to bribe with"; + } else { + var totalAmount = money + (stockShares * stockPrice); + var repGain = totalAmount / BribeToRepRatio; + console.log("repGain: " + repGain); + repGainText.innerText = "You will gain " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + + " reputation with " + + factionSelector.options[factionSelector.selectedIndex].value + + " with this bribe"; + } + } + }); + var confirmButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Bribe", display:"inline-block", + clickListener:()=>{ + var money = moneyInput.value == null || moneyInput.value == "" ? 0 : parseFloat(moneyInput.value); + var stockPrice = this.sharePrice; + var stockShares = stockSharesInput.value == null || stockSharesInput.value == ""? 0 : Math.round(parseFloat(stockSharesInput.value)); + var fac = __WEBPACK_IMPORTED_MODULE_2__Faction_js__["b" /* Factions */][factionSelector.options[factionSelector.selectedIndex].value]; + if (fac == null) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You must select a faction to bribe"); + return false; + } + if (isNaN(money) || isNaN(stockShares) || money < 0 || stockShares < 0) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid value(s) entered"); + } else if (this.funds.lt(money)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have this much money to bribe with"); + } else if (stockShares > this.numShares) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: You do not have this many shares to bribe with"); + } else { + var totalAmount = money + (stockShares * stockPrice); + var repGain = totalAmount / BribeToRepRatio; + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You gained " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(repGain, 0) + + " reputation with " + fac.name + " by bribing them."); + fac.playerReputation += repGain; + this.funds = this.funds.minus(money); + this.numShares -= stockShares; + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + } + }); + var cancelButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Cancel", display:"inline-block", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, factionSelector, repGainText, + moneyInput, stockSharesInput, confirmButton, cancelButton]); + } + }); + companyManagementPanel.appendChild(bribeFactions); + } else { + var findInvestors = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: this.fundingRound >= 4 ? "a-link-button-inactive" : "a-link-button tooltip", + innerText: "Find Investors", + display:"inline-block", + clickListener:()=>{ + this.getInvestment(); + } + }); + if (this.fundingRound < 4) { + var findInvestorsTooltip = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { + class:"tooltiptext", + innerText:"Search for private investors who will give you startup funding in exchange " + + "for equity (stock shares) in your company" + }); + findInvestors.appendChild(findInvestorsTooltip); + } + + var goPublic = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button tooltip", + innerText:"Go Public", + display:"inline-block", + clickListener:()=>{ + this.goPublic(); + return false; + } + }); + var goPublicTooltip = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("span", { + class:"tooltiptext", + innerText: "Become a publicly traded and owned entity. Going public involves " + + "issuing shares for an IPO. Once you are a public company, " + + "your shares will be traded on the stock market." + }); + goPublic.appendChild(goPublicTooltip); + + companyManagementPanel.appendChild(findInvestors); + companyManagementPanel.appendChild(goPublic); + } + + //Update overview text + this.updateCorporationOverviewContent(); + + //Don't show upgrades if player hasn't opened any divisions + if (this.divisions.length <= 0) {return; } + //Corporation Upgrades + var upgradeContainer = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-upgrade-container", + }); + upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Unlocks", margin:"6px", padding:"6px", + })); + + //Unlock upgrades + var corp = this; + var numUnlockUpgrades = Object.keys(CorporationUnlockUpgrades).length, + numUpgrades = Object.keys(CorporationUpgrades).length; + if (this.unlockUpgrades == null || this.upgrades == null) { //Backwards compatibility + this.unlockUpgrades = Array(numUnlockUpgrades).fill(0); + this.upgrades = Array(numUpgrades).fill(0); + } + while (this.unlockUpgrades.length < numUnlockUpgrades) {this.unlockUpgrades.push(0);} + while (this.upgrades.length < numUpgrades) {this.upgrades.push(0);} + while (this.upgradeMultipliers < numUpgrades) {this.upgradeMultipliers.push(1);} + + for (var i = 0; i < numUnlockUpgrades; ++i) { + (function(i, corp) { + if (corp.unlockUpgrades[i] === 0) { + var upgrade = CorporationUnlockUpgrades[i.toString()]; + if (upgrade == null) { + console.log("ERROR: Could not find upgrade index " + i); + return; + } + + upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-upgrade-div", width:"45%", + innerHTML:upgrade[2] + " - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgrade[1]).format("$0.000a"), + tooltip: upgrade[3], + clickListener:()=>{ + if (corp.funds.lt(upgrade[1])) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); + } else { + corp.unlock(upgrade); + corp.displayCorporationOverviewContent(); + } + } + })); + } + })(i, corp); + } + + //Levelable upgrades + upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h1", { + innerText:"Upgrades", margin:"6px", padding:"6px", + })); + + for (var i = 0; i < numUpgrades; ++i) { + (function(i, corp) { + var upgrade = CorporationUpgrades[i.toString()]; + if (upgrade == null) { + console.log("ERROR: Could not find levelable upgrade index " + i); + return; + } + + var baseCost = upgrade[1], priceMult = upgrade[2]; + var cost = baseCost * Math.pow(priceMult, corp.upgrades[i]); + upgradeContainer.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-upgrade-div", width:"45%", + innerHTML:upgrade[4] + " - " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(cost).format("$0.000a"), + tooltip:upgrade[5], + clickListener:()=>{ + if (corp.funds.lt(cost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); + } else { + corp.upgrade(upgrade); + corp.displayCorporationOverviewContent(); + } + } + })); + })(i, corp); + } + + companyManagementPanel.appendChild(upgradeContainer); +} + +Corporation.prototype.updateCorporationOverviewContent = function() { + var p = document.getElementById("cmpy-mgmt-overview-text"); + if (p == null) { + console.log("WARNING: Could not find overview text elemtn in updateCorporationOverviewContent()"); + return; + } + var totalFunds = this.funds, + totalRevenue = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0), + totalExpenses = new __WEBPACK_IMPORTED_MODULE_6__utils_decimal_js___default.a(0); + + var profit = this.revenue.minus(this.expenses).toNumber(), + profitStr = profit >= 0 ? __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(profit).format("$0.000a") : "-" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(-1 * profit).format("$0.000a"); + + var txt = "Total Funds: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(totalFunds.toNumber()).format('$0.000a') + "
" + + "Total Revenue: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.revenue.toNumber()).format("$0.000a") + " / s
" + + "Total Expenses: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.expenses.toNumber()).format("$0.000a") + "/ s
" + + "Total Profits: " + profitStr + " / s
" + + "Publicly Traded: " + (this.public ? "Yes" : "No") + "
" + + "Owned Stock Shares: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.numShares).format('0.000a') + "
" + + "Stock Price: " + (this.public ? "$" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(this.sharePrice, 2) : "N/A") + "

"; + + var prodMult = this.getProductionMultiplier(), + storageMult = this.getStorageMultiplier(), + advMult = this.getAdvertisingMultiplier(), + empCreMult = this.getEmployeeCreMultiplier(), + empChaMult = this.getEmployeeChaMultiplier(), + empIntMult = this.getEmployeeIntMultiplier(), + empEffMult = this.getEmployeeEffMultiplier(), + salesMult = this.getSalesMultiplier(), + sciResMult = this.getScientificResearchMultiplier(); + if (prodMult > 1) {txt += "Production Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(prodMult, 3) + "
";} + if (storageMult > 1) {txt += "Storage Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(storageMult, 3) + "
";} + if (advMult > 1) {txt += "Advertising Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(advMult, 3) + "
";} + if (empCreMult > 1) {txt += "Empl. Creativity Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empCreMult, 3) + "
";} + if (empChaMult > 1) {txt += "Empl. Charisma Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empChaMult, 3) + "
";} + if (empIntMult > 1) {txt += "Empl. Intelligence Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empIntMult, 3) + "
";} + if (empEffMult > 1) {txt += "Empl. Efficiency Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(empEffMult, 3) + "
";} + if (salesMult > 1) {txt += "Sales Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(salesMult, 3) + "
";} + if (sciResMult > 1) {txt += "Scientific Research Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(sciResMult, 3) + "
";} + p.innerHTML = txt; +} + +Corporation.prototype.displayDivisionContent = function(division, city) { + this.clearUIPanel(); + currentCityUi = city; + + //Add the city tabs on the left + for (var cityName in division.offices) { + if (division.offices[cityName] instanceof OfficeSpace) { + this.createCityUITab(cityName, division); + } + } + cityTabs = companyManagementPanel.getElementsByClassName("cmpy-mgmt-city-tab"); + if (cityTabs.length > 0) { + this.selectCityTab(document.getElementById("cmpy-mgmt-city-" + city + "-tab"), city); + } + + //Expand into new City button + companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { + class:"cmpy-mgmt-city-tab", innerText:"Expand into new City", display:"inline-block", + clickListener:()=>{ + var popupId = "cmpy-mgmt-expand-city-popup"; + var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText: "Would you like to expand into a new city by opening an office? " + + "This would cost " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(OfficeInitialCost).format('$0.000a'), + }); + var citySelector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {margin:"5px"}); + for (var cityName in division.offices) { + if (division.offices.hasOwnProperty(cityName)) { + if (!(division.offices[cityName] instanceof OfficeSpace)) { + citySelector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + text: cityName, + value: cityName + })); + } + } + } + + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Confirm", class:"a-link-button", display:"inline-block", margin:"3px", + clickListener:()=>{ + var city = citySelector.options[citySelector.selectedIndex].value; + if (this.funds.lt(OfficeInitialCost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to open a new office!"); + } else { + this.funds = this.funds.minus(OfficeInitialCost); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Opened a new office in " + city + "!"); + division.offices[city] = new OfficeSpace({ + loc:city, + size:OfficeInitialSize, + }); + this.displayDivisionContent(division, city); + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Cancel", class:"a-link-button", display:"inline-block", margin:"3px", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }) + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [text, citySelector, confirmBtn, cancelBtn]); + return false; + } + })); + companyManagementPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); // Force line break + + //Get office object + var office = division.offices[currentCityUi]; + if (!(office instanceof OfficeSpace)) { + console.log("ERROR: Current city for UI does not have an office space"); + return; + } + + //Left and right panels + var leftPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"cmpy-mgmt-industry-left-panel"}); + var rightPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {class:"cmpy-mgmt-industry-right-panel"}); + companyManagementPanel.appendChild(leftPanel); + companyManagementPanel.appendChild(rightPanel); + + //Different sections (Overview, Employee/Office, and Warehouse) + industryOverviewPanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"cmpy-mgmt-industry-overview-panel", class:"cmpy-mgmt-industry-overview-panel" + }); + leftPanel.appendChild(industryOverviewPanel); + + industryEmployeePanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"cmpy-mgmt-employee-panel", class:"cmpy-mgmt-employee-panel" + }); + leftPanel.appendChild(industryEmployeePanel); + + industryWarehousePanel = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + id:"cmpy-mgmt-warehouse-panel", class:"cmpy-mgmt-warehouse-panel" + }); + rightPanel.appendChild(industryWarehousePanel); + + //Industry overview text + industryOverviewText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {}); + industryOverviewPanel.appendChild(industryOverviewText); + industryOverviewPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + //Industry overview Purchases & Upgrades + var numUpgrades = Object.keys(IndustryUpgrades).length; + while (division.upgrades.length < numUpgrades) {division.upgrades.push(0);} //Backwards compatibility + + var industryOverviewUpgrades = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {}); + industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("u", { + innerText:"Purchases & Upgrades", margin:"2px", padding:"2px", + fontSize:"14px", + })); + industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + for (var i = 0; i < numUpgrades; ++i) { + (function(i, corp, division, office) { + var upgrade = IndustryUpgrades[i.toString()]; + if (upgrade == null) { + console.log("ERROR: Could not find levelable upgrade index: " + i); + return; + } + + var baseCost = upgrade[1], priceMult = upgrade[2], cost = 0; + switch(i) { + case 0: //Coffee, cost is static per employee + cost = office.employees.length * baseCost; + break; + default: + cost = baseCost * Math.pow(priceMult, division.upgrades[i]); + break; + } + industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + class:"cmpy-mgmt-upgrade-div", display:"inline-block", + innerHTML:upgrade[4] + ' - ' + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(cost).format("$0.000a"), + tooltip:upgrade[5], + clickListener:()=>{ + if (corp.funds.lt(cost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Insufficient funds"); + } else { + corp.funds = corp.funds.minus(cost); + division.upgrade(upgrade, { + corporation:corp, + office:office, + }); + corp.displayDivisionContent(division, city); + } + } + })); + industryOverviewUpgrades.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + })(i, this, division, office); + } + + + industryOverviewPanel.appendChild(industryOverviewUpgrades); + + //Industry Overview 'Create Product' button if applicable + if (division.makesProducts) { + //Get the text on the button based on Industry type + var createProductButtonText, createProductPopupText; + switch(division.type) { + case Industries.Food: + createProductButtonText = "Build Restaurant"; + createProductPopupText = "Build and manage a new restaurant!" + break; + case Industries.Tobacco: + createProductButtonText = "Create Product"; + createProductPopupText = "Create a new tobacco product!"; + break; + case Industries.Pharmaceutical: + createProductButtonText = "Create Drug"; + createProductPopupText = "Design and develop a new pharmaceutical drug!"; + break; + case Industries.Computer: + case "Computer": + createProductButtonText = "Create Product"; + createProductPopupText = "Design and manufacture a new computer hardware product!"; + break; + case Industries.Robotics: + createProductButtonText = "Design Robot"; + createProductPopupText = "Design and create a new robot or robotic system!"; + break; + case Industries.Software: + createProductButtonText = "Develop Software"; + createProductPopupText = "Develop a new piece of software!"; + break; + case Industries.HealthCare: + createProductButtonText = "Build Hospital"; + createProductPopupText = "Build and manage a new hospital!"; + break; + case Industries.RealEstate: + createProductButtonText = "Develop Property"; + createProductPopupText = "Develop a new piece of real estate property!"; + break; + default: + createProductButtonText = "Create Product"; + return ""; + } + createProductPopupText += "

To begin developing a product, " + + "first choose the city in which it will be designed. The stats of your employees " + + "in the selected city affect the properties of the finished product, such as its " + + "quality, performance, and durability.

" + + "You can also choose to invest money in the design and marketing of " + + "the product. Investing money in its design will result in a superior product. " + + "Investing money in marketing the product will help the product's sales."; + + //Create the button + industryOverviewPanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:createProductButtonText, margin:"6px", display:"inline-block", + clickListener:()=>{ + var popupId = "cmpy-mgmt-create-product-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML:createProductPopupText, + }); + var designCity = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", {}); + for (var cityName in division.offices) { + if (division.offices[cityName] instanceof OfficeSpace) { + designCity.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", { + value:cityName, + text:cityName + })); + } + } + var foo = "Product Name"; + if (division.type === Industries.Food) { + foo = "Restaurant Name"; + } else if (division.type === Industries.Healthcare) { + foo = "Hospital Name"; + } else if (division.type === Industries.RealEstate) { + foo = "Property Name"; + } + var productNameInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + placeholder:foo, + }); + var lineBreak1 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br",{}); + var designInvestInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", + placeholder:"Design investment" + }); + var marketingInvestInput = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", + placeholder:"Marketing investment" + }); + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Develop Product", + clickListener:()=>{ + if (designInvestInput.value == null) {designInvestInput.value = 0;} + if (marketingInvestInput.value == null) {marketingInvestInput.value = 0;} + var designInvest = parseFloat(designInvestInput.value), + marketingInvest = parseFloat(marketingInvestInput.value); + if (productNameInput.value == null || productNameInput.value === "") { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You must specify a name for your product!"); + } else if (isNaN(designInvest)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for design investment"); + } else if (isNaN(marketingInvest)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value for marketing investment"); + } else if (this.funds.lt(designInvest + marketingInvest)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to make this large of an investment"); + } else { + var product = new Product({ + name:productNameInput.value.replace(/[<>]/g, ''), //Sanitize for HTMl elements + createCity:designCity.options[designCity.selectedIndex].value, + designCost: designInvest, + advCost: marketingInvest, + }); + this.funds = this.funds.minus(designInvest + marketingInvest); + division.products[product.name] = product; + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + } + //this.updateUIContent(); + this.displayDivisionContent(division, city); + return false; + } + }) + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }) + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, designCity, productNameInput, lineBreak1, + designInvestInput, marketingInvestInput, confirmBtn, cancelBtn]); + } + })); + } + + //Employee and Office Panel + industryEmployeeText = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + id: "cmpy-mgmt-employee-p", + display:"block", + innerHTML: "

Office Space


" + + "Type: " + office.tier + "
" + + "Comfort: " + office.comf + "
" + + "Beauty: " + office.beau + "
" + + "Size: " + office.employees.length + " / " + office.size + " employees", + }); + industryEmployeePanel.appendChild(industryEmployeeText); + + //Hire Employee button + if (office.employees.length === 0) { + industryEmployeeHireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button",display:"inline-block", + innerText:"Hire Employee", fontSize:"13px", + tooltip:"You'll need to hire some employees to get your operations started! " + + "It's recommended to have at least one employee in every position", + clickListener:()=>{ + office.findEmployees({corporation:this, division:division}); + return false; + } + }); + //industryEmployeeHireButton.classList.add("flashing-button"); + } else { + industryEmployeeHireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button",display:"inline-block", + innerText:"Hire Employee", fontSize:"13px", + clickListener:()=>{ + office.findEmployees({corporation:this, division:division}); + return false; + } + }); + } + industryEmployeePanel.appendChild(industryEmployeeHireButton); + + //Autohire Employee button + industryEmployeeAutohireButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", + innerText:"Autohire Employee", fontSize:"13px", + tooltip:"Automatically hires an employee and gives him/her a random name", + clickListener:()=>{ + office.hireRandomEmployee({corporation:this, division:division}); + return false; + } + }); + industryEmployeePanel.appendChild(industryEmployeeAutohireButton); + + //Upgrade Office Size button + industryEmployeePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + industryOfficeUpgradeSizeButton = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Upgrade size", + display:"inline-block", margin:"6px", fontSize:"13px", + tooltip:"Upgrade the office's size so that it can hold more employees!", + clickListener:()=>{ + var popupId = "cmpy-mgmt-upgrade-office-size-popup"; + var initialPriceMult = Math.round(office.size / OfficeInitialSize); + var upgradeCost = OfficeInitialCost * Math.pow(1.07, initialPriceMult); + + //Calculate cost to upgrade size by 15 employees + var mult = 0; + for (var i = 0; i < 5; ++i) { + mult += (Math.pow(1.07, initialPriceMult + i)); + } + var upgradeCost15 = OfficeInitialCost * mult; + + //Calculate max upgrade size and cost + var maxMult = (this.funds.dividedBy(OfficeInitialCost)).toNumber(); + var maxNum = 1; + mult = Math.pow(1.07, initialPriceMult); + while(maxNum < 50) { //Hard cap of 50x (extra 150 employees) + if (mult >= maxMult) {break;} + var multIncrease = Math.pow(1.07, initialPriceMult + maxNum); + if (mult + multIncrease > maxMult) { + break; + } else { + mult += multIncrease; + } + ++maxNum; + } + + var upgradeCostMax = OfficeInitialCost * mult; + + var text = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Increase the size of your office space to fit additional employees!" + }); + var text2 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {innerText: "Upgrade size: "}); + + var confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: this.funds.lt(upgradeCost) ? "a-link-button-inactive" : "a-link-button", + display:"inline-block", margin:"4px", innerText:"by 3", + tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost).format("$0.000a"), + clickListener:()=>{ + if (this.funds.lt(upgradeCost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); + } else { + office.size += OfficeInitialSize; + this.funds = this.funds.minus(upgradeCost); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); + this.updateUIContent(); + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var confirmBtn15 = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: this.funds.lt(upgradeCost15) ? "a-link-button-inactive" : "a-link-button", + display:"inline-block", margin:"4px", innerText:"by 15", + tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCost15).format("$0.000a"), + clickListener:()=>{ + if (this.funds.lt(upgradeCost15)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); + } else { + office.size += (OfficeInitialSize * 5); + this.funds = this.funds.minus(upgradeCost15); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); + this.updateUIContent(); + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var confirmBtnMax = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:this.funds.lt(upgradeCostMax) ? "a-link-button-inactive" : "a-link-button", + display:"inline-block", margin:"4px", innerText:"by MAX (" + maxNum*OfficeInitialSize + ")", + tooltip:__WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(upgradeCostMax).format("$0.000a"), + clickListener:()=>{ + if (this.funds.lt(upgradeCostMax)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to purchase this upgrade!"); + } else { + office.size += (OfficeInitialSize * maxNum); + this.funds = this.funds.minus(upgradeCostMax); + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Office space increased! It can now hold " + office.size + " employees"); + this.updateUIContent(); + } + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", innerText:"Cancel", display:"inline-block", margin:"4px", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }) + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [text, text2, confirmBtn, confirmBtn15, confirmBtnMax, cancelBtn]); + return false; + } + }); + industryEmployeePanel.appendChild(industryOfficeUpgradeSizeButton); + + //Throw Office Party + industryEmployeePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", innerText:"Throw Party", + fontSize:"13px", + tooltip:"Throw an office party to increase your employee's morale and happiness", + clickListener:()=>{ + var popupId = "cmpy-mgmt-throw-office-party-popup"; + var txt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Enter the amount of money you would like to spend PER EMPLOYEE " + + "on this office party" + }); + var totalCostTxt = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Throwing this party will cost a total of $0" + }); + var confirmBtn; + var input = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("input", { + type:"number", margin:"5px", placeholder:"$ / employee", + inputListener:()=>{ + if (isNaN(input.value) || input.value < 0) { + totalCostTxt.innerText = "Invalid value entered!" + } else { + var totalCost = input.value * office.employees.length; + totalCostTxt.innerText = "Throwing this party will cost a total of " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(totalCost).format('$0.000a'); + } + }, + onkeyup:(e)=>{ + e.preventDefault(); + if (e.keyCode === 13) {confirmBtn.click();} + } + }); + confirmBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + display:"inline-block", + innerText:"Throw Party", + clickListener:()=>{ + if (isNaN(input.value) || input.value < 0) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Invalid value entered"); + } else { + var totalCost = input.value * office.employees.length; + if (this.funds.lt(totalCost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You don't have enough company funds to throw this party!"); + } else { + this.funds = this.funds.minus(totalCost); + var mult; + for (var fooit = 0; fooit < office.employees.length; ++fooit) { + mult = office.employees[fooit].throwParty(input.value); + } + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You threw a party for the office! The morale and happiness " + + "of each employee increased by " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])((mult-1) * 100, 2) + "%."); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + } + } + return false; + } + }); + var cancelBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", + display:"inline-block", + innerText:"Cancel", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(popupId); + return false; + } + }); + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["g" /* createPopup */])(popupId, [txt, totalCostTxt, input, confirmBtn, cancelBtn]); + } + })); + + industryEmployeeManagementUI = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {}); + industryEmployeeInfo = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", {margin:"4px", padding:"4px"}); + if (empManualAssignmentModeActive) { + //Employees manually assigned + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", margin:"4px", + innerText:"Switch to Auto Mode", + tooltip:"Switch to Automatic Assignment Mode, which will automatically " + + "assign employees to your selected jobs. You simply have to select " + + "the number of assignments for each job", + clickListener:()=>{ + empManualAssignmentModeActive = false; + this.displayDivisionContent(division, city); + } + })); + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + industryIndividualEmployeeInfo = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", {margin:"4px", padding:"4px"}); + var selector = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("select", { + color: "white", backgroundColor:"black", margin:"4px", padding:"4px", + changeListener:()=>{ + var name = selector.options[selector.selectedIndex].text; + for (var i = 0; i < office.employees.length; ++i) { + if (office.employees[i].name === name) { + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryIndividualEmployeeInfo); + office.employees[i].createUI(industryIndividualEmployeeInfo, this); + return; + } + } + console.log("ERROR: Employee in selector could not be found"); + } + }); + + for (var i = 0; i < office.employees.length; ++i) { + selector.add(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("option", {text:office.employees[i].name})); + } + + selector.selectedIndex = -1; + + industryEmployeeManagementUI.appendChild(industryEmployeeInfo); + industryEmployeeManagementUI.appendChild(selector); + industryEmployeeManagementUI.appendChild(industryIndividualEmployeeInfo); + } else { + //Player only manages the number of each occupation, not who gets what job + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class:"a-link-button", display:"inline-block", margin:"4px", + innerText:"Switch to Manual Mode", + tooltip:"Switch to Manual Assignment Mode, which allows you to " + + "specify which employees should get which jobs", + clickListener:()=>{ + empManualAssignmentModeActive = true; + this.displayDivisionContent(division, city); + } + })); + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + var opCount = 0, engCount = 0, busCount = 0, + mgmtCount = 0, rndCount = 0, unassignedCount = 0, + trainingCount = 0; + for (var i = 0; i < office.employees.length; ++i) { + switch (office.employees[i].pos) { + case EmployeePositions.Operations: + ++opCount; break; + case EmployeePositions.Engineer: + ++engCount; break; + case EmployeePositions.Business: + ++busCount; break; + case EmployeePositions.Management: + ++mgmtCount; break; + case EmployeePositions.RandD: + ++rndCount; break; + case EmployeePositions.Unassigned: + ++unassignedCount; break; + case EmployeePositions.Training: + ++trainingCount; break; + default: + console.log("ERROR: Unrecognized employee position: " + office.employees[i].pos); + break; + } + } + + //Unassigned employee count display + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + display:"inline-block", + innerText:"Unassigned Employees: " + unassignedCount, + })); + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + //General display of employee information (avg morale, avg energy, etc.) + industryEmployeeManagementUI.appendChild(industryEmployeeInfo); + industryEmployeeManagementUI.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + + var positions = [EmployeePositions.Operations, EmployeePositions.Engineer, + EmployeePositions.Business, EmployeePositions.Management, + EmployeePositions.RandD, EmployeePositions.Training]; + var descriptions = ["Manages supply chain operations. Improves production.", //Operations + "Develops and maintains products and production systems. Improves production.", //Engineer + "Handles sales and finances. Improves sales.", //Business + "Leads and oversees employees and office operations. Improves production.", //Management + "Research new innovative ways to improve the company. Generates Scientific Research", //RandD + "Set employee to training, which will increase some of their stats. Employees in training do not affect any company operations."] //Training + var counts = [opCount, engCount, busCount, mgmtCount, rndCount, trainingCount]; + for (var i = 0; i < positions.length; ++i) { + (function(corp, i) { + var info = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("h2", { + display:"inline-block", width:"40%", fontSize:"15px", + innerText: positions[i] + "(" + counts[i] + ")", + tooltipleft: descriptions[i] + }); + var plusBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: unassignedCount > 0 ? "a-link-button" : "a-link-button-inactive", + display:"inline-block", innerText:"+", + clickListener:()=>{ + office.assignEmployeeToJob(positions[i]); + corp.displayDivisionContent(division, city); + } + }); + var minusBtn = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + class: counts[i] > 0 ? "a-link-button" : "a-link-button-inactive", + display:"inline-block", innerText:"-", + clickListener:()=>{ + office.unassignEmployeeFromJob(positions[i]); + corp.displayDivisionContent(division, city); + } + }); + var newline = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {}); + industryEmployeeManagementUI.appendChild(info); + industryEmployeeManagementUI.appendChild(plusBtn); + industryEmployeeManagementUI.appendChild(minusBtn); + industryEmployeeManagementUI.appendChild(newline); + })(this, i); + } + } + industryEmployeePanel.appendChild(industryEmployeeManagementUI); + + //Warehouse Panel + var warehouse = division.warehouses[currentCityUi]; + if (warehouse instanceof Warehouse) { + warehouse.createUI({industry:division, company: this}); + } else { + industryWarehousePanel.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("a", { + innerText:"Purchase Warehouse ($5b)", + class: "a-link-button", + clickListener:()=>{ + if (this.funds.lt(WarehouseInitialCost)) { + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough funds to do this!"); + } else { + division.warehouses[currentCityUi] = new Warehouse({ + loc:currentCityUi, + size:WarehouseInitialSize, + }); + this.funds = this.funds.minus(WarehouseInitialCost); + this.displayDivisionContent(division, currentCityUi); + } + return false; + } + })); + } + this.updateDivisionContent(division); +} + +Corporation.prototype.updateDivisionContent = function(division) { + if (!(division instanceof Industry)) { + console.log("ERROR: Invalid 'division' argument in Corporation.updateDivisionContent"); + return; + } + var vechain = (this.unlockUpgrades[4] === 1); + //Industry Overview Text + var profit = division.lastCycleRevenue.minus(division.lastCycleExpenses).toNumber(), + profitStr = profit >= 0 ? __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(profit).format("$0.000a") : "-" + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(-1 * profit).format("$0.000a"); + var advertisingInfo = ""; + if (vechain) { + var advertisingFactors = division.getAdvertisingFactors(); + var awarenessFac = advertisingFactors[1]; + var popularityFac = advertisingFactors[2]; + var ratioFac = advertisingFactors[3]; + var totalAdvertisingFac = advertisingFactors[0]; + advertisingInfo = + "

Advertising Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalAdvertisingFac, 3) + + "Total multiplier for this industry's sales due to its awareness and popularity
" + + "Awareness Bonus: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(awarenessFac, 0.85), 3) + "
" + + "Popularity Bonus: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(popularityFac, 0.85), 3) + "
" + + "Ratio Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(Math.pow(ratioFac, 0.85), 3) + "


" + + } + + Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["k" /* removeChildrenFromElement */])(industryOverviewText); + industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerHTML:"Industry: " + division.type + " (Corp Funds: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(this.funds.toNumber()).format("$0.000a") + ")

" + + "Awareness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.awareness, 3) + "
" + + "Popularity: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.popularity, 3) + "
" + + advertisingInfo + "
" + + "Revenue: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(division.lastCycleRevenue.toNumber()).format("$0.000a") + " / s
" + + "Expenses: " + __WEBPACK_IMPORTED_MODULE_10__utils_numeral_min_js___default()(division.lastCycleExpenses.toNumber()).format("$0.000a") + " /s
" + + "Profit: " + profitStr + " / s

" + })); + industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + marginTop:"2px", + innerText:"Production Multiplier: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.prodMult, 2), + tooltip:"Production gain from owning production-boosting materials " + + "such as hardware, Robots, AI Cores, and Real Estate" + })); + industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("div", { + innerText:"?", class:"help-tip", + clickListener:()=>{ + Object(__WEBPACK_IMPORTED_MODULE_7__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Owning Hardware, Robots, AI Cores, and Real Estate " + + "can boost your Industry's production. The effect these " + + "materials have on your production varies between Industries. " + + "For example, Real Estate may be very effective for some Industries, " + + "but ineffective for others.

" + + "This division's production multiplier is calculated by summing " + + "the individual production multiplier of each of its office locations. " + + "This production multiplier is applied to each office. Therefore, it is " + + "beneficial to expand into new cities as this can greatly increase the " + + "production multiplier of your entire Division." + ) + } + })); + industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br")); + industryOverviewText.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + display:"inline-block", + innerText:"Scientific Research: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.sciResearch.qty, 3), + tooltip:"Scientific Research increases the quality of the materials and " + + "products that you produce." + })); + + //Office and Employee List + var office = division.offices[currentCityUi]; + industryEmployeeText.innerHTML = + "

Office Space


" + + "Type: " + office.tier + "
" + + "Comfort: " + office.comf + "
" + + "Beauty: " + office.beau + "
" + + "Size: " + office.employees.length + " / " + office.size + " employees"; + if (office.employees.length >= office.size) { + industryEmployeeHireButton.className = "a-link-button-inactive"; + industryEmployeeAutohireButton.className = "a-link-button-inactive tooltip"; + } else if (office.employees.length === 0) { + industryEmployeeHireButton.className = "a-link-button tooltip flashing-button"; + industryEmployeeAutohireButton.className = "a-link-button tooltip"; + } else { + industryEmployeeHireButton.className = "a-link-button"; + industryEmployeeAutohireButton.className = "a-link-button tooltip"; + } + + //Employee Overview stats + //Calculate average morale, happiness, and energy + var totalMorale = 0, totalHappiness = 0, totalEnergy = 0, + avgMorale = 0, avgHappiness = 0, avgEnergy = 0; + for (var i = 0; i < office.employees.length; ++i) { + totalMorale += office.employees[i].mor; + totalHappiness += office.employees[i].hap; + totalEnergy += office.employees[i].ene; + } + if (office.employees.length > 0) { + avgMorale = totalMorale / office.employees.length; + avgHappiness = totalHappiness / office.employees.length; + avgEnergy = totalEnergy / office.employees.length; + } + industryEmployeeInfo.innerHTML = + "Avg Employee Morale: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgMorale, 3) + "
" + + "Avg Employee Happiness: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgHappiness, 3) + "
" + + "Avg Employee Energy: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(avgEnergy, 3); + if (vechain) { //VeChain - Statistics + industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Material Production: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText:"Product Production: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* 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(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("br", {})); + industryEmployeeInfo.appendChild(Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("p", { + innerText: "Business Multiplier: x" + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(division.getBusinessFactor(office), 3), + tooltip: "The effect this office's 'Business' employees has on boosting sales" + })); + } + + //Warehouse + var warehouse = division.warehouses[currentCityUi]; + if (warehouse instanceof Warehouse) { + warehouse.updateUI({industry:division, company:this}); + } +} + +Corporation.prototype.createCityUITab = function(city, division) { + var tab = Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["f" /* createElement */])("button", { + id:"cmpy-mgmt-city-" + city + "-tab", + class:"cmpy-mgmt-city-tab", + innerText:city, + clickListener:()=>{ + this.selectCityTab(tab, city); + this.displayDivisionContent(division, city); + return false; + } + }); + companyManagementPanel.appendChild(tab); +} + +Corporation.prototype.selectCityTab = function(activeTab, city) { + if (activeTab == null) { + activeTab = document.getElementById("cmpy-mgmt-city-" + city + "-tab"); + if (activeTab == null) {return;} + } + for (var i = 0; i < cityTabs.length; ++i) { + cityTabs[i].className = "cmpy-mgmt-city-tab"; + } + activeTab.className = "cmpy-mgmt-city-tab current"; +} + +Corporation.prototype.clearUI = function() { + //Delete everything + if (companyManagementDiv != null) {Object(__WEBPACK_IMPORTED_MODULE_8__utils_HelperFunctions_js__["m" /* removeElementById */])(companyManagementDiv.id);} + + //Reset global DOM variables + companyManagementDiv = null; + companyManagementPanel = null; + currentCityUi = null; + + corporationUnlockUpgrades = null; + corporationUpgrades = null; + + industryOverviewPanel = null; + industryOverviewText = null; + + industryEmployeePanel = null; + industryEmployeeText = null; + industryEmployeeHireButton = null; + industryEmployeeAutohireButton = null; + industryEmployeeManagementUI = null; + industryEmployeeInfo = null; + industryIndividualEmployeeInfo = null; + + industryOfficeUpgradeSizeButton = null; + + industryWarehousePanel = null; + industrySmartSupplyCheckbox = null; + industryWarehouseStorageText = null; + industryWarehouseUpgradeSizeButton = null; + industryWarehouseStateText = null; + industryWarehouseMaterials = null; + industryWarehouseProducts = null; + + companyManagementHeaderTabs = null; + headerTabs = null; + cityTabs = null; + + document.getElementById("character-overview-wrapper").style.visibility = "visible"; +} + +Corporation.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Corporation", this); +} + +Corporation.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Corporation, value.data); +} + +__WEBPACK_IMPORTED_MODULE_9__utils_JSONReviver_js__["c" /* Reviver */].constructors.Corporation = Corporation; + + + + +/***/ }), +/* 54 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -52820,6 +56206,46 @@ function initLiterature() { "-Corporations do not reset when installing Augmentations, but they do reset when destroying a BitNode"; Literatures[fn] = new Literature(title, fn, txt); + title = "A Brief History of Synthoids"; + fn = "history-of-synthoids.lit"; + txt = "Synthetic androids, or Synthoids for short, are genetically engineered robots and, short of Augmentations, " + + "are composed entirely of organic substances. For this reason, Synthoids are virtually identical to " + + "humans in form, composition, and appearance.

" + + "Synthoids were first designed and manufactured by OmniTek Incorporated sometime around the turn of the century. " + + "Their original purpose was to be used for manual labor and as emergency responders for disasters. As such, they " + + "were initially programmed only for their specific tasks. Each iteration that followed improved upon the " + + "intelligence and capabilities of the Synthoids. By the 6th iteration, called MK-VI, the Synthoids were " + + "so smart and capable enough of making their own decisions that many argued OmniTek had created the first " + + "sentient AI. These MK-VI Synthoids were produced in mass quantities (estimates up to 50 billion) with the hopes of increasing society's " + + "productivity and bolstering the global economy. Stemming from humanity's desire for technological advancement, optimism " + + "and excitement about the future had never been higher.

" + + "All of that excitement and optimism quickly turned to fear, panic, and dread in 2070, when a terrorist group " + + "called Ascendis Totalis hacked into OmniTek and uploaded a rogue AI into severeal of their Synthoid manufacturing facilities. " + + "This hack went undetected and for months OmniTek unknowingly churned out legions of Synthoids embedded with this " + + "rogue AI. Then, on December 24th, 2070, Omnica activated dormant protocols in the rogue AI, causing all of the " + + "infected Synthoids to immediately launch a military campaign to seek and destroy all of humanity.

" + + "What ensued was the deadlist conflict in human history. This crisis, now commonly known as the Synthoid Uprising, " + + "resulted in almost ten billion deaths over the course of a year. Despite the nations of the world banding together " + + "to combat the threat, the MK-VI Synthoids were simply stronger, faster, more intelligent, and more adaptable than humans, " + + "outsmarting them at every turn.

" + + "It wasn't until the sacrifice of an elite international military taskforce, called the Bladeburners, that humanity " + + "was finally able to defeat the Synthoids. The Bladeburners' final act was a suicide bombing mission that " + + "destroyed a large portion of the MK-VI Synthoids, including many of its leaders. In the following " + + "weeks militaries from around the world were able to round up and shut down the remaining rogue MK-VI Synthoids, ending " + + "the Synthoid Uprising.

" + + "In the aftermath of the bloodshed, the Synthoid Accords were drawn up. These Accords banned OmniTek Incorporated " + + "from manufacturing any Synthoids beyond the MK-III series. They also banned any other corporation " + + "from constructing androids with advanced, near-sentient AI. MK-VI Synthoids that did not have the rogue Ascendis Totalis " + + "AI were allowed to continue their existence, but they were stripped of all rights and protections as they " + + "were not considered humans. They were also banned from doing anything that may pose a global security threat, such " + + "as working for any military/defense organization or conducting any bioengineering, computing, or robotics related research.

" + + "Unfortunately, many believe that not all of the rogue MK-VI Synthoids from the Uprising were found and destroyed, " + + "and that many of them are blending in as normal humans in society today. In response, many nations have created " + + "Bladeburner divisions, special military branches that are tasked with investigating and dealing with any Synthoid threads.

" + + "To this day, tensions still exist between the remaining Synthoids and humans as a result of the Uprising.

" + + "Nobody knows what happened to the terrorist group Ascendis Totalis."; + Literatures[fn] = new Literature(title, fn, txt); + title = "A Green Tomorrow"; fn = "A-Green-Tomorrow.lit"; txt = "Starting a few decades ago, there was a massive global movement towards the generation of renewable energy in an effort to " + @@ -53117,13 +56543,325 @@ function initLiterature() { fn = "the-secret-war.lit"; txt = "" Literatures[fn] = new Literature(title, fn, txt); + } /***/ }), -/* 44 */ +/* 55 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return commitShopliftCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return commitRobStoreCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return commitMugCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return commitLarcenyCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return commitDealDrugsCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return commitBondForgeryCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return commitTraffickArmsCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return commitHomicideCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return commitGrandTheftAutoCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return commitKidnapCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return commitAssassinationCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return commitHeistCrime; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return determineCrimeSuccess; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return determineCrimeChanceShoplift; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return determineCrimeChanceRobStore; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return determineCrimeChanceMug; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return determineCrimeChanceLarceny; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return determineCrimeChanceDealDrugs; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return determineCrimeChanceBondForgery; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return determineCrimeChanceTraffickArms; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return determineCrimeChanceHomicide; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return determineCrimeChanceGrandTheftAuto; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return determineCrimeChanceKidnap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return determineCrimeChanceAssassination; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return determineCrimeChanceHeist; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__ = __webpack_require__(1); + + + + +/* Crimes.js */ +function commitShopliftCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeShoplift; + var time = 2000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 0, 0, 2/div, 2/div, 0, 15000/div, time, singParams); //$7500/s, 1 exp/s + return time; +} + +function commitRobStoreCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeRobStore; + var time = 60000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(30/div, 0, 0, 45/div, 45/div, 0, 400000/div, time, singParams); //$6666,6/2, 0.5exp/s, 0.75exp/s + return time; +} + +function commitMugCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeMug; + var time = 4000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 3/div, 3/div, 3/div, 3/div, 0, 36000/div, time, singParams); //$9000/s, .66 exp/s + return time; +} + +function commitLarcenyCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeLarceny; + var time = 90000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(45/div, 0, 0, 60/div, 60/div, 0, 800000/div, time, singParams) // $8888.88/s, .5 exp/s, .66 exp/s + return time; +} + +function commitDealDrugsCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeDrugs; + var time = 10000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 0, 0, 5/div, 5/div, 10/div, 120000/div, time, singParams); //$12000/s, .5 exp/s, 1 exp/s + return time; +} + +function commitBondForgeryCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeBondForgery; + var time = 300000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(100/div, 0, 0, 150/div, 0, 15/div, 4500000/div, time, singParams); //$15000/s, 0.33 hack exp/s, .5 dex exp/s, .05 cha exp + return time; +} + +function commitTraffickArmsCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeTraffickArms; + var time = 40000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 20/div, 20/div, 20/div, 20/div, 40/div, 600000/div, time, singParams); //$15000/s, .5 combat exp/s, 1 cha exp/s + return time; +} + +function commitHomicideCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHomicide; + var time = 3000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 2/div, 2/div, 2/div, 2/div, 0, 45000/div, time, singParams); //$15000/s, 0.66 combat exp/s + return time; +} + +function commitGrandTheftAutoCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeGrandTheftAuto; + var time = 80000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 20/div, 20/div, 20/div, 80/div, 40/div, 1600000/div, time, singParams); //$20000/s, .25 exp/s, 1 exp/s, .5 exp/s + return time; +} + +function commitKidnapCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeKidnap; + var time = 120000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 80/div, 80/div, 80/div, 80/div, 80/div, 3600000/div, time, singParams); //$30000/s. .66 exp/s + return time; +} + +function commitAssassinationCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeAssassination; + var time = 300000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(0, 300/div, 300/div, 300/div, 300/div, 0, 12000000/div, time, singParams); //$40000/s, 1 exp/s + return time; +} + +function commitHeistCrime(div=1, singParams=null) { + if (div <= 0) {div = 1;} + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crimeType = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHeist; + var time = 600000; + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].startCrime(450/div, 450/div, 450/div, 450/div, 450/div, 450/div, 120000000/div, time, singParams); //$200000/s, .75exp/s + return time; +} + +function determineCrimeSuccess(crime, moneyGained) { + var chance = 0; + switch (crime) { + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeShoplift: + chance = determineCrimeChanceShoplift(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeRobStore: + chance = determineCrimeChanceRobStore(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeMug: + chance = determineCrimeChanceMug(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeLarceny: + chance = determineCrimeChanceLarceny(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeDrugs: + chance = determineCrimeChanceDealDrugs(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeBondForgery: + chance = determineCrimeChanceBondForgery(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeTraffickArms: + chance = determineCrimeChanceTraffickArms(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHomicide: + chance = determineCrimeChanceHomicide(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeGrandTheftAuto: + chance = determineCrimeChanceGrandTheftAuto(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeKidnap: + chance = determineCrimeChanceKidnap(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeAssassination: + chance = determineCrimeChanceAssassination(); + break; + case __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].CrimeHeist: + chance = determineCrimeChanceHeist(); + break; + default: + console.log(crime); + Object(__WEBPACK_IMPORTED_MODULE_2__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERR: Unrecognized crime type. This is probably a bug please contact the developer"); + return; + } + + if (Math.random() <= chance) { + //Success + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].gainMoney(moneyGained); + return true; + } else { + //Failure + return false; + } +} + +let intWgt = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].IntelligenceCrimeWeight; +let maxLvl = __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].MaxSkillLevel; + +function determineCrimeChanceShoplift() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 20; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceRobStore() { + var chance = (0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + + 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + 1 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 5; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceMug() { + var chance = (1.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + + 1.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 5; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceLarceny() { + var chance = (0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) * 3; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceDealDrugs() { + var chance = (3*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + + 2*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceBondForgery() { + var chance = (0.1*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + + 2.5*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + 2*intWgt*__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceTraffickArms() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 2; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceHomicide() { + var chance = (2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + + 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + 0.5 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl); + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceGrandTheftAuto() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + 4 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 8; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceKidnap() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 5; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceAssassination() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + 2 * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 8; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + +function determineCrimeChanceHeist() { + var chance = (__WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].hacking_skill / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].strength / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].defense / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].dexterity / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].agility / maxLvl + + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].charisma / maxLvl + + intWgt * __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].intelligence / maxLvl) / 18; + chance *= __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].crime_success_mult; + return Math.min(chance, 1); +} + + + + +/***/ }), +/* 56 */ /***/ (function(module, exports) { module.exports = function() { @@ -53132,250 +56870,125 @@ module.exports = function() { /***/ }), -/* 45 */ -/***/ (function(module, exports) { +/* 57 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { -module.exports.id = 'ace/mode/javascript_worker'; -module.exports.src = "\"no use strict\";!function(window){function resolveModuleId(id,paths){for(var testPath=id,tail=\"\";testPath;){var alias=paths[testPath];if(\"string\"==typeof alias)return alias+tail;if(alias)return alias.location.replace(/\\/*$/,\"/\")+(tail||alias.main||alias.name);if(alias===!1)return\"\";var i=testPath.lastIndexOf(\"/\");if(-1===i)break;tail=testPath.substr(i)+tail,testPath=testPath.slice(0,i)}return id}if(!(void 0!==window.window&&window.document||window.acequire&&window.define)){window.console||(window.console=function(){var msgs=Array.prototype.slice.call(arguments,0);postMessage({type:\"log\",data:msgs})},window.console.error=window.console.warn=window.console.log=window.console.trace=window.console),window.window=window,window.ace=window,window.onerror=function(message,file,line,col,err){postMessage({type:\"error\",data:{message:message,data:err.data,file:file,line:line,col:col,stack:err.stack}})},window.normalizeModule=function(parentId,moduleName){if(-1!==moduleName.indexOf(\"!\")){var chunks=moduleName.split(\"!\");return window.normalizeModule(parentId,chunks[0])+\"!\"+window.normalizeModule(parentId,chunks[1])}if(\".\"==moduleName.charAt(0)){var base=parentId.split(\"/\").slice(0,-1).join(\"/\");for(moduleName=(base?base+\"/\":\"\")+moduleName;-1!==moduleName.indexOf(\".\")&&previous!=moduleName;){var previous=moduleName;moduleName=moduleName.replace(/^\\.\\//,\"\").replace(/\\/\\.\\//,\"/\").replace(/[^\\/]+\\/\\.\\.\\//,\"\")}}return moduleName},window.acequire=function acequire(parentId,id){if(id||(id=parentId,parentId=null),!id.charAt)throw Error(\"worker.js acequire() accepts only (parentId, id) as arguments\");id=window.normalizeModule(parentId,id);var module=window.acequire.modules[id];if(module)return module.initialized||(module.initialized=!0,module.exports=module.factory().exports),module.exports;if(!window.acequire.tlns)return console.log(\"unable to load \"+id);var path=resolveModuleId(id,window.acequire.tlns);return\".js\"!=path.slice(-3)&&(path+=\".js\"),window.acequire.id=id,window.acequire.modules[id]={},importScripts(path),window.acequire(parentId,id)},window.acequire.modules={},window.acequire.tlns={},window.define=function(id,deps,factory){if(2==arguments.length?(factory=deps,\"string\"!=typeof id&&(deps=id,id=window.acequire.id)):1==arguments.length&&(factory=id,deps=[],id=window.acequire.id),\"function\"!=typeof factory)return window.acequire.modules[id]={exports:factory,initialized:!0},void 0;deps.length||(deps=[\"require\",\"exports\",\"module\"]);var req=function(childId){return window.acequire(id,childId)};window.acequire.modules[id]={exports:{},factory:function(){var module=this,returnExports=factory.apply(this,deps.map(function(dep){switch(dep){case\"require\":return req;case\"exports\":return module.exports;case\"module\":return module;default:return req(dep)}}));return returnExports&&(module.exports=returnExports),module}}},window.define.amd={},acequire.tlns={},window.initBaseUrls=function(topLevelNamespaces){for(var i in topLevelNamespaces)acequire.tlns[i]=topLevelNamespaces[i]},window.initSender=function(){var EventEmitter=window.acequire(\"ace/lib/event_emitter\").EventEmitter,oop=window.acequire(\"ace/lib/oop\"),Sender=function(){};return function(){oop.implement(this,EventEmitter),this.callback=function(data,callbackId){postMessage({type:\"call\",id:callbackId,data:data})},this.emit=function(name,data){postMessage({type:\"event\",name:name,data:data})}}.call(Sender.prototype),new Sender};var main=window.main=null,sender=window.sender=null;window.onmessage=function(e){var msg=e.data;if(msg.event&&sender)sender._signal(msg.event,msg.data);else if(msg.command)if(main[msg.command])main[msg.command].apply(main,msg.args);else{if(!window[msg.command])throw Error(\"Unknown command:\"+msg.command);window[msg.command].apply(window,msg.args)}else if(msg.init){window.initBaseUrls(msg.tlns),acequire(\"ace/lib/es5-shim\"),sender=window.sender=window.initSender();var clazz=acequire(msg.module)[msg.classname];main=window.main=new clazz(sender)}}}}(this),ace.define(\"ace/lib/oop\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.inherits=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},exports.mixin=function(obj,mixin){for(var key in mixin)obj[key]=mixin[key];return obj},exports.implement=function(proto,mixin){exports.mixin(proto,mixin)}}),ace.define(\"ace/range\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},Range=function(startRow,startColumn,endRow,endColumn){this.start={row:startRow,column:startColumn},this.end={row:endRow,column:endColumn}};(function(){this.isEqual=function(range){return this.start.row===range.start.row&&this.end.row===range.end.row&&this.start.column===range.start.column&&this.end.column===range.end.column},this.toString=function(){return\"Range: [\"+this.start.row+\"/\"+this.start.column+\"] -> [\"+this.end.row+\"/\"+this.end.column+\"]\"},this.contains=function(row,column){return 0==this.compare(row,column)},this.compareRange=function(range){var cmp,end=range.end,start=range.start;return cmp=this.compare(end.row,end.column),1==cmp?(cmp=this.compare(start.row,start.column),1==cmp?2:0==cmp?1:0):-1==cmp?-2:(cmp=this.compare(start.row,start.column),-1==cmp?-1:1==cmp?42:0)},this.comparePoint=function(p){return this.compare(p.row,p.column)},this.containsRange=function(range){return 0==this.comparePoint(range.start)&&0==this.comparePoint(range.end)},this.intersects=function(range){var cmp=this.compareRange(range);return-1==cmp||0==cmp||1==cmp},this.isEnd=function(row,column){return this.end.row==row&&this.end.column==column},this.isStart=function(row,column){return this.start.row==row&&this.start.column==column},this.setStart=function(row,column){\"object\"==typeof row?(this.start.column=row.column,this.start.row=row.row):(this.start.row=row,this.start.column=column)},this.setEnd=function(row,column){\"object\"==typeof row?(this.end.column=row.column,this.end.row=row.row):(this.end.row=row,this.end.column=column)},this.inside=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)||this.isStart(row,column)?!1:!0:!1},this.insideStart=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)?!1:!0:!1},this.insideEnd=function(row,column){return 0==this.compare(row,column)?this.isStart(row,column)?!1:!0:!1},this.compare=function(row,column){return this.isMultiLine()||row!==this.start.row?this.start.row>row?-1:row>this.end.row?1:this.start.row===row?column>=this.start.column?0:-1:this.end.row===row?this.end.column>=column?0:1:0:this.start.column>column?-1:column>this.end.column?1:0},this.compareStart=function(row,column){return this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.compareEnd=function(row,column){return this.end.row==row&&this.end.column==column?1:this.compare(row,column)},this.compareInside=function(row,column){return this.end.row==row&&this.end.column==column?1:this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.clipRows=function(firstRow,lastRow){if(this.end.row>lastRow)var end={row:lastRow+1,column:0};else if(firstRow>this.end.row)var end={row:firstRow,column:0};if(this.start.row>lastRow)var start={row:lastRow+1,column:0};else if(firstRow>this.start.row)var start={row:firstRow,column:0};return Range.fromPoints(start||this.start,end||this.end)},this.extend=function(row,column){var cmp=this.compare(row,column);if(0==cmp)return this;if(-1==cmp)var start={row:row,column:column};else var end={row:row,column:column};return Range.fromPoints(start||this.start,end||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return Range.fromPoints(this.start,this.end)},this.collapseRows=function(){return 0==this.end.column?new Range(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new Range(this.start.row,0,this.end.row,0)},this.toScreenRange=function(session){var screenPosStart=session.documentToScreenPosition(this.start),screenPosEnd=session.documentToScreenPosition(this.end);return new Range(screenPosStart.row,screenPosStart.column,screenPosEnd.row,screenPosEnd.column)},this.moveBy=function(row,column){this.start.row+=row,this.start.column+=column,this.end.row+=row,this.end.column+=column}}).call(Range.prototype),Range.fromPoints=function(start,end){return new Range(start.row,start.column,end.row,end.column)},Range.comparePoints=comparePoints,Range.comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},exports.Range=Range}),ace.define(\"ace/apply_delta\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.applyDelta=function(docLines,delta){var row=delta.start.row,startColumn=delta.start.column,line=docLines[row]||\"\";switch(delta.action){case\"insert\":var lines=delta.lines;if(1===lines.length)docLines[row]=line.substring(0,startColumn)+delta.lines[0]+line.substring(startColumn);else{var args=[row,1].concat(delta.lines);docLines.splice.apply(docLines,args),docLines[row]=line.substring(0,startColumn)+docLines[row],docLines[row+delta.lines.length-1]+=line.substring(startColumn)}break;case\"remove\":var endColumn=delta.end.column,endRow=delta.end.row;row===endRow?docLines[row]=line.substring(0,startColumn)+line.substring(endColumn):docLines.splice(row,endRow-row+1,line.substring(0,startColumn)+docLines[endRow].substring(endColumn))}}}),ace.define(\"ace/lib/event_emitter\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var EventEmitter={},stopPropagation=function(){this.propagationStopped=!0},preventDefault=function(){this.defaultPrevented=!0};EventEmitter._emit=EventEmitter._dispatchEvent=function(eventName,e){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var listeners=this._eventRegistry[eventName]||[],defaultHandler=this._defaultHandlers[eventName];if(listeners.length||defaultHandler){\"object\"==typeof e&&e||(e={}),e.type||(e.type=eventName),e.stopPropagation||(e.stopPropagation=stopPropagation),e.preventDefault||(e.preventDefault=preventDefault),listeners=listeners.slice();for(var i=0;listeners.length>i&&(listeners[i](e,this),!e.propagationStopped);i++);return defaultHandler&&!e.defaultPrevented?defaultHandler(e,this):void 0}},EventEmitter._signal=function(eventName,e){var listeners=(this._eventRegistry||{})[eventName];if(listeners){listeners=listeners.slice();for(var i=0;listeners.length>i;i++)listeners[i](e,this)}},EventEmitter.once=function(eventName,callback){var _self=this;callback&&this.addEventListener(eventName,function newCallback(){_self.removeEventListener(eventName,newCallback),callback.apply(null,arguments)})},EventEmitter.setDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers||(handlers=this._defaultHandlers={_disabled_:{}}),handlers[eventName]){var old=handlers[eventName],disabled=handlers._disabled_[eventName];disabled||(handlers._disabled_[eventName]=disabled=[]),disabled.push(old);var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}handlers[eventName]=callback},EventEmitter.removeDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers){var disabled=handlers._disabled_[eventName];if(handlers[eventName]==callback)handlers[eventName],disabled&&this.setDefaultHandler(eventName,disabled.pop());else if(disabled){var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}}},EventEmitter.on=EventEmitter.addEventListener=function(eventName,callback,capturing){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];return listeners||(listeners=this._eventRegistry[eventName]=[]),-1==listeners.indexOf(callback)&&listeners[capturing?\"unshift\":\"push\"](callback),callback},EventEmitter.off=EventEmitter.removeListener=EventEmitter.removeEventListener=function(eventName,callback){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];if(listeners){var index=listeners.indexOf(callback);-1!==index&&listeners.splice(index,1)}},EventEmitter.removeAllListeners=function(eventName){this._eventRegistry&&(this._eventRegistry[eventName]=[])},exports.EventEmitter=EventEmitter}),ace.define(\"ace/anchor\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/lib/event_emitter\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Anchor=exports.Anchor=function(doc,row,column){this.$onChange=this.onChange.bind(this),this.attach(doc),column===void 0?this.setPosition(row.row,row.column):this.setPosition(row,column)};(function(){function $pointsInOrder(point1,point2,equalPointsInOrder){var bColIsAfter=equalPointsInOrder?point1.column<=point2.column:point1.columnthis.row)){var point=$getTransformedPoint(delta,{row:this.row,column:this.column},this.$insertRight);this.setPosition(point.row,point.column,!0)}},this.setPosition=function(row,column,noClip){var pos;if(pos=noClip?{row:row,column:column}:this.$clipPositionToDocument(row,column),this.row!=pos.row||this.column!=pos.column){var old={row:this.row,column:this.column};this.row=pos.row,this.column=pos.column,this._signal(\"change\",{old:old,value:pos})}},this.detach=function(){this.document.removeEventListener(\"change\",this.$onChange)},this.attach=function(doc){this.document=doc||this.document,this.document.on(\"change\",this.$onChange)},this.$clipPositionToDocument=function(row,column){var pos={};return row>=this.document.getLength()?(pos.row=Math.max(0,this.document.getLength()-1),pos.column=this.document.getLine(pos.row).length):0>row?(pos.row=0,pos.column=0):(pos.row=row,pos.column=Math.min(this.document.getLine(pos.row).length,Math.max(0,column))),0>column&&(pos.column=0),pos}}).call(Anchor.prototype)}),ace.define(\"ace/document\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/apply_delta\",\"ace/lib/event_emitter\",\"ace/range\",\"ace/anchor\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),applyDelta=acequire(\"./apply_delta\").applyDelta,EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Range=acequire(\"./range\").Range,Anchor=acequire(\"./anchor\").Anchor,Document=function(textOrLines){this.$lines=[\"\"],0===textOrLines.length?this.$lines=[\"\"]:Array.isArray(textOrLines)?this.insertMergedLines({row:0,column:0},textOrLines):this.insert({row:0,column:0},textOrLines)};(function(){oop.implement(this,EventEmitter),this.setValue=function(text){var len=this.getLength()-1;this.remove(new Range(0,0,len,this.getLine(len).length)),this.insert({row:0,column:0},text)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(row,column){return new Anchor(this,row,column)},this.$split=0===\"aaa\".split(/a/).length?function(text){return text.replace(/\\r\\n|\\r/g,\"\\n\").split(\"\\n\")}:function(text){return text.split(/\\r\\n|\\r|\\n/)},this.$detectNewLine=function(text){var match=text.match(/^.*?(\\r\\n|\\r|\\n)/m);this.$autoNewLine=match?match[1]:\"\\n\",this._signal(\"changeNewLineMode\")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case\"windows\":return\"\\r\\n\";case\"unix\":return\"\\n\";default:return this.$autoNewLine||\"\\n\"}},this.$autoNewLine=\"\",this.$newLineMode=\"auto\",this.setNewLineMode=function(newLineMode){this.$newLineMode!==newLineMode&&(this.$newLineMode=newLineMode,this._signal(\"changeNewLineMode\"))},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(text){return\"\\r\\n\"==text||\"\\r\"==text||\"\\n\"==text},this.getLine=function(row){return this.$lines[row]||\"\"},this.getLines=function(firstRow,lastRow){return this.$lines.slice(firstRow,lastRow+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(range){return this.getLinesForRange(range).join(this.getNewLineCharacter())},this.getLinesForRange=function(range){var lines;if(range.start.row===range.end.row)lines=[this.getLine(range.start.row).substring(range.start.column,range.end.column)];else{lines=this.getLines(range.start.row,range.end.row),lines[0]=(lines[0]||\"\").substring(range.start.column);var l=lines.length-1;range.end.row-range.start.row==l&&(lines[l]=lines[l].substring(0,range.end.column))}return lines},this.insertLines=function(row,lines){return console.warn(\"Use of document.insertLines is deprecated. Use the insertFullLines method instead.\"),this.insertFullLines(row,lines)},this.removeLines=function(firstRow,lastRow){return console.warn(\"Use of document.removeLines is deprecated. Use the removeFullLines method instead.\"),this.removeFullLines(firstRow,lastRow)},this.insertNewLine=function(position){return console.warn(\"Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.\"),this.insertMergedLines(position,[\"\",\"\"])},this.insert=function(position,text){return 1>=this.getLength()&&this.$detectNewLine(text),this.insertMergedLines(position,this.$split(text))},this.insertInLine=function(position,text){var start=this.clippedPos(position.row,position.column),end=this.pos(position.row,position.column+text.length);return this.applyDelta({start:start,end:end,action:\"insert\",lines:[text]},!0),this.clonePos(end)},this.clippedPos=function(row,column){var length=this.getLength();void 0===row?row=length:0>row?row=0:row>=length&&(row=length-1,column=void 0);var line=this.getLine(row);return void 0==column&&(column=line.length),column=Math.min(Math.max(column,0),line.length),{row:row,column:column}},this.clonePos=function(pos){return{row:pos.row,column:pos.column}},this.pos=function(row,column){return{row:row,column:column}},this.$clipPosition=function(position){var length=this.getLength();return position.row>=length?(position.row=Math.max(0,length-1),position.column=this.getLine(length-1).length):(position.row=Math.max(0,position.row),position.column=Math.min(Math.max(position.column,0),this.getLine(position.row).length)),position},this.insertFullLines=function(row,lines){row=Math.min(Math.max(row,0),this.getLength());var column=0;this.getLength()>row?(lines=lines.concat([\"\"]),column=0):(lines=[\"\"].concat(lines),row--,column=this.$lines[row].length),this.insertMergedLines({row:row,column:column},lines)},this.insertMergedLines=function(position,lines){var start=this.clippedPos(position.row,position.column),end={row:start.row+lines.length-1,column:(1==lines.length?start.column:0)+lines[lines.length-1].length};return this.applyDelta({start:start,end:end,action:\"insert\",lines:lines}),this.clonePos(end)},this.remove=function(range){var start=this.clippedPos(range.start.row,range.start.column),end=this.clippedPos(range.end.row,range.end.column);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})}),this.clonePos(start)},this.removeInLine=function(row,startColumn,endColumn){var start=this.clippedPos(row,startColumn),end=this.clippedPos(row,endColumn);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})},!0),this.clonePos(start)},this.removeFullLines=function(firstRow,lastRow){firstRow=Math.min(Math.max(0,firstRow),this.getLength()-1),lastRow=Math.min(Math.max(0,lastRow),this.getLength()-1);var deleteFirstNewLine=lastRow==this.getLength()-1&&firstRow>0,deleteLastNewLine=this.getLength()-1>lastRow,startRow=deleteFirstNewLine?firstRow-1:firstRow,startCol=deleteFirstNewLine?this.getLine(startRow).length:0,endRow=deleteLastNewLine?lastRow+1:lastRow,endCol=deleteLastNewLine?0:this.getLine(endRow).length,range=new Range(startRow,startCol,endRow,endCol),deletedLines=this.$lines.slice(firstRow,lastRow+1);return this.applyDelta({start:range.start,end:range.end,action:\"remove\",lines:this.getLinesForRange(range)}),deletedLines},this.removeNewLine=function(row){this.getLength()-1>row&&row>=0&&this.applyDelta({start:this.pos(row,this.getLine(row).length),end:this.pos(row+1,0),action:\"remove\",lines:[\"\",\"\"]})},this.replace=function(range,text){if(range instanceof Range||(range=Range.fromPoints(range.start,range.end)),0===text.length&&range.isEmpty())return range.start;if(text==this.getTextRange(range))return range.end;this.remove(range);var end;return end=text?this.insert(range.start,text):range.start},this.applyDeltas=function(deltas){for(var i=0;deltas.length>i;i++)this.applyDelta(deltas[i])},this.revertDeltas=function(deltas){for(var i=deltas.length-1;i>=0;i--)this.revertDelta(deltas[i])},this.applyDelta=function(delta,doNotValidate){var isInsert=\"insert\"==delta.action;(isInsert?1>=delta.lines.length&&!delta.lines[0]:!Range.comparePoints(delta.start,delta.end))||(isInsert&&delta.lines.length>2e4&&this.$splitAndapplyLargeDelta(delta,2e4),applyDelta(this.$lines,delta,doNotValidate),this._signal(\"change\",delta))},this.$splitAndapplyLargeDelta=function(delta,MAX){for(var lines=delta.lines,l=lines.length,row=delta.start.row,column=delta.start.column,from=0,to=0;;){from=to,to+=MAX-1;var chunk=lines.slice(from,to);if(to>l){delta.lines=chunk,delta.start.row=row+from,delta.start.column=column;break}chunk.push(\"\"),this.applyDelta({start:this.pos(row+from,column),end:this.pos(row+to,column=0),action:delta.action,lines:chunk},!0)}},this.revertDelta=function(delta){this.applyDelta({start:this.clonePos(delta.start),end:this.clonePos(delta.end),action:\"insert\"==delta.action?\"remove\":\"insert\",lines:delta.lines.slice()})},this.indexToPosition=function(index,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,i=startRow||0,l=lines.length;l>i;i++)if(index-=lines[i].length+newlineLength,0>index)return{row:i,column:index+lines[i].length+newlineLength};return{row:l-1,column:lines[l-1].length}},this.positionToIndex=function(pos,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,index=0,row=Math.min(pos.row,lines.length),i=startRow||0;row>i;++i)index+=lines[i].length+newlineLength;return index+pos.column}}).call(Document.prototype),exports.Document=Document}),ace.define(\"ace/lib/lang\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.last=function(a){return a[a.length-1]},exports.stringReverse=function(string){return string.split(\"\").reverse().join(\"\")},exports.stringRepeat=function(string,count){for(var result=\"\";count>0;)1&count&&(result+=string),(count>>=1)&&(string+=string);return result};var trimBeginRegexp=/^\\s\\s*/,trimEndRegexp=/\\s\\s*$/;exports.stringTrimLeft=function(string){return string.replace(trimBeginRegexp,\"\")},exports.stringTrimRight=function(string){return string.replace(trimEndRegexp,\"\")},exports.copyObject=function(obj){var copy={};for(var key in obj)copy[key]=obj[key];return copy},exports.copyArray=function(array){for(var copy=[],i=0,l=array.length;l>i;i++)copy[i]=array[i]&&\"object\"==typeof array[i]?this.copyObject(array[i]):array[i];return copy},exports.deepCopy=function deepCopy(obj){if(\"object\"!=typeof obj||!obj)return obj;var copy;if(Array.isArray(obj)){copy=[];for(var key=0;obj.length>key;key++)copy[key]=deepCopy(obj[key]);return copy}if(\"[object Object]\"!==Object.prototype.toString.call(obj))return obj;copy={};for(var key in obj)copy[key]=deepCopy(obj[key]);return copy},exports.arrayToMap=function(arr){for(var map={},i=0;arr.length>i;i++)map[arr[i]]=1;return map},exports.createMap=function(props){var map=Object.create(null);for(var i in props)map[i]=props[i];return map},exports.arrayRemove=function(array,value){for(var i=0;array.length>=i;i++)value===array[i]&&array.splice(i,1)},exports.escapeRegExp=function(str){return str.replace(/([.*+?^${}()|[\\]\\/\\\\])/g,\"\\\\$1\")},exports.escapeHTML=function(str){return str.replace(/&/g,\"&\").replace(/\"/g,\""\").replace(/'/g,\"'\").replace(/i;i+=2){if(Array.isArray(data[i+1]))var d={action:\"insert\",start:data[i],lines:data[i+1]};else var d={action:\"remove\",start:data[i],end:data[i+1]};doc.applyDelta(d,!0)}return _self.$timeout?deferredUpdate.schedule(_self.$timeout):(_self.onUpdate(),void 0)})};(function(){this.$timeout=500,this.setTimeout=function(timeout){this.$timeout=timeout},this.setValue=function(value){this.doc.setValue(value),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(callbackId){this.sender.callback(this.doc.getValue(),callbackId)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(Mirror.prototype)}),ace.define(\"ace/mode/javascript/jshint\",[\"require\",\"exports\",\"module\"],function(acequire,exports,module){module.exports=function outer(modules,cache,entry){function newRequire(name,jumped){if(!cache[name]){if(!modules[name]){var currentRequire=\"function\"==typeof acequire&&acequire;if(!jumped&¤tRequire)return currentRequire(name,!0);if(previousRequire)return previousRequire(name,!0);var err=Error(\"Cannot find module '\"+name+\"'\");throw err.code=\"MODULE_NOT_FOUND\",err}var m=cache[name]={exports:{}};modules[name][0].call(m.exports,function(x){var id=modules[name][1][x];return newRequire(id?id:x)},m,m.exports,outer,modules,cache,entry)}return cache[name].exports}for(var previousRequire=\"function\"==typeof acequire&&acequire,i=0;entry.length>i;i++)newRequire(entry[i]);return newRequire(entry[0])}({\"/node_modules/browserify/node_modules/events/events.js\":[function(_dereq_,module){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return\"function\"==typeof arg}function isNumber(arg){return\"number\"==typeof arg}function isObject(arg){return\"object\"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError(\"n must be a positive number\");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),\"error\"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified \"error\" event.')}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];handler.apply(this,args)}else if(isObject(handler)){for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];for(listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args)}return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(this._events||(this._events={}),this._events.newListener&&this.emit(\"newListener\",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned){var m;m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error(\"(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.\",this._events[type].length),\"function\"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError(\"listener must be a function\");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit(\"removeListener\",type,listener);else if(isObject(list)){for(i=length;i-->0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit(\"removeListener\",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)\"removeListener\"!==key&&this.removeAllListeners(key);return this.removeAllListeners(\"removeListener\"),this._events={},this\n}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.listenerCount=function(emitter,type){var ret;return ret=emitter._events&&emitter._events[type]?isFunction(emitter._events[type])?1:emitter._events[type].length:0}},{}],\"/node_modules/jshint/data/ascii-identifier-data.js\":[function(_dereq_,module){for(var identifierStartTable=[],i=0;128>i;i++)identifierStartTable[i]=36===i||i>=65&&90>=i||95===i||i>=97&&122>=i;for(var identifierPartTable=[],i=0;128>i;i++)identifierPartTable[i]=identifierStartTable[i]||i>=48&&57>=i;module.exports={asciiIdentifierStartTable:identifierStartTable,asciiIdentifierPartTable:identifierPartTable}},{}],\"/node_modules/jshint/lodash.js\":[function(_dereq_,module,exports){(function(global){(function(){function baseFindIndex(array,predicate,fromRight){for(var length=array.length,index=fromRight?length:-1;fromRight?index--:length>++index;)if(predicate(array[index],index,array))return index;return-1}function baseIndexOf(array,value,fromIndex){if(value!==value)return indexOfNaN(array,fromIndex);for(var index=fromIndex-1,length=array.length;length>++index;)if(array[index]===value)return index;return-1}function baseIsFunction(value){return\"function\"==typeof value||!1}function baseToString(value){return\"string\"==typeof value?value:null==value?\"\":value+\"\"}function indexOfNaN(array,fromIndex,fromRight){for(var length=array.length,index=fromIndex+(fromRight?0:-1);fromRight?index--:length>++index;){var other=array[index];if(other!==other)return index}return-1}function isObjectLike(value){return!!value&&\"object\"==typeof value}function lodash(){}function arrayCopy(source,array){var index=-1,length=source.length;for(array||(array=Array(length));length>++index;)array[index]=source[index];return array}function arrayEach(array,iteratee){for(var index=-1,length=array.length;length>++index&&iteratee(array[index],index,array)!==!1;);return array}function arrayFilter(array,predicate){for(var index=-1,length=array.length,resIndex=-1,result=[];length>++index;){var value=array[index];predicate(value,index,array)&&(result[++resIndex]=value)}return result}function arrayMap(array,iteratee){for(var index=-1,length=array.length,result=Array(length);length>++index;)result[index]=iteratee(array[index],index,array);return result}function arrayMax(array){for(var index=-1,length=array.length,result=NEGATIVE_INFINITY;length>++index;){var value=array[index];value>result&&(result=value)}return result}function arraySome(array,predicate){for(var index=-1,length=array.length;length>++index;)if(predicate(array[index],index,array))return!0;return!1}function assignWith(object,source,customizer){var props=keys(source);push.apply(props,getSymbols(source));for(var index=-1,length=props.length;length>++index;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(value!==undefined||key in object)||(object[key]=result)}return object}function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;length>++index;){var key=props[index];object[key]=source[key]}return object}function baseCallback(func,thisArg,argCount){var type=typeof func;return\"function\"==type?thisArg===undefined?func:bindCallback(func,thisArg,argCount):null==func?identity:\"object\"==type?baseMatches(func):thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseClone(value,isDeep,customizer,key,object,stackA,stackB){var result;if(customizer&&(result=object?customizer(value,key,object):customizer(value)),result!==undefined)return result;if(!isObject(value))return value;var isArr=isArray(value);if(isArr){if(result=initCloneArray(value),!isDeep)return arrayCopy(value,result)}else{var tag=objToString.call(value),isFunc=tag==funcTag;if(tag!=objectTag&&tag!=argsTag&&(!isFunc||object))return cloneableTags[tag]?initCloneByTag(value,tag,isDeep):object?value:{};if(result=initCloneObject(isFunc?{}:value),!isDeep)return baseAssign(result,value)}stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==value)return stackB[length];return stackA.push(value),stackB.push(result),(isArr?arrayEach:baseForOwn)(value,function(subValue,key){result[key]=baseClone(subValue,isDeep,customizer,key,value,stackA,stackB)}),result}function baseFilter(collection,predicate){var result=[];return baseEach(collection,function(value,index,collection){predicate(value,index,collection)&&result.push(value)}),result}function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseGet(object,path,pathKey){if(null!=object){pathKey!==undefined&&pathKey in toObject(object)&&(path=[pathKey]);for(var index=-1,length=path.length;null!=object&&length>++index;)var result=object=object[path[index]];return result}}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other)return 0!==value||1/value==1/other;var valType=typeof value,othType=typeof other;return\"function\"!=valType&&\"object\"!=valType&&\"function\"!=othType&&\"object\"!=othType||null==value||null==other?value!==value&&other!==other:baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;objIsArr||(objTag=objToString.call(object),objTag==argsTag?objTag=objectTag:objTag!=objectTag&&(objIsArr=isTypedArray(object))),othIsArr||(othTag=objToString.call(other),othTag==argsTag?othTag=objectTag:othTag!=objectTag&&(othIsArr=isTypedArray(other)));var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!objIsArr&&!objIsObj)return equalByTag(object,other,objTag);if(!isLoose){var valWrapped=objIsObj&&hasOwnProperty.call(object,\"__wrapped__\"),othWrapped=othIsObj&&hasOwnProperty.call(other,\"__wrapped__\");if(valWrapped||othWrapped)return equalFunc(valWrapped?object.value():object,othWrapped?other.value():other,customizer,isLoose,stackA,stackB)}if(!isSameTag)return!1;stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==object)return stackB[length]==other;stackA.push(object),stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);return stackA.pop(),stackB.pop(),result}function baseIsMatch(object,props,values,strictCompareFlags,customizer){for(var index=-1,length=props.length,noCustomizer=!customizer;length>++index;)if(noCustomizer&&strictCompareFlags[index]?values[index]!==object[props[index]]:!(props[index]in object))return!1;for(index=-1;length>++index;){var key=props[index],objValue=object[key],srcValue=values[index];if(noCustomizer&&strictCompareFlags[index])var result=objValue!==undefined||key in object;else result=customizer?customizer(objValue,srcValue,key):undefined,result===undefined&&(result=baseIsEqual(srcValue,objValue,customizer,!0));if(!result)return!1}return!0}function baseMatches(source){var props=keys(source),length=props.length;if(!length)return constant(!0);if(1==length){var key=props[0],value=source[key];if(isStrictComparable(value))return function(object){return null==object?!1:object[key]===value&&(value!==undefined||key in toObject(object))}}for(var values=Array(length),strictCompareFlags=Array(length);length--;)value=source[props[length]],values[length]=value,strictCompareFlags[length]=isStrictComparable(value);return function(object){return null!=object&&baseIsMatch(toObject(object),props,values,strictCompareFlags)}}function baseMatchesProperty(path,value){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(value),pathKey=path+\"\";return path=toPath(path),function(object){if(null==object)return!1;var key=pathKey;if(object=toObject(object),!(!isArr&&isCommon||key in object)){if(object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),null==object)return!1;key=last(path),object=toObject(object)}return object[key]===value?value!==undefined||key in object:baseIsEqual(value,object[key],null,!0)}}function baseMerge(object,source,customizer,stackA,stackB){if(!isObject(object))return object;var isSrcArr=isLength(source.length)&&(isArray(source)||isTypedArray(source));if(!isSrcArr){var props=keys(source);push.apply(props,getSymbols(source))}return arrayEach(props||source,function(srcValue,key){if(props&&(key=srcValue,srcValue=source[key]),isObjectLike(srcValue))stackA||(stackA=[]),stackB||(stackB=[]),baseMergeDeep(object,source,key,baseMerge,customizer,stackA,stackB);else{var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue),!isSrcArr&&result===undefined||!isCommon&&(result===result?result===value:value!==value)||(object[key]=result)}}),object}function baseMergeDeep(object,source,key,mergeFunc,customizer,stackA,stackB){for(var length=stackA.length,srcValue=source[key];length--;)if(stackA[length]==srcValue)return object[key]=stackB[length],undefined;var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue,isLength(srcValue.length)&&(isArray(srcValue)||isTypedArray(srcValue))?result=isArray(value)?value:getLength(value)?arrayCopy(value):[]:isPlainObject(srcValue)||isArguments(srcValue)?result=isArguments(value)?toPlainObject(value):isPlainObject(value)?value:{}:isCommon=!1),stackA.push(srcValue),stackB.push(result),isCommon?object[key]=mergeFunc(result,srcValue,customizer,stackA,stackB):(result===result?result!==value:value===value)&&(object[key]=result)}function baseProperty(key){return function(object){return null==object?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+\"\";return path=toPath(path),function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=null==start?0:+start||0,0>start&&(start=-start>length?0:length+start),end=end===undefined||end>length?length:+end||0,0>end&&(end+=length),length=start>end?0:end-start>>>0,start>>>=0;for(var result=Array(length);length>++index;)result[index]=array[index+start];return result}function baseSome(collection,predicate){var result;return baseEach(collection,function(value,index,collection){return result=predicate(value,index,collection),!result}),!!result}function baseValues(object,props){for(var index=-1,length=props.length,result=Array(length);length>++index;)result[index]=object[props[index]];return result}function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(\"number\"==typeof value&&value===value&&HALF_MAX_ARRAY_LENGTH>=high){for(;high>low;){var mid=low+high>>>1,computed=array[mid];(retHighest?value>=computed:value>computed)?low=mid+1:high=mid}return high}return binaryIndexBy(array,value,identity,retHighest)}function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);for(var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsUndef=value===undefined;high>low;){var mid=floor((low+high)/2),computed=iteratee(array[mid]),isReflexive=computed===computed;if(valIsNaN)var setLow=isReflexive||retHighest;else setLow=valIsUndef?isReflexive&&(retHighest||computed!==undefined):retHighest?value>=computed:value>computed;setLow?low=mid+1:high=mid}return nativeMin(high,MAX_ARRAY_INDEX)}function bindCallback(func,thisArg,argCount){if(\"function\"!=typeof func)return identity;if(thisArg===undefined)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function bufferClone(buffer){return bufferSlice.call(buffer,0)}function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2&&sources[length-2],guard=length>2&&sources[2],thisArg=length>1&&sources[length-1];for(\"function\"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer=\"function\"==typeof thisArg?thisArg:null,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?null:customizer,length=1);length>++index;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length))return eachFunc(collection,iteratee);for(var index=fromRight?length:-1,iterable=toObject(collection);(fromRight?index--:length>++index)&&iteratee(iterable[index],index,iterable)!==!1;);return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){for(var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;fromRight?index--:length>++index;){var key=props[index];if(iteratee(iterable[key],key,iterable)===!1)break}return object}}function createFindIndex(fromRight){return function(array,predicate,thisArg){return array&&array.length?(predicate=getCallback(predicate,thisArg,3),baseFindIndex(array,predicate,fromRight)):-1}}function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return\"function\"==typeof iteratee&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length,result=!0;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength))return!1;for(;result&&arrLength>++index;){var arrValue=array[index],othValue=other[index];if(result=undefined,customizer&&(result=isLoose?customizer(othValue,arrValue,index):customizer(arrValue,othValue,index)),result===undefined)if(isLoose)for(var othIndex=othLength;othIndex--&&(othValue=other[othIndex],!(result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))););else result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)}return!!result}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:0==object?1/object==1/other:object==+other;case regexpTag:case stringTag:return object==other+\"\"}return!1}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose)return!1;for(var skipCtor=isLoose,index=-1;objLength>++index;){var key=objProps[index],result=isLoose?key in other:hasOwnProperty.call(other,key);if(result){var objValue=object[key],othValue=other[key];result=undefined,customizer&&(result=isLoose?customizer(othValue,objValue,key):customizer(objValue,othValue,key)),result===undefined&&(result=objValue&&objValue===othValue||equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB))}if(!result)return!1;skipCtor||(skipCtor=\"constructor\"==key)}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&\"constructor\"in object&&\"constructor\"in other&&!(\"function\"==typeof objCtor&&objCtor instanceof objCtor&&\"function\"==typeof othCtor&&othCtor instanceof othCtor))return!1}return!0}function getCallback(func,thisArg,argCount){var result=lodash.callback||callback;return result=result===callback?baseCallback:result,argCount?result(func,thisArg,argCount):result}function getIndexOf(collection,target,fromIndex){var result=lodash.indexOf||indexOf;return result=result===indexOf?baseIndexOf:result,collection?result(collection,target,fromIndex):result}function initCloneArray(array){var length=array.length,result=new array.constructor(length);return length&&\"string\"==typeof array[0]&&hasOwnProperty.call(array,\"index\")&&(result.index=array.index,result.input=array.input),result}function initCloneObject(object){var Ctor=object.constructor;return\"function\"==typeof Ctor&&Ctor instanceof Ctor||(Ctor=Object),new Ctor}function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return bufferClone(object);case boolTag:case dateTag:return new Ctor(+object);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:var buffer=object.buffer;return new Ctor(isDeep?bufferClone(buffer):buffer,object.byteOffset,object.length);case numberTag:case stringTag:return new Ctor(object);case regexpTag:var result=new Ctor(object.source,reFlags.exec(object));result.lastIndex=object.lastIndex}return result}function isIndex(value,length){return value=+value,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&0==value%1&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if(\"number\"==type)var length=getLength(object),prereq=isLength(length)&&isIndex(index,length);else prereq=\"string\"==type&&index in object;if(prereq){var other=object[index];return value===value?value===other:other!==other}return!1}function isKey(value,object){var type=typeof value;if(\"string\"==type&&reIsPlainProp.test(value)||\"number\"==type)return!0;if(isArray(value))return!1;var result=!reIsDeepProp.test(value);return result||null!=object&&value in toObject(object)}function isLength(value){return\"number\"==typeof value&&value>-1&&0==value%1&&MAX_SAFE_INTEGER>=value}function isStrictComparable(value){return value===value&&(0===value?1/value>0:!isObject(value))}function shimIsPlainObject(value){var Ctor;if(lodash.support,!isObjectLike(value)||objToString.call(value)!=objectTag||!hasOwnProperty.call(value,\"constructor\")&&(Ctor=value.constructor,\"function\"==typeof Ctor&&!(Ctor instanceof Ctor)))return!1;var result;return baseForIn(value,function(subValue,key){result=key}),result===undefined||hasOwnProperty.call(value,result)}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,support=lodash.support,allowIndexes=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object)),index=-1,result=[];propsLength>++index;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value))return value;var result=[];return baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,\"$1\"):number||match)}),result}function indexOf(array,value,fromIndex){var length=array?array.length:0;if(!length)return-1;if(\"number\"==typeof fromIndex)fromIndex=0>fromIndex?nativeMax(length+fromIndex,0):fromIndex;else if(fromIndex){var index=binaryIndex(array,value),other=array[index];return(value===value?value===other:other!==other)?index:-1}return baseIndexOf(array,value,fromIndex||0)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function slice(array,start,end){var length=array?array.length:0;return length?(end&&\"number\"!=typeof end&&isIterateeCall(array,start,end)&&(start=0,end=length),baseSlice(array,start,end)):[]}function unzip(array){for(var index=-1,length=(array&&array.length&&arrayMax(arrayMap(array,getLength)))>>>0,result=Array(length);length>++index;)result[index]=arrayMap(array,baseProperty(index));return result}function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;return isLength(length)||(collection=values(collection),length=collection.length),length?(fromIndex=\"number\"!=typeof fromIndex||guard&&isIterateeCall(target,fromIndex,guard)?0:0>fromIndex?nativeMax(length+fromIndex,0):fromIndex||0,\"string\"==typeof collection||!isArray(collection)&&isString(collection)?length>fromIndex&&collection.indexOf(target,fromIndex)>-1:getIndexOf(collection,target,fromIndex)>-1):!1}function reject(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;return predicate=getCallback(predicate,thisArg,3),func(collection,function(value,index,collection){return!predicate(value,index,collection)})}function some(collection,predicate,thisArg){var func=isArray(collection)?arraySome:baseSome;return thisArg&&isIterateeCall(collection,predicate,thisArg)&&(predicate=null),(\"function\"!=typeof predicate||thisArg!==undefined)&&(predicate=getCallback(predicate,thisArg,3)),func(collection,predicate)}function restParam(func,start){if(\"function\"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(start===undefined?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);length>++index;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;start>++index;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}function clone(value,isDeep,customizer,thisArg){return isDeep&&\"boolean\"!=typeof isDeep&&isIterateeCall(value,isDeep,customizer)?isDeep=!1:\"function\"==typeof isDeep&&(thisArg=customizer,customizer=isDeep,isDeep=!1),customizer=\"function\"==typeof customizer&&bindCallback(customizer,thisArg,1),baseClone(value,isDeep,customizer)}function isArguments(value){var length=isObjectLike(value)?value.length:undefined;return isLength(length)&&objToString.call(value)==argsTag}function isEmpty(value){if(null==value)return!0;var length=getLength(value);return isLength(length)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))?!length:!keys(value).length}function isObject(value){var type=typeof value;return\"function\"==type||!!value&&\"object\"==type}function isNative(value){return null==value?!1:objToString.call(value)==funcTag?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}function isNumber(value){return\"number\"==typeof value||isObjectLike(value)&&objToString.call(value)==numberTag}function isString(value){return\"string\"==typeof value||isObjectLike(value)&&objToString.call(value)==stringTag}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}function toPlainObject(value){return baseCopy(value,keysIn(value))}function has(object,path){if(null==object)return!1;var result=hasOwnProperty.call(object,path);return result||isKey(path)||(path=toPath(path),object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),path=last(path),result=null!=object&&hasOwnProperty.call(object,path)),result}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto=\"function\"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;length>++index;)result[index]=index+\"\";for(var key in object)skipIndexes&&isIndex(key,length)||\"constructor\"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}function values(object){return baseValues(object,keys(object))}function escapeRegExp(string){return string=baseToString(string),string&&reHasRegExpChars.test(string)?string.replace(reRegExpChars,\"\\\\$&\"):string}function callback(func,thisArg,guard){return guard&&isIterateeCall(func,thisArg,guard)&&(thisArg=null),baseCallback(func,thisArg)}function constant(value){return function(){return value}}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}var undefined,VERSION=\"3.7.0\",FUNC_ERROR_TEXT=\"Expected a function\",argsTag=\"[object Arguments]\",arrayTag=\"[object Array]\",boolTag=\"[object Boolean]\",dateTag=\"[object Date]\",errorTag=\"[object Error]\",funcTag=\"[object Function]\",mapTag=\"[object Map]\",numberTag=\"[object Number]\",objectTag=\"[object Object]\",regexpTag=\"[object RegExp]\",setTag=\"[object Set]\",stringTag=\"[object String]\",weakMapTag=\"[object WeakMap]\",arrayBufferTag=\"[object ArrayBuffer]\",float32Tag=\"[object Float32Array]\",float64Tag=\"[object Float64Array]\",int8Tag=\"[object Int8Array]\",int16Tag=\"[object Int16Array]\",int32Tag=\"[object Int32Array]\",uint8Tag=\"[object Uint8Array]\",uint8ClampedTag=\"[object Uint8ClampedArray]\",uint16Tag=\"[object Uint16Array]\",uint32Tag=\"[object Uint32Array]\",reIsDeepProp=/\\.|\\[(?:[^[\\]]+|([\"'])(?:(?!\\1)[^\\n\\\\]|\\\\.)*?)\\1\\]/,reIsPlainProp=/^\\w*$/,rePropName=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\n\\\\]|\\\\.)*?)\\2)\\]/g,reRegExpChars=/[.*+?^${}()|[\\]\\/\\\\]/g,reHasRegExpChars=RegExp(reRegExpChars.source),reEscapeChar=/\\\\(\\\\)?/g,reFlags=/\\w*$/,reIsHostCtor=/^\\[object .+?Constructor\\]$/,typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=!1;var objectTypes={\"function\":!0,object:!0},freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports,freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module,freeGlobal=freeExports&&freeModule&&\"object\"==typeof global&&global&&global.Object&&global,freeSelf=objectTypes[typeof self]&&self&&self.Object&&self,freeWindow=objectTypes[typeof window]&&window&&window.Object&&window,moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports,root=freeGlobal||freeWindow!==(this&&this.window)&&freeWindow||freeSelf||this,arrayProto=Array.prototype,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp(\"^\"+escapeRegExp(objToString).replace(/toString|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g,\"$1.*?\")+\"$\"),ArrayBuffer=isNative(ArrayBuffer=root.ArrayBuffer)&&ArrayBuffer,bufferSlice=isNative(bufferSlice=ArrayBuffer&&new ArrayBuffer(0).slice)&&bufferSlice,floor=Math.floor,getOwnPropertySymbols=isNative(getOwnPropertySymbols=Object.getOwnPropertySymbols)&&getOwnPropertySymbols,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,push=arrayProto.push,preventExtensions=isNative(Object.preventExtensions=Object.preventExtensions)&&preventExtensions,propertyIsEnumerable=objectProto.propertyIsEnumerable,Uint8Array=isNative(Uint8Array=root.Uint8Array)&&Uint8Array,Float64Array=function(){try{var func=isNative(func=root.Float64Array)&&func,result=new func(new ArrayBuffer(10),0,1)&&func}catch(e){}return result}(),nativeAssign=function(){var object={1:0},func=preventExtensions&&isNative(func=Object.assign)&&func;try{func(preventExtensions(object),\"xo\")}catch(e){}return!object[1]&&func}(),nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,MAX_ARRAY_LENGTH=Math.pow(2,32)-1,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1,FLOAT64_BYTES_PER_ELEMENT=Float64Array?Float64Array.BYTES_PER_ELEMENT:0,MAX_SAFE_INTEGER=Math.pow(2,53)-1,support=lodash.support={};(function(x){var Ctor=function(){this.x=x},props=[];Ctor.prototype={valueOf:x,y:x};for(var key in new Ctor)props.push(key);support.funcDecomp=/\\bthis\\b/.test(function(){return this}),support.funcNames=\"string\"==typeof Function.name;try{support.nonEnumArgs=!propertyIsEnumerable.call(arguments,1)}catch(e){support.nonEnumArgs=!0}})(1,0);var baseAssign=nativeAssign||function(object,source){return null==source?object:baseCopy(source,getSymbols(source),baseCopy(source,keys(source),object))},baseEach=createBaseEach(baseForOwn),baseFor=createBaseFor();bufferSlice||(bufferClone=ArrayBuffer&&Uint8Array?function(buffer){var byteLength=buffer.byteLength,floatLength=Float64Array?floor(byteLength/FLOAT64_BYTES_PER_ELEMENT):0,offset=floatLength*FLOAT64_BYTES_PER_ELEMENT,result=new ArrayBuffer(byteLength);if(floatLength){var view=new Float64Array(result,0,floatLength);view.set(new Float64Array(buffer,0,floatLength))}return byteLength!=offset&&(view=new Uint8Array(result,offset),view.set(new Uint8Array(buffer,offset))),result}:constant(null));var getLength=baseProperty(\"length\"),getSymbols=getOwnPropertySymbols?function(object){return getOwnPropertySymbols(toObject(object))}:constant([]),findLastIndex=createFindIndex(!0),zip=restParam(unzip),forEach=createForEach(arrayEach,baseEach),isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag},isFunction=baseIsFunction(/x/)||Uint8Array&&!baseIsFunction(Uint8Array)?function(value){return objToString.call(value)==funcTag}:baseIsFunction,isPlainObject=getPrototypeOf?function(value){if(!value||objToString.call(value)!=objectTag)return!1;var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)}:shimIsPlainObject,assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)}),keys=nativeKeys?function(object){if(object)var Ctor=object.constructor,length=object.length;return\"function\"==typeof Ctor&&Ctor.prototype===object||\"function\"!=typeof object&&isLength(length)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys,merge=createAssigner(baseMerge);lodash.assign=assign,lodash.callback=callback,lodash.constant=constant,lodash.forEach=forEach,lodash.keys=keys,lodash.keysIn=keysIn,lodash.merge=merge,lodash.property=property,lodash.reject=reject,lodash.restParam=restParam,lodash.slice=slice,lodash.toPlainObject=toPlainObject,lodash.unzip=unzip,lodash.values=values,lodash.zip=zip,lodash.each=forEach,lodash.extend=assign,lodash.iteratee=callback,lodash.clone=clone,lodash.escapeRegExp=escapeRegExp,lodash.findLastIndex=findLastIndex,lodash.has=has,lodash.identity=identity,lodash.includes=includes,lodash.indexOf=indexOf,lodash.isArguments=isArguments,lodash.isArray=isArray,lodash.isEmpty=isEmpty,lodash.isFunction=isFunction,lodash.isNative=isNative,lodash.isNumber=isNumber,lodash.isObject=isObject,lodash.isPlainObject=isPlainObject,lodash.isString=isString,lodash.isTypedArray=isTypedArray,lodash.last=last,lodash.some=some,lodash.any=some,lodash.contains=includes,lodash.include=includes,lodash.VERSION=VERSION,freeExports&&freeModule?moduleExports?(freeModule.exports=lodash)._=lodash:freeExports._=lodash:root._=lodash\n}).call(this)}).call(this,\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}],\"/node_modules/jshint/src/jshint.js\":[function(_dereq_,module,exports){var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),vars=_dereq_(\"./vars.js\"),messages=_dereq_(\"./messages.js\"),Lexer=_dereq_(\"./lex.js\").Lexer,reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,style=_dereq_(\"./style.js\"),options=_dereq_(\"./options.js\"),scopeManager=_dereq_(\"./scope-manager.js\"),JSHINT=function(){\"use strict\";function checkOption(name,t){return name=name.trim(),/^[+-]W\\d{3}$/g.test(name)?!0:-1!==options.validNames.indexOf(name)||\"jslint\"===t.type||_.has(options.removed,name)?!0:(error(\"E001\",t,name),!1)}function isString(obj){return\"[object String]\"===Object.prototype.toString.call(obj)}function isIdentifier(tkn,value){return tkn?tkn.identifier&&tkn.value===value?!0:!1:!1}function isReserved(token){if(!token.reserved)return!1;var meta=token.meta;if(meta&&meta.isFutureReservedWord&&state.inES5()){if(!meta.es5)return!1;if(meta.strictOnly&&!state.option.strict&&!state.isStrict())return!1;if(token.isProperty)return!1}return!0}function supplant(str,data){return str.replace(/\\{([^{}]*)\\}/g,function(a,b){var r=data[b];return\"string\"==typeof r||\"number\"==typeof r?r:a})}function combine(dest,src){Object.keys(src).forEach(function(name){_.has(JSHINT.blacklist,name)||(dest[name]=src[name])})}function processenforceall(){if(state.option.enforceall){for(var enforceopt in options.bool.enforcing)void 0!==state.option[enforceopt]||options.noenforceall[enforceopt]||(state.option[enforceopt]=!0);for(var relaxopt in options.bool.relaxing)void 0===state.option[relaxopt]&&(state.option[relaxopt]=!1)}}function assume(){processenforceall(),state.option.esversion||state.option.moz||(state.option.esversion=state.option.es3?3:state.option.esnext?6:5),state.inES5()&&combine(predefined,vars.ecmaIdentifiers[5]),state.inES6()&&combine(predefined,vars.ecmaIdentifiers[6]),state.option.module&&(state.option.strict===!0&&(state.option.strict=\"global\"),state.inES6()||warning(\"W134\",state.tokens.next,\"module\",6)),state.option.couch&&combine(predefined,vars.couch),state.option.qunit&&combine(predefined,vars.qunit),state.option.rhino&&combine(predefined,vars.rhino),state.option.shelljs&&(combine(predefined,vars.shelljs),combine(predefined,vars.node)),state.option.typed&&combine(predefined,vars.typed),state.option.phantom&&(combine(predefined,vars.phantom),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.prototypejs&&combine(predefined,vars.prototypejs),state.option.node&&(combine(predefined,vars.node),combine(predefined,vars.typed),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.devel&&combine(predefined,vars.devel),state.option.dojo&&combine(predefined,vars.dojo),state.option.browser&&(combine(predefined,vars.browser),combine(predefined,vars.typed)),state.option.browserify&&(combine(predefined,vars.browser),combine(predefined,vars.typed),combine(predefined,vars.browserify),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.nonstandard&&combine(predefined,vars.nonstandard),state.option.jasmine&&combine(predefined,vars.jasmine),state.option.jquery&&combine(predefined,vars.jquery),state.option.mootools&&combine(predefined,vars.mootools),state.option.worker&&combine(predefined,vars.worker),state.option.wsh&&combine(predefined,vars.wsh),state.option.globalstrict&&state.option.strict!==!1&&(state.option.strict=\"global\"),state.option.yui&&combine(predefined,vars.yui),state.option.mocha&&combine(predefined,vars.mocha)}function quit(code,line,chr){var percentage=Math.floor(100*(line/state.lines.length)),message=messages.errors[code].desc;throw{name:\"JSHintError\",line:line,character:chr,message:message+\" (\"+percentage+\"% scanned).\",raw:message,code:code}}function removeIgnoredMessages(){var ignored=state.ignoredLines;_.isEmpty(ignored)||(JSHINT.errors=_.reject(JSHINT.errors,function(err){return ignored[err.line]}))}function warning(code,t,a,b,c,d){var ch,l,w,msg;if(/^W\\d{3}$/.test(code)){if(state.ignored[code])return;msg=messages.warnings[code]}else/E\\d{3}/.test(code)?msg=messages.errors[code]:/I\\d{3}/.test(code)&&(msg=messages.info[code]);return t=t||state.tokens.next||{},\"(end)\"===t.id&&(t=state.tokens.curr),l=t.line||0,ch=t.from||0,w={id:\"(error)\",raw:msg.desc,code:msg.code,evidence:state.lines[l-1]||\"\",line:l,character:ch,scope:JSHINT.scope,a:a,b:b,c:c,d:d},w.reason=supplant(msg.desc,w),JSHINT.errors.push(w),removeIgnoredMessages(),JSHINT.errors.length>=state.option.maxerr&&quit(\"E043\",l,ch),w}function warningAt(m,l,ch,a,b,c,d){return warning(m,{line:l,from:ch},a,b,c,d)}function error(m,t,a,b,c,d){warning(m,t,a,b,c,d)}function errorAt(m,l,ch,a,b,c,d){return error(m,{line:l,from:ch},a,b,c,d)}function addInternalSrc(elem,src){var i;return i={id:\"(internal)\",elem:elem,value:src},JSHINT.internals.push(i),i}function doOption(){var nt=state.tokens.next,body=nt.body.match(/(-\\s+)?[^\\s,:]+(?:\\s*:\\s*(-\\s+)?[^\\s,]+)?/g)||[],predef={};if(\"globals\"===nt.type){body.forEach(function(g,idx){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(\"-\"===key||!key.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}\"-\"===key.charAt(0)?(key=key.slice(1),val=!1,JSHINT.blacklist[key]=key,delete predefined[key]):predef[key]=\"true\"===val}),combine(predefined,predef);for(var key in predef)_.has(predef,key)&&(declared[key]=nt)}\"exported\"===nt.type&&body.forEach(function(e,idx){if(!e.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}state.funct[\"(scope)\"].addExported(e)}),\"members\"===nt.type&&(membersOnly=membersOnly||{},body.forEach(function(m){var ch1=m.charAt(0),ch2=m.charAt(m.length-1);ch1!==ch2||'\"'!==ch1&&\"'\"!==ch1||(m=m.substr(1,m.length-2).replace('\\\\\"','\"')),membersOnly[m]=!1}));var numvals=[\"maxstatements\",\"maxparams\",\"maxdepth\",\"maxcomplexity\",\"maxerr\",\"maxlen\",\"indent\"];(\"jshint\"===nt.type||\"jslint\"===nt.type)&&(body.forEach(function(g){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(checkOption(key,nt))if(numvals.indexOf(key)>=0)if(\"false\"!==val){if(val=+val,\"number\"!=typeof val||!isFinite(val)||0>=val||Math.floor(val)!==val)return error(\"E032\",nt,g[1].trim()),void 0;state.option[key]=val}else state.option[key]=\"indent\"===key?4:!1;else{if(\"validthis\"===key)return state.funct[\"(global)\"]?void error(\"E009\"):\"true\"!==val&&\"false\"!==val?void error(\"E002\",nt):(state.option.validthis=\"true\"===val,void 0);if(\"quotmark\"!==key)if(\"shadow\"!==key)if(\"unused\"!==key)if(\"latedef\"!==key)if(\"ignore\"!==key)if(\"strict\"!==key){\"module\"===key&&(hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"module\"));var esversions={es3:3,es5:5,esnext:6};if(!_.has(esversions,key)){if(\"esversion\"===key){switch(val){case\"5\":state.inES5(!0)&&warning(\"I003\");case\"3\":case\"6\":state.option.moz=!1,state.option.esversion=+val;break;case\"2015\":state.option.moz=!1,state.option.esversion=6;break;default:error(\"E002\",nt)}return hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"esversion\"),void 0}var match=/^([+-])(W\\d{3})$/g.exec(key);if(match)return state.ignored[match[2]]=\"-\"===match[1],void 0;var tn;return\"true\"===val||\"false\"===val?(\"jslint\"===nt.type?(tn=options.renamed[key]||key,state.option[tn]=\"true\"===val,void 0!==options.inverted[tn]&&(state.option[tn]=!state.option[tn])):state.option[key]=\"true\"===val,\"newcap\"===key&&(state.option[\"(explicitNewcap)\"]=!0),void 0):(error(\"E002\",nt),void 0)}switch(val){case\"true\":state.option.moz=!1,state.option.esversion=esversions[key];break;case\"false\":state.option.moz||(state.option.esversion=5);break;default:error(\"E002\",nt)}}else switch(val){case\"true\":state.option.strict=!0;break;case\"false\":state.option.strict=!1;break;case\"func\":case\"global\":case\"implied\":state.option.strict=val;break;default:error(\"E002\",nt)}else switch(val){case\"line\":state.ignoredLines[nt.line]=!0,removeIgnoredMessages();break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.latedef=!0;break;case\"false\":state.option.latedef=!1;break;case\"nofunc\":state.option.latedef=\"nofunc\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.unused=!0;break;case\"false\":state.option.unused=!1;break;case\"vars\":case\"strict\":state.option.unused=val;break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.shadow=!0;break;case\"outer\":state.option.shadow=\"outer\";break;case\"false\":case\"inner\":state.option.shadow=\"inner\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":case\"false\":state.option.quotmark=\"true\"===val;break;case\"double\":case\"single\":state.option.quotmark=val;break;default:error(\"E002\",nt)}}}),assume())}function peek(p){var t,i=p||0,j=lookahead.length;if(j>i)return lookahead[i];for(;i>=j;)t=lookahead[j],t||(t=lookahead[j]=lex.token()),j+=1;return t||\"(end)\"!==state.tokens.next.id?t:state.tokens.next}function peekIgnoreEOL(){var t,i=0;do t=peek(i++);while(\"(endline)\"===t.id);return t}function advance(id,t){switch(state.tokens.curr.id){case\"(number)\":\".\"===state.tokens.next.id&&warning(\"W005\",state.tokens.curr);break;case\"-\":(\"-\"===state.tokens.next.id||\"--\"===state.tokens.next.id)&&warning(\"W006\");break;case\"+\":(\"+\"===state.tokens.next.id||\"++\"===state.tokens.next.id)&&warning(\"W007\")}for(id&&state.tokens.next.id!==id&&(t?\"(end)\"===state.tokens.next.id?error(\"E019\",t,t.id):error(\"E020\",state.tokens.next,id,t.id,t.line,state.tokens.next.value):(\"(identifier)\"!==state.tokens.next.type||state.tokens.next.value!==id)&&warning(\"W116\",state.tokens.next,id,state.tokens.next.value)),state.tokens.prev=state.tokens.curr,state.tokens.curr=state.tokens.next;;){if(state.tokens.next=lookahead.shift()||lex.token(),state.tokens.next||quit(\"E041\",state.tokens.curr.line),\"(end)\"===state.tokens.next.id||\"(error)\"===state.tokens.next.id)return;if(state.tokens.next.check&&state.tokens.next.check(),state.tokens.next.isSpecial)\"falls through\"===state.tokens.next.type?state.tokens.curr.caseFallsThrough=!0:doOption();else if(\"(endline)\"!==state.tokens.next.id)break}}function isInfix(token){return token.infix||!token.identifier&&!token.template&&!!token.led}function isEndOfExpr(){var curr=state.tokens.curr,next=state.tokens.next;return\";\"===next.id||\"}\"===next.id||\":\"===next.id?!0:isInfix(next)===isInfix(curr)||\"yield\"===curr.id&&state.inMoz()?curr.line!==startLine(next):!1}function isBeginOfExpr(prev){return!prev.left&&\"unary\"!==prev.arity}function expression(rbp,initial){var left,isArray=!1,isObject=!1,isLetExpr=!1;state.nameStack.push(),initial||\"let\"!==state.tokens.next.value||\"(\"!==peek(0).value||(state.inMoz()||warning(\"W118\",state.tokens.next,\"let expressions\"),isLetExpr=!0,state.funct[\"(scope)\"].stack(),advance(\"let\"),advance(\"(\"),state.tokens.prev.fud(),advance(\")\")),\"(end)\"===state.tokens.next.id&&error(\"E006\",state.tokens.curr);var isDangerous=state.option.asi&&state.tokens.prev.line!==startLine(state.tokens.curr)&&_.contains([\"]\",\")\"],state.tokens.prev.id)&&_.contains([\"[\",\"(\"],state.tokens.curr.id);if(isDangerous&&warning(\"W014\",state.tokens.curr,state.tokens.curr.id),advance(),initial&&(state.funct[\"(verb)\"]=state.tokens.curr.value,state.tokens.curr.beginsStmt=!0),initial===!0&&state.tokens.curr.fud)left=state.tokens.curr.fud();else for(state.tokens.curr.nud?left=state.tokens.curr.nud():error(\"E030\",state.tokens.curr,state.tokens.curr.id);(state.tokens.next.lbp>rbp||\"(template)\"===state.tokens.next.type)&&!isEndOfExpr();)isArray=\"Array\"===state.tokens.curr.value,isObject=\"Object\"===state.tokens.curr.value,left&&(left.value||left.first&&left.first.value)&&(\"new\"!==left.value||left.first&&left.first.value&&\".\"===left.first.value)&&(isArray=!1,left.value!==state.tokens.curr.value&&(isObject=!1)),advance(),isArray&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W009\",state.tokens.curr),isObject&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W010\",state.tokens.curr),left&&state.tokens.curr.led?left=state.tokens.curr.led(left):error(\"E033\",state.tokens.curr,state.tokens.curr.id);return isLetExpr&&state.funct[\"(scope)\"].unstack(),state.nameStack.pop(),left}function startLine(token){return token.startLine||token.line}function nobreaknonadjacent(left,right){left=left||state.tokens.curr,right=right||state.tokens.next,state.option.laxbreak||left.line===startLine(right)||warning(\"W014\",right,right.value)}function nolinebreak(t){t=t||state.tokens.curr,t.line!==startLine(state.tokens.next)&&warning(\"E022\",t,t.value)}function nobreakcomma(left,right){left.line!==startLine(right)&&(state.option.laxcomma||(comma.first&&(warning(\"I001\"),comma.first=!1),warning(\"W014\",left,right.value)))}function comma(opts){if(opts=opts||{},opts.peek?nobreakcomma(state.tokens.prev,state.tokens.curr):(nobreakcomma(state.tokens.curr,state.tokens.next),advance(\",\")),state.tokens.next.identifier&&(!opts.property||!state.inES5()))switch(state.tokens.next.value){case\"break\":case\"case\":case\"catch\":case\"continue\":case\"default\":case\"do\":case\"else\":case\"finally\":case\"for\":case\"if\":case\"in\":case\"instanceof\":case\"return\":case\"switch\":case\"throw\":case\"try\":case\"var\":case\"let\":case\"while\":case\"with\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}if(\"(punctuator)\"===state.tokens.next.type)switch(state.tokens.next.value){case\"}\":case\"]\":case\",\":if(opts.allowTrailing)return!0;case\")\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}return!0}function symbol(s,p){var x=state.syntax[s];return x&&\"object\"==typeof x||(state.syntax[s]=x={id:s,lbp:p,value:s}),x}function delim(s){var x=symbol(s,0);return x.delim=!0,x}function stmt(s,f){var x=delim(s);return x.identifier=x.reserved=!0,x.fud=f,x}function blockstmt(s,f){var x=stmt(s,f);return x.block=!0,x}function reserveName(x){var c=x.id.charAt(0);return(c>=\"a\"&&\"z\">=c||c>=\"A\"&&\"Z\">=c)&&(x.identifier=x.reserved=!0),x}function prefix(s,f){var x=symbol(s,150);return reserveName(x),x.nud=\"function\"==typeof f?f:function(){return this.arity=\"unary\",this.right=expression(150),(\"++\"===this.id||\"--\"===this.id)&&(state.option.plusplus?warning(\"W016\",this,this.id):!this.right||this.right.identifier&&!isReserved(this.right)||\".\"===this.right.id||\"[\"===this.right.id||warning(\"W017\",this),this.right&&this.right.isMetaProperty?error(\"E031\",this):this.right&&this.right.identifier&&state.funct[\"(scope)\"].block.modify(this.right.value,this)),this},x}function type(s,f){var x=delim(s);return x.type=s,x.nud=f,x}function reserve(name,func){var x=type(name,func);return x.identifier=!0,x.reserved=!0,x}function FutureReservedWord(name,meta){var x=type(name,meta&&meta.nud||function(){return this});return meta=meta||{},meta.isFutureReservedWord=!0,x.value=name,x.identifier=!0,x.reserved=!0,x.meta=meta,x}function reservevar(s,v){return reserve(s,function(){return\"function\"==typeof v&&v(this),this})}function infix(s,f,p,w){var x=symbol(s,p);return reserveName(x),x.infix=!0,x.led=function(left){return w||nobreaknonadjacent(state.tokens.prev,state.tokens.curr),\"in\"!==s&&\"instanceof\"!==s||\"!\"!==left.id||warning(\"W018\",left,\"!\"),\"function\"==typeof f?f(left,this):(this.left=left,this.right=expression(p),this)},x}function application(s){var x=symbol(s,42);return x.led=function(left){return nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left,this.right=doFunction({type:\"arrow\",loneArg:left}),this},x}function relation(s,f){var x=symbol(s,100);return x.led=function(left){nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left;var right=this.right=expression(100);return isIdentifier(left,\"NaN\")||isIdentifier(right,\"NaN\")?warning(\"W019\",this):f&&f.apply(this,[left,right]),left&&right||quit(\"E041\",state.tokens.curr.line),\"!\"===left.id&&warning(\"W018\",left,\"!\"),\"!\"===right.id&&warning(\"W018\",right,\"!\"),this},x}function isPoorRelation(node){return node&&(\"(number)\"===node.type&&0===+node.value||\"(string)\"===node.type&&\"\"===node.value||\"null\"===node.type&&!state.option.eqnull||\"true\"===node.type||\"false\"===node.type||\"undefined\"===node.type)}function isTypoTypeof(left,right,state){var values;return state.option.notypeof?!1:left&&right?(values=state.inES6()?typeofValues.es6:typeofValues.es3,\"(identifier)\"===right.type&&\"typeof\"===right.value&&\"(string)\"===left.type?!_.contains(values,left.value):!1):!1}function isGlobalEval(left,state){var isGlobal=!1;return\"this\"===left.type&&null===state.funct[\"(context)\"]?isGlobal=!0:\"(identifier)\"===left.type&&(state.option.node&&\"global\"===left.value?isGlobal=!0:!state.option.browser||\"window\"!==left.value&&\"document\"!==left.value||(isGlobal=!0)),isGlobal}function findNativePrototype(left){function walkPrototype(obj){return\"object\"==typeof obj?\"prototype\"===obj.right?obj:walkPrototype(obj.left):void 0}function walkNative(obj){for(;!obj.identifier&&\"object\"==typeof obj.left;)obj=obj.left;return obj.identifier&&natives.indexOf(obj.value)>=0?obj.value:void 0}var natives=[\"Array\",\"ArrayBuffer\",\"Boolean\",\"Collator\",\"DataView\",\"Date\",\"DateTimeFormat\",\"Error\",\"EvalError\",\"Float32Array\",\"Float64Array\",\"Function\",\"Infinity\",\"Intl\",\"Int16Array\",\"Int32Array\",\"Int8Array\",\"Iterator\",\"Number\",\"NumberFormat\",\"Object\",\"RangeError\",\"ReferenceError\",\"RegExp\",\"StopIteration\",\"String\",\"SyntaxError\",\"TypeError\",\"Uint16Array\",\"Uint32Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"URIError\"],prototype=walkPrototype(left);return prototype?walkNative(prototype):void 0}function checkLeftSideAssign(left,assignToken,options){var allowDestructuring=options&&options.allowDestructuring;if(assignToken=assignToken||left,state.option.freeze){var nativeObject=findNativePrototype(left);nativeObject&&warning(\"W121\",left,nativeObject)}return left.identifier&&!left.isMetaProperty&&state.funct[\"(scope)\"].block.reassign(left.value,left),\".\"===left.id?((!left.left||\"arguments\"===left.left.value&&!state.isStrict())&&warning(\"E031\",assignToken),state.nameStack.set(state.tokens.prev),!0):\"{\"===left.id||\"[\"===left.id?(allowDestructuring&&state.tokens.curr.left.destructAssign?state.tokens.curr.left.destructAssign.forEach(function(t){t.id&&state.funct[\"(scope)\"].block.modify(t.id,t.token)}):\"{\"!==left.id&&left.left?\"arguments\"!==left.left.value||state.isStrict()||warning(\"E031\",assignToken):warning(\"E031\",assignToken),\"[\"===left.id&&state.nameStack.set(left.right),!0):left.isMetaProperty?(error(\"E031\",assignToken),!0):left.identifier&&!isReserved(left)?(\"exception\"===state.funct[\"(scope)\"].labeltype(left.value)&&warning(\"W022\",left),state.nameStack.set(left),!0):(left===state.syntax[\"function\"]&&warning(\"W023\",state.tokens.curr),!1)}function assignop(s,f,p){var x=infix(s,\"function\"==typeof f?f:function(left,that){return that.left=left,left&&checkLeftSideAssign(left,that,{allowDestructuring:!0})?(that.right=expression(10),that):(error(\"E031\",that),void 0)},p);return x.exps=!0,x.assign=!0,x}function bitwise(s,f,p){var x=symbol(s,p);return reserveName(x),x.led=\"function\"==typeof f?f:function(left){return state.option.bitwise&&warning(\"W016\",this,this.id),this.left=left,this.right=expression(p),this},x}function bitwiseassignop(s){return assignop(s,function(left,that){return state.option.bitwise&&warning(\"W016\",that,that.id),left&&checkLeftSideAssign(left,that)?(that.right=expression(10),that):(error(\"E031\",that),void 0)},20)}function suffix(s){var x=symbol(s,150);return x.led=function(left){return state.option.plusplus?warning(\"W016\",this,this.id):left.identifier&&!isReserved(left)||\".\"===left.id||\"[\"===left.id||warning(\"W017\",this),left.isMetaProperty?error(\"E031\",this):left&&left.identifier&&state.funct[\"(scope)\"].block.modify(left.value,left),this.left=left,this},x}function optionalidentifier(fnparam,prop,preserve){if(state.tokens.next.identifier){preserve||advance();var curr=state.tokens.curr,val=state.tokens.curr.value;return isReserved(curr)?prop&&state.inES5()?val:fnparam&&\"undefined\"===val?val:(warning(\"W024\",state.tokens.curr,state.tokens.curr.id),val):val}}function identifier(fnparam,prop){var i=optionalidentifier(fnparam,prop,!1);if(i)return i;if(\"...\"===state.tokens.next.value){if(state.inES6(!0)||warning(\"W119\",state.tokens.next,\"spread/rest operator\",\"6\"),advance(),checkPunctuator(state.tokens.next,\"...\"))for(warning(\"E024\",state.tokens.next,\"...\");checkPunctuator(state.tokens.next,\"...\");)advance();return state.tokens.next.identifier?identifier(fnparam,prop):(warning(\"E024\",state.tokens.curr,\"...\"),void 0)}error(\"E030\",state.tokens.next,state.tokens.next.value),\";\"!==state.tokens.next.id&&advance()}function reachable(controlToken){var t,i=0;if(\";\"===state.tokens.next.id&&!controlToken.inBracelessBlock)for(;;){do t=peek(i),i+=1;while(\"(end)\"!==t.id&&\"(comment)\"===t.id);if(t.reach)return;if(\"(endline)\"!==t.id){if(\"function\"===t.id){state.option.latedef===!0&&warning(\"W026\",t);break}warning(\"W027\",t,t.value,controlToken.value);break}}}function parseFinalSemicolon(){if(\";\"!==state.tokens.next.id){if(state.tokens.next.isUnclosed)return advance();var sameLine=startLine(state.tokens.next)===state.tokens.curr.line&&\"(end)\"!==state.tokens.next.id,blockEnd=checkPunctuator(state.tokens.next,\"}\");sameLine&&!blockEnd?errorAt(\"E058\",state.tokens.curr.line,state.tokens.curr.character):state.option.asi||(blockEnd&&!state.option.lastsemic||!sameLine)&&warningAt(\"W033\",state.tokens.curr.line,state.tokens.curr.character)}else advance(\";\")}function statement(){var r,i=indent,t=state.tokens.next,hasOwnScope=!1;if(\";\"===t.id)return advance(\";\"),void 0;var res=isReserved(t);if(res&&t.meta&&t.meta.isFutureReservedWord&&\":\"===peek().id&&(warning(\"W024\",t,t.id),res=!1),t.identifier&&!res&&\":\"===peek().id&&(advance(),advance(\":\"),hasOwnScope=!0,state.funct[\"(scope)\"].stack(),state.funct[\"(scope)\"].block.addBreakLabel(t.value,{token:state.tokens.curr}),state.tokens.next.labelled||\"{\"===state.tokens.next.value||warning(\"W028\",state.tokens.next,t.value,state.tokens.next.value),state.tokens.next.label=t.value,t=state.tokens.next),\"{\"===t.id){var iscase=\"case\"===state.funct[\"(verb)\"]&&\":\"===state.tokens.curr.value;return block(!0,!0,!1,!1,iscase),void 0}return r=expression(0,!0),!r||r.identifier&&\"function\"===r.value||\"(punctuator)\"===r.type&&r.left&&r.left.identifier&&\"function\"===r.left.value||state.isStrict()||\"global\"!==state.option.strict||warning(\"E007\"),t.block||(state.option.expr||r&&r.exps?state.option.nonew&&r&&r.left&&\"(\"===r.id&&\"new\"===r.left.id&&warning(\"W031\",t):warning(\"W030\",state.tokens.curr),parseFinalSemicolon()),indent=i,hasOwnScope&&state.funct[\"(scope)\"].unstack(),r}function statements(){for(var p,a=[];!state.tokens.next.reach&&\"(end)\"!==state.tokens.next.id;)\";\"===state.tokens.next.id?(p=peek(),(!p||\"(\"!==p.id&&\"[\"!==p.id)&&warning(\"W032\"),advance(\";\")):a.push(statement());return a}function directives(){for(var i,p,pn;\"(string)\"===state.tokens.next.id;){if(p=peek(0),\"(endline)\"===p.id){i=1;do pn=peek(i++);while(\"(endline)\"===pn.id);if(\";\"===pn.id)p=pn;else{if(\"[\"===pn.value||\".\"===pn.value)break;state.option.asi&&\"(\"!==pn.value||warning(\"W033\",state.tokens.next)}}else{if(\".\"===p.id||\"[\"===p.id)break;\";\"!==p.id&&warning(\"W033\",p)}advance();var directive=state.tokens.curr.value;(state.directive[directive]||\"use strict\"===directive&&\"implied\"===state.option.strict)&&warning(\"W034\",state.tokens.curr,directive),state.directive[directive]=!0,\";\"===p.id&&advance(\";\")}state.isStrict()&&(state.option[\"(explicitNewcap)\"]||(state.option.newcap=!0),state.option.undef=!0)}function block(ordinary,stmt,isfunc,isfatarrow,iscase){var a,m,t,line,d,b=inblock,old_indent=indent;inblock=ordinary,t=state.tokens.next;var metrics=state.funct[\"(metrics)\"];if(metrics.nestedBlockDepth+=1,metrics.verifyMaxNestedBlockDepthPerFunction(),\"{\"===state.tokens.next.id){if(advance(\"{\"),state.funct[\"(scope)\"].stack(),line=state.tokens.curr.line,\"}\"!==state.tokens.next.id){for(indent+=state.option.indent;!ordinary&&state.tokens.next.from>indent;)indent+=state.option.indent;if(isfunc){m={};for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);directives(),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\"))}a=statements(),metrics.statementCount+=a.length,indent-=state.option.indent}advance(\"}\",t),isfunc&&(state.funct[\"(scope)\"].validateParams(),m&&(state.directive=m)),state.funct[\"(scope)\"].unstack(),indent=old_indent}else if(ordinary)state.funct[\"(noblockscopedvar)\"]=\"for\"!==state.tokens.next.id,state.funct[\"(scope)\"].stack(),(!stmt||state.option.curly)&&warning(\"W116\",state.tokens.next,\"{\",state.tokens.next.value),state.tokens.next.inBracelessBlock=!0,indent+=state.option.indent,a=[statement()],indent-=state.option.indent,state.funct[\"(scope)\"].unstack(),delete state.funct[\"(noblockscopedvar)\"];else if(isfunc){if(state.funct[\"(scope)\"].stack(),m={},!stmt||isfatarrow||state.inMoz()||error(\"W118\",state.tokens.curr,\"function closure expressions\"),!stmt)for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);expression(10),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\")),state.funct[\"(scope)\"].unstack()}else error(\"E021\",state.tokens.next,\"{\",state.tokens.next.value);switch(state.funct[\"(verb)\"]){case\"break\":case\"continue\":case\"return\":case\"throw\":if(iscase)break;default:state.funct[\"(verb)\"]=null}return inblock=b,!ordinary||!state.option.noempty||a&&0!==a.length||warning(\"W035\",state.tokens.prev),metrics.nestedBlockDepth-=1,a}function countMember(m){membersOnly&&\"boolean\"!=typeof membersOnly[m]&&warning(\"W036\",state.tokens.curr,m),\"number\"==typeof member[m]?member[m]+=1:member[m]=1}function comprehensiveArrayExpression(){var res={};res.exps=!0,state.funct[\"(comparray)\"].stack();var reversed=!1;return\"for\"!==state.tokens.next.value&&(reversed=!0,state.inMoz()||warning(\"W116\",state.tokens.next,\"for\",state.tokens.next.value),state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"for\"),\"each\"===state.tokens.next.value&&(advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"define\"),res.left=expression(130),_.contains([\"in\",\"of\"],state.tokens.next.value)?advance():error(\"E045\",state.tokens.curr),state.funct[\"(comparray)\"].setState(\"generate\"),expression(10),advance(\")\"),\"if\"===state.tokens.next.value&&(advance(\"if\"),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"filter\"),res.filter=expression(10),advance(\")\")),reversed||(state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"]\"),state.funct[\"(comparray)\"].unstack(),res}function isMethod(){return state.funct[\"(statement)\"]&&\"class\"===state.funct[\"(statement)\"].type||state.funct[\"(context)\"]&&\"class\"===state.funct[\"(context)\"][\"(verb)\"]}function isPropertyName(token){return token.identifier||\"(string)\"===token.id||\"(number)\"===token.id}function propertyName(preserveOrToken){var id,preserve=!0;return\"object\"==typeof preserveOrToken?id=preserveOrToken:(preserve=preserveOrToken,id=optionalidentifier(!1,!0,preserve)),id?\"object\"==typeof id&&(\"(string)\"===id.id||\"(identifier)\"===id.id?id=id.value:\"(number)\"===id.id&&(id=\"\"+id.value)):\"(string)\"===state.tokens.next.id?(id=state.tokens.next.value,preserve||advance()):\"(number)\"===state.tokens.next.id&&(id=\"\"+state.tokens.next.value,preserve||advance()),\"hasOwnProperty\"===id&&warning(\"W001\"),id}function functionparams(options){function addParam(addParamArgs){state.funct[\"(scope)\"].addParam.apply(state.funct[\"(scope)\"],addParamArgs)}var next,ident,t,paramsIds=[],tokens=[],pastDefault=!1,pastRest=!1,arity=0,loneArg=options&&options.loneArg;if(loneArg&&loneArg.identifier===!0)return state.funct[\"(scope)\"].addParam(loneArg.value,loneArg),{arity:1,params:[loneArg.value]};if(next=state.tokens.next,options&&options.parsedOpening||advance(\"(\"),\")\"===state.tokens.next.id)return advance(\")\"),void 0;for(;;){arity++;var currentParams=[];if(_.contains([\"{\",\"[\"],state.tokens.next.id)){tokens=destructuringPattern();for(t in tokens)t=tokens[t],t.id&&(paramsIds.push(t.id),currentParams.push([t.id,t.token]))}else if(checkPunctuator(state.tokens.next,\"...\")&&(pastRest=!0),ident=identifier(!0))paramsIds.push(ident),currentParams.push([ident,state.tokens.curr]);else for(;!checkPunctuators(state.tokens.next,[\",\",\")\"]);)advance();if(pastDefault&&\"=\"!==state.tokens.next.id&&error(\"W138\",state.tokens.current),\"=\"===state.tokens.next.id&&(state.inES6()||warning(\"W119\",state.tokens.next,\"default parameters\",\"6\"),advance(\"=\"),pastDefault=!0,expression(10)),currentParams.forEach(addParam),\",\"!==state.tokens.next.id)return advance(\")\",next),{arity:arity,params:paramsIds};pastRest&&warning(\"W131\",state.tokens.next),comma()}}function functor(name,token,overwrites){var funct={\"(name)\":name,\"(breakage)\":0,\"(loopage)\":0,\"(tokens)\":{},\"(properties)\":{},\"(catch)\":!1,\"(global)\":!1,\"(line)\":null,\"(character)\":null,\"(metrics)\":null,\"(statement)\":null,\"(context)\":null,\"(scope)\":null,\"(comparray)\":null,\"(generator)\":null,\"(arrow)\":null,\"(params)\":null};return token&&_.extend(funct,{\"(line)\":token.line,\"(character)\":token.character,\"(metrics)\":createMetrics(token)}),_.extend(funct,overwrites),funct[\"(context)\"]&&(funct[\"(scope)\"]=funct[\"(context)\"][\"(scope)\"],funct[\"(comparray)\"]=funct[\"(context)\"][\"(comparray)\"]),funct}function isFunctor(token){return\"(scope)\"in token}function hasParsedCode(funct){return funct[\"(global)\"]&&!funct[\"(verb)\"]}function doTemplateLiteral(left){function end(){if(state.tokens.curr.template&&state.tokens.curr.tail&&state.tokens.curr.context===ctx)return!0;var complete=state.tokens.next.template&&state.tokens.next.tail&&state.tokens.next.context===ctx;return complete&&advance(),complete||state.tokens.next.isUnclosed}var ctx=this.context,noSubst=this.noSubst,depth=this.depth;if(!noSubst)for(;!end();)!state.tokens.next.template||state.tokens.next.depth>depth?expression(0):advance();return{id:\"(template)\",type:\"(template)\",tag:left}}function doFunction(options){var f,token,name,statement,classExprBinding,isGenerator,isArrow,ignoreLoopFunc,oldOption=state.option,oldIgnored=state.ignored;options&&(name=options.name,statement=options.statement,classExprBinding=options.classExprBinding,isGenerator=\"generator\"===options.type,isArrow=\"arrow\"===options.type,ignoreLoopFunc=options.ignoreLoopFunc),state.option=Object.create(state.option),state.ignored=Object.create(state.ignored),state.funct=functor(name||state.nameStack.infer(),state.tokens.next,{\"(statement)\":statement,\"(context)\":state.funct,\"(arrow)\":isArrow,\"(generator)\":isGenerator}),f=state.funct,token=state.tokens.curr,token.funct=state.funct,functions.push(state.funct),state.funct[\"(scope)\"].stack(\"functionouter\");var internallyAccessibleName=name||classExprBinding;internallyAccessibleName&&state.funct[\"(scope)\"].block.add(internallyAccessibleName,classExprBinding?\"class\":\"function\",state.tokens.curr,!1),state.funct[\"(scope)\"].stack(\"functionparams\");var paramsInfo=functionparams(options);return paramsInfo?(state.funct[\"(params)\"]=paramsInfo.params,state.funct[\"(metrics)\"].arity=paramsInfo.arity,state.funct[\"(metrics)\"].verifyMaxParametersPerFunction()):state.funct[\"(metrics)\"].arity=0,isArrow&&(state.inES6(!0)||warning(\"W119\",state.tokens.curr,\"arrow function syntax (=>)\",\"6\"),options.loneArg||advance(\"=>\")),block(!1,!0,!0,isArrow),!state.option.noyield&&isGenerator&&\"yielded\"!==state.funct[\"(generator)\"]&&warning(\"W124\",state.tokens.curr),state.funct[\"(metrics)\"].verifyMaxStatementsPerFunction(),state.funct[\"(metrics)\"].verifyMaxComplexityPerFunction(),state.funct[\"(unusedOption)\"]=state.option.unused,state.option=oldOption,state.ignored=oldIgnored,state.funct[\"(last)\"]=state.tokens.curr.line,state.funct[\"(lastcharacter)\"]=state.tokens.curr.character,state.funct[\"(scope)\"].unstack(),state.funct[\"(scope)\"].unstack(),state.funct=state.funct[\"(context)\"],ignoreLoopFunc||state.option.loopfunc||!state.funct[\"(loopage)\"]||f[\"(isCapturing)\"]&&warning(\"W083\",token),f}function createMetrics(functionStartToken){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){state.option.maxstatements&&this.statementCount>state.option.maxstatements&&warning(\"W071\",functionStartToken,this.statementCount)\n},verifyMaxParametersPerFunction:function(){_.isNumber(state.option.maxparams)&&this.arity>state.option.maxparams&&warning(\"W072\",functionStartToken,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){state.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===state.option.maxdepth+1&&warning(\"W073\",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var max=state.option.maxcomplexity,cc=this.ComplexityCount;max&&cc>max&&warning(\"W074\",functionStartToken,cc)}}}function increaseComplexityCount(){state.funct[\"(metrics)\"].ComplexityCount+=1}function checkCondAssignment(expr){var id,paren;switch(expr&&(id=expr.id,paren=expr.paren,\",\"===id&&(expr=expr.exprs[expr.exprs.length-1])&&(id=expr.id,paren=paren||expr.paren)),id){case\"=\":case\"+=\":case\"-=\":case\"*=\":case\"%=\":case\"&=\":case\"|=\":case\"^=\":case\"/=\":paren||state.option.boss||warning(\"W084\")}}function checkProperties(props){if(state.inES5())for(var name in props)props[name]&&props[name].setterToken&&!props[name].getterToken&&warning(\"W078\",props[name].setterToken)}function metaProperty(name,c){if(checkPunctuator(state.tokens.next,\".\")){var left=state.tokens.curr.id;advance(\".\");var id=identifier();return state.tokens.curr.isMetaProperty=!0,name!==id?error(\"E057\",state.tokens.prev,left,id):c(),state.tokens.curr}}function destructuringPattern(options){var isAssignment=options&&options.assignment;return state.inES6()||warning(\"W104\",state.tokens.curr,isAssignment?\"destructuring assignment\":\"destructuring binding\",\"6\"),destructuringPatternRecursive(options)}function destructuringPatternRecursive(options){var ids,identifiers=[],openingParsed=options&&options.openingParsed,isAssignment=options&&options.assignment,recursiveOptions=isAssignment?{assignment:isAssignment}:null,firstToken=openingParsed?state.tokens.curr:state.tokens.next,nextInnerDE=function(){var ident;if(checkPunctuators(state.tokens.next,[\"[\",\"{\"])){ids=destructuringPatternRecursive(recursiveOptions);for(var id in ids)id=ids[id],identifiers.push({id:id.id,token:id.token})}else if(checkPunctuator(state.tokens.next,\",\"))identifiers.push({id:null,token:state.tokens.curr});else{if(!checkPunctuator(state.tokens.next,\"(\")){var is_rest=checkPunctuator(state.tokens.next,\"...\");if(isAssignment){var identifierToken=is_rest?peek(0):state.tokens.next;identifierToken.identifier||warning(\"E030\",identifierToken,identifierToken.value);var assignTarget=expression(155);assignTarget&&(checkLeftSideAssign(assignTarget),assignTarget.identifier&&(ident=assignTarget.value))}else ident=identifier();return ident&&identifiers.push({id:ident,token:state.tokens.curr}),is_rest}advance(\"(\"),nextInnerDE(),advance(\")\")}return!1},assignmentProperty=function(){var id;checkPunctuator(state.tokens.next,\"[\")?(advance(\"[\"),expression(10),advance(\"]\"),advance(\":\"),nextInnerDE()):\"(string)\"===state.tokens.next.id||\"(number)\"===state.tokens.next.id?(advance(),advance(\":\"),nextInnerDE()):(id=identifier(),checkPunctuator(state.tokens.next,\":\")?(advance(\":\"),nextInnerDE()):id&&(isAssignment&&checkLeftSideAssign(state.tokens.curr),identifiers.push({id:id,token:state.tokens.curr})))};if(checkPunctuator(firstToken,\"[\")){openingParsed||advance(\"[\"),checkPunctuator(state.tokens.next,\"]\")&&warning(\"W137\",state.tokens.curr);for(var element_after_rest=!1;!checkPunctuator(state.tokens.next,\"]\");)nextInnerDE()&&!element_after_rest&&checkPunctuator(state.tokens.next,\",\")&&(warning(\"W130\",state.tokens.next),element_after_rest=!0),checkPunctuator(state.tokens.next,\"=\")&&(checkPunctuator(state.tokens.prev,\"...\")?advance(\"]\"):advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"]\")||advance(\",\");advance(\"]\")}else if(checkPunctuator(firstToken,\"{\")){for(openingParsed||advance(\"{\"),checkPunctuator(state.tokens.next,\"}\")&&warning(\"W137\",state.tokens.curr);!checkPunctuator(state.tokens.next,\"}\")&&(assignmentProperty(),checkPunctuator(state.tokens.next,\"=\")&&(advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"}\")||(advance(\",\"),!checkPunctuator(state.tokens.next,\"}\"))););advance(\"}\")}return identifiers}function destructuringPatternMatch(tokens,value){var first=value.first;first&&_.zip(tokens,Array.isArray(first)?first:[first]).forEach(function(val){var token=val[0],value=val[1];token&&value?token.first=value:token&&token.first&&!value&&warning(\"W080\",token.first,token.first.value)})}function blockVariableStatement(type,statement,context){var tokens,lone,value,letblock,prefix=context&&context.prefix,inexport=context&&context.inexport,isLet=\"let\"===type,isConst=\"const\"===type;for(state.inES6()||warning(\"W104\",state.tokens.curr,type,\"6\"),isLet&&\"(\"===state.tokens.next.value?(state.inMoz()||warning(\"W118\",state.tokens.next,\"let block\"),advance(\"(\"),state.funct[\"(scope)\"].stack(),letblock=!0):state.funct[\"(noblockscopedvar)\"]&&error(\"E048\",state.tokens.curr,isConst?\"Const\":\"Let\"),statement.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),!prefix&&isConst&&\"=\"!==state.tokens.next.id&&warning(\"E012\",state.tokens.curr,state.tokens.curr.value);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],state.funct[\"(scope)\"].block.isGlobal()&&predefined[t.id]===!1&&warning(\"W079\",t.token,t.id),t.id&&!state.funct[\"(noblockscopedvar)\"]&&(state.funct[\"(scope)\"].addlabel(t.id,{type:type,token:t.token}),names.push(t.token),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.token.value,t.token)));if(\"=\"===state.tokens.next.id&&(advance(\"=\"),prefix||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),!prefix&&\"=\"===peek(0).id&&state.tokens.next.identifier&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),statement.first=statement.first.concat(names),\",\"!==state.tokens.next.id)break;comma()}return letblock&&(advance(\")\"),block(!0,!0),statement.block=!0,state.funct[\"(scope)\"].unstack()),statement}function classdef(isStatement){return state.inES6()||warning(\"W104\",state.tokens.curr,\"class\",\"6\"),isStatement?(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"class\",token:state.tokens.curr})):state.tokens.next.identifier&&\"extends\"!==state.tokens.next.value?(this.name=identifier(),this.namedExpr=!0):this.name=state.nameStack.infer(),classtail(this),this}function classtail(c){var wasInClassBody=state.inClassBody;\"extends\"===state.tokens.next.value&&(advance(\"extends\"),c.heritage=expression(10)),state.inClassBody=!0,advance(\"{\"),c.body=classbody(c),advance(\"}\"),state.inClassBody=wasInClassBody}function classbody(c){for(var name,isStatic,isGenerator,getset,computed,props=Object.create(null),staticProps=Object.create(null),i=0;\"}\"!==state.tokens.next.id;++i)if(name=state.tokens.next,isStatic=!1,isGenerator=!1,getset=null,\";\"!==name.id){if(\"*\"===name.id&&(isGenerator=!0,advance(\"*\"),name=state.tokens.next),\"[\"===name.id)name=computedPropertyName(),computed=!0;else{if(!isPropertyName(name)){warning(\"W052\",state.tokens.next,state.tokens.next.value||state.tokens.next.type),advance();continue}advance(),computed=!1,name.identifier&&\"static\"===name.value&&(checkPunctuator(state.tokens.next,\"*\")&&(isGenerator=!0,advance(\"*\")),(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,isStatic=!0,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())),!name.identifier||\"get\"!==name.value&&\"set\"!==name.value||(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,getset=name,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())}if(!checkPunctuator(state.tokens.next,\"(\")){for(error(\"E054\",state.tokens.next,state.tokens.next.value);\"}\"!==state.tokens.next.id&&!checkPunctuator(state.tokens.next,\"(\");)advance();\"(\"!==state.tokens.next.value&&doFunction({statement:c})}if(computed||(getset?saveAccessor(getset.value,isStatic?staticProps:props,name.value,name,!0,isStatic):(\"constructor\"===name.value?state.nameStack.set(c):state.nameStack.set(name),saveProperty(isStatic?staticProps:props,name.value,name,!0,isStatic))),getset&&\"constructor\"===name.value){var propDesc=\"get\"===getset.value?\"class getter method\":\"class setter method\";error(\"E049\",name,propDesc,\"constructor\")}else\"prototype\"===name.value&&error(\"E049\",name,\"class method\",\"prototype\");propertyName(name),doFunction({statement:c,type:isGenerator?\"generator\":null,classExprBinding:c.namedExpr?c.name:null})}else warning(\"W032\"),advance(\";\");checkProperties(props)}function saveProperty(props,name,tkn,isClass,isStatic){var msg=[\"key\",\"class method\",\"static class method\"];msg=msg[(isClass||!1)+(isStatic||!1)],tkn.identifier&&(name=tkn.value),props[name]&&\"__proto__\"!==name?warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name].basic=!0,props[name].basictkn=tkn}function saveAccessor(accessorType,props,name,tkn,isClass,isStatic){var flagName=\"get\"===accessorType?\"getterToken\":\"setterToken\",msg=\"\";isClass?(isStatic&&(msg+=\"static \"),msg+=accessorType+\"ter method\"):msg=\"key\",state.tokens.curr.accessorType=accessorType,state.nameStack.set(tkn),props[name]?(props[name].basic||props[name][flagName])&&\"__proto__\"!==name&&warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name][flagName]=tkn}function computedPropertyName(){advance(\"[\"),state.inES6()||warning(\"W119\",state.tokens.curr,\"computed property names\",\"6\");var value=expression(10);return advance(\"]\"),value}function checkPunctuators(token,values){return\"(punctuator)\"===token.type?_.contains(values,token.value):!1}function checkPunctuator(token,value){return\"(punctuator)\"===token.type&&token.value===value}function destructuringAssignOrJsonValue(){var block=lookupBlockType();block.notJson?(!state.inES6()&&block.isDestAssign&&warning(\"W104\",state.tokens.curr,\"destructuring assignment\",\"6\"),statements()):(state.option.laxbreak=!0,state.jsonMode=!0,jsonValue())}function jsonValue(){function jsonObject(){var o={},t=state.tokens.next;if(advance(\"{\"),\"}\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E026\",state.tokens.next,t.line);else{if(\"}\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id?error(\"E028\",state.tokens.next):\"(string)\"!==state.tokens.next.id&&warning(\"W095\",state.tokens.next,state.tokens.next.value)}if(o[state.tokens.next.value]===!0?warning(\"W075\",state.tokens.next,\"key\",state.tokens.next.value):\"__proto__\"===state.tokens.next.value&&!state.option.proto||\"__iterator__\"===state.tokens.next.value&&!state.option.iterator?warning(\"W096\",state.tokens.next,state.tokens.next.value):o[state.tokens.next.value]=!0,advance(),advance(\":\"),jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"}\")}function jsonArray(){var t=state.tokens.next;if(advance(\"[\"),\"]\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E027\",state.tokens.next,t.line);else{if(\"]\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id&&error(\"E028\",state.tokens.next)}if(jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"]\")}switch(state.tokens.next.id){case\"{\":jsonObject();break;case\"[\":jsonArray();break;case\"true\":case\"false\":case\"null\":case\"(number)\":case\"(string)\":advance();break;case\"-\":advance(\"-\"),advance(\"(number)\");break;default:error(\"E003\",state.tokens.next)}}var api,declared,functions,inblock,indent,lookahead,lex,member,membersOnly,predefined,stack,urls,bang={\"<\":!0,\"<=\":!0,\"==\":!0,\"===\":!0,\"!==\":!0,\"!=\":!0,\">\":!0,\">=\":!0,\"+\":!0,\"-\":!0,\"*\":!0,\"/\":!0,\"%\":!0},functionicity=[\"closure\",\"exception\",\"global\",\"label\",\"outer\",\"unused\",\"var\"],extraModules=[],emitter=new events.EventEmitter,typeofValues={};typeofValues.legacy=[\"xml\",\"unknown\"],typeofValues.es3=[\"undefined\",\"boolean\",\"number\",\"string\",\"function\",\"object\"],typeofValues.es3=typeofValues.es3.concat(typeofValues.legacy),typeofValues.es6=typeofValues.es3.concat(\"symbol\"),type(\"(number)\",function(){return this}),type(\"(string)\",function(){return this}),state.syntax[\"(identifier)\"]={type:\"(identifier)\",lbp:0,identifier:!0,nud:function(){var v=this.value;return\"=>\"===state.tokens.next.id?this:(state.funct[\"(comparray)\"].check(v)||state.funct[\"(scope)\"].block.use(v,state.tokens.curr),this)},led:function(){error(\"E033\",state.tokens.next,state.tokens.next.value)}};var baseTemplateSyntax={lbp:0,identifier:!1,template:!0};state.syntax[\"(template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template middle)\"]=_.extend({type:\"(template middle)\",middle:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template tail)\"]=_.extend({type:\"(template tail)\",tail:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(no subst template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!0,tail:!0},baseTemplateSyntax),type(\"(regexp)\",function(){return this}),delim(\"(endline)\"),delim(\"(begin)\"),delim(\"(end)\").reach=!0,delim(\"(error)\").reach=!0,delim(\"}\").reach=!0,delim(\")\"),delim(\"]\"),delim('\"').reach=!0,delim(\"'\").reach=!0,delim(\";\"),delim(\":\").reach=!0,delim(\"#\"),reserve(\"else\"),reserve(\"case\").reach=!0,reserve(\"catch\"),reserve(\"default\").reach=!0,reserve(\"finally\"),reservevar(\"arguments\",function(x){state.isStrict()&&state.funct[\"(global)\"]&&warning(\"E008\",x)}),reservevar(\"eval\"),reservevar(\"false\"),reservevar(\"Infinity\"),reservevar(\"null\"),reservevar(\"this\",function(x){state.isStrict()&&!isMethod()&&!state.option.validthis&&(state.funct[\"(statement)\"]&&state.funct[\"(name)\"].charAt(0)>\"Z\"||state.funct[\"(global)\"])&&warning(\"W040\",x)}),reservevar(\"true\"),reservevar(\"undefined\"),assignop(\"=\",\"assign\",20),assignop(\"+=\",\"assignadd\",20),assignop(\"-=\",\"assignsub\",20),assignop(\"*=\",\"assignmult\",20),assignop(\"/=\",\"assigndiv\",20).nud=function(){error(\"E014\")},assignop(\"%=\",\"assignmod\",20),bitwiseassignop(\"&=\"),bitwiseassignop(\"|=\"),bitwiseassignop(\"^=\"),bitwiseassignop(\"<<=\"),bitwiseassignop(\">>=\"),bitwiseassignop(\">>>=\"),infix(\",\",function(left,that){var expr;if(that.exprs=[left],state.option.nocomma&&warning(\"W127\"),!comma({peek:!0}))return that;for(;;){if(!(expr=expression(10)))break;if(that.exprs.push(expr),\",\"!==state.tokens.next.value||!comma())break}return that},10,!0),infix(\"?\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(10),advance(\":\"),that[\"else\"]=expression(10),that},30);var orPrecendence=40;infix(\"||\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(orPrecendence),that},orPrecendence),infix(\"&&\",\"and\",50),bitwise(\"|\",\"bitor\",70),bitwise(\"^\",\"bitxor\",80),bitwise(\"&\",\"bitand\",90),relation(\"==\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));switch(!0){case!eqnull&&state.option.eqeqeq:this.from=this.character,warning(\"W116\",this,\"===\",\"==\");break;case isPoorRelation(left):warning(\"W041\",this,\"===\",left.value);break;case isPoorRelation(right):warning(\"W041\",this,\"===\",right.value);break;case isTypoTypeof(right,left,state):warning(\"W122\",this,right.value);break;case isTypoTypeof(left,right,state):warning(\"W122\",this,left.value)}return this}),relation(\"===\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!=\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));return!eqnull&&state.option.eqeqeq?(this.from=this.character,warning(\"W116\",this,\"!==\",\"!=\")):isPoorRelation(left)?warning(\"W041\",this,\"!==\",left.value):isPoorRelation(right)?warning(\"W041\",this,\"!==\",right.value):isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!==\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"<\"),relation(\">\"),relation(\"<=\"),relation(\">=\"),bitwise(\"<<\",\"shiftleft\",120),bitwise(\">>\",\"shiftright\",120),bitwise(\">>>\",\"shiftrightunsigned\",120),infix(\"in\",\"in\",120),infix(\"instanceof\",\"instanceof\",120),infix(\"+\",function(left,that){var right;return that.left=left,that.right=right=expression(130),left&&right&&\"(string)\"===left.id&&\"(string)\"===right.id?(left.value+=right.value,left.character=right.character,!state.option.scripturl&®.javascriptURL.test(left.value)&&warning(\"W050\",left),left):that},130),prefix(\"+\",\"num\"),prefix(\"+++\",function(){return warning(\"W007\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"+++\",function(left){return warning(\"W007\"),this.left=left,this.right=expression(130),this},130),infix(\"-\",\"sub\",130),prefix(\"-\",\"neg\"),prefix(\"---\",function(){return warning(\"W006\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"---\",function(left){return warning(\"W006\"),this.left=left,this.right=expression(130),this},130),infix(\"*\",\"mult\",140),infix(\"/\",\"div\",140),infix(\"%\",\"mod\",140),suffix(\"++\"),prefix(\"++\",\"preinc\"),state.syntax[\"++\"].exps=!0,suffix(\"--\"),prefix(\"--\",\"predec\"),state.syntax[\"--\"].exps=!0,prefix(\"delete\",function(){var p=expression(10);return p?(\".\"!==p.id&&\"[\"!==p.id&&warning(\"W051\"),this.first=p,p.identifier&&!state.isStrict()&&(p.forgiveUndef=!0),this):this}).exps=!0,prefix(\"~\",function(){return state.option.bitwise&&warning(\"W016\",this,\"~\"),this.arity=\"unary\",this.right=expression(150),this}),prefix(\"...\",function(){return state.inES6(!0)||warning(\"W119\",this,\"spread/rest operator\",\"6\"),state.tokens.next.identifier||\"(string)\"===state.tokens.next.type||checkPunctuators(state.tokens.next,[\"[\",\"(\"])||error(\"E030\",state.tokens.next,state.tokens.next.value),expression(150),this}),prefix(\"!\",function(){return this.arity=\"unary\",this.right=expression(150),this.right||quit(\"E041\",this.line||0),bang[this.right.id]===!0&&warning(\"W018\",this,\"!\"),this}),prefix(\"typeof\",function(){var p=expression(150);return this.first=this.right=p,p||quit(\"E041\",this.line||0,this.character||0),p.identifier&&(p.forgiveUndef=!0),this}),prefix(\"new\",function(){var mp=metaProperty(\"target\",function(){state.inES6(!0)||warning(\"W119\",state.tokens.prev,\"new.target\",\"6\");for(var inFunction,c=state.funct;c&&(inFunction=!c[\"(global)\"],c[\"(arrow)\"]);)c=c[\"(context)\"];inFunction||warning(\"W136\",state.tokens.prev,\"new.target\")});if(mp)return mp;var i,c=expression(155);if(c&&\"function\"!==c.id)if(c.identifier)switch(c[\"new\"]=!0,c.value){case\"Number\":case\"String\":case\"Boolean\":case\"Math\":case\"JSON\":warning(\"W053\",state.tokens.prev,c.value);break;case\"Symbol\":state.inES6()&&warning(\"W053\",state.tokens.prev,c.value);break;case\"Function\":state.option.evil||warning(\"W054\");break;case\"Date\":case\"RegExp\":case\"this\":break;default:\"function\"!==c.id&&(i=c.value.substr(0,1),state.option.newcap&&(\"A\">i||i>\"Z\")&&!state.funct[\"(scope)\"].isPredefined(c.value)&&warning(\"W055\",state.tokens.curr))}else\".\"!==c.id&&\"[\"!==c.id&&\"(\"!==c.id&&warning(\"W056\",state.tokens.curr);else state.option.supernew||warning(\"W057\",this);return\"(\"===state.tokens.next.id||state.option.supernew||warning(\"W058\",state.tokens.curr,state.tokens.curr.value),this.first=this.right=c,this}),state.syntax[\"new\"].exps=!0,prefix(\"void\").exps=!0,infix(\".\",function(left,that){var m=identifier(!1,!0);return\"string\"==typeof m&&countMember(m),that.left=left,that.right=m,m&&\"hasOwnProperty\"===m&&\"=\"===state.tokens.next.value&&warning(\"W001\"),!left||\"arguments\"!==left.value||\"callee\"!==m&&\"caller\"!==m?state.option.evil||!left||\"document\"!==left.value||\"write\"!==m&&\"writeln\"!==m||warning(\"W060\",left):state.option.noarg?warning(\"W059\",left,m):state.isStrict()&&error(\"E008\"),state.option.evil||\"eval\"!==m&&\"execScript\"!==m||isGlobalEval(left,state)&&warning(\"W061\"),that},160,!0),infix(\"(\",function(left,that){state.option.immed&&left&&!left.immed&&\"function\"===left.id&&warning(\"W062\");var n=0,p=[];if(left&&\"(identifier)\"===left.type&&left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1===\"Array Number String Boolean Date Object Error Symbol\".indexOf(left.value)&&(\"Math\"===left.value?warning(\"W063\",left):state.option.newcap&&warning(\"W064\",left)),\")\"!==state.tokens.next.id)for(;p[p.length]=expression(10),n+=1,\",\"===state.tokens.next.id;)comma();return advance(\")\"),\"object\"==typeof left&&(state.inES5()||\"parseInt\"!==left.value||1!==n||warning(\"W065\",state.tokens.curr),state.option.evil||(\"eval\"===left.value||\"Function\"===left.value||\"execScript\"===left.value?(warning(\"W061\",left),p[0]&&\"(string)\"===[0].id&&addInternalSrc(left,p[0].value)):!p[0]||\"(string)\"!==p[0].id||\"setTimeout\"!==left.value&&\"setInterval\"!==left.value?!p[0]||\"(string)\"!==p[0].id||\".\"!==left.value||\"window\"!==left.left.value||\"setTimeout\"!==left.right&&\"setInterval\"!==left.right||(warning(\"W066\",left),addInternalSrc(left,p[0].value)):(warning(\"W066\",left),addInternalSrc(left,p[0].value))),left.identifier||\".\"===left.id||\"[\"===left.id||\"=>\"===left.id||\"(\"===left.id||\"&&\"===left.id||\"||\"===left.id||\"?\"===left.id||state.inES6()&&left[\"(name)\"]||warning(\"W067\",that)),that.left=left,that},155,!0).exps=!0,prefix(\"(\",function(){var pn1,ret,triggerFnExpr,first,last,pn=state.tokens.next,i=-1,parens=1,opening=state.tokens.curr,preceeding=state.tokens.prev,isNecessary=!state.option.singleGroups;do\"(\"===pn.value?parens+=1:\")\"===pn.value&&(parens-=1),i+=1,pn1=pn,pn=peek(i);while((0!==parens||\")\"!==pn1.value)&&\";\"!==pn.value&&\"(end)\"!==pn.type);if(\"function\"===state.tokens.next.id&&(triggerFnExpr=state.tokens.next.immed=!0),\"=>\"===pn.value)return doFunction({type:\"arrow\",parsedOpening:!0});var exprs=[];if(\")\"!==state.tokens.next.id)for(;exprs.push(expression(10)),\",\"===state.tokens.next.id;)state.option.nocomma&&warning(\"W127\"),comma();return advance(\")\",this),state.option.immed&&exprs[0]&&\"function\"===exprs[0].id&&\"(\"!==state.tokens.next.id&&\".\"!==state.tokens.next.id&&\"[\"!==state.tokens.next.id&&warning(\"W068\",this),exprs.length?(exprs.length>1?(ret=Object.create(state.syntax[\",\"]),ret.exprs=exprs,first=exprs[0],last=exprs[exprs.length-1],isNecessary||(isNecessary=preceeding.assign||preceeding.delim)):(ret=first=last=exprs[0],isNecessary||(isNecessary=opening.beginsStmt&&(\"{\"===ret.id||triggerFnExpr||isFunctor(ret))||triggerFnExpr&&(!isEndOfExpr()||\"}\"!==state.tokens.prev.id)||isFunctor(ret)&&!isEndOfExpr()||\"{\"===ret.id&&\"=>\"===preceeding.id||\"(number)\"===ret.type&&checkPunctuator(pn,\".\")&&/^\\d+$/.test(ret.value))),ret&&(!isNecessary&&(first.left||first.right||ret.exprs)&&(isNecessary=!isBeginOfExpr(preceeding)&&first.lbp<=preceeding.lbp||!isEndOfExpr()&&last.lbp\"),infix(\"[\",function(left,that){var s,e=expression(10);return e&&\"(string)\"===e.type&&(state.option.evil||\"eval\"!==e.value&&\"execScript\"!==e.value||isGlobalEval(left,state)&&warning(\"W061\"),countMember(e.value),!state.option.sub&®.identifier.test(e.value)&&(s=state.syntax[e.value],s&&isReserved(s)||warning(\"W069\",state.tokens.prev,e.value))),advance(\"]\",that),e&&\"hasOwnProperty\"===e.value&&\"=\"===state.tokens.next.value&&warning(\"W001\"),that.left=left,that.right=e,that},160,!0),prefix(\"[\",function(){var blocktype=lookupBlockType();if(blocktype.isCompArray)return state.option.esnext||state.inMoz()||warning(\"W118\",state.tokens.curr,\"array comprehension\"),comprehensiveArrayExpression();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;var b=state.tokens.curr.line!==startLine(state.tokens.next);for(this.first=[],b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));\"(end)\"!==state.tokens.next.id;){for(;\",\"===state.tokens.next.id;){if(!state.option.elision){if(state.inES5()){warning(\"W128\");do advance(\",\");while(\",\"===state.tokens.next.id);continue}warning(\"W070\")}advance(\",\")}if(\"]\"===state.tokens.next.id)break;if(this.first.push(expression(10)),\",\"!==state.tokens.next.id)break;if(comma({allowTrailing:!0}),\"]\"===state.tokens.next.id&&!state.inES5()){warning(\"W070\",state.tokens.curr);break}}return b&&(indent-=state.option.indent),advance(\"]\",this),this}),function(x){x.nud=function(){var b,f,i,p,t,nextVal,isGeneratorMethod=!1,props=Object.create(null);b=state.tokens.curr.line!==startLine(state.tokens.next),b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));var blocktype=lookupBlockType();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;for(;\"}\"!==state.tokens.next.id;){if(nextVal=state.tokens.next.value,!state.tokens.next.identifier||\",\"!==peekIgnoreEOL().id&&\"}\"!==peekIgnoreEOL().id)if(\":\"===peek().id||\"get\"!==nextVal&&\"set\"!==nextVal){if(\"*\"===state.tokens.next.value&&\"(punctuator)\"===state.tokens.next.type?(state.inES6()||warning(\"W104\",state.tokens.next,\"generator functions\",\"6\"),advance(\"*\"),isGeneratorMethod=!0):isGeneratorMethod=!1,\"[\"===state.tokens.next.id)i=computedPropertyName(),state.nameStack.set(i);else if(state.nameStack.set(state.tokens.next),i=propertyName(),saveProperty(props,i,state.tokens.next),\"string\"!=typeof i)break;\"(\"===state.tokens.next.value?(state.inES6()||warning(\"W104\",state.tokens.curr,\"concise methods\",\"6\"),doFunction({type:isGeneratorMethod?\"generator\":null})):(advance(\":\"),expression(10))}else advance(nextVal),state.inES5()||error(\"E034\"),i=propertyName(),i||state.inES6()||error(\"E035\"),i&&saveAccessor(nextVal,props,i,state.tokens.curr),t=state.tokens.next,f=doFunction(),p=f[\"(params)\"],\"get\"===nextVal&&i&&p?warning(\"W076\",t,p[0],i):\"set\"!==nextVal||!i||p&&1===p.length||warning(\"W077\",t,i);else state.inES6()||warning(\"W104\",state.tokens.next,\"object short notation\",\"6\"),i=propertyName(!0),saveProperty(props,i,state.tokens.next),expression(10);if(countMember(i),\",\"!==state.tokens.next.id)break;comma({allowTrailing:!0,property:!0}),\",\"===state.tokens.next.id?warning(\"W070\",state.tokens.curr):\"}\"!==state.tokens.next.id||state.inES5()||warning(\"W070\",state.tokens.curr)}return b&&(indent-=state.option.indent),advance(\"}\",this),checkProperties(props),this},x.fud=function(){error(\"E036\",state.tokens.curr)}}(delim(\"{\"));var conststatement=stmt(\"const\",function(context){return blockVariableStatement(\"const\",this,context)});conststatement.exps=!0;var letstatement=stmt(\"let\",function(context){return blockVariableStatement(\"let\",this,context)});letstatement.exps=!0;var varstatement=stmt(\"var\",function(context){var tokens,lone,value,prefix=context&&context.prefix,inexport=context&&context.inexport,implied=context&&context.implied,report=!(context&&context.ignore);for(this.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),prefix&&implied||!report||!state.option.varstmt||warning(\"W132\",this),this.first=this.first.concat(names);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],!implied&&state.funct[\"(global)\"]&&(predefined[t.id]===!1?warning(\"W079\",t.token,t.id):state.option.futurehostile===!1&&(!state.inES5()&&vars.ecmaIdentifiers[5][t.id]===!1||!state.inES6()&&vars.ecmaIdentifiers[6][t.id]===!1)&&warning(\"W129\",t.token,t.id)),t.id&&(\"for\"===implied?(state.funct[\"(scope)\"].has(t.id)||report&&warning(\"W088\",t.token,t.id),state.funct[\"(scope)\"].block.use(t.id,t.token)):(state.funct[\"(scope)\"].addlabel(t.id,{type:\"var\",token:t.token}),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.id,t.token)),names.push(t.token)));if(\"=\"===state.tokens.next.id&&(state.nameStack.set(state.tokens.curr),advance(\"=\"),prefix||!report||state.funct[\"(loopage)\"]||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),\"=\"===peek(0).id&&state.tokens.next.identifier&&(!prefix&&report&&!state.funct[\"(params)\"]||-1===state.funct[\"(params)\"].indexOf(state.tokens.next.value))&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),\",\"!==state.tokens.next.id)break;comma()}return this});varstatement.exps=!0,blockstmt(\"class\",function(){return classdef.call(this,!0)}),blockstmt(\"function\",function(context){var inexport=context&&context.inexport,generator=!1;\"*\"===state.tokens.next.value&&(advance(\"*\"),state.inES6({strict:!0})?generator=!0:warning(\"W119\",state.tokens.curr,\"function*\",\"6\")),inblock&&warning(\"W082\",state.tokens.curr);var i=optionalidentifier();return state.funct[\"(scope)\"].addlabel(i,{type:\"function\",token:state.tokens.curr}),void 0===i?warning(\"W025\"):inexport&&state.funct[\"(scope)\"].setExported(i,state.tokens.prev),doFunction({name:i,statement:this,type:generator?\"generator\":null,ignoreLoopFunc:inblock}),\"(\"===state.tokens.next.id&&state.tokens.next.line===state.tokens.curr.line&&error(\"E039\"),this}),prefix(\"function\",function(){var generator=!1;\"*\"===state.tokens.next.value&&(state.inES6()||warning(\"W119\",state.tokens.curr,\"function*\",\"6\"),advance(\"*\"),generator=!0);var i=optionalidentifier();return doFunction({name:i,type:generator?\"generator\":null}),this}),blockstmt(\"if\",function(){var t=state.tokens.next;increaseComplexityCount(),state.condition=!0,advance(\"(\");var expr=expression(0);checkCondAssignment(expr);var forinifcheck=null;state.option.forin&&state.forinifcheckneeded&&(state.forinifcheckneeded=!1,forinifcheck=state.forinifchecks[state.forinifchecks.length-1],forinifcheck.type=\"(punctuator)\"===expr.type&&\"!\"===expr.value?\"(negative)\":\"(positive)\"),advance(\")\",t),state.condition=!1;var s=block(!0,!0);return forinifcheck&&\"(negative)\"===forinifcheck.type&&s&&s[0]&&\"(identifier)\"===s[0].type&&\"continue\"===s[0].value&&(forinifcheck.type=\"(negative-with-continue)\"),\"else\"===state.tokens.next.id&&(advance(\"else\"),\"if\"===state.tokens.next.id||\"switch\"===state.tokens.next.id?statement():block(!0,!0)),this}),blockstmt(\"try\",function(){function doCatch(){if(advance(\"catch\"),advance(\"(\"),state.funct[\"(scope)\"].stack(\"catchparams\"),checkPunctuators(state.tokens.next,[\"[\",\"{\"])){var tokens=destructuringPattern();_.each(tokens,function(token){token.id&&state.funct[\"(scope)\"].addParam(token.id,token,\"exception\")})}else\"(identifier)\"!==state.tokens.next.type?warning(\"E030\",state.tokens.next,state.tokens.next.value):state.funct[\"(scope)\"].addParam(identifier(),state.tokens.curr,\"exception\");\"if\"===state.tokens.next.value&&(state.inMoz()||warning(\"W118\",state.tokens.curr,\"catch filter\"),advance(\"if\"),expression(0)),advance(\")\"),block(!1),state.funct[\"(scope)\"].unstack()}var b;for(block(!0);\"catch\"===state.tokens.next.id;)increaseComplexityCount(),b&&!state.inMoz()&&warning(\"W118\",state.tokens.next,\"multiple catch blocks\"),doCatch(),b=!0;return\"finally\"===state.tokens.next.id?(advance(\"finally\"),block(!0),void 0):(b||error(\"E021\",state.tokens.next,\"catch\",state.tokens.next.value),this)}),blockstmt(\"while\",function(){var t=state.tokens.next;return state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this}).labelled=!0,blockstmt(\"with\",function(){var t=state.tokens.next;return state.isStrict()?error(\"E010\",state.tokens.curr):state.option.withstmt||warning(\"W085\",state.tokens.curr),advance(\"(\"),expression(0),advance(\")\",t),block(!0,!0),this}),blockstmt(\"switch\",function(){var t=state.tokens.next,g=!1,noindent=!1;\nfor(state.funct[\"(breakage)\"]+=1,advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),t=state.tokens.next,advance(\"{\"),state.tokens.next.from===indent&&(noindent=!0),noindent||(indent+=state.option.indent),this.cases=[];;)switch(state.tokens.next.id){case\"case\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"case\":case\"continue\":case\"return\":case\"switch\":case\"throw\":break;default:state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"case\")}advance(\"case\"),this.cases.push(expression(0)),increaseComplexityCount(),g=!0,advance(\":\"),state.funct[\"(verb)\"]=\"case\";break;case\"default\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"continue\":case\"return\":case\"throw\":break;default:this.cases.length&&(state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"default\"))}advance(\"default\"),g=!0,advance(\":\");break;case\"}\":return noindent||(indent-=state.option.indent),advance(\"}\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(verb)\"]=void 0,void 0;case\"(end)\":return error(\"E023\",state.tokens.next,\"}\"),void 0;default:if(indent+=state.option.indent,g)switch(state.tokens.curr.id){case\",\":return error(\"E040\"),void 0;case\":\":g=!1,statements();break;default:return error(\"E025\",state.tokens.curr),void 0}else{if(\":\"!==state.tokens.curr.id)return error(\"E021\",state.tokens.next,\"case\",state.tokens.next.value),void 0;advance(\":\"),error(\"E024\",state.tokens.curr,\":\"),statements()}indent-=state.option.indent}return this}).labelled=!0,stmt(\"debugger\",function(){return state.option.debug||warning(\"W087\",this),this}).exps=!0,function(){var x=stmt(\"do\",function(){state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),this.first=block(!0,!0),advance(\"while\");var t=state.tokens.next;return advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this});x.labelled=!0,x.exps=!0}(),blockstmt(\"for\",function(){var s,t=state.tokens.next,letscope=!1,foreachtok=null;\"each\"===t.value&&(foreachtok=t,advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),increaseComplexityCount(),advance(\"(\");var nextop,comma,initializer,i=0,inof=[\"in\",\"of\"],level=0;checkPunctuators(state.tokens.next,[\"{\",\"[\"])&&++level;do{if(nextop=peek(i),++i,checkPunctuators(nextop,[\"{\",\"[\"])?++level:checkPunctuators(nextop,[\"}\",\"]\"])&&--level,0>level)break;0===level&&(!comma&&checkPunctuator(nextop,\",\")?comma=nextop:!initializer&&checkPunctuator(nextop,\"=\")&&(initializer=nextop))}while(level>0||!_.contains(inof,nextop.value)&&\";\"!==nextop.value&&\"(end)\"!==nextop.type);if(_.contains(inof,nextop.value)){state.inES6()||\"of\"!==nextop.value||warning(\"W104\",nextop,\"for of\",\"6\");var ok=!(initializer||comma);if(initializer&&error(\"W133\",comma,nextop.value,\"initializer is forbidden\"),comma&&error(\"W133\",comma,nextop.value,\"more than one ForBinding\"),\"var\"===state.tokens.next.id?(advance(\"var\"),state.tokens.curr.fud({prefix:!0})):\"let\"===state.tokens.next.id||\"const\"===state.tokens.next.id?(advance(state.tokens.next.id),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud({prefix:!0})):Object.create(varstatement).fud({prefix:!0,implied:\"for\",ignore:!ok}),advance(nextop.value),expression(20),advance(\")\",t),\"in\"===nextop.value&&state.option.forin&&(state.forinifcheckneeded=!0,void 0===state.forinifchecks&&(state.forinifchecks=[]),state.forinifchecks.push({type:\"(none)\"})),state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,s=block(!0,!0),\"in\"===nextop.value&&state.option.forin){if(state.forinifchecks&&state.forinifchecks.length>0){var check=state.forinifchecks.pop();(s&&s.length>0&&(\"object\"!=typeof s[0]||\"if\"!==s[0].value)||\"(positive)\"===check.type&&s.length>1||\"(negative)\"===check.type)&&warning(\"W089\",this)}state.forinifcheckneeded=!1}state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}else{if(foreachtok&&error(\"E045\",foreachtok),\";\"!==state.tokens.next.id)if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud();else if(\"let\"===state.tokens.next.id)advance(\"let\"),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud();else for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();if(nolinebreak(state.tokens.curr),advance(\";\"),state.funct[\"(loopage)\"]+=1,\";\"!==state.tokens.next.id&&checkCondAssignment(expression(0)),nolinebreak(state.tokens.curr),advance(\";\"),\";\"===state.tokens.next.id&&error(\"E021\",state.tokens.next,\")\",\";\"),\")\"!==state.tokens.next.id)for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();advance(\")\",t),state.funct[\"(breakage)\"]+=1,block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}return letscope&&state.funct[\"(scope)\"].unstack(),this}).labelled=!0,stmt(\"break\",function(){var v=state.tokens.next.value;return state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line!==startLine(state.tokens.next)?0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value):(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"continue\",function(){var v=state.tokens.next.value;return 0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value),state.funct[\"(loopage)\"]||warning(\"W052\",state.tokens.next,this.value),state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line===startLine(state.tokens.next)&&(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"return\",function(){return this.line===startLine(state.tokens.next)?\";\"===state.tokens.next.id||state.tokens.next.reach||(this.first=expression(0),!this.first||\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)):\"(punctuator)\"===state.tokens.next.type&&[\"[\",\"{\",\"+\",\"-\"].indexOf(state.tokens.next.value)>-1&&nolinebreak(this),reachable(this),this}).exps=!0,function(x){x.exps=!0,x.lbp=25}(prefix(\"yield\",function(){var prev=state.tokens.prev;state.inES6(!0)&&!state.funct[\"(generator)\"]?\"(catch)\"===state.funct[\"(name)\"]&&state.funct[\"(context)\"][\"(generator)\"]||error(\"E046\",state.tokens.curr,\"yield\"):state.inES6()||warning(\"W104\",state.tokens.curr,\"yield\",\"6\"),state.funct[\"(generator)\"]=\"yielded\";var delegatingYield=!1;return\"*\"===state.tokens.next.value&&(delegatingYield=!0,advance(\"*\")),this.line!==startLine(state.tokens.next)&&state.inMoz()?state.option.asi||nolinebreak(this):((delegatingYield||\";\"!==state.tokens.next.id&&!state.option.asi&&!state.tokens.next.reach&&state.tokens.next.nud)&&(nobreaknonadjacent(state.tokens.curr,state.tokens.next),this.first=expression(10),\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)),state.inMoz()&&\")\"!==state.tokens.next.id&&(prev.lbp>30||!prev.assign&&!isEndOfExpr()||\"yield\"===prev.id)&&error(\"E050\",this)),this})),stmt(\"throw\",function(){return nolinebreak(this),this.first=expression(20),reachable(this),this}).exps=!0,stmt(\"import\",function(){if(state.inES6()||warning(\"W119\",state.tokens.curr,\"import\",\"6\"),\"(string)\"===state.tokens.next.type)return advance(\"(string)\"),this;if(state.tokens.next.identifier){if(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value)return advance(\"from\"),advance(\"(string)\"),this;advance(\",\")}if(\"*\"===state.tokens.next.id)advance(\"*\"),advance(\"as\"),state.tokens.next.identifier&&(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}));else for(advance(\"{\");;){if(\"}\"===state.tokens.next.value){advance(\"}\");break}var importName;if(\"default\"===state.tokens.next.type?(importName=\"default\",advance(\"default\")):importName=identifier(),\"as\"===state.tokens.next.value&&(advance(\"as\"),importName=identifier()),state.funct[\"(scope)\"].addlabel(importName,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return advance(\"from\"),advance(\"(string)\"),this}).exps=!0,stmt(\"export\",function(){var token,identifier,ok=!0;if(state.inES6()||(warning(\"W119\",state.tokens.curr,\"export\",\"6\"),ok=!1),state.funct[\"(scope)\"].block.isGlobal()||(error(\"E053\",state.tokens.curr),ok=!1),\"*\"===state.tokens.next.value)return advance(\"*\"),advance(\"from\"),advance(\"(string)\"),this;if(\"default\"===state.tokens.next.type){state.nameStack.set(state.tokens.next),advance(\"default\");var exportType=state.tokens.next.id;return(\"function\"===exportType||\"class\"===exportType)&&(this.block=!0),token=peek(),expression(10),identifier=token.value,this.block&&(state.funct[\"(scope)\"].addlabel(identifier,{type:exportType,token:token}),state.funct[\"(scope)\"].setExported(identifier,token)),this}if(\"{\"===state.tokens.next.value){advance(\"{\");for(var exportedTokens=[];;){if(state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance(),exportedTokens.push(state.tokens.curr),\"as\"===state.tokens.next.value&&(advance(\"as\"),state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance()),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return\"from\"===state.tokens.next.value?(advance(\"from\"),advance(\"(string)\")):ok&&exportedTokens.forEach(function(token){state.funct[\"(scope)\"].setExported(token.value,token)}),this}if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud({inexport:!0});else if(\"let\"===state.tokens.next.id)advance(\"let\"),state.tokens.curr.fud({inexport:!0});else if(\"const\"===state.tokens.next.id)advance(\"const\"),state.tokens.curr.fud({inexport:!0});else if(\"function\"===state.tokens.next.id)this.block=!0,advance(\"function\"),state.syntax[\"function\"].fud({inexport:!0});else if(\"class\"===state.tokens.next.id){this.block=!0,advance(\"class\");var classNameToken=state.tokens.next;state.syntax[\"class\"].fud(),state.funct[\"(scope)\"].setExported(classNameToken.value,classNameToken)}else error(\"E024\",state.tokens.next,state.tokens.next.value);return this}).exps=!0,FutureReservedWord(\"abstract\"),FutureReservedWord(\"boolean\"),FutureReservedWord(\"byte\"),FutureReservedWord(\"char\"),FutureReservedWord(\"class\",{es5:!0,nud:classdef}),FutureReservedWord(\"double\"),FutureReservedWord(\"enum\",{es5:!0}),FutureReservedWord(\"export\",{es5:!0}),FutureReservedWord(\"extends\",{es5:!0}),FutureReservedWord(\"final\"),FutureReservedWord(\"float\"),FutureReservedWord(\"goto\"),FutureReservedWord(\"implements\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"import\",{es5:!0}),FutureReservedWord(\"int\"),FutureReservedWord(\"interface\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"long\"),FutureReservedWord(\"native\"),FutureReservedWord(\"package\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"private\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"protected\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"public\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"short\"),FutureReservedWord(\"static\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"super\",{es5:!0}),FutureReservedWord(\"synchronized\"),FutureReservedWord(\"transient\"),FutureReservedWord(\"volatile\");var lookupBlockType=function(){var pn,pn1,prev,i=-1,bracketStack=0,ret={};checkPunctuators(state.tokens.curr,[\"[\",\"{\"])&&(bracketStack+=1);do{if(prev=-1===i?state.tokens.curr:pn,pn=-1===i?state.tokens.next:peek(i),pn1=peek(i+1),i+=1,checkPunctuators(pn,[\"[\",\"{\"])?bracketStack+=1:checkPunctuators(pn,[\"]\",\"}\"])&&(bracketStack-=1),1===bracketStack&&pn.identifier&&\"for\"===pn.value&&!checkPunctuator(prev,\".\")){ret.isCompArray=!0,ret.notJson=!0;break}if(0===bracketStack&&checkPunctuators(pn,[\"}\",\"]\"])){if(\"=\"===pn1.value){ret.isDestAssign=!0,ret.notJson=!0;break}if(\".\"===pn1.value){ret.notJson=!0;break}}checkPunctuator(pn,\";\")&&(ret.isBlock=!0,ret.notJson=!0)}while(bracketStack>0&&\"(end)\"!==pn.id);return ret},arrayComprehension=function(){function declare(v){var l=_current.variables.filter(function(elt){return elt.value===v?(elt.undef=!1,v):void 0}).length;return 0!==l}function use(v){var l=_current.variables.filter(function(elt){return elt.value!==v||elt.undef?void 0:(elt.unused===!0&&(elt.unused=!1),v)}).length;return 0===l}var _current,CompArray=function(){this.mode=\"use\",this.variables=[]},_carrays=[];return{stack:function(){_current=new CompArray,_carrays.push(_current)},unstack:function(){_current.variables.filter(function(v){v.unused&&warning(\"W098\",v.token,v.raw_text||v.value),v.undef&&state.funct[\"(scope)\"].block.use(v.value,v.token)}),_carrays.splice(-1,1),_current=_carrays[_carrays.length-1]},setState:function(s){_.contains([\"use\",\"define\",\"generate\",\"filter\"],s)&&(_current.mode=s)},check:function(v){return _current?_current&&\"use\"===_current.mode?(use(v)&&_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!0,unused:!1}),!0):_current&&\"define\"===_current.mode?(declare(v)||_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!1,unused:!0}),!0):_current&&\"generate\"===_current.mode?(state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):_current&&\"filter\"===_current.mode?(use(v)&&state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):!1:void 0}}},escapeRegex=function(str){return str.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")},itself=function(s,o,g){function each(obj,cb){obj&&(Array.isArray(obj)||\"object\"!=typeof obj||(obj=Object.keys(obj)),obj.forEach(cb))}var i,k,x,reIgnoreStr,reIgnore,optionKeys,newOptionObj={},newIgnoredObj={};o=_.clone(o),state.reset(),o&&o.scope?JSHINT.scope=o.scope:(JSHINT.errors=[],JSHINT.undefs=[],JSHINT.internals=[],JSHINT.blacklist={},JSHINT.scope=\"(main)\"),predefined=Object.create(null),combine(predefined,vars.ecmaIdentifiers[3]),combine(predefined,vars.reservedVars),combine(predefined,g||{}),declared=Object.create(null);var exported=Object.create(null);if(o)for(each(o.predef||null,function(item){var slice,prop;\"-\"===item[0]?(slice=item.slice(1),JSHINT.blacklist[slice]=slice,delete predefined[slice]):(prop=Object.getOwnPropertyDescriptor(o.predef,item),predefined[item]=prop?prop.value:!1)}),each(o.exported||null,function(item){exported[item]=!0}),delete o.predef,delete o.exported,optionKeys=Object.keys(o),x=0;optionKeys.length>x;x++)if(/^-W\\d{3}$/g.test(optionKeys[x]))newIgnoredObj[optionKeys[x].slice(1)]=!0;else{var optionKey=optionKeys[x];newOptionObj[optionKey]=o[optionKey],(\"esversion\"===optionKey&&5===o[optionKey]||\"es5\"===optionKey&&o[optionKey])&&warning(\"I003\"),\"newcap\"===optionKeys[x]&&o[optionKey]===!1&&(newOptionObj[\"(explicitNewcap)\"]=!0)}state.option=newOptionObj,state.ignored=newIgnoredObj,state.option.indent=state.option.indent||4,state.option.maxerr=state.option.maxerr||50,indent=1;var scopeManagerInst=scopeManager(state,predefined,exported,declared);if(scopeManagerInst.on(\"warning\",function(ev){warning.apply(null,[ev.code,ev.token].concat(ev.data))}),scopeManagerInst.on(\"error\",function(ev){error.apply(null,[ev.code,ev.token].concat(ev.data))}),state.funct=functor(\"(global)\",null,{\"(global)\":!0,\"(scope)\":scopeManagerInst,\"(comparray)\":arrayComprehension(),\"(metrics)\":createMetrics(state.tokens.next)}),functions=[state.funct],urls=[],stack=null,member={},membersOnly=null,inblock=!1,lookahead=[],!isString(s)&&!Array.isArray(s))return errorAt(\"E004\",0),!1;api={get isJSON(){return state.jsonMode},getOption:function(name){return state.option[name]||null},getCache:function(name){return state.cache[name]},setCache:function(name,value){state.cache[name]=value},warn:function(code,data){warningAt.apply(null,[code,data.line,data.char].concat(data.data))},on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)}.bind(this))}},emitter.removeAllListeners(),(extraModules||[]).forEach(function(func){func(api)}),state.tokens.prev=state.tokens.curr=state.tokens.next=state.syntax[\"(begin)\"],o&&o.ignoreDelimiters&&(Array.isArray(o.ignoreDelimiters)||(o.ignoreDelimiters=[o.ignoreDelimiters]),o.ignoreDelimiters.forEach(function(delimiterPair){delimiterPair.start&&delimiterPair.end&&(reIgnoreStr=escapeRegex(delimiterPair.start)+\"[\\\\s\\\\S]*?\"+escapeRegex(delimiterPair.end),reIgnore=RegExp(reIgnoreStr,\"ig\"),s=s.replace(reIgnore,function(match){return match.replace(/./g,\" \")}))})),lex=new Lexer(s),lex.on(\"warning\",function(ev){warningAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"error\",function(ev){errorAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"fatal\",function(ev){quit(\"E041\",ev.line,ev.from)}),lex.on(\"Identifier\",function(ev){emitter.emit(\"Identifier\",ev)}),lex.on(\"String\",function(ev){emitter.emit(\"String\",ev)}),lex.on(\"Number\",function(ev){emitter.emit(\"Number\",ev)}),lex.start();for(var name in o)_.has(o,name)&&checkOption(name,state.tokens.curr);assume(),combine(predefined,g||{}),comma.first=!0;try{switch(advance(),state.tokens.next.id){case\"{\":case\"[\":destructuringAssignOrJsonValue();break;default:directives(),state.directive[\"use strict\"]&&\"global\"!==state.option.strict&&warning(\"W097\",state.tokens.prev),statements()}\"(end)\"!==state.tokens.next.id&&quit(\"E041\",state.tokens.curr.line),state.funct[\"(scope)\"].unstack()}catch(err){if(!err||\"JSHintError\"!==err.name)throw err;var nt=state.tokens.next||{};JSHINT.errors.push({scope:\"(main)\",raw:err.raw,code:err.code,reason:err.message,line:err.line||nt.line,character:err.character||nt.from},null)}if(\"(main)\"===JSHINT.scope)for(o=o||{},i=0;JSHINT.internals.length>i;i+=1)k=JSHINT.internals[i],o.scope=k.elem,itself(k.value,o,g);return 0===JSHINT.errors.length};return itself.addModule=function(func){extraModules.push(func)},itself.addModule(style.register),itself.data=function(){var fu,f,i,j,n,globals,data={functions:[],options:state.option};itself.errors.length&&(data.errors=itself.errors),state.jsonMode&&(data.json=!0);var impliedGlobals=state.funct[\"(scope)\"].getImpliedGlobals();for(impliedGlobals.length>0&&(data.implieds=impliedGlobals),urls.length>0&&(data.urls=urls),globals=state.funct[\"(scope)\"].getUsedOrDefinedGlobals(),globals.length>0&&(data.globals=globals),i=1;functions.length>i;i+=1){for(f=functions[i],fu={},j=0;functionicity.length>j;j+=1)fu[functionicity[j]]=[];for(j=0;functionicity.length>j;j+=1)0===fu[functionicity[j]].length&&delete fu[functionicity[j]];fu.name=f[\"(name)\"],fu.param=f[\"(params)\"],fu.line=f[\"(line)\"],fu.character=f[\"(character)\"],fu.last=f[\"(last)\"],fu.lastcharacter=f[\"(lastcharacter)\"],fu.metrics={complexity:f[\"(metrics)\"].ComplexityCount,parameters:f[\"(metrics)\"].arity,statements:f[\"(metrics)\"].statementCount},data.functions.push(fu)}var unuseds=state.funct[\"(scope)\"].getUnuseds();unuseds.length>0&&(data.unused=unuseds);for(n in member)if(\"number\"==typeof member[n]){data.member=member;break}return data},itself.jshint=itself,itself}();\"object\"==typeof exports&&exports&&(exports.JSHINT=JSHINT)},{\"../lodash\":\"/node_modules/jshint/lodash.js\",\"./lex.js\":\"/node_modules/jshint/src/lex.js\",\"./messages.js\":\"/node_modules/jshint/src/messages.js\",\"./options.js\":\"/node_modules/jshint/src/options.js\",\"./reg.js\":\"/node_modules/jshint/src/reg.js\",\"./scope-manager.js\":\"/node_modules/jshint/src/scope-manager.js\",\"./state.js\":\"/node_modules/jshint/src/state.js\",\"./style.js\":\"/node_modules/jshint/src/style.js\",\"./vars.js\":\"/node_modules/jshint/src/vars.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/lex.js\":[function(_dereq_,module,exports){\"use strict\";function asyncTrigger(){var _checks=[];return{push:function(fn){_checks.push(fn)},check:function(){for(var check=0;_checks.length>check;++check)_checks[check]();_checks.splice(0,_checks.length)}}}function Lexer(source){var lines=source;\"string\"==typeof lines&&(lines=lines.replace(/\\r\\n/g,\"\\n\").replace(/\\r/g,\"\\n\").split(\"\\n\")),lines[0]&&\"#!\"===lines[0].substr(0,2)&&(-1!==lines[0].indexOf(\"node\")&&(state.option.node=!0),lines[0]=\"\"),this.emitter=new events.EventEmitter,this.source=source,this.setLines(lines),this.prereg=!0,this.line=0,this.char=1,this.from=1,this.input=\"\",this.inComment=!1,this.context=[],this.templateStarts=[];for(var i=0;state.option.indent>i;i+=1)state.tab+=\" \";this.ignoreLinterErrors=!1}var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,unicodeData=_dereq_(\"../data/ascii-identifier-data.js\"),asciiIdentifierStartTable=unicodeData.asciiIdentifierStartTable,asciiIdentifierPartTable=unicodeData.asciiIdentifierPartTable,Token={Identifier:1,Punctuator:2,NumericLiteral:3,StringLiteral:4,Comment:5,Keyword:6,NullLiteral:7,BooleanLiteral:8,RegExp:9,TemplateHead:10,TemplateMiddle:11,TemplateTail:12,NoSubstTemplate:13},Context={Block:1,Template:2};Lexer.prototype={_lines:[],inContext:function(ctxType){return this.context.length>0&&this.context[this.context.length-1].type===ctxType},pushContext:function(ctxType){this.context.push({type:ctxType})},popContext:function(){return this.context.pop()},isContext:function(context){return this.context.length>0&&this.context[this.context.length-1]===context},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=state.lines,this._lines},setLines:function(val){this._lines=val,state.lines=this._lines},peek:function(i){return this.input.charAt(i||0)},skip:function(i){i=i||1,this.char+=i,this.input=this.input.slice(i)},on:function(names,listener){names.split(\" \").forEach(function(name){this.emitter.on(name,listener)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(type,args,checks,fn){checks.push(function(){fn()&&this.trigger(type,args)}.bind(this))},scanPunctuator:function(){var ch2,ch3,ch4,ch1=this.peek();switch(ch1){case\".\":if(/^[0-9]$/.test(this.peek(1)))return null;if(\".\"===this.peek(1)&&\".\"===this.peek(2))return{type:Token.Punctuator,value:\"...\"};case\"(\":case\")\":case\";\":case\",\":case\"[\":case\"]\":case\":\":case\"~\":case\"?\":return{type:Token.Punctuator,value:ch1};case\"{\":return this.pushContext(Context.Block),{type:Token.Punctuator,value:ch1};case\"}\":return this.inContext(Context.Block)&&this.popContext(),{type:Token.Punctuator,value:ch1};case\"#\":return{type:Token.Punctuator,value:ch1};case\"\":return null}return ch2=this.peek(1),ch3=this.peek(2),ch4=this.peek(3),\">\"===ch1&&\">\"===ch2&&\">\"===ch3&&\"=\"===ch4?{type:Token.Punctuator,value:\">>>=\"}:\"=\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"===\"}:\"!\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"!==\"}:\">\"===ch1&&\">\"===ch2&&\">\"===ch3?{type:Token.Punctuator,value:\">>>\"}:\"<\"===ch1&&\"<\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"<<=\"}:\">\"===ch1&&\">\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\">>=\"}:\"=\"===ch1&&\">\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:ch1===ch2&&\"+-<>&|\".indexOf(ch1)>=0?{type:Token.Punctuator,value:ch1+ch2}:\"<>=!+-*%&|^\".indexOf(ch1)>=0?\"=\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:{type:Token.Punctuator,value:ch1}:\"/\"===ch1?\"=\"===ch2?{type:Token.Punctuator,value:\"/=\"}:{type:Token.Punctuator,value:\"/\"}:null},scanComments:function(){function commentToken(label,body,opt){var special=[\"jshint\",\"jslint\",\"members\",\"member\",\"globals\",\"global\",\"exported\"],isSpecial=!1,value=label+body,commentType=\"plain\";return opt=opt||{},opt.isMultiline&&(value+=\"*/\"),body=body.replace(/\\n/g,\" \"),\"/*\"===label&®.fallsThrough.test(body)&&(isSpecial=!0,commentType=\"falls through\"),special.forEach(function(str){if(!isSpecial&&(\"//\"!==label||\"jshint\"===str)&&(\" \"===body.charAt(str.length)&&body.substr(0,str.length)===str&&(isSpecial=!0,label+=str,body=body.substr(str.length)),isSpecial||\" \"!==body.charAt(0)||\" \"!==body.charAt(str.length+1)||body.substr(1,str.length)!==str||(isSpecial=!0,label=label+\" \"+str,body=body.substr(str.length+1)),isSpecial))switch(str){case\"member\":commentType=\"members\";break;case\"global\":commentType=\"globals\";break;default:var options=body.split(\":\").map(function(v){return v.replace(/^\\s+/,\"\").replace(/\\s+$/,\"\")});if(2===options.length)switch(options[0]){case\"ignore\":switch(options[1]){case\"start\":self.ignoringLinterErrors=!0,isSpecial=!1;break;case\"end\":self.ignoringLinterErrors=!1,isSpecial=!1}}commentType=str}}),{type:Token.Comment,commentType:commentType,value:value,body:body,isSpecial:isSpecial,isMultiline:opt.isMultiline||!1,isMalformed:opt.isMalformed||!1}}var ch1=this.peek(),ch2=this.peek(1),rest=this.input.substr(2),startLine=this.line,startChar=this.char,self=this;if(\"*\"===ch1&&\"/\"===ch2)return this.trigger(\"error\",{code:\"E018\",line:startLine,character:startChar}),this.skip(2),null;if(\"/\"!==ch1||\"*\"!==ch2&&\"/\"!==ch2)return null;if(\"/\"===ch2)return this.skip(this.input.length),commentToken(\"//\",rest);var body=\"\";if(\"*\"===ch2){for(this.inComment=!0,this.skip(2);\"*\"!==this.peek()||\"/\"!==this.peek(1);)if(\"\"===this.peek()){if(body+=\"\\n\",!this.nextLine())return this.trigger(\"error\",{code:\"E017\",line:startLine,character:startChar}),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0,isMalformed:!0})}else body+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0})}},scanKeyword:function(){var result=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),keywords=[\"if\",\"in\",\"do\",\"var\",\"for\",\"new\",\"try\",\"let\",\"this\",\"else\",\"case\",\"void\",\"with\",\"enum\",\"while\",\"break\",\"catch\",\"throw\",\"const\",\"yield\",\"class\",\"super\",\"return\",\"typeof\",\"delete\",\"switch\",\"export\",\"import\",\"default\",\"finally\",\"extends\",\"function\",\"continue\",\"debugger\",\"instanceof\"];return result&&keywords.indexOf(result[0])>=0?{type:Token.Keyword,value:result[0]}:null},scanIdentifier:function(){function isNonAsciiIdentifierStart(code){return code>256}function isNonAsciiIdentifierPart(code){return code>256}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function removeEscapeSequences(id){return id.replace(/\\\\u([0-9a-fA-F]{4})/g,function(m0,codepoint){return String.fromCharCode(parseInt(codepoint,16))})}var type,char,id=\"\",index=0,readUnicodeEscapeSequence=function(){if(index+=1,\"u\"!==this.peek(index))return null;var code,ch1=this.peek(index+1),ch2=this.peek(index+2),ch3=this.peek(index+3),ch4=this.peek(index+4);return isHexDigit(ch1)&&isHexDigit(ch2)&&isHexDigit(ch3)&&isHexDigit(ch4)?(code=parseInt(ch1+ch2+ch3+ch4,16),asciiIdentifierPartTable[code]||isNonAsciiIdentifierPart(code)?(index+=5,\"\\\\u\"+ch1+ch2+ch3+ch4):null):null}.bind(this),getIdentifierStart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierStartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierStart(code)?(index+=1,chr):null}.bind(this),getIdentifierPart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierPartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierPart(code)?(index+=1,chr):null}.bind(this);if(char=getIdentifierStart(),null===char)return null;for(id=char;char=getIdentifierPart(),null!==char;)id+=char;switch(id){case\"true\":case\"false\":type=Token.BooleanLiteral;break;case\"null\":type=Token.NullLiteral;break;default:type=Token.Identifier}return{type:type,value:removeEscapeSequences(id),text:id,tokenLength:id.length}},scanNumericLiteral:function(){function isDecimalDigit(str){return/^[0-9]$/.test(str)}function isOctalDigit(str){return/^[0-7]$/.test(str)}function isBinaryDigit(str){return/^[01]$/.test(str)}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function isIdentifierStart(ch){return\"$\"===ch||\"_\"===ch||\"\\\\\"===ch||ch>=\"a\"&&\"z\">=ch||ch>=\"A\"&&\"Z\">=ch}var bad,index=0,value=\"\",length=this.input.length,char=this.peek(index),isAllowedDigit=isDecimalDigit,base=10,isLegacy=!1;if(\".\"!==char&&!isDecimalDigit(char))return null;if(\".\"!==char){for(value=this.peek(index),index+=1,char=this.peek(index),\"0\"===value&&((\"x\"===char||\"X\"===char)&&(isAllowedDigit=isHexDigit,base=16,index+=1,value+=char),(\"o\"===char||\"O\"===char)&&(isAllowedDigit=isOctalDigit,base=8,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Octal integer literal\",\"6\"]}),index+=1,value+=char),(\"b\"===char||\"B\"===char)&&(isAllowedDigit=isBinaryDigit,base=2,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Binary integer literal\",\"6\"]}),index+=1,value+=char),isOctalDigit(char)&&(isAllowedDigit=isOctalDigit,base=8,isLegacy=!0,bad=!1,index+=1,value+=char),!isOctalDigit(char)&&isDecimalDigit(char)&&(index+=1,value+=char));length>index;){if(char=this.peek(index),isLegacy&&isDecimalDigit(char))bad=!0;else if(!isAllowedDigit(char))break;value+=char,index+=1}if(isAllowedDigit!==isDecimalDigit)return!isLegacy&&2>=value.length?{type:Token.NumericLiteral,value:value,isMalformed:!0}:length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isLegacy:isLegacy,isMalformed:!1}}if(\".\"===char)for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1;if(\"e\"===char||\"E\"===char){if(value+=char,index+=1,char=this.peek(index),(\"+\"===char||\"-\"===char)&&(value+=this.peek(index),index+=1),char=this.peek(index),!isDecimalDigit(char))return null;for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1}return length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isMalformed:!isFinite(value)}},scanEscapeSequence:function(checks){var allowNewLine=!1,jump=1;this.skip();var char=this.peek();switch(char){case\"'\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\'\"]},checks,function(){return state.jsonMode});break;case\"b\":char=\"\\\\b\";break;case\"f\":char=\"\\\\f\";break;case\"n\":char=\"\\\\n\";break;case\"r\":char=\"\\\\r\";break;case\"t\":char=\"\\\\t\";break;case\"0\":char=\"\\\\0\";var n=parseInt(this.peek(1),10);this.triggerAsync(\"warning\",{code:\"W115\",line:this.line,character:this.char},checks,function(){return n>=0&&7>=n&&state.isStrict()});break;case\"u\":var hexCode=this.input.substr(1,4),code=parseInt(hexCode,16);isNaN(code)&&this.trigger(\"warning\",{code:\"W052\",line:this.line,character:this.char,data:[\"u\"+hexCode]}),char=String.fromCharCode(code),jump=5;break;case\"v\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\v\"]},checks,function(){return state.jsonMode}),char=\"\u000b\";break;case\"x\":var x=parseInt(this.input.substr(1,2),16);this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\x-\"]},checks,function(){return state.jsonMode}),char=String.fromCharCode(x),jump=3;break;case\"\\\\\":char=\"\\\\\\\\\";break;case'\"':char='\\\\\"';break;case\"/\":break;case\"\":allowNewLine=!0,char=\"\"}return{\"char\":char,jump:jump,allowNewLine:allowNewLine}},scanTemplateLiteral:function(checks){var tokenType,ch,value=\"\",startLine=this.line,startChar=this.char,depth=this.templateStarts.length;if(!state.inES6(!0))return null;if(\"`\"===this.peek())tokenType=Token.TemplateHead,this.templateStarts.push({line:this.line,\"char\":this.char}),depth=this.templateStarts.length,this.skip(1),this.pushContext(Context.Template);else{if(!this.inContext(Context.Template)||\"}\"!==this.peek())return null;tokenType=Token.TemplateMiddle}for(;\"`\"!==this.peek();){for(;\"\"===(ch=this.peek());)if(value+=\"\\n\",!this.nextLine()){var startPos=this.templateStarts.pop();return this.trigger(\"error\",{code:\"E052\",line:startPos.line,character:startPos.char}),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,depth:depth,context:this.popContext()}}if(\"$\"===ch&&\"{\"===this.peek(1))return value+=\"${\",this.skip(2),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.currentContext()};\nif(\"\\\\\"===ch){var escape=this.scanEscapeSequence(checks);value+=escape.char,this.skip(escape.jump)}else\"`\"!==ch&&(value+=ch,this.skip(1))}return tokenType=tokenType===Token.TemplateHead?Token.NoSubstTemplate:Token.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.popContext()}},scanStringLiteral:function(checks){var quote=this.peek();if('\"'!==quote&&\"'\"!==quote)return null;this.triggerAsync(\"warning\",{code:\"W108\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&'\"'!==quote});var value=\"\",startLine=this.line,startChar=this.char,allowNewLine=!1;for(this.skip();this.peek()!==quote;)if(\"\"===this.peek()){if(allowNewLine?(allowNewLine=!1,this.triggerAsync(\"warning\",{code:\"W043\",line:this.line,character:this.char},checks,function(){return!state.option.multistr}),this.triggerAsync(\"warning\",{code:\"W042\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&state.option.multistr})):this.trigger(\"warning\",{code:\"W112\",line:this.line,character:this.char}),!this.nextLine())return this.trigger(\"error\",{code:\"E029\",line:startLine,character:startChar}),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,quote:quote}}else{allowNewLine=!1;var char=this.peek(),jump=1;if(\" \">char&&this.trigger(\"warning\",{code:\"W113\",line:this.line,character:this.char,data:[\"\"]}),\"\\\\\"===char){var parsed=this.scanEscapeSequence(checks);char=parsed.char,jump=parsed.jump,allowNewLine=parsed.allowNewLine}value+=char,this.skip(jump)}return this.skip(),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,quote:quote}},scanRegExp:function(){var terminated,index=0,length=this.input.length,char=this.peek(),value=char,body=\"\",flags=[],malformed=!1,isCharSet=!1,scanUnexpectedChars=function(){\" \">char&&(malformed=!0,this.trigger(\"warning\",{code:\"W048\",line:this.line,character:this.char})),\"<\"===char&&(malformed=!0,this.trigger(\"warning\",{code:\"W049\",line:this.line,character:this.char,data:[char]}))}.bind(this);if(!this.prereg||\"/\"!==char)return null;for(index+=1,terminated=!1;length>index;)if(char=this.peek(index),value+=char,body+=char,isCharSet)\"]\"===char&&(\"\\\\\"!==this.peek(index-1)||\"\\\\\"===this.peek(index-2))&&(isCharSet=!1),\"\\\\\"===char&&(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars()),index+=1;else{if(\"\\\\\"===char){if(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars(),\"/\"===char){index+=1;continue}if(\"[\"===char){index+=1;continue}}if(\"[\"!==char){if(\"/\"===char){body=body.substr(0,body.length-1),terminated=!0,index+=1;break}index+=1}else isCharSet=!0,index+=1}if(!terminated)return this.trigger(\"error\",{code:\"E015\",line:this.line,character:this.from}),void this.trigger(\"fatal\",{line:this.line,from:this.from});for(;length>index&&(char=this.peek(index),/[gim]/.test(char));)flags.push(char),value+=char,index+=1;try{RegExp(body,flags.join(\"\"))}catch(err){malformed=!0,this.trigger(\"error\",{code:\"E016\",line:this.line,character:this.char,data:[err.message]})}return{type:Token.RegExp,value:value,flags:flags,isMalformed:malformed}},scanNonBreakingSpaces:function(){return state.option.nonbsp?this.input.search(/(\\u00A0)/):-1},scanUnsafeChars:function(){return this.input.search(reg.unsafeChars)},next:function(checks){this.from=this.char;var start;if(/\\s/.test(this.peek()))for(start=this.char;/\\s/.test(this.peek());)this.from+=1,this.skip();var match=this.scanComments()||this.scanStringLiteral(checks)||this.scanTemplateLiteral(checks);return match?match:(match=this.scanRegExp()||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier()||this.scanNumericLiteral(),match?(this.skip(match.tokenLength||match.value.length),match):null)},nextLine:function(){var char;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var inputTrimmed=this.input.trim(),startsWith=function(){return _.some(arguments,function(prefix){return 0===inputTrimmed.indexOf(prefix)})},endsWith=function(){return _.some(arguments,function(suffix){return-1!==inputTrimmed.indexOf(suffix,inputTrimmed.length-suffix.length)})};if(this.ignoringLinterErrors===!0&&(startsWith(\"/*\",\"//\")||this.inComment&&endsWith(\"*/\")||(this.input=\"\")),char=this.scanNonBreakingSpaces(),char>=0&&this.trigger(\"warning\",{code:\"W125\",line:this.line,character:char+1}),this.input=this.input.replace(/\\t/g,state.tab),char=this.scanUnsafeChars(),char>=0&&this.trigger(\"warning\",{code:\"W100\",line:this.line,character:char}),!this.ignoringLinterErrors&&state.option.maxlen&&state.option.maxlen=0;--i){var scopeLabels=_scopeStack[i][\"(labels)\"];if(scopeLabels[labelName])return scopeLabels}}function usedSoFarInCurrentFunction(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(usages)\"][labelName])return current[\"(usages)\"][labelName];if(current===_currentFunctBody)break}return!1}function _checkOuterShadow(labelName,token){if(\"outer\"===state.option.shadow)for(var isGlobal=\"global\"===_currentFunctBody[\"(type)\"],isNewFunction=\"functionparams\"===_current[\"(type)\"],outsideCurrentFunction=!isGlobal,i=0;_scopeStack.length>i;i++){var stackItem=_scopeStack[i];isNewFunction||_scopeStack[i+1]!==_currentFunctBody||(outsideCurrentFunction=!1),outsideCurrentFunction&&stackItem[\"(labels)\"][labelName]&&warning(\"W123\",token,labelName),stackItem[\"(breakLabels)\"][labelName]&&warning(\"W123\",token,labelName)}}function _latedefWarning(type,labelName,token){state.option.latedef&&(state.option.latedef===!0&&\"function\"===type||\"function\"!==type)&&warning(\"W003\",token,labelName)}var _current,_scopeStack=[];_newScope(\"global\"),_current[\"(predefined)\"]=predefined;var _currentFunctBody=_current,usedPredefinedAndGlobals=Object.create(null),impliedGlobals=Object.create(null),unuseds=[],emitter=new events.EventEmitter,_getUnusedOption=function(unused_opt){return void 0===unused_opt&&(unused_opt=state.option.unused),unused_opt===!0&&(unused_opt=\"last-param\"),unused_opt},_warnUnused=function(name,tkn,type,unused_opt){var line=tkn.line,chr=tkn.from,raw_name=tkn.raw_text||name;unused_opt=_getUnusedOption(unused_opt);var warnable_types={vars:[\"var\"],\"last-param\":[\"var\",\"param\"],strict:[\"var\",\"param\",\"last-param\"]};unused_opt&&warnable_types[unused_opt]&&-1!==warnable_types[unused_opt].indexOf(type)&&warning(\"W098\",{line:line,from:chr},raw_name),(unused_opt||\"var\"===type)&&unuseds.push({name:name,line:line,character:chr})},scopeManagerInst={on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)})},isPredefined:function(labelName){return!this.has(labelName)&&_.has(_scopeStack[0][\"(predefined)\"],labelName)},stack:function(type){var previousScope=_current;_newScope(type),type||\"functionparams\"!==previousScope[\"(type)\"]||(_current[\"(isFuncBody)\"]=!0,_current[\"(context)\"]=_currentFunctBody,_currentFunctBody=_current)},unstack:function(){var i,j,subScope=_scopeStack.length>1?_scopeStack[_scopeStack.length-2]:null,isUnstackingFunctionBody=_current===_currentFunctBody,isUnstackingFunctionParams=\"functionparams\"===_current[\"(type)\"],isUnstackingFunctionOuter=\"functionouter\"===_current[\"(type)\"],currentUsages=_current[\"(usages)\"],currentLabels=_current[\"(labels)\"],usedLabelNameList=Object.keys(currentUsages);for(currentUsages.__proto__&&-1===usedLabelNameList.indexOf(\"__proto__\")&&usedLabelNameList.push(\"__proto__\"),i=0;usedLabelNameList.length>i;i++){var usedLabelName=usedLabelNameList[i],usage=currentUsages[usedLabelName],usedLabel=currentLabels[usedLabelName];if(usedLabel){var usedLabelType=usedLabel[\"(type)\"];if(usedLabel[\"(useOutsideOfScope)\"]&&!state.option.funcscope){var usedTokens=usage[\"(tokens)\"];if(usedTokens)for(j=0;usedTokens.length>j;j++)usedLabel[\"(function)\"]===usedTokens[j][\"(function)\"]&&error(\"W038\",usedTokens[j],usedLabelName)}if(_current[\"(labels)\"][usedLabelName][\"(unused)\"]=!1,\"const\"===usedLabelType&&usage[\"(modified)\"])for(j=0;usage[\"(modified)\"].length>j;j++)error(\"E013\",usage[\"(modified)\"][j],usedLabelName);if((\"function\"===usedLabelType||\"class\"===usedLabelType)&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)error(\"W021\",usage[\"(reassigned)\"][j],usedLabelName,usedLabelType)}else if(isUnstackingFunctionOuter&&(state.funct[\"(isCapturing)\"]=!0),subScope)if(subScope[\"(usages)\"][usedLabelName]){var subScopeUsage=subScope[\"(usages)\"][usedLabelName];subScopeUsage[\"(modified)\"]=subScopeUsage[\"(modified)\"].concat(usage[\"(modified)\"]),subScopeUsage[\"(tokens)\"]=subScopeUsage[\"(tokens)\"].concat(usage[\"(tokens)\"]),subScopeUsage[\"(reassigned)\"]=subScopeUsage[\"(reassigned)\"].concat(usage[\"(reassigned)\"]),subScopeUsage[\"(onlyUsedSubFunction)\"]=!1}else subScope[\"(usages)\"][usedLabelName]=usage,isUnstackingFunctionBody&&(subScope[\"(usages)\"][usedLabelName][\"(onlyUsedSubFunction)\"]=!0);else if(\"boolean\"==typeof _current[\"(predefined)\"][usedLabelName]){if(delete declared[usedLabelName],usedPredefinedAndGlobals[usedLabelName]=marker,_current[\"(predefined)\"][usedLabelName]===!1&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)warning(\"W020\",usage[\"(reassigned)\"][j])}else if(usage[\"(tokens)\"])for(j=0;usage[\"(tokens)\"].length>j;j++){var undefinedToken=usage[\"(tokens)\"][j];undefinedToken.forgiveUndef||(state.option.undef&&!undefinedToken.ignoreUndef&&warning(\"W117\",undefinedToken,usedLabelName),impliedGlobals[usedLabelName]?impliedGlobals[usedLabelName].line.push(undefinedToken.line):impliedGlobals[usedLabelName]={name:usedLabelName,line:[undefinedToken.line]})}}if(subScope||Object.keys(declared).forEach(function(labelNotUsed){_warnUnused(labelNotUsed,declared[labelNotUsed],\"var\")}),subScope&&!isUnstackingFunctionBody&&!isUnstackingFunctionParams&&!isUnstackingFunctionOuter){var labelNames=Object.keys(currentLabels);for(i=0;labelNames.length>i;i++){var defLabelName=labelNames[i];currentLabels[defLabelName][\"(blockscoped)\"]||\"exception\"===currentLabels[defLabelName][\"(type)\"]||this.funct.has(defLabelName,{excludeCurrent:!0})||(subScope[\"(labels)\"][defLabelName]=currentLabels[defLabelName],\"global\"!==_currentFunctBody[\"(type)\"]&&(subScope[\"(labels)\"][defLabelName][\"(useOutsideOfScope)\"]=!0),delete currentLabels[defLabelName])}}_checkForUnused(),_scopeStack.pop(),isUnstackingFunctionBody&&(_currentFunctBody=_scopeStack[_.findLastIndex(_scopeStack,function(scope){return scope[\"(isFuncBody)\"]||\"global\"===scope[\"(type)\"]})]),_current=subScope},addParam:function(labelName,token,type){if(type=type||\"param\",\"exception\"===type){var previouslyDefinedLabelType=this.funct.labeltype(labelName);previouslyDefinedLabelType&&\"exception\"!==previouslyDefinedLabelType&&(state.option.node||warning(\"W002\",state.tokens.next,labelName))}if(_.has(_current[\"(labels)\"],labelName)?_current[\"(labels)\"][labelName].duplicated=!0:(_checkOuterShadow(labelName,token,type),_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":token,\"(unused)\":!0},_current[\"(params)\"].push(labelName)),_.has(_current[\"(usages)\"],labelName)){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}},validateParams:function(){if(\"global\"!==_currentFunctBody[\"(type)\"]){var isStrict=state.isStrict(),currentFunctParamScope=_currentFunctBody[\"(parent)\"];currentFunctParamScope[\"(params)\"]&¤tFunctParamScope[\"(params)\"].forEach(function(labelName){var label=currentFunctParamScope[\"(labels)\"][labelName];label&&label.duplicated&&(isStrict?warning(\"E011\",label[\"(token)\"],labelName):state.option.shadow!==!0&&warning(\"W004\",label[\"(token)\"],labelName))})}},getUsedOrDefinedGlobals:function(){var list=Object.keys(usedPredefinedAndGlobals);return usedPredefinedAndGlobals.__proto__===marker&&-1===list.indexOf(\"__proto__\")&&list.push(\"__proto__\"),list},getImpliedGlobals:function(){var values=_.values(impliedGlobals),hasProto=!1;return impliedGlobals.__proto__&&(hasProto=values.some(function(value){return\"__proto__\"===value.name}),hasProto||values.push(impliedGlobals.__proto__)),values},getUnuseds:function(){return unuseds},has:function(labelName){return Boolean(_getLabel(labelName))},labeltype:function(labelName){var scopeLabels=_getLabel(labelName);return scopeLabels?scopeLabels[labelName][\"(type)\"]:null},addExported:function(labelName){var globalLabels=_scopeStack[0][\"(labels)\"];if(_.has(declared,labelName))delete declared[labelName];else if(_.has(globalLabels,labelName))globalLabels[labelName][\"(unused)\"]=!1;else{for(var i=1;_scopeStack.length>i;i++){var scope=_scopeStack[i];if(scope[\"(type)\"])break;if(_.has(scope[\"(labels)\"],labelName)&&!scope[\"(labels)\"][labelName][\"(blockscoped)\"])return scope[\"(labels)\"][labelName][\"(unused)\"]=!1,void 0}exported[labelName]=!0}},setExported:function(labelName,token){this.block.use(labelName,token)\n},addlabel:function(labelName,opts){var type=opts.type,token=opts.token,isblockscoped=\"let\"===type||\"const\"===type||\"class\"===type,isexported=\"global\"===(isblockscoped?_current:_currentFunctBody)[\"(type)\"]&&_.has(exported,labelName);if(_checkOuterShadow(labelName,token,type),isblockscoped){var declaredInCurrentScope=_current[\"(labels)\"][labelName];if(declaredInCurrentScope||_current!==_currentFunctBody||\"global\"===_current[\"(type)\"]||(declaredInCurrentScope=!!_currentFunctBody[\"(parent)\"][\"(labels)\"][labelName]),!declaredInCurrentScope&&_current[\"(usages)\"][labelName]){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}declaredInCurrentScope?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&scopeManagerInst.funct.has(labelName)&&warning(\"W004\",token,labelName),scopeManagerInst.block.add(labelName,type,token,!isexported)}else{var declaredInCurrentFunctionScope=scopeManagerInst.funct.has(labelName);!declaredInCurrentFunctionScope&&usedSoFarInCurrentFunction(labelName)&&_latedefWarning(type,labelName,token),scopeManagerInst.funct.has(labelName,{onlyBlockscoped:!0})?warning(\"E011\",token,labelName):state.option.shadow!==!0&&declaredInCurrentFunctionScope&&\"__proto__\"!==labelName&&\"global\"!==_currentFunctBody[\"(type)\"]&&warning(\"W004\",token,labelName),scopeManagerInst.funct.add(labelName,type,token,!isexported),\"global\"===_currentFunctBody[\"(type)\"]&&(usedPredefinedAndGlobals[labelName]=marker)}},funct:{labeltype:function(labelName,options){for(var onlyBlockscoped=options&&options.onlyBlockscoped,excludeParams=options&&options.excludeParams,currentScopeIndex=_scopeStack.length-(options&&options.excludeCurrent?2:1),i=currentScopeIndex;i>=0;i--){var current=_scopeStack[i];if(current[\"(labels)\"][labelName]&&(!onlyBlockscoped||current[\"(labels)\"][labelName][\"(blockscoped)\"]))return current[\"(labels)\"][labelName][\"(type)\"];var scopeCheck=excludeParams?_scopeStack[i-1]:current;if(scopeCheck&&\"functionparams\"===scopeCheck[\"(type)\"])return null}return null},hasBreakLabel:function(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(breakLabels)\"][labelName])return!0;if(\"functionparams\"===current[\"(type)\"])return!1}return!1},has:function(labelName,options){return Boolean(this.labeltype(labelName,options))},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!1,\"(function)\":_currentFunctBody,\"(unused)\":unused}}},block:{isGlobal:function(){return\"global\"===_current[\"(type)\"]},use:function(labelName,token){var paramScope=_currentFunctBody[\"(parent)\"];paramScope&¶mScope[\"(labels)\"][labelName]&&\"param\"===paramScope[\"(labels)\"][labelName][\"(type)\"]&&(scopeManagerInst.funct.has(labelName,{excludeParams:!0,onlyBlockscoped:!0})||(paramScope[\"(labels)\"][labelName][\"(unused)\"]=!1)),token&&(state.ignored.W117||state.option.undef===!1)&&(token.ignoreUndef=!0),_setupUsages(labelName),token&&(token[\"(function)\"]=_currentFunctBody,_current[\"(usages)\"][labelName][\"(tokens)\"].push(token))},reassign:function(labelName,token){this.modify(labelName,token),_current[\"(usages)\"][labelName][\"(reassigned)\"].push(token)},modify:function(labelName,token){_setupUsages(labelName),_current[\"(usages)\"][labelName][\"(modified)\"].push(token)},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!0,\"(unused)\":unused}},addBreakLabel:function(labelName,opts){var token=opts.token;scopeManagerInst.funct.hasBreakLabel(labelName)?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&(scopeManagerInst.funct.has(labelName)?warning(\"W004\",token,labelName):_checkOuterShadow(labelName,token)),_current[\"(breakLabels)\"][labelName]=token}}};return scopeManagerInst};module.exports=scopeManager},{\"../lodash\":\"/node_modules/jshint/lodash.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/state.js\":[function(_dereq_,module,exports){\"use strict\";var NameStack=_dereq_(\"./name-stack.js\"),state={syntax:{},isStrict:function(){return this.directive[\"use strict\"]||this.inClassBody||this.option.module||\"implied\"===this.option.strict},inMoz:function(){return this.option.moz},inES6:function(){return this.option.moz||this.option.esversion>=6},inES5:function(strict){return strict?!(this.option.esversion&&5!==this.option.esversion||this.option.moz):!this.option.esversion||this.option.esversion>=5||this.option.moz},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={},this.funct=null,this.ignored={},this.directive={},this.jsonMode=!1,this.jsonWarnings=[],this.lines=[],this.tab=\"\",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new NameStack,this.inClassBody=!1}};exports.state=state},{\"./name-stack.js\":\"/node_modules/jshint/src/name-stack.js\"}],\"/node_modules/jshint/src/style.js\":[function(_dereq_,module,exports){\"use strict\";exports.register=function(linter){linter.on(\"Identifier\",function(data){linter.getOption(\"proto\")||\"__proto__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name,\"6\"]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"iterator\")||\"__iterator__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"camelcase\")&&data.name.replace(/^_+|_+$/g,\"\").indexOf(\"_\")>-1&&!data.name.match(/^[A-Z0-9_]*$/)&&linter.warn(\"W106\",{line:data.line,\"char\":data.from,data:[data.name]})}),linter.on(\"String\",function(data){var code,quotmark=linter.getOption(\"quotmark\");quotmark&&(\"single\"===quotmark&&\"'\"!==data.quote&&(code=\"W109\"),\"double\"===quotmark&&'\"'!==data.quote&&(code=\"W108\"),quotmark===!0&&(linter.getCache(\"quotmark\")||linter.setCache(\"quotmark\",data.quote),linter.getCache(\"quotmark\")!==data.quote&&(code=\"W110\")),code&&linter.warn(code,{line:data.line,\"char\":data.char}))}),linter.on(\"Number\",function(data){\".\"===data.value.charAt(0)&&linter.warn(\"W008\",{line:data.line,\"char\":data.char,data:[data.value]}),\".\"===data.value.substr(data.value.length-1)&&linter.warn(\"W047\",{line:data.line,\"char\":data.char,data:[data.value]}),/^00+/.test(data.value)&&linter.warn(\"W046\",{line:data.line,\"char\":data.char,data:[data.value]})}),linter.on(\"String\",function(data){var re=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\\s*:/i;linter.getOption(\"scripturl\")||re.test(data.value)&&linter.warn(\"W107\",{line:data.line,\"char\":data.char})})}},{}],\"/node_modules/jshint/src/vars.js\":[function(_dereq_,module,exports){\"use strict\";exports.reservedVars={arguments:!1,NaN:!1},exports.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,WeakMap:!1,WeakSet:!1}},exports.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,performance:!1,print:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},exports.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},exports.worker={importScripts:!0,postMessage:!0,self:!0,FileReaderSync:!0},exports.nonstandard={escape:!1,unescape:!1},exports.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},exports.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,acequire:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},exports.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,acequire:!1,Buffer:!0,exports:!0,process:!0},exports.phantom={phantom:!0,acequire:!0,WebPage:!0,console:!0,exports:!0},exports.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,\"throws\":!1},exports.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},exports.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},exports.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},exports.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},exports.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},exports.jquery={$:!1,jQuery:!1},exports.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},exports.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},exports.yui={YUI:!1,Y:!1,YUI_config:!1},exports.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},exports.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1}},{}]},{},[\"/node_modules/jshint/src/jshint.js\"])}),ace.define(\"ace/mode/javascript_worker\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/worker/mirror\",\"ace/mode/javascript/jshint\"],function(acequire,exports,module){\"use strict\";function startRegex(arr){return RegExp(\"^(\"+arr.join(\"|\")+\")\")}var oop=acequire(\"../lib/oop\"),Mirror=acequire(\"../worker/mirror\").Mirror,lint=acequire(\"./javascript/jshint\").JSHINT,disabledWarningsRe=startRegex([\"Bad for in variable '(.+)'.\",'Missing \"use strict\"']),errorsRe=startRegex([\"Unexpected\",\"Expected \",\"Confusing (plus|minus)\",\"\\\\{a\\\\} unterminated regular expression\",\"Unclosed \",\"Unmatched \",\"Unbegun comment\",\"Bad invocation\",\"Missing space after\",\"Missing operator at\"]),infoRe=startRegex([\"Expected an assignment\",\"Bad escapement of EOL\",\"Unexpected comma\",\"Unexpected space\",\"Missing radix parameter.\",\"A leading decimal point can\",\"\\\\['{a}'\\\\] is better written in dot notation.\",\"'{a}' used out of scope\"]),JavaScriptWorker=exports.JavaScriptWorker=function(sender){Mirror.call(this,sender),this.setTimeout(500),this.setOptions()};oop.inherits(JavaScriptWorker,Mirror),function(){this.setOptions=function(options){this.options=options||{esnext:!0,moz:!0,devel:!0,browser:!0,node:!0,laxcomma:!0,laxbreak:!0,lastsemic:!0,onevar:!1,passfail:!1,maxerr:100,expr:!0,multistr:!0,globalstrict:!0},this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.changeOptions=function(newOptions){oop.mixin(this.options,newOptions),this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.isValidJS=function(str){try{eval(\"throw 0;\"+str)}catch(e){if(0===e)return!0}return!1},this.onUpdate=function(){var value=this.doc.getValue();if(value=value.replace(/^#!.*\\n/,\"\\n\"),!value)return this.sender.emit(\"annotate\",[]);var errors=[],maxErrorLevel=this.isValidJS(value)?\"warning\":\"error\";lint(value,this.options,this.options.globals);for(var results=lint.errors,errorAdded=!1,i=0;results.length>i;i++){var error=results[i];if(error){var raw=error.raw,type=\"warning\";if(\"Missing semicolon.\"==raw){var str=error.evidence.substr(error.character);str=str.charAt(str.search(/\\S/)),\"error\"==maxErrorLevel&&str&&/[\\w\\d{(['\"]/.test(str)?(error.reason='Missing \";\" before statement',type=\"error\"):type=\"info\"}else{if(disabledWarningsRe.test(raw))continue;infoRe.test(raw)?type=\"info\":errorsRe.test(raw)?(errorAdded=!0,type=maxErrorLevel):\"'{a}' is not defined.\"==raw?type=\"warning\":\"'{a}' is defined but never used.\"==raw&&(type=\"info\")}errors.push({row:error.line-1,column:error.character-1,text:error.reason,type:type,raw:raw})}}this.sender.emit(\"annotate\",errors)}}.call(JavaScriptWorker.prototype)}),ace.define(\"ace/lib/es5-shim\",[\"require\",\"exports\",\"module\"],function(){function Empty(){}function doesDefinePropertyWork(object){try{return Object.defineProperty(object,\"sentinel\",{}),\"sentinel\"in object}catch(exception){}}function toInteger(n){return n=+n,n!==n?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))),n}Function.prototype.bind||(Function.prototype.bind=function(that){var target=this;if(\"function\"!=typeof target)throw new TypeError(\"Function.prototype.bind called on incompatible \"+target);var args=slice.call(arguments,1),bound=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));return Object(result)===result?result:this}return target.apply(that,args.concat(slice.call(arguments)))};return target.prototype&&(Empty.prototype=target.prototype,bound.prototype=new Empty,Empty.prototype=null),bound});var defineGetter,defineSetter,lookupGetter,lookupSetter,supportsAccessors,call=Function.prototype.call,prototypeOfArray=Array.prototype,prototypeOfObject=Object.prototype,slice=prototypeOfArray.slice,_toString=call.bind(prototypeOfObject.toString),owns=call.bind(prototypeOfObject.hasOwnProperty);if((supportsAccessors=owns(prototypeOfObject,\"__defineGetter__\"))&&(defineGetter=call.bind(prototypeOfObject.__defineGetter__),defineSetter=call.bind(prototypeOfObject.__defineSetter__),lookupGetter=call.bind(prototypeOfObject.__lookupGetter__),lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)),2!=[1,2].splice(0).length)if(function(){function makeArray(l){var a=Array(l+2);return a[0]=a[1]=0,a}var lengthBefore,array=[];return array.splice.apply(array,makeArray(20)),array.splice.apply(array,makeArray(26)),lengthBefore=array.length,array.splice(5,0,\"XXX\"),lengthBefore+1==array.length,lengthBefore+1==array.length?!0:void 0}()){var array_splice=Array.prototype.splice;Array.prototype.splice=function(start,deleteCount){return arguments.length?array_splice.apply(this,[void 0===start?0:start,void 0===deleteCount?this.length-start:deleteCount].concat(slice.call(arguments,2))):[]}}else Array.prototype.splice=function(pos,removeCount){var length=this.length;pos>0?pos>length&&(pos=length):void 0==pos?pos=0:0>pos&&(pos=Math.max(length+pos,0)),length>pos+removeCount||(removeCount=length-pos);var removed=this.slice(pos,pos+removeCount),insert=slice.call(arguments,2),add=insert.length;if(pos===length)add&&this.push.apply(this,insert);else{var remove=Math.min(removeCount,length-pos),tailOldPos=pos+remove,tailNewPos=tailOldPos+add-remove,tailCount=length-tailOldPos,lengthAfterRemove=length-remove;if(tailOldPos>tailNewPos)for(var i=0;tailCount>i;++i)this[tailNewPos+i]=this[tailOldPos+i];else if(tailNewPos>tailOldPos)for(i=tailCount;i--;)this[tailNewPos+i]=this[tailOldPos+i];if(add&&pos===lengthAfterRemove)this.length=lengthAfterRemove,this.push.apply(this,insert);else for(this.length=lengthAfterRemove+add,i=0;add>i;++i)this[pos+i]=insert[i]}return removed};Array.isArray||(Array.isArray=function(obj){return\"[object Array]\"==_toString(obj)});var boxedString=Object(\"a\"),splitString=\"a\"!=boxedString[0]||!(0 in boxedString);if(Array.prototype.forEach||(Array.prototype.forEach=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,thisp=arguments[1],i=-1,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError;for(;length>++i;)i in self&&fun.call(thisp,self[i],i,object)}),Array.prototype.map||(Array.prototype.map=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=Array(length),thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(result[i]=fun.call(thisp,self[i],i,object));return result}),Array.prototype.filter||(Array.prototype.filter=function(fun){var value,object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=[],thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(value=self[i],fun.call(thisp,value,i,object)&&result.push(value));return result}),Array.prototype.every||(Array.prototype.every=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&!fun.call(thisp,self[i],i,object))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&fun.call(thisp,self[i],i,object))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduce of empty array with no initial value\");var result,i=0;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i++];break}if(++i>=length)throw new TypeError(\"reduce of empty array with no initial value\")}for(;length>i;i++)i in self&&(result=fun.call(void 0,result,self[i],i,object));return result}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduceRight of empty array with no initial value\");var result,i=length-1;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i--];break}if(0>--i)throw new TypeError(\"reduceRight of empty array with no initial value\")}do i in this&&(result=fun.call(void 0,result,self[i],i,object));while(i--);return result}),Array.prototype.indexOf&&-1==[0,1].indexOf(1,2)||(Array.prototype.indexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=0;for(arguments.length>1&&(i=toInteger(arguments[1])),i=i>=0?i:Math.max(0,length+i);length>i;i++)if(i in self&&self[i]===sought)return i;return-1}),Array.prototype.lastIndexOf&&-1==[0,1].lastIndexOf(0,-3)||(Array.prototype.lastIndexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=length-1;for(arguments.length>1&&(i=Math.min(i,toInteger(arguments[1]))),i=i>=0?i:length-Math.abs(i);i>=0;i--)if(i in self&&sought===self[i])return i;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(object){return object.__proto__||(object.constructor?object.constructor.prototype:prototypeOfObject)}),!Object.getOwnPropertyDescriptor){var ERR_NON_OBJECT=\"Object.getOwnPropertyDescriptor called on a non-object: \";Object.getOwnPropertyDescriptor=function(object,property){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT+object);if(owns(object,property)){var descriptor,getter,setter;if(descriptor={enumerable:!0,configurable:!0},supportsAccessors){var prototype=object.__proto__;object.__proto__=prototypeOfObject;var getter=lookupGetter(object,property),setter=lookupSetter(object,property);if(object.__proto__=prototype,getter||setter)return getter&&(descriptor.get=getter),setter&&(descriptor.set=setter),descriptor}return descriptor.value=object[property],descriptor}}}if(Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(object){return Object.keys(object)}),!Object.create){var createEmpty;createEmpty=null===Object.prototype.__proto__?function(){return{__proto__:null}}:function(){var empty={};for(var i in empty)empty[i]=null;return empty.constructor=empty.hasOwnProperty=empty.propertyIsEnumerable=empty.isPrototypeOf=empty.toLocaleString=empty.toString=empty.valueOf=empty.__proto__=null,empty},Object.create=function(prototype,properties){var object;if(null===prototype)object=createEmpty();else{if(\"object\"!=typeof prototype)throw new TypeError(\"typeof prototype[\"+typeof prototype+\"] != 'object'\");var Type=function(){};Type.prototype=prototype,object=new Type,object.__proto__=prototype}return void 0!==properties&&Object.defineProperties(object,properties),object}}if(Object.defineProperty){var definePropertyWorksOnObject=doesDefinePropertyWork({}),definePropertyWorksOnDom=\"undefined\"==typeof document||doesDefinePropertyWork(document.createElement(\"div\"));if(!definePropertyWorksOnObject||!definePropertyWorksOnDom)var definePropertyFallback=Object.defineProperty}if(!Object.defineProperty||definePropertyFallback){var ERR_NON_OBJECT_DESCRIPTOR=\"Property description must be an object: \",ERR_NON_OBJECT_TARGET=\"Object.defineProperty called on non-object: \",ERR_ACCESSORS_NOT_SUPPORTED=\"getters & setters can not be defined on this javascript engine\";Object.defineProperty=function(object,property,descriptor){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT_TARGET+object);if(\"object\"!=typeof descriptor&&\"function\"!=typeof descriptor||null===descriptor)throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR+descriptor);if(definePropertyFallback)try{return definePropertyFallback.call(Object,object,property,descriptor)}catch(exception){}if(owns(descriptor,\"value\"))if(supportsAccessors&&(lookupGetter(object,property)||lookupSetter(object,property))){var prototype=object.__proto__;object.__proto__=prototypeOfObject,delete object[property],object[property]=descriptor.value,object.__proto__=prototype}else object[property]=descriptor.value;else{if(!supportsAccessors)throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);owns(descriptor,\"get\")&&defineGetter(object,property,descriptor.get),owns(descriptor,\"set\")&&defineSetter(object,property,descriptor.set)}return object}}Object.defineProperties||(Object.defineProperties=function(object,properties){for(var property in properties)owns(properties,property)&&Object.defineProperty(object,property,properties[property]);return object}),Object.seal||(Object.seal=function(object){return object}),Object.freeze||(Object.freeze=function(object){return object});try{Object.freeze(function(){})}catch(exception){Object.freeze=function(freezeObject){return function(object){return\"function\"==typeof object?object:freezeObject(object)}}(Object.freeze)}if(Object.preventExtensions||(Object.preventExtensions=function(object){return object}),Object.isSealed||(Object.isSealed=function(){return!1}),Object.isFrozen||(Object.isFrozen=function(){return!1}),Object.isExtensible||(Object.isExtensible=function(object){if(Object(object)===object)throw new TypeError;for(var name=\"\";owns(object,name);)name+=\"?\";object[name]=!0;var returnValue=owns(object,name);return delete object[name],returnValue}),!Object.keys){var hasDontEnumBug=!0,dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;for(var key in{toString:null})hasDontEnumBug=!1;Object.keys=function(object){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(\"Object.keys called on a non-object\");var keys=[];for(var name in object)owns(object,name)&&keys.push(name);if(hasDontEnumBug)for(var i=0,ii=dontEnumsLength;ii>i;i++){var dontEnum=dontEnums[i];owns(object,dontEnum)&&keys.push(dontEnum)}return keys}}Date.now||(Date.now=function(){return(new Date).getTime()});var ws=\"\t\\n\u000b\\f\\r   ᠎              \\u2028\\u2029\";if(!String.prototype.trim||ws.trim()){ws=\"[\"+ws+\"]\";var trimBeginRegexp=RegExp(\"^\"+ws+ws+\"*\"),trimEndRegexp=RegExp(ws+ws+\"*$\");String.prototype.trim=function(){return(this+\"\").replace(trimBeginRegexp,\"\").replace(trimEndRegexp,\"\")}}var toObject=function(o){if(null==o)throw new TypeError(\"can't convert \"+o+\" to object\");return Object(o)}});"; +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Environment; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HacknetNode_js__ = __webpack_require__(43); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__NetscriptPort_js__ = __webpack_require__(69); -/***/ }), -/* 46 */ -/***/ (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: /^[\+\-]/ +/* 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(__WEBPACK_IMPORTED_MODULE_1__NetscriptFunctions_js__["a" /* NetscriptFunctions */])(workerScript); } + this.parent = parent; + this.stopFlag = false; +} +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); + }, - 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) - } + //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 output - } + return null; + }, - var sprintf_cache = Object.create(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); + }, - function sprintf_parse(fmt) { - if (sprintf_cache[fmt]) { - return sprintf_cache[fmt] + //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]; } - 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) + //Cant assign to ports or HacknetNodes + if (res[idx[idx.length-1]] instanceof __WEBPACK_IMPORTED_MODULE_0__HacknetNode_js__["a" /* HacknetNode */]) { + throw new Error("Cannot assign a Hacknet Node handle to a new value"); } - 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__)) + if (res[idx[idx.length-1]] instanceof __WEBPACK_IMPORTED_MODULE_2__NetscriptPort_js__["a" /* 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; } - /* eslint-enable quote-props */ -}() +}; + + /***/ }), -/* 47 */ +/* 58 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return redPillFlag; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return hackWorldDaemon; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Prestige_js__ = __webpack_require__(36); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceFile_js__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Terminal_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Prestige_js__ = __webpack_require__(59); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceFile_js__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Terminal_js__ = __webpack_require__(24); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_YesNoBox_js__ = __webpack_require__(15); @@ -53706,200 +57319,5337 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa -/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) /***/ }), -/* 48 */ +/* 59 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return prestigeAugmentation; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return prestigeSourceFile; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Company_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Faction_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Gang_js__ = __webpack_require__(45); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Location_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Message_js__ = __webpack_require__(33); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__ = __webpack_require__(29); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__StockMarket_js__ = __webpack_require__(46); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Terminal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js__ = __webpack_require__(32); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_17__utils_decimal_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__utils_DialogBox_js__ = __webpack_require__(1); + + + + + + + + + + + + + + + + + + + + + +//Prestige by purchasing augmentation +function prestigeAugmentation() { + Object(__WEBPACK_IMPORTED_MODULE_2__BitNode_js__["c" /* initBitNodeMultipliers */])(); + + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].prestigeAugmentation(); + + //Delete all Worker Scripts objects + Object(__WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__["e" /* prestigeWorkerScripts */])(); + + var homeComp = __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].getHomeComputer(); + //Delete all servers except home computer + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["h" /* prestigeAllServers */])(); + + //Delete Special Server IPs + Object(__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["e" /* prestigeSpecialServerIps */])(); //Must be done before initForeignServers() + + //Reset home computer (only the programs) and add to AllServers + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["a" /* AddToAllServers */])(homeComp); + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["i" /* prestigeHomeComputer */])(homeComp); + + if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].Neurolink) && + __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].Neurolink].owned) { + homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); + homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); + } + if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].CashRoot) && + __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].CashRoot].owned) { + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].setMoney(new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(1000000)); + homeComp.programs.push(__WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); + } + + //Re-create foreign servers + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["f" /* initForeignServers */])(); + + //Darkweb is purchase-able + document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); + + //Gain favor for Companies + for (var member in __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */]) { + if (__WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */].hasOwnProperty(member)) { + __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */][member].gainFavor(); + } + } + + //Gain favor for factions + for (var member in __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */]) { + if (__WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */].hasOwnProperty(member)) { + __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][member].gainFavor(); + } + } + + //Stop a Terminal action if there is onerror + if (__WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress) { + __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress = false; + __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].finishAction(true); + } + + //Re-initialize things - This will update any changes + Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["f" /* initFactions */])(); //Factions must be initialized before augmentations + Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* initAugmentations */])(); //Calls reapplyAllAugmentations() and resets Player multipliers + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].reapplyAllSourceFiles(); + Object(__WEBPACK_IMPORTED_MODULE_3__Company_js__["h" /* initCompanies */])(); + + //Clear terminal + $("#terminal tr:not(:last)").remove(); + Object(__WEBPACK_IMPORTED_MODULE_16__Terminal_js__["c" /* postNetburnerText */])(); + + //Messages + Object(__WEBPACK_IMPORTED_MODULE_9__Message_js__["d" /* initMessages */])(); + + //Reset Stock market + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount) { + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["g" /* initStockMarket */])(); + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["i" /* initSymbolToStockMap */])(); + } + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["m" /* setStockMarketContentCreated */])(false); + var stockMarketList = document.getElementById("stock-market-list"); + while(stockMarketList.firstChild) { + stockMarketList.removeChild(stockMarketList.firstChild); + } + + //Gang, in BitNode 2 + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN == 2 && __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].inGang()) { + var faction = __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gang.facName]; + if (faction instanceof __WEBPACK_IMPORTED_MODULE_6__Faction_js__["a" /* Faction */]) { + Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["h" /* joinFaction */])(faction); + } + } + + //BitNode 8: Ghost of Wall Street + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 8) {__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].money = new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(100e6);} + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 8 || __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__["e" /* hasWallStreetSF */]) { + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount = true; + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasTixApiAccess = true; + } + + var mainMenu = document.getElementById("mainmenu-container"); + mainMenu.style.visibility = "visible"; + __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].resetTerminalInput(); + __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"].loadTerminalContent(); + + //Red Pill + if (Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].TheRedPill) && + __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].TheRedPill].owned) { + var WorldDaemon = __WEBPACK_IMPORTED_MODULE_13__Server_js__["b" /* AllServers */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["a" /* SpecialServerIps */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["b" /* SpecialServerNames */].WorldDaemon]]; + var DaedalusServer = __WEBPACK_IMPORTED_MODULE_13__Server_js__["b" /* AllServers */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["a" /* SpecialServerIps */][__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["b" /* SpecialServerNames */].DaedalusServer]]; + if (WorldDaemon && DaedalusServer) { + WorldDaemon.serversOnNetwork.push(DaedalusServer.ip); + DaedalusServer.serversOnNetwork.push(WorldDaemon.ip); + } + } +} + + +//Prestige by destroying Bit Node and gaining a Source File +function prestigeSourceFile() { + Object(__WEBPACK_IMPORTED_MODULE_2__BitNode_js__["c" /* initBitNodeMultipliers */])(); + + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].prestigeSourceFile(); + Object(__WEBPACK_IMPORTED_MODULE_11__NetscriptWorker_js__["e" /* prestigeWorkerScripts */])(); //Delete all Worker Scripts objects + + var homeComp = __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].getHomeComputer(); + + //Delete all servers except home computer + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["h" /* prestigeAllServers */])(); //Must be done before initForeignServers() + + //Delete Special Server IPs + Object(__WEBPACK_IMPORTED_MODULE_14__SpecialServerIps_js__["e" /* prestigeSpecialServerIps */])(); + + //Reset home computer (only the programs) and add to AllServers + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["a" /* AddToAllServers */])(homeComp); + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["i" /* prestigeHomeComputer */])(homeComp); + + //Re-create foreign servers + Object(__WEBPACK_IMPORTED_MODULE_13__Server_js__["f" /* initForeignServers */])(); + + var srcFile1Owned = false; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].sourceFiles.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].sourceFiles[i].n == 1) { + srcFile1Owned = true; + } + } + if (srcFile1Owned) { + homeComp.setMaxRam(32); + } else { + homeComp.setMaxRam(8); + } + homeComp.cpuCores = 1; + + //Darkweb is purchase-able + document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button"); + + //Reset favor for Companies + for (var member in __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */]) { + if (__WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */].hasOwnProperty(member)) { + __WEBPACK_IMPORTED_MODULE_3__Company_js__["a" /* Companies */][member].favor = 0; + } + } + + //Reset favor for factions + for (var member in __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */]) { + if (__WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */].hasOwnProperty(member)) { + __WEBPACK_IMPORTED_MODULE_6__Faction_js__["b" /* Factions */][member].favor = 0; + } + } + + //Stop a Terminal action if there is one + if (__WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress) { + __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"]._actionInProgress = false; + __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].finishAction(true); + } + + //Delete all Augmentations + for (var name in __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */]) { + if (__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */].hasOwnProperty(name)) { + delete __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; + } + } + + //Re-initialize things - This will update any changes + Object(__WEBPACK_IMPORTED_MODULE_6__Faction_js__["f" /* initFactions */])(); //Factions must be initialized before augmentations + Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* initAugmentations */])(); //Calls reapplyAllAugmentations() and resets Player multipliers + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].reapplyAllSourceFiles(); + Object(__WEBPACK_IMPORTED_MODULE_3__Company_js__["h" /* initCompanies */])(); + + //Clear terminal + $("#terminal tr:not(:last)").remove(); + Object(__WEBPACK_IMPORTED_MODULE_16__Terminal_js__["c" /* postNetburnerText */])(); + + //Messages + Object(__WEBPACK_IMPORTED_MODULE_9__Message_js__["d" /* initMessages */])(); + + var mainMenu = document.getElementById("mainmenu-container"); + mainMenu.style.visibility = "visible"; + __WEBPACK_IMPORTED_MODULE_16__Terminal_js__["a" /* Terminal */].resetTerminalInput(); + __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"].loadTerminalContent(); + + //Reinitialize Bit Node flags + Object(__WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__["f" /* initSingularitySFFlags */])(); + + //Reset Stock market, gang, and corporation + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].hasWseAccount) { + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["g" /* initStockMarket */])(); + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["i" /* initSymbolToStockMap */])(); + } + Object(__WEBPACK_IMPORTED_MODULE_15__StockMarket_js__["m" /* setStockMarketContentCreated */])(false); + var stockMarketList = document.getElementById("stock-market-list"); + while(stockMarketList.firstChild) { + stockMarketList.removeChild(stockMarketList.firstChild); + } + + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gang = null; + Object(__WEBPACK_IMPORTED_MODULE_7__Gang_js__["c" /* deleteGangDisplayContent */])(); + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].corporation = null; + + //BitNode 3: Corporatocracy + if (__WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].bitNodeN === 3) { + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].money = new __WEBPACK_IMPORTED_MODULE_17__utils_decimal_js___default.a(150e9); + homeComp.messages.push("corporation-management-handbook.lit"); + Object(__WEBPACK_IMPORTED_MODULE_18__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You received a copy of the Corporation Management Handbook on your home computer. " + + "Read it if you need help getting started with Corporations!"); + } + + //Gain int exp + __WEBPACK_IMPORTED_MODULE_12__Player_js__["a" /* Player */].gainIntelligenceExp(5); +} + + + +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) + +/***/ }), +/* 60 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TextFile; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getTextFile; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createTextFile; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Server_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__ = __webpack_require__(9); + + + + +function TextFile(fn="", txt="") { + this.fn = fn.endsWith(".txt") ? fn : fn + ".txt"; + this.fn = this.fn.replace(/\s+/g, ''); + this.text = String(txt); +} + +TextFile.prototype.append = function(txt) { + this.text += String(txt); +} + +TextFile.prototype.write = function(txt) { + this.text = String(txt); +} + +TextFile.prototype.read = function() { + return this.txt; +} + +TextFile.prototype.show = function() { + Object(__WEBPACK_IMPORTED_MODULE_1__utils_DialogBox_js__["a" /* dialogBoxCreate */])(this.fn + "

" + this.text, true); +} + +TextFile.prototype.download = function() { + var filename = this.fn; + var file = new Blob([this.text], {type: 'text/plain'}); + if (window.navigator.msSaveOrOpenBlob) {// IE10+ + window.navigator.msSaveOrOpenBlob(file, filename); + } else { // Others + var a = document.createElement("a"), + url = URL.createObjectURL(file); + a.href = url; + a.download = this.fn; + document.body.appendChild(a); + a.click(); + setTimeout(function() { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); + } +} + +TextFile.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["b" /* Generic_toJSON */])("TextFile", this); +} + +TextFile.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(TextFile, value.data); +} + +__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["c" /* Reviver */].constructors.TextFile = TextFile; + +function getTextFile(fn, server) { + if (!fn.endsWith(".txt")) {fn += ".txt";} + for (var i = 0; i < server.textFiles.length; ++i) { + if (server.textFiles[i].fn === fn) { + return server.textFiles[i]; + } + } + return null; +} + +//Returns the TextFile object that was just created +function createTextFile(fn, txt, server) { + if (getTextFile(fn, server) !== null) { + console.log("ERROR: createTextFile failed because the specified " + + "server already has a text file with the same fn"); + return; + } + var file = new TextFile(fn, txt); + server.textFiles.push(file); + return file; +} + +function deleteTextFile(fn, server) { + if (!fn.endsWith(".txt")) {fn += ".txt";} + for (var i = 0; i < server.textFiles.length; ++i) { + if (server.textFiles[i].fn === fn) { + server.textFiles.splice(i, 1); + return true; + } + } + return false; +} + + + + +/***/ }), +/* 61 */ /***/ (function(module, exports) { -// shim for using process in browser -var process = module.exports = {}; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; } -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } +module.exports = EventEmitter; +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + return true; +}; +EventEmitter.prototype.addListener = function(type, listener) { + var m; -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; } else { - queueIndex = -1; + m = EventEmitter.defaultMaxListeners; } - if (queue.length) { - drainQueue(); + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; } -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); +function isNumber(arg) { + return typeof arg === 'number'; } -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; } -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; +function isUndefined(arg) { + return arg === void 0; +} /***/ }), -/* 49 */ +/* 62 */ +/***/ (function(module, exports, __webpack_require__) { + +exports = module.exports = __webpack_require__(77); +exports.Stream = exports; +exports.Readable = exports; +exports.Writable = __webpack_require__(63); +exports.Duplex = __webpack_require__(25); +exports.Transform = __webpack_require__(82); +exports.PassThrough = __webpack_require__(133); + + +/***/ }), +/* 63 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + + + +/**/ + +var processNextTick = __webpack_require__(48).nextTick; +/**/ + +module.exports = Writable; + +/* */ +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + this.finish = function () { + onCorkedFinish(_this, state); + }; +} +/* */ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/**/ + +/**/ +var Duplex; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = __webpack_require__(36); +util.inherits = __webpack_require__(31); +/**/ + +/**/ +var internalUtil = { + deprecate: __webpack_require__(132) +}; +/**/ + +/**/ +var Stream = __webpack_require__(78); +/**/ + +/**/ + +var Buffer = __webpack_require__(49).Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +var destroyImpl = __webpack_require__(79); + +util.inherits(Writable, Stream); + +function nop() {} + +function WritableState(options, stream) { + Duplex = Duplex || __webpack_require__(25); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var writableHwm = options.writableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // if _final has been called + this.finalCalled = false; + + // drain event flag. + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // has it been destroyed + this.destroyed = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // allocate the first CorkedRequest, there is always + // one allocated and free to use, and we maintain at most two + this.corkedRequestsFree = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function getBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003') + }); + } catch (_) {} +})(); + +// Test _writableState for inheritance to account for Duplex streams, +// whose prototype chain only points to Readable. +var realHasInstance; +if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') { + realHasInstance = Function.prototype[Symbol.hasInstance]; + Object.defineProperty(Writable, Symbol.hasInstance, { + value: function (object) { + if (realHasInstance.call(this, object)) return true; + if (this !== Writable) return false; + + return object && object._writableState instanceof WritableState; + } + }); +} else { + realHasInstance = function (object) { + return object instanceof this; + }; +} + +function Writable(options) { + Duplex = Duplex || __webpack_require__(25); + + // Writable ctor is applied to Duplexes, too. + // `realHasInstance` is necessary because using plain `instanceof` + // would return false, as no `_writableState` property is attached. + + // Trying to use the custom `instanceof` for Writable here will also break the + // Node.js LazyTransform implementation, which has a non-trivial getter for + // `_writableState` that would lead to infinite recursion. + if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { + return new Writable(options); + } + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + + if (typeof options.final === 'function') this._final = options.final; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe, not readable')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); +} + +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. +function validChunk(stream, state, chunk, cb) { + var valid = true; + var er = false; + + if (chunk === null) { + er = new TypeError('May not write null values to stream'); + } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + if (er) { + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + var isBuf = !state.objectMode && _isUint8Array(chunk); + + if (isBuf && !Buffer.isBuffer(chunk)) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; + return this; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = Buffer.from(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + var newChunk = decodeChunk(state, chunk, encoding); + if (chunk !== newChunk) { + isBuf = true; + encoding = 'buffer'; + chunk = newChunk; + } + } + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = { + chunk: chunk, + encoding: encoding, + isBuf: isBuf, + callback: cb, + next: null + }; + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + + if (sync) { + // defer the callback if we are being called synchronously + // to avoid piling up things on the stack + processNextTick(cb, er); + // this can emit finish, and it will always happen + // after error + processNextTick(finishMaybe, stream, state); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + } else { + // the caller expect this to happen before if + // it is async + cb(er); + stream._writableState.errorEmitted = true; + stream.emit('error', er); + // this can emit finish, but finish must + // always follow error + finishMaybe(stream, state); + } +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + var allBuffers = true; + while (entry) { + buffer[count] = entry; + if (!entry.isBuf) allBuffers = false; + entry = entry.next; + count += 1; + } + buffer.allBuffers = allBuffers; + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is almost always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + if (holder.next) { + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + state.corkedRequestsFree = new CorkedRequest(state); + } + state.bufferedRequestCount = 0; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + state.bufferedRequestCount--; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('_write() is not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} +function callFinal(stream, state) { + stream._final(function (err) { + state.pendingcb--; + if (err) { + stream.emit('error', err); + } + state.prefinished = true; + stream.emit('prefinish'); + finishMaybe(stream, state); + }); +} +function prefinish(stream, state) { + if (!state.prefinished && !state.finalCalled) { + if (typeof stream._final === 'function') { + state.pendingcb++; + state.finalCalled = true; + processNextTick(callFinal, stream, state); + } else { + state.prefinished = true; + stream.emit('prefinish'); + } + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + prefinish(stream, state); + if (state.pendingcb === 0) { + state.finished = true; + stream.emit('finish'); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) processNextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +function onCorkedFinish(corkReq, state, err) { + var entry = corkReq.entry; + corkReq.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = corkReq; + } else { + state.corkedRequestsFree = corkReq; + } +} + +Object.defineProperty(Writable.prototype, 'destroyed', { + get: function () { + if (this._writableState === undefined) { + return false; + } + return this._writableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._writableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._writableState.destroyed = value; + } +}); + +Writable.prototype.destroy = destroyImpl.destroy; +Writable.prototype._undestroy = destroyImpl.undestroy; +Writable.prototype._destroy = function (err, cb) { + this.end(); + cb(err); +}; +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(35), __webpack_require__(80).setImmediate, __webpack_require__(21))) + +/***/ }), +/* 64 */ +/***/ (function(module, exports) { + +module.exports = function(it){ + return typeof it === 'object' ? it !== null : typeof it === 'function'; +}; + +/***/ }), +/* 65 */ +/***/ (function(module, exports, __webpack_require__) { + +// Thank's IE8 for his funny defineProperty +module.exports = !__webpack_require__(86)(function(){ + return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; +}); + +/***/ }), +/* 66 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var external = __webpack_require__(37); +var DataWorker = __webpack_require__(90); +var DataLengthProbe = __webpack_require__(91); +var Crc32Probe = __webpack_require__(92); +var DataLengthProbe = __webpack_require__(91); + +/** + * Represent a compressed object, with everything needed to decompress it. + * @constructor + * @param {number} compressedSize the size of the data compressed. + * @param {number} uncompressedSize the size of the data after decompression. + * @param {number} crc32 the crc32 of the decompressed file. + * @param {object} compression the type of compression, see lib/compressions.js. + * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data. + */ +function CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) { + this.compressedSize = compressedSize; + this.uncompressedSize = uncompressedSize; + this.crc32 = crc32; + this.compression = compression; + this.compressedContent = data; +} + +CompressedObject.prototype = { + /** + * Create a worker to get the uncompressed content. + * @return {GenericWorker} the worker. + */ + getContentWorker : function () { + var worker = new DataWorker(external.Promise.resolve(this.compressedContent)) + .pipe(this.compression.uncompressWorker()) + .pipe(new DataLengthProbe("data_length")); + + var that = this; + worker.on("end", function () { + if(this.streamInfo['data_length'] !== that.uncompressedSize) { + throw new Error("Bug : uncompressed data size mismatch"); + } + }); + return worker; + }, + /** + * Create a worker to get the compressed content. + * @return {GenericWorker} the worker. + */ + getCompressedWorker : function () { + return new DataWorker(external.Promise.resolve(this.compressedContent)) + .withStreamInfo("compressedSize", this.compressedSize) + .withStreamInfo("uncompressedSize", this.uncompressedSize) + .withStreamInfo("crc32", this.crc32) + .withStreamInfo("compression", this.compression) + ; + } +}; + +/** + * Chain the given worker with other workers to compress the content with the + * given compresion. + * @param {GenericWorker} uncompressedWorker the worker to pipe. + * @param {Object} compression the compression object. + * @param {Object} compressionOptions the options to use when compressing. + * @return {GenericWorker} the new worker compressing the content. + */ +CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) { + return uncompressedWorker + .pipe(new Crc32Probe()) + .pipe(new DataLengthProbe("uncompressedSize")) + .pipe(compression.compressWorker(compressionOptions)) + .pipe(new DataLengthProbe("compressedSize")) + .withStreamInfo("compression", compression); +}; + +module.exports = CompressedObject; + + +/***/ }), +/* 67 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(3); + +/** + * The following functions come from pako, from pako/lib/zlib/crc32.js + * released under the MIT license, see pako https://github.com/nodeca/pako/ + */ + +// Use ordinary array, since untyped makes no boost here +function makeTable() { + var c, table = []; + + for(var n =0; n < 256; n++){ + c = n; + for(var k =0; k < 8; k++){ + c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); + } + table[n] = c; + } + + return table; +} + +// Create table on load. Just 255 signed longs. Not a problem. +var crcTable = makeTable(); + + +function crc32(crc, buf, len, pos) { + var t = crcTable, end = pos + len; + + crc = crc ^ (-1); + + for (var i = pos; i < end; i++ ) { + crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; + } + + return (crc ^ (-1)); // >>> 0; +} + +// That's all for the pako functions. + +/** + * Compute the crc32 of a string. + * This is almost the same as the function crc32, but for strings. Using the + * same function for the two use cases leads to horrible performances. + * @param {Number} crc the starting value of the crc. + * @param {String} str the string to use. + * @param {Number} len the length of the string. + * @param {Number} pos the starting position for the crc32 computation. + * @return {Number} the computed crc32. + */ +function crc32str(crc, str, len, pos) { + var t = crcTable, end = pos + len; + + crc = crc ^ (-1); + + for (var i = pos; i < end; i++ ) { + crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF]; + } + + return (crc ^ (-1)); // >>> 0; +} + +module.exports = function crc32wrapper(input, crc) { + if (typeof input === "undefined" || !input.length) { + return 0; + } + + var isArray = utils.getTypeOf(input) !== "string"; + + if(isArray) { + return crc32(crc|0, input, input.length, 0); + } else { + return crc32str(crc|0, input, input.length, 0); + } +}; + + +/***/ }), +/* 68 */ +/***/ (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. + +module.exports = { + 2: 'need dictionary', /* Z_NEED_DICT 2 */ + 1: 'stream end', /* Z_STREAM_END 1 */ + 0: '', /* Z_OK 0 */ + '-1': 'file error', /* Z_ERRNO (-1) */ + '-2': 'stream error', /* Z_STREAM_ERROR (-2) */ + '-3': 'data error', /* Z_DATA_ERROR (-3) */ + '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */ + '-5': 'buffer error', /* Z_BUF_ERROR (-5) */ + '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ +}; + + +/***/ }), +/* 69 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NetscriptPort; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Settings_js__ = __webpack_require__(14); + + +function NetscriptPort() { + this.data = []; +} + +NetscriptPort.prototype.write = function(data) { + this.data.push(data); + if (this.data.length > __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* Settings */].MaxPortCapacity) { + return this.data.shift(); + } + return null; +} + +NetscriptPort.prototype.tryWrite = function(data) { + if (this.data.length >= __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* 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 == __WEBPACK_IMPORTED_MODULE_0__Settings_js__["a" /* Settings */].MaxPortCapacity; +} + +NetscriptPort.prototype.empty = function() { + return this.data.length === 0; +} + +NetscriptPort.prototype.clear = function() { + this.data.length = 0; +} + + + + +/***/ }), +/* 70 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return gameOptionsBoxOpen; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return gameOptionsBoxClose; }); +/* GameOptions.js */ + +//Close box when clicking outside +$(document).click(function(event) { + if (gameOptionsOpened) { + if ( $(event.target).closest(".game-options-box").get(0) == null ) { + gameOptionsBoxClose(); + } + } +}); + +var gameOptionsOpened = false; +function gameOptionsBoxInit() { + //Menu link button + document.getElementById("options-menu-link").addEventListener("click", function() { + gameOptionsBoxOpen(); + return false; + }); + + //Close button + var closeButton = document.getElementById("game-options-close-button"); + closeButton.addEventListener("click", function() { + gameOptionsBoxClose(); + return false; + }); +}; + +document.addEventListener("DOMContentLoaded", gameOptionsBoxInit, false); + +function gameOptionsBoxClose() { + gameOptionsOpened = false; + var box = document.getElementById("game-options-container"); + box.style.display = "none"; +} + +function gameOptionsBoxOpen() { + var box = document.getElementById("game-options-container"); + box.style.display = "block"; + setTimeout(function() { + gameOptionsOpened = true; + }, 500); + +} + + + +/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(11))) + +/***/ }), +/* 71 */ +/***/ (function(module, exports) { + +module.exports.id = 'ace/mode/javascript_worker'; +module.exports.src = "\"no use strict\";!function(window){function resolveModuleId(id,paths){for(var testPath=id,tail=\"\";testPath;){var alias=paths[testPath];if(\"string\"==typeof alias)return alias+tail;if(alias)return alias.location.replace(/\\/*$/,\"/\")+(tail||alias.main||alias.name);if(alias===!1)return\"\";var i=testPath.lastIndexOf(\"/\");if(-1===i)break;tail=testPath.substr(i)+tail,testPath=testPath.slice(0,i)}return id}if(!(void 0!==window.window&&window.document||window.acequire&&window.define)){window.console||(window.console=function(){var msgs=Array.prototype.slice.call(arguments,0);postMessage({type:\"log\",data:msgs})},window.console.error=window.console.warn=window.console.log=window.console.trace=window.console),window.window=window,window.ace=window,window.onerror=function(message,file,line,col,err){postMessage({type:\"error\",data:{message:message,data:err.data,file:file,line:line,col:col,stack:err.stack}})},window.normalizeModule=function(parentId,moduleName){if(-1!==moduleName.indexOf(\"!\")){var chunks=moduleName.split(\"!\");return window.normalizeModule(parentId,chunks[0])+\"!\"+window.normalizeModule(parentId,chunks[1])}if(\".\"==moduleName.charAt(0)){var base=parentId.split(\"/\").slice(0,-1).join(\"/\");for(moduleName=(base?base+\"/\":\"\")+moduleName;-1!==moduleName.indexOf(\".\")&&previous!=moduleName;){var previous=moduleName;moduleName=moduleName.replace(/^\\.\\//,\"\").replace(/\\/\\.\\//,\"/\").replace(/[^\\/]+\\/\\.\\.\\//,\"\")}}return moduleName},window.acequire=function acequire(parentId,id){if(id||(id=parentId,parentId=null),!id.charAt)throw Error(\"worker.js acequire() accepts only (parentId, id) as arguments\");id=window.normalizeModule(parentId,id);var module=window.acequire.modules[id];if(module)return module.initialized||(module.initialized=!0,module.exports=module.factory().exports),module.exports;if(!window.acequire.tlns)return console.log(\"unable to load \"+id);var path=resolveModuleId(id,window.acequire.tlns);return\".js\"!=path.slice(-3)&&(path+=\".js\"),window.acequire.id=id,window.acequire.modules[id]={},importScripts(path),window.acequire(parentId,id)},window.acequire.modules={},window.acequire.tlns={},window.define=function(id,deps,factory){if(2==arguments.length?(factory=deps,\"string\"!=typeof id&&(deps=id,id=window.acequire.id)):1==arguments.length&&(factory=id,deps=[],id=window.acequire.id),\"function\"!=typeof factory)return window.acequire.modules[id]={exports:factory,initialized:!0},void 0;deps.length||(deps=[\"require\",\"exports\",\"module\"]);var req=function(childId){return window.acequire(id,childId)};window.acequire.modules[id]={exports:{},factory:function(){var module=this,returnExports=factory.apply(this,deps.map(function(dep){switch(dep){case\"require\":return req;case\"exports\":return module.exports;case\"module\":return module;default:return req(dep)}}));return returnExports&&(module.exports=returnExports),module}}},window.define.amd={},acequire.tlns={},window.initBaseUrls=function(topLevelNamespaces){for(var i in topLevelNamespaces)acequire.tlns[i]=topLevelNamespaces[i]},window.initSender=function(){var EventEmitter=window.acequire(\"ace/lib/event_emitter\").EventEmitter,oop=window.acequire(\"ace/lib/oop\"),Sender=function(){};return function(){oop.implement(this,EventEmitter),this.callback=function(data,callbackId){postMessage({type:\"call\",id:callbackId,data:data})},this.emit=function(name,data){postMessage({type:\"event\",name:name,data:data})}}.call(Sender.prototype),new Sender};var main=window.main=null,sender=window.sender=null;window.onmessage=function(e){var msg=e.data;if(msg.event&&sender)sender._signal(msg.event,msg.data);else if(msg.command)if(main[msg.command])main[msg.command].apply(main,msg.args);else{if(!window[msg.command])throw Error(\"Unknown command:\"+msg.command);window[msg.command].apply(window,msg.args)}else if(msg.init){window.initBaseUrls(msg.tlns),acequire(\"ace/lib/es5-shim\"),sender=window.sender=window.initSender();var clazz=acequire(msg.module)[msg.classname];main=window.main=new clazz(sender)}}}}(this),ace.define(\"ace/lib/oop\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.inherits=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})},exports.mixin=function(obj,mixin){for(var key in mixin)obj[key]=mixin[key];return obj},exports.implement=function(proto,mixin){exports.mixin(proto,mixin)}}),ace.define(\"ace/range\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},Range=function(startRow,startColumn,endRow,endColumn){this.start={row:startRow,column:startColumn},this.end={row:endRow,column:endColumn}};(function(){this.isEqual=function(range){return this.start.row===range.start.row&&this.end.row===range.end.row&&this.start.column===range.start.column&&this.end.column===range.end.column},this.toString=function(){return\"Range: [\"+this.start.row+\"/\"+this.start.column+\"] -> [\"+this.end.row+\"/\"+this.end.column+\"]\"},this.contains=function(row,column){return 0==this.compare(row,column)},this.compareRange=function(range){var cmp,end=range.end,start=range.start;return cmp=this.compare(end.row,end.column),1==cmp?(cmp=this.compare(start.row,start.column),1==cmp?2:0==cmp?1:0):-1==cmp?-2:(cmp=this.compare(start.row,start.column),-1==cmp?-1:1==cmp?42:0)},this.comparePoint=function(p){return this.compare(p.row,p.column)},this.containsRange=function(range){return 0==this.comparePoint(range.start)&&0==this.comparePoint(range.end)},this.intersects=function(range){var cmp=this.compareRange(range);return-1==cmp||0==cmp||1==cmp},this.isEnd=function(row,column){return this.end.row==row&&this.end.column==column},this.isStart=function(row,column){return this.start.row==row&&this.start.column==column},this.setStart=function(row,column){\"object\"==typeof row?(this.start.column=row.column,this.start.row=row.row):(this.start.row=row,this.start.column=column)},this.setEnd=function(row,column){\"object\"==typeof row?(this.end.column=row.column,this.end.row=row.row):(this.end.row=row,this.end.column=column)},this.inside=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)||this.isStart(row,column)?!1:!0:!1},this.insideStart=function(row,column){return 0==this.compare(row,column)?this.isEnd(row,column)?!1:!0:!1},this.insideEnd=function(row,column){return 0==this.compare(row,column)?this.isStart(row,column)?!1:!0:!1},this.compare=function(row,column){return this.isMultiLine()||row!==this.start.row?this.start.row>row?-1:row>this.end.row?1:this.start.row===row?column>=this.start.column?0:-1:this.end.row===row?this.end.column>=column?0:1:0:this.start.column>column?-1:column>this.end.column?1:0},this.compareStart=function(row,column){return this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.compareEnd=function(row,column){return this.end.row==row&&this.end.column==column?1:this.compare(row,column)},this.compareInside=function(row,column){return this.end.row==row&&this.end.column==column?1:this.start.row==row&&this.start.column==column?-1:this.compare(row,column)},this.clipRows=function(firstRow,lastRow){if(this.end.row>lastRow)var end={row:lastRow+1,column:0};else if(firstRow>this.end.row)var end={row:firstRow,column:0};if(this.start.row>lastRow)var start={row:lastRow+1,column:0};else if(firstRow>this.start.row)var start={row:firstRow,column:0};return Range.fromPoints(start||this.start,end||this.end)},this.extend=function(row,column){var cmp=this.compare(row,column);if(0==cmp)return this;if(-1==cmp)var start={row:row,column:column};else var end={row:row,column:column};return Range.fromPoints(start||this.start,end||this.end)},this.isEmpty=function(){return this.start.row===this.end.row&&this.start.column===this.end.column},this.isMultiLine=function(){return this.start.row!==this.end.row},this.clone=function(){return Range.fromPoints(this.start,this.end)},this.collapseRows=function(){return 0==this.end.column?new Range(this.start.row,0,Math.max(this.start.row,this.end.row-1),0):new Range(this.start.row,0,this.end.row,0)},this.toScreenRange=function(session){var screenPosStart=session.documentToScreenPosition(this.start),screenPosEnd=session.documentToScreenPosition(this.end);return new Range(screenPosStart.row,screenPosStart.column,screenPosEnd.row,screenPosEnd.column)},this.moveBy=function(row,column){this.start.row+=row,this.start.column+=column,this.end.row+=row,this.end.column+=column}}).call(Range.prototype),Range.fromPoints=function(start,end){return new Range(start.row,start.column,end.row,end.column)},Range.comparePoints=comparePoints,Range.comparePoints=function(p1,p2){return p1.row-p2.row||p1.column-p2.column},exports.Range=Range}),ace.define(\"ace/apply_delta\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.applyDelta=function(docLines,delta){var row=delta.start.row,startColumn=delta.start.column,line=docLines[row]||\"\";switch(delta.action){case\"insert\":var lines=delta.lines;if(1===lines.length)docLines[row]=line.substring(0,startColumn)+delta.lines[0]+line.substring(startColumn);else{var args=[row,1].concat(delta.lines);docLines.splice.apply(docLines,args),docLines[row]=line.substring(0,startColumn)+docLines[row],docLines[row+delta.lines.length-1]+=line.substring(startColumn)}break;case\"remove\":var endColumn=delta.end.column,endRow=delta.end.row;row===endRow?docLines[row]=line.substring(0,startColumn)+line.substring(endColumn):docLines.splice(row,endRow-row+1,line.substring(0,startColumn)+docLines[endRow].substring(endColumn))}}}),ace.define(\"ace/lib/event_emitter\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";var EventEmitter={},stopPropagation=function(){this.propagationStopped=!0},preventDefault=function(){this.defaultPrevented=!0};EventEmitter._emit=EventEmitter._dispatchEvent=function(eventName,e){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var listeners=this._eventRegistry[eventName]||[],defaultHandler=this._defaultHandlers[eventName];if(listeners.length||defaultHandler){\"object\"==typeof e&&e||(e={}),e.type||(e.type=eventName),e.stopPropagation||(e.stopPropagation=stopPropagation),e.preventDefault||(e.preventDefault=preventDefault),listeners=listeners.slice();for(var i=0;listeners.length>i&&(listeners[i](e,this),!e.propagationStopped);i++);return defaultHandler&&!e.defaultPrevented?defaultHandler(e,this):void 0}},EventEmitter._signal=function(eventName,e){var listeners=(this._eventRegistry||{})[eventName];if(listeners){listeners=listeners.slice();for(var i=0;listeners.length>i;i++)listeners[i](e,this)}},EventEmitter.once=function(eventName,callback){var _self=this;callback&&this.addEventListener(eventName,function newCallback(){_self.removeEventListener(eventName,newCallback),callback.apply(null,arguments)})},EventEmitter.setDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers||(handlers=this._defaultHandlers={_disabled_:{}}),handlers[eventName]){var old=handlers[eventName],disabled=handlers._disabled_[eventName];disabled||(handlers._disabled_[eventName]=disabled=[]),disabled.push(old);var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}handlers[eventName]=callback},EventEmitter.removeDefaultHandler=function(eventName,callback){var handlers=this._defaultHandlers;if(handlers){var disabled=handlers._disabled_[eventName];if(handlers[eventName]==callback)handlers[eventName],disabled&&this.setDefaultHandler(eventName,disabled.pop());else if(disabled){var i=disabled.indexOf(callback);-1!=i&&disabled.splice(i,1)}}},EventEmitter.on=EventEmitter.addEventListener=function(eventName,callback,capturing){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];return listeners||(listeners=this._eventRegistry[eventName]=[]),-1==listeners.indexOf(callback)&&listeners[capturing?\"unshift\":\"push\"](callback),callback},EventEmitter.off=EventEmitter.removeListener=EventEmitter.removeEventListener=function(eventName,callback){this._eventRegistry=this._eventRegistry||{};var listeners=this._eventRegistry[eventName];if(listeners){var index=listeners.indexOf(callback);-1!==index&&listeners.splice(index,1)}},EventEmitter.removeAllListeners=function(eventName){this._eventRegistry&&(this._eventRegistry[eventName]=[])},exports.EventEmitter=EventEmitter}),ace.define(\"ace/anchor\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/lib/event_emitter\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Anchor=exports.Anchor=function(doc,row,column){this.$onChange=this.onChange.bind(this),this.attach(doc),column===void 0?this.setPosition(row.row,row.column):this.setPosition(row,column)};(function(){function $pointsInOrder(point1,point2,equalPointsInOrder){var bColIsAfter=equalPointsInOrder?point1.column<=point2.column:point1.columnthis.row)){var point=$getTransformedPoint(delta,{row:this.row,column:this.column},this.$insertRight);this.setPosition(point.row,point.column,!0)}},this.setPosition=function(row,column,noClip){var pos;if(pos=noClip?{row:row,column:column}:this.$clipPositionToDocument(row,column),this.row!=pos.row||this.column!=pos.column){var old={row:this.row,column:this.column};this.row=pos.row,this.column=pos.column,this._signal(\"change\",{old:old,value:pos})}},this.detach=function(){this.document.removeEventListener(\"change\",this.$onChange)},this.attach=function(doc){this.document=doc||this.document,this.document.on(\"change\",this.$onChange)},this.$clipPositionToDocument=function(row,column){var pos={};return row>=this.document.getLength()?(pos.row=Math.max(0,this.document.getLength()-1),pos.column=this.document.getLine(pos.row).length):0>row?(pos.row=0,pos.column=0):(pos.row=row,pos.column=Math.min(this.document.getLine(pos.row).length,Math.max(0,column))),0>column&&(pos.column=0),pos}}).call(Anchor.prototype)}),ace.define(\"ace/document\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/apply_delta\",\"ace/lib/event_emitter\",\"ace/range\",\"ace/anchor\"],function(acequire,exports){\"use strict\";var oop=acequire(\"./lib/oop\"),applyDelta=acequire(\"./apply_delta\").applyDelta,EventEmitter=acequire(\"./lib/event_emitter\").EventEmitter,Range=acequire(\"./range\").Range,Anchor=acequire(\"./anchor\").Anchor,Document=function(textOrLines){this.$lines=[\"\"],0===textOrLines.length?this.$lines=[\"\"]:Array.isArray(textOrLines)?this.insertMergedLines({row:0,column:0},textOrLines):this.insert({row:0,column:0},textOrLines)};(function(){oop.implement(this,EventEmitter),this.setValue=function(text){var len=this.getLength()-1;this.remove(new Range(0,0,len,this.getLine(len).length)),this.insert({row:0,column:0},text)},this.getValue=function(){return this.getAllLines().join(this.getNewLineCharacter())},this.createAnchor=function(row,column){return new Anchor(this,row,column)},this.$split=0===\"aaa\".split(/a/).length?function(text){return text.replace(/\\r\\n|\\r/g,\"\\n\").split(\"\\n\")}:function(text){return text.split(/\\r\\n|\\r|\\n/)},this.$detectNewLine=function(text){var match=text.match(/^.*?(\\r\\n|\\r|\\n)/m);this.$autoNewLine=match?match[1]:\"\\n\",this._signal(\"changeNewLineMode\")},this.getNewLineCharacter=function(){switch(this.$newLineMode){case\"windows\":return\"\\r\\n\";case\"unix\":return\"\\n\";default:return this.$autoNewLine||\"\\n\"}},this.$autoNewLine=\"\",this.$newLineMode=\"auto\",this.setNewLineMode=function(newLineMode){this.$newLineMode!==newLineMode&&(this.$newLineMode=newLineMode,this._signal(\"changeNewLineMode\"))},this.getNewLineMode=function(){return this.$newLineMode},this.isNewLine=function(text){return\"\\r\\n\"==text||\"\\r\"==text||\"\\n\"==text},this.getLine=function(row){return this.$lines[row]||\"\"},this.getLines=function(firstRow,lastRow){return this.$lines.slice(firstRow,lastRow+1)},this.getAllLines=function(){return this.getLines(0,this.getLength())},this.getLength=function(){return this.$lines.length},this.getTextRange=function(range){return this.getLinesForRange(range).join(this.getNewLineCharacter())},this.getLinesForRange=function(range){var lines;if(range.start.row===range.end.row)lines=[this.getLine(range.start.row).substring(range.start.column,range.end.column)];else{lines=this.getLines(range.start.row,range.end.row),lines[0]=(lines[0]||\"\").substring(range.start.column);var l=lines.length-1;range.end.row-range.start.row==l&&(lines[l]=lines[l].substring(0,range.end.column))}return lines},this.insertLines=function(row,lines){return console.warn(\"Use of document.insertLines is deprecated. Use the insertFullLines method instead.\"),this.insertFullLines(row,lines)},this.removeLines=function(firstRow,lastRow){return console.warn(\"Use of document.removeLines is deprecated. Use the removeFullLines method instead.\"),this.removeFullLines(firstRow,lastRow)},this.insertNewLine=function(position){return console.warn(\"Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.\"),this.insertMergedLines(position,[\"\",\"\"])},this.insert=function(position,text){return 1>=this.getLength()&&this.$detectNewLine(text),this.insertMergedLines(position,this.$split(text))},this.insertInLine=function(position,text){var start=this.clippedPos(position.row,position.column),end=this.pos(position.row,position.column+text.length);return this.applyDelta({start:start,end:end,action:\"insert\",lines:[text]},!0),this.clonePos(end)},this.clippedPos=function(row,column){var length=this.getLength();void 0===row?row=length:0>row?row=0:row>=length&&(row=length-1,column=void 0);var line=this.getLine(row);return void 0==column&&(column=line.length),column=Math.min(Math.max(column,0),line.length),{row:row,column:column}},this.clonePos=function(pos){return{row:pos.row,column:pos.column}},this.pos=function(row,column){return{row:row,column:column}},this.$clipPosition=function(position){var length=this.getLength();return position.row>=length?(position.row=Math.max(0,length-1),position.column=this.getLine(length-1).length):(position.row=Math.max(0,position.row),position.column=Math.min(Math.max(position.column,0),this.getLine(position.row).length)),position},this.insertFullLines=function(row,lines){row=Math.min(Math.max(row,0),this.getLength());var column=0;this.getLength()>row?(lines=lines.concat([\"\"]),column=0):(lines=[\"\"].concat(lines),row--,column=this.$lines[row].length),this.insertMergedLines({row:row,column:column},lines)},this.insertMergedLines=function(position,lines){var start=this.clippedPos(position.row,position.column),end={row:start.row+lines.length-1,column:(1==lines.length?start.column:0)+lines[lines.length-1].length};return this.applyDelta({start:start,end:end,action:\"insert\",lines:lines}),this.clonePos(end)},this.remove=function(range){var start=this.clippedPos(range.start.row,range.start.column),end=this.clippedPos(range.end.row,range.end.column);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})}),this.clonePos(start)},this.removeInLine=function(row,startColumn,endColumn){var start=this.clippedPos(row,startColumn),end=this.clippedPos(row,endColumn);return this.applyDelta({start:start,end:end,action:\"remove\",lines:this.getLinesForRange({start:start,end:end})},!0),this.clonePos(start)},this.removeFullLines=function(firstRow,lastRow){firstRow=Math.min(Math.max(0,firstRow),this.getLength()-1),lastRow=Math.min(Math.max(0,lastRow),this.getLength()-1);var deleteFirstNewLine=lastRow==this.getLength()-1&&firstRow>0,deleteLastNewLine=this.getLength()-1>lastRow,startRow=deleteFirstNewLine?firstRow-1:firstRow,startCol=deleteFirstNewLine?this.getLine(startRow).length:0,endRow=deleteLastNewLine?lastRow+1:lastRow,endCol=deleteLastNewLine?0:this.getLine(endRow).length,range=new Range(startRow,startCol,endRow,endCol),deletedLines=this.$lines.slice(firstRow,lastRow+1);return this.applyDelta({start:range.start,end:range.end,action:\"remove\",lines:this.getLinesForRange(range)}),deletedLines},this.removeNewLine=function(row){this.getLength()-1>row&&row>=0&&this.applyDelta({start:this.pos(row,this.getLine(row).length),end:this.pos(row+1,0),action:\"remove\",lines:[\"\",\"\"]})},this.replace=function(range,text){if(range instanceof Range||(range=Range.fromPoints(range.start,range.end)),0===text.length&&range.isEmpty())return range.start;if(text==this.getTextRange(range))return range.end;this.remove(range);var end;return end=text?this.insert(range.start,text):range.start},this.applyDeltas=function(deltas){for(var i=0;deltas.length>i;i++)this.applyDelta(deltas[i])},this.revertDeltas=function(deltas){for(var i=deltas.length-1;i>=0;i--)this.revertDelta(deltas[i])},this.applyDelta=function(delta,doNotValidate){var isInsert=\"insert\"==delta.action;(isInsert?1>=delta.lines.length&&!delta.lines[0]:!Range.comparePoints(delta.start,delta.end))||(isInsert&&delta.lines.length>2e4&&this.$splitAndapplyLargeDelta(delta,2e4),applyDelta(this.$lines,delta,doNotValidate),this._signal(\"change\",delta))},this.$splitAndapplyLargeDelta=function(delta,MAX){for(var lines=delta.lines,l=lines.length,row=delta.start.row,column=delta.start.column,from=0,to=0;;){from=to,to+=MAX-1;var chunk=lines.slice(from,to);if(to>l){delta.lines=chunk,delta.start.row=row+from,delta.start.column=column;break}chunk.push(\"\"),this.applyDelta({start:this.pos(row+from,column),end:this.pos(row+to,column=0),action:delta.action,lines:chunk},!0)}},this.revertDelta=function(delta){this.applyDelta({start:this.clonePos(delta.start),end:this.clonePos(delta.end),action:\"insert\"==delta.action?\"remove\":\"insert\",lines:delta.lines.slice()})},this.indexToPosition=function(index,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,i=startRow||0,l=lines.length;l>i;i++)if(index-=lines[i].length+newlineLength,0>index)return{row:i,column:index+lines[i].length+newlineLength};return{row:l-1,column:lines[l-1].length}},this.positionToIndex=function(pos,startRow){for(var lines=this.$lines||this.getAllLines(),newlineLength=this.getNewLineCharacter().length,index=0,row=Math.min(pos.row,lines.length),i=startRow||0;row>i;++i)index+=lines[i].length+newlineLength;return index+pos.column}}).call(Document.prototype),exports.Document=Document}),ace.define(\"ace/lib/lang\",[\"require\",\"exports\",\"module\"],function(acequire,exports){\"use strict\";exports.last=function(a){return a[a.length-1]},exports.stringReverse=function(string){return string.split(\"\").reverse().join(\"\")},exports.stringRepeat=function(string,count){for(var result=\"\";count>0;)1&count&&(result+=string),(count>>=1)&&(string+=string);return result};var trimBeginRegexp=/^\\s\\s*/,trimEndRegexp=/\\s\\s*$/;exports.stringTrimLeft=function(string){return string.replace(trimBeginRegexp,\"\")},exports.stringTrimRight=function(string){return string.replace(trimEndRegexp,\"\")},exports.copyObject=function(obj){var copy={};for(var key in obj)copy[key]=obj[key];return copy},exports.copyArray=function(array){for(var copy=[],i=0,l=array.length;l>i;i++)copy[i]=array[i]&&\"object\"==typeof array[i]?this.copyObject(array[i]):array[i];return copy},exports.deepCopy=function deepCopy(obj){if(\"object\"!=typeof obj||!obj)return obj;var copy;if(Array.isArray(obj)){copy=[];for(var key=0;obj.length>key;key++)copy[key]=deepCopy(obj[key]);return copy}if(\"[object Object]\"!==Object.prototype.toString.call(obj))return obj;copy={};for(var key in obj)copy[key]=deepCopy(obj[key]);return copy},exports.arrayToMap=function(arr){for(var map={},i=0;arr.length>i;i++)map[arr[i]]=1;return map},exports.createMap=function(props){var map=Object.create(null);for(var i in props)map[i]=props[i];return map},exports.arrayRemove=function(array,value){for(var i=0;array.length>=i;i++)value===array[i]&&array.splice(i,1)},exports.escapeRegExp=function(str){return str.replace(/([.*+?^${}()|[\\]\\/\\\\])/g,\"\\\\$1\")},exports.escapeHTML=function(str){return str.replace(/&/g,\"&\").replace(/\"/g,\""\").replace(/'/g,\"'\").replace(/i;i+=2){if(Array.isArray(data[i+1]))var d={action:\"insert\",start:data[i],lines:data[i+1]};else var d={action:\"remove\",start:data[i],end:data[i+1]};doc.applyDelta(d,!0)}return _self.$timeout?deferredUpdate.schedule(_self.$timeout):(_self.onUpdate(),void 0)})};(function(){this.$timeout=500,this.setTimeout=function(timeout){this.$timeout=timeout},this.setValue=function(value){this.doc.setValue(value),this.deferredUpdate.schedule(this.$timeout)},this.getValue=function(callbackId){this.sender.callback(this.doc.getValue(),callbackId)},this.onUpdate=function(){},this.isPending=function(){return this.deferredUpdate.isPending()}}).call(Mirror.prototype)}),ace.define(\"ace/mode/javascript/jshint\",[\"require\",\"exports\",\"module\"],function(acequire,exports,module){module.exports=function outer(modules,cache,entry){function newRequire(name,jumped){if(!cache[name]){if(!modules[name]){var currentRequire=\"function\"==typeof acequire&&acequire;if(!jumped&¤tRequire)return currentRequire(name,!0);if(previousRequire)return previousRequire(name,!0);var err=Error(\"Cannot find module '\"+name+\"'\");throw err.code=\"MODULE_NOT_FOUND\",err}var m=cache[name]={exports:{}};modules[name][0].call(m.exports,function(x){var id=modules[name][1][x];return newRequire(id?id:x)},m,m.exports,outer,modules,cache,entry)}return cache[name].exports}for(var previousRequire=\"function\"==typeof acequire&&acequire,i=0;entry.length>i;i++)newRequire(entry[i]);return newRequire(entry[0])}({\"/node_modules/browserify/node_modules/events/events.js\":[function(_dereq_,module){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return\"function\"==typeof arg}function isNumber(arg){return\"number\"==typeof arg}function isObject(arg){return\"object\"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||0>n||isNaN(n))throw TypeError(\"n must be a positive number\");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),\"error\"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(er=arguments[1],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified \"error\" event.')}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];handler.apply(this,args)}else if(isObject(handler)){for(len=arguments.length,args=Array(len-1),i=1;len>i;i++)args[i-1]=arguments[i];for(listeners=handler.slice(),len=listeners.length,i=0;len>i;i++)listeners[i].apply(this,args)}return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(this._events||(this._events={}),this._events.newListener&&this.emit(\"newListener\",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned){var m;m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error(\"(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.\",this._events[type].length),\"function\"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError(\"listener must be a function\");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError(\"listener must be a function\");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit(\"removeListener\",type,listener);else if(isObject(list)){for(i=length;i-->0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit(\"removeListener\",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)\"removeListener\"!==key&&this.removeAllListeners(key);return this.removeAllListeners(\"removeListener\"),this._events={},this\n}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.listenerCount=function(emitter,type){var ret;return ret=emitter._events&&emitter._events[type]?isFunction(emitter._events[type])?1:emitter._events[type].length:0}},{}],\"/node_modules/jshint/data/ascii-identifier-data.js\":[function(_dereq_,module){for(var identifierStartTable=[],i=0;128>i;i++)identifierStartTable[i]=36===i||i>=65&&90>=i||95===i||i>=97&&122>=i;for(var identifierPartTable=[],i=0;128>i;i++)identifierPartTable[i]=identifierStartTable[i]||i>=48&&57>=i;module.exports={asciiIdentifierStartTable:identifierStartTable,asciiIdentifierPartTable:identifierPartTable}},{}],\"/node_modules/jshint/lodash.js\":[function(_dereq_,module,exports){(function(global){(function(){function baseFindIndex(array,predicate,fromRight){for(var length=array.length,index=fromRight?length:-1;fromRight?index--:length>++index;)if(predicate(array[index],index,array))return index;return-1}function baseIndexOf(array,value,fromIndex){if(value!==value)return indexOfNaN(array,fromIndex);for(var index=fromIndex-1,length=array.length;length>++index;)if(array[index]===value)return index;return-1}function baseIsFunction(value){return\"function\"==typeof value||!1}function baseToString(value){return\"string\"==typeof value?value:null==value?\"\":value+\"\"}function indexOfNaN(array,fromIndex,fromRight){for(var length=array.length,index=fromIndex+(fromRight?0:-1);fromRight?index--:length>++index;){var other=array[index];if(other!==other)return index}return-1}function isObjectLike(value){return!!value&&\"object\"==typeof value}function lodash(){}function arrayCopy(source,array){var index=-1,length=source.length;for(array||(array=Array(length));length>++index;)array[index]=source[index];return array}function arrayEach(array,iteratee){for(var index=-1,length=array.length;length>++index&&iteratee(array[index],index,array)!==!1;);return array}function arrayFilter(array,predicate){for(var index=-1,length=array.length,resIndex=-1,result=[];length>++index;){var value=array[index];predicate(value,index,array)&&(result[++resIndex]=value)}return result}function arrayMap(array,iteratee){for(var index=-1,length=array.length,result=Array(length);length>++index;)result[index]=iteratee(array[index],index,array);return result}function arrayMax(array){for(var index=-1,length=array.length,result=NEGATIVE_INFINITY;length>++index;){var value=array[index];value>result&&(result=value)}return result}function arraySome(array,predicate){for(var index=-1,length=array.length;length>++index;)if(predicate(array[index],index,array))return!0;return!1}function assignWith(object,source,customizer){var props=keys(source);push.apply(props,getSymbols(source));for(var index=-1,length=props.length;length>++index;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(value!==undefined||key in object)||(object[key]=result)}return object}function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;length>++index;){var key=props[index];object[key]=source[key]}return object}function baseCallback(func,thisArg,argCount){var type=typeof func;return\"function\"==type?thisArg===undefined?func:bindCallback(func,thisArg,argCount):null==func?identity:\"object\"==type?baseMatches(func):thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseClone(value,isDeep,customizer,key,object,stackA,stackB){var result;if(customizer&&(result=object?customizer(value,key,object):customizer(value)),result!==undefined)return result;if(!isObject(value))return value;var isArr=isArray(value);if(isArr){if(result=initCloneArray(value),!isDeep)return arrayCopy(value,result)}else{var tag=objToString.call(value),isFunc=tag==funcTag;if(tag!=objectTag&&tag!=argsTag&&(!isFunc||object))return cloneableTags[tag]?initCloneByTag(value,tag,isDeep):object?value:{};if(result=initCloneObject(isFunc?{}:value),!isDeep)return baseAssign(result,value)}stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==value)return stackB[length];return stackA.push(value),stackB.push(result),(isArr?arrayEach:baseForOwn)(value,function(subValue,key){result[key]=baseClone(subValue,isDeep,customizer,key,value,stackA,stackB)}),result}function baseFilter(collection,predicate){var result=[];return baseEach(collection,function(value,index,collection){predicate(value,index,collection)&&result.push(value)}),result}function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseGet(object,path,pathKey){if(null!=object){pathKey!==undefined&&pathKey in toObject(object)&&(path=[pathKey]);for(var index=-1,length=path.length;null!=object&&length>++index;)var result=object=object[path[index]];return result}}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other)return 0!==value||1/value==1/other;var valType=typeof value,othType=typeof other;return\"function\"!=valType&&\"object\"!=valType&&\"function\"!=othType&&\"object\"!=othType||null==value||null==other?value!==value&&other!==other:baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;objIsArr||(objTag=objToString.call(object),objTag==argsTag?objTag=objectTag:objTag!=objectTag&&(objIsArr=isTypedArray(object))),othIsArr||(othTag=objToString.call(other),othTag==argsTag?othTag=objectTag:othTag!=objectTag&&(othIsArr=isTypedArray(other)));var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!objIsArr&&!objIsObj)return equalByTag(object,other,objTag);if(!isLoose){var valWrapped=objIsObj&&hasOwnProperty.call(object,\"__wrapped__\"),othWrapped=othIsObj&&hasOwnProperty.call(other,\"__wrapped__\");if(valWrapped||othWrapped)return equalFunc(valWrapped?object.value():object,othWrapped?other.value():other,customizer,isLoose,stackA,stackB)}if(!isSameTag)return!1;stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==object)return stackB[length]==other;stackA.push(object),stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);return stackA.pop(),stackB.pop(),result}function baseIsMatch(object,props,values,strictCompareFlags,customizer){for(var index=-1,length=props.length,noCustomizer=!customizer;length>++index;)if(noCustomizer&&strictCompareFlags[index]?values[index]!==object[props[index]]:!(props[index]in object))return!1;for(index=-1;length>++index;){var key=props[index],objValue=object[key],srcValue=values[index];if(noCustomizer&&strictCompareFlags[index])var result=objValue!==undefined||key in object;else result=customizer?customizer(objValue,srcValue,key):undefined,result===undefined&&(result=baseIsEqual(srcValue,objValue,customizer,!0));if(!result)return!1}return!0}function baseMatches(source){var props=keys(source),length=props.length;if(!length)return constant(!0);if(1==length){var key=props[0],value=source[key];if(isStrictComparable(value))return function(object){return null==object?!1:object[key]===value&&(value!==undefined||key in toObject(object))}}for(var values=Array(length),strictCompareFlags=Array(length);length--;)value=source[props[length]],values[length]=value,strictCompareFlags[length]=isStrictComparable(value);return function(object){return null!=object&&baseIsMatch(toObject(object),props,values,strictCompareFlags)}}function baseMatchesProperty(path,value){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(value),pathKey=path+\"\";return path=toPath(path),function(object){if(null==object)return!1;var key=pathKey;if(object=toObject(object),!(!isArr&&isCommon||key in object)){if(object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),null==object)return!1;key=last(path),object=toObject(object)}return object[key]===value?value!==undefined||key in object:baseIsEqual(value,object[key],null,!0)}}function baseMerge(object,source,customizer,stackA,stackB){if(!isObject(object))return object;var isSrcArr=isLength(source.length)&&(isArray(source)||isTypedArray(source));if(!isSrcArr){var props=keys(source);push.apply(props,getSymbols(source))}return arrayEach(props||source,function(srcValue,key){if(props&&(key=srcValue,srcValue=source[key]),isObjectLike(srcValue))stackA||(stackA=[]),stackB||(stackB=[]),baseMergeDeep(object,source,key,baseMerge,customizer,stackA,stackB);else{var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue),!isSrcArr&&result===undefined||!isCommon&&(result===result?result===value:value!==value)||(object[key]=result)}}),object}function baseMergeDeep(object,source,key,mergeFunc,customizer,stackA,stackB){for(var length=stackA.length,srcValue=source[key];length--;)if(stackA[length]==srcValue)return object[key]=stackB[length],undefined;var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue,isLength(srcValue.length)&&(isArray(srcValue)||isTypedArray(srcValue))?result=isArray(value)?value:getLength(value)?arrayCopy(value):[]:isPlainObject(srcValue)||isArguments(srcValue)?result=isArguments(value)?toPlainObject(value):isPlainObject(value)?value:{}:isCommon=!1),stackA.push(srcValue),stackB.push(result),isCommon?object[key]=mergeFunc(result,srcValue,customizer,stackA,stackB):(result===result?result!==value:value===value)&&(object[key]=result)}function baseProperty(key){return function(object){return null==object?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+\"\";return path=toPath(path),function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=null==start?0:+start||0,0>start&&(start=-start>length?0:length+start),end=end===undefined||end>length?length:+end||0,0>end&&(end+=length),length=start>end?0:end-start>>>0,start>>>=0;for(var result=Array(length);length>++index;)result[index]=array[index+start];return result}function baseSome(collection,predicate){var result;return baseEach(collection,function(value,index,collection){return result=predicate(value,index,collection),!result}),!!result}function baseValues(object,props){for(var index=-1,length=props.length,result=Array(length);length>++index;)result[index]=object[props[index]];return result}function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(\"number\"==typeof value&&value===value&&HALF_MAX_ARRAY_LENGTH>=high){for(;high>low;){var mid=low+high>>>1,computed=array[mid];(retHighest?value>=computed:value>computed)?low=mid+1:high=mid}return high}return binaryIndexBy(array,value,identity,retHighest)}function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);for(var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsUndef=value===undefined;high>low;){var mid=floor((low+high)/2),computed=iteratee(array[mid]),isReflexive=computed===computed;if(valIsNaN)var setLow=isReflexive||retHighest;else setLow=valIsUndef?isReflexive&&(retHighest||computed!==undefined):retHighest?value>=computed:value>computed;setLow?low=mid+1:high=mid}return nativeMin(high,MAX_ARRAY_INDEX)}function bindCallback(func,thisArg,argCount){if(\"function\"!=typeof func)return identity;if(thisArg===undefined)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function bufferClone(buffer){return bufferSlice.call(buffer,0)}function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2&&sources[length-2],guard=length>2&&sources[2],thisArg=length>1&&sources[length-1];for(\"function\"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer=\"function\"==typeof thisArg?thisArg:null,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?null:customizer,length=1);length>++index;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length))return eachFunc(collection,iteratee);for(var index=fromRight?length:-1,iterable=toObject(collection);(fromRight?index--:length>++index)&&iteratee(iterable[index],index,iterable)!==!1;);return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){for(var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;fromRight?index--:length>++index;){var key=props[index];if(iteratee(iterable[key],key,iterable)===!1)break}return object}}function createFindIndex(fromRight){return function(array,predicate,thisArg){return array&&array.length?(predicate=getCallback(predicate,thisArg,3),baseFindIndex(array,predicate,fromRight)):-1}}function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return\"function\"==typeof iteratee&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length,result=!0;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength))return!1;for(;result&&arrLength>++index;){var arrValue=array[index],othValue=other[index];if(result=undefined,customizer&&(result=isLoose?customizer(othValue,arrValue,index):customizer(arrValue,othValue,index)),result===undefined)if(isLoose)for(var othIndex=othLength;othIndex--&&(othValue=other[othIndex],!(result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))););else result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)}return!!result}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:0==object?1/object==1/other:object==+other;case regexpTag:case stringTag:return object==other+\"\"}return!1}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose)return!1;for(var skipCtor=isLoose,index=-1;objLength>++index;){var key=objProps[index],result=isLoose?key in other:hasOwnProperty.call(other,key);if(result){var objValue=object[key],othValue=other[key];result=undefined,customizer&&(result=isLoose?customizer(othValue,objValue,key):customizer(objValue,othValue,key)),result===undefined&&(result=objValue&&objValue===othValue||equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB))}if(!result)return!1;skipCtor||(skipCtor=\"constructor\"==key)}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&\"constructor\"in object&&\"constructor\"in other&&!(\"function\"==typeof objCtor&&objCtor instanceof objCtor&&\"function\"==typeof othCtor&&othCtor instanceof othCtor))return!1}return!0}function getCallback(func,thisArg,argCount){var result=lodash.callback||callback;return result=result===callback?baseCallback:result,argCount?result(func,thisArg,argCount):result}function getIndexOf(collection,target,fromIndex){var result=lodash.indexOf||indexOf;return result=result===indexOf?baseIndexOf:result,collection?result(collection,target,fromIndex):result}function initCloneArray(array){var length=array.length,result=new array.constructor(length);return length&&\"string\"==typeof array[0]&&hasOwnProperty.call(array,\"index\")&&(result.index=array.index,result.input=array.input),result}function initCloneObject(object){var Ctor=object.constructor;return\"function\"==typeof Ctor&&Ctor instanceof Ctor||(Ctor=Object),new Ctor}function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return bufferClone(object);case boolTag:case dateTag:return new Ctor(+object);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:var buffer=object.buffer;return new Ctor(isDeep?bufferClone(buffer):buffer,object.byteOffset,object.length);case numberTag:case stringTag:return new Ctor(object);case regexpTag:var result=new Ctor(object.source,reFlags.exec(object));result.lastIndex=object.lastIndex}return result}function isIndex(value,length){return value=+value,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&0==value%1&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if(\"number\"==type)var length=getLength(object),prereq=isLength(length)&&isIndex(index,length);else prereq=\"string\"==type&&index in object;if(prereq){var other=object[index];return value===value?value===other:other!==other}return!1}function isKey(value,object){var type=typeof value;if(\"string\"==type&&reIsPlainProp.test(value)||\"number\"==type)return!0;if(isArray(value))return!1;var result=!reIsDeepProp.test(value);return result||null!=object&&value in toObject(object)}function isLength(value){return\"number\"==typeof value&&value>-1&&0==value%1&&MAX_SAFE_INTEGER>=value}function isStrictComparable(value){return value===value&&(0===value?1/value>0:!isObject(value))}function shimIsPlainObject(value){var Ctor;if(lodash.support,!isObjectLike(value)||objToString.call(value)!=objectTag||!hasOwnProperty.call(value,\"constructor\")&&(Ctor=value.constructor,\"function\"==typeof Ctor&&!(Ctor instanceof Ctor)))return!1;var result;return baseForIn(value,function(subValue,key){result=key}),result===undefined||hasOwnProperty.call(value,result)}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,support=lodash.support,allowIndexes=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object)),index=-1,result=[];propsLength>++index;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value))return value;var result=[];return baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,\"$1\"):number||match)}),result}function indexOf(array,value,fromIndex){var length=array?array.length:0;if(!length)return-1;if(\"number\"==typeof fromIndex)fromIndex=0>fromIndex?nativeMax(length+fromIndex,0):fromIndex;else if(fromIndex){var index=binaryIndex(array,value),other=array[index];return(value===value?value===other:other!==other)?index:-1}return baseIndexOf(array,value,fromIndex||0)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function slice(array,start,end){var length=array?array.length:0;return length?(end&&\"number\"!=typeof end&&isIterateeCall(array,start,end)&&(start=0,end=length),baseSlice(array,start,end)):[]}function unzip(array){for(var index=-1,length=(array&&array.length&&arrayMax(arrayMap(array,getLength)))>>>0,result=Array(length);length>++index;)result[index]=arrayMap(array,baseProperty(index));return result}function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;return isLength(length)||(collection=values(collection),length=collection.length),length?(fromIndex=\"number\"!=typeof fromIndex||guard&&isIterateeCall(target,fromIndex,guard)?0:0>fromIndex?nativeMax(length+fromIndex,0):fromIndex||0,\"string\"==typeof collection||!isArray(collection)&&isString(collection)?length>fromIndex&&collection.indexOf(target,fromIndex)>-1:getIndexOf(collection,target,fromIndex)>-1):!1}function reject(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;return predicate=getCallback(predicate,thisArg,3),func(collection,function(value,index,collection){return!predicate(value,index,collection)})}function some(collection,predicate,thisArg){var func=isArray(collection)?arraySome:baseSome;return thisArg&&isIterateeCall(collection,predicate,thisArg)&&(predicate=null),(\"function\"!=typeof predicate||thisArg!==undefined)&&(predicate=getCallback(predicate,thisArg,3)),func(collection,predicate)}function restParam(func,start){if(\"function\"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(start===undefined?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);length>++index;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;start>++index;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}function clone(value,isDeep,customizer,thisArg){return isDeep&&\"boolean\"!=typeof isDeep&&isIterateeCall(value,isDeep,customizer)?isDeep=!1:\"function\"==typeof isDeep&&(thisArg=customizer,customizer=isDeep,isDeep=!1),customizer=\"function\"==typeof customizer&&bindCallback(customizer,thisArg,1),baseClone(value,isDeep,customizer)}function isArguments(value){var length=isObjectLike(value)?value.length:undefined;return isLength(length)&&objToString.call(value)==argsTag}function isEmpty(value){if(null==value)return!0;var length=getLength(value);return isLength(length)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))?!length:!keys(value).length}function isObject(value){var type=typeof value;return\"function\"==type||!!value&&\"object\"==type}function isNative(value){return null==value?!1:objToString.call(value)==funcTag?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}function isNumber(value){return\"number\"==typeof value||isObjectLike(value)&&objToString.call(value)==numberTag}function isString(value){return\"string\"==typeof value||isObjectLike(value)&&objToString.call(value)==stringTag}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}function toPlainObject(value){return baseCopy(value,keysIn(value))}function has(object,path){if(null==object)return!1;var result=hasOwnProperty.call(object,path);return result||isKey(path)||(path=toPath(path),object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),path=last(path),result=null!=object&&hasOwnProperty.call(object,path)),result}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto=\"function\"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;length>++index;)result[index]=index+\"\";for(var key in object)skipIndexes&&isIndex(key,length)||\"constructor\"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}function values(object){return baseValues(object,keys(object))}function escapeRegExp(string){return string=baseToString(string),string&&reHasRegExpChars.test(string)?string.replace(reRegExpChars,\"\\\\$&\"):string}function callback(func,thisArg,guard){return guard&&isIterateeCall(func,thisArg,guard)&&(thisArg=null),baseCallback(func,thisArg)}function constant(value){return function(){return value}}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}var undefined,VERSION=\"3.7.0\",FUNC_ERROR_TEXT=\"Expected a function\",argsTag=\"[object Arguments]\",arrayTag=\"[object Array]\",boolTag=\"[object Boolean]\",dateTag=\"[object Date]\",errorTag=\"[object Error]\",funcTag=\"[object Function]\",mapTag=\"[object Map]\",numberTag=\"[object Number]\",objectTag=\"[object Object]\",regexpTag=\"[object RegExp]\",setTag=\"[object Set]\",stringTag=\"[object String]\",weakMapTag=\"[object WeakMap]\",arrayBufferTag=\"[object ArrayBuffer]\",float32Tag=\"[object Float32Array]\",float64Tag=\"[object Float64Array]\",int8Tag=\"[object Int8Array]\",int16Tag=\"[object Int16Array]\",int32Tag=\"[object Int32Array]\",uint8Tag=\"[object Uint8Array]\",uint8ClampedTag=\"[object Uint8ClampedArray]\",uint16Tag=\"[object Uint16Array]\",uint32Tag=\"[object Uint32Array]\",reIsDeepProp=/\\.|\\[(?:[^[\\]]+|([\"'])(?:(?!\\1)[^\\n\\\\]|\\\\.)*?)\\1\\]/,reIsPlainProp=/^\\w*$/,rePropName=/[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\n\\\\]|\\\\.)*?)\\2)\\]/g,reRegExpChars=/[.*+?^${}()|[\\]\\/\\\\]/g,reHasRegExpChars=RegExp(reRegExpChars.source),reEscapeChar=/\\\\(\\\\)?/g,reFlags=/\\w*$/,reIsHostCtor=/^\\[object .+?Constructor\\]$/,typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=!1;var objectTypes={\"function\":!0,object:!0},freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports,freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module,freeGlobal=freeExports&&freeModule&&\"object\"==typeof global&&global&&global.Object&&global,freeSelf=objectTypes[typeof self]&&self&&self.Object&&self,freeWindow=objectTypes[typeof window]&&window&&window.Object&&window,moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports,root=freeGlobal||freeWindow!==(this&&this.window)&&freeWindow||freeSelf||this,arrayProto=Array.prototype,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp(\"^\"+escapeRegExp(objToString).replace(/toString|(function).*?(?=\\\\\\()| for .+?(?=\\\\\\])/g,\"$1.*?\")+\"$\"),ArrayBuffer=isNative(ArrayBuffer=root.ArrayBuffer)&&ArrayBuffer,bufferSlice=isNative(bufferSlice=ArrayBuffer&&new ArrayBuffer(0).slice)&&bufferSlice,floor=Math.floor,getOwnPropertySymbols=isNative(getOwnPropertySymbols=Object.getOwnPropertySymbols)&&getOwnPropertySymbols,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,push=arrayProto.push,preventExtensions=isNative(Object.preventExtensions=Object.preventExtensions)&&preventExtensions,propertyIsEnumerable=objectProto.propertyIsEnumerable,Uint8Array=isNative(Uint8Array=root.Uint8Array)&&Uint8Array,Float64Array=function(){try{var func=isNative(func=root.Float64Array)&&func,result=new func(new ArrayBuffer(10),0,1)&&func}catch(e){}return result}(),nativeAssign=function(){var object={1:0},func=preventExtensions&&isNative(func=Object.assign)&&func;try{func(preventExtensions(object),\"xo\")}catch(e){}return!object[1]&&func}(),nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,MAX_ARRAY_LENGTH=Math.pow(2,32)-1,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1,FLOAT64_BYTES_PER_ELEMENT=Float64Array?Float64Array.BYTES_PER_ELEMENT:0,MAX_SAFE_INTEGER=Math.pow(2,53)-1,support=lodash.support={};(function(x){var Ctor=function(){this.x=x},props=[];Ctor.prototype={valueOf:x,y:x};for(var key in new Ctor)props.push(key);support.funcDecomp=/\\bthis\\b/.test(function(){return this}),support.funcNames=\"string\"==typeof Function.name;try{support.nonEnumArgs=!propertyIsEnumerable.call(arguments,1)}catch(e){support.nonEnumArgs=!0}})(1,0);var baseAssign=nativeAssign||function(object,source){return null==source?object:baseCopy(source,getSymbols(source),baseCopy(source,keys(source),object))},baseEach=createBaseEach(baseForOwn),baseFor=createBaseFor();bufferSlice||(bufferClone=ArrayBuffer&&Uint8Array?function(buffer){var byteLength=buffer.byteLength,floatLength=Float64Array?floor(byteLength/FLOAT64_BYTES_PER_ELEMENT):0,offset=floatLength*FLOAT64_BYTES_PER_ELEMENT,result=new ArrayBuffer(byteLength);if(floatLength){var view=new Float64Array(result,0,floatLength);view.set(new Float64Array(buffer,0,floatLength))}return byteLength!=offset&&(view=new Uint8Array(result,offset),view.set(new Uint8Array(buffer,offset))),result}:constant(null));var getLength=baseProperty(\"length\"),getSymbols=getOwnPropertySymbols?function(object){return getOwnPropertySymbols(toObject(object))}:constant([]),findLastIndex=createFindIndex(!0),zip=restParam(unzip),forEach=createForEach(arrayEach,baseEach),isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag},isFunction=baseIsFunction(/x/)||Uint8Array&&!baseIsFunction(Uint8Array)?function(value){return objToString.call(value)==funcTag}:baseIsFunction,isPlainObject=getPrototypeOf?function(value){if(!value||objToString.call(value)!=objectTag)return!1;var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)}:shimIsPlainObject,assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)}),keys=nativeKeys?function(object){if(object)var Ctor=object.constructor,length=object.length;return\"function\"==typeof Ctor&&Ctor.prototype===object||\"function\"!=typeof object&&isLength(length)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys,merge=createAssigner(baseMerge);lodash.assign=assign,lodash.callback=callback,lodash.constant=constant,lodash.forEach=forEach,lodash.keys=keys,lodash.keysIn=keysIn,lodash.merge=merge,lodash.property=property,lodash.reject=reject,lodash.restParam=restParam,lodash.slice=slice,lodash.toPlainObject=toPlainObject,lodash.unzip=unzip,lodash.values=values,lodash.zip=zip,lodash.each=forEach,lodash.extend=assign,lodash.iteratee=callback,lodash.clone=clone,lodash.escapeRegExp=escapeRegExp,lodash.findLastIndex=findLastIndex,lodash.has=has,lodash.identity=identity,lodash.includes=includes,lodash.indexOf=indexOf,lodash.isArguments=isArguments,lodash.isArray=isArray,lodash.isEmpty=isEmpty,lodash.isFunction=isFunction,lodash.isNative=isNative,lodash.isNumber=isNumber,lodash.isObject=isObject,lodash.isPlainObject=isPlainObject,lodash.isString=isString,lodash.isTypedArray=isTypedArray,lodash.last=last,lodash.some=some,lodash.any=some,lodash.contains=includes,lodash.include=includes,lodash.VERSION=VERSION,freeExports&&freeModule?moduleExports?(freeModule.exports=lodash)._=lodash:freeExports._=lodash:root._=lodash\n}).call(this)}).call(this,\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:\"undefined\"!=typeof window?window:{})},{}],\"/node_modules/jshint/src/jshint.js\":[function(_dereq_,module,exports){var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),vars=_dereq_(\"./vars.js\"),messages=_dereq_(\"./messages.js\"),Lexer=_dereq_(\"./lex.js\").Lexer,reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,style=_dereq_(\"./style.js\"),options=_dereq_(\"./options.js\"),scopeManager=_dereq_(\"./scope-manager.js\"),JSHINT=function(){\"use strict\";function checkOption(name,t){return name=name.trim(),/^[+-]W\\d{3}$/g.test(name)?!0:-1!==options.validNames.indexOf(name)||\"jslint\"===t.type||_.has(options.removed,name)?!0:(error(\"E001\",t,name),!1)}function isString(obj){return\"[object String]\"===Object.prototype.toString.call(obj)}function isIdentifier(tkn,value){return tkn?tkn.identifier&&tkn.value===value?!0:!1:!1}function isReserved(token){if(!token.reserved)return!1;var meta=token.meta;if(meta&&meta.isFutureReservedWord&&state.inES5()){if(!meta.es5)return!1;if(meta.strictOnly&&!state.option.strict&&!state.isStrict())return!1;if(token.isProperty)return!1}return!0}function supplant(str,data){return str.replace(/\\{([^{}]*)\\}/g,function(a,b){var r=data[b];return\"string\"==typeof r||\"number\"==typeof r?r:a})}function combine(dest,src){Object.keys(src).forEach(function(name){_.has(JSHINT.blacklist,name)||(dest[name]=src[name])})}function processenforceall(){if(state.option.enforceall){for(var enforceopt in options.bool.enforcing)void 0!==state.option[enforceopt]||options.noenforceall[enforceopt]||(state.option[enforceopt]=!0);for(var relaxopt in options.bool.relaxing)void 0===state.option[relaxopt]&&(state.option[relaxopt]=!1)}}function assume(){processenforceall(),state.option.esversion||state.option.moz||(state.option.esversion=state.option.es3?3:state.option.esnext?6:5),state.inES5()&&combine(predefined,vars.ecmaIdentifiers[5]),state.inES6()&&combine(predefined,vars.ecmaIdentifiers[6]),state.option.module&&(state.option.strict===!0&&(state.option.strict=\"global\"),state.inES6()||warning(\"W134\",state.tokens.next,\"module\",6)),state.option.couch&&combine(predefined,vars.couch),state.option.qunit&&combine(predefined,vars.qunit),state.option.rhino&&combine(predefined,vars.rhino),state.option.shelljs&&(combine(predefined,vars.shelljs),combine(predefined,vars.node)),state.option.typed&&combine(predefined,vars.typed),state.option.phantom&&(combine(predefined,vars.phantom),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.prototypejs&&combine(predefined,vars.prototypejs),state.option.node&&(combine(predefined,vars.node),combine(predefined,vars.typed),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.devel&&combine(predefined,vars.devel),state.option.dojo&&combine(predefined,vars.dojo),state.option.browser&&(combine(predefined,vars.browser),combine(predefined,vars.typed)),state.option.browserify&&(combine(predefined,vars.browser),combine(predefined,vars.typed),combine(predefined,vars.browserify),state.option.strict===!0&&(state.option.strict=\"global\")),state.option.nonstandard&&combine(predefined,vars.nonstandard),state.option.jasmine&&combine(predefined,vars.jasmine),state.option.jquery&&combine(predefined,vars.jquery),state.option.mootools&&combine(predefined,vars.mootools),state.option.worker&&combine(predefined,vars.worker),state.option.wsh&&combine(predefined,vars.wsh),state.option.globalstrict&&state.option.strict!==!1&&(state.option.strict=\"global\"),state.option.yui&&combine(predefined,vars.yui),state.option.mocha&&combine(predefined,vars.mocha)}function quit(code,line,chr){var percentage=Math.floor(100*(line/state.lines.length)),message=messages.errors[code].desc;throw{name:\"JSHintError\",line:line,character:chr,message:message+\" (\"+percentage+\"% scanned).\",raw:message,code:code}}function removeIgnoredMessages(){var ignored=state.ignoredLines;_.isEmpty(ignored)||(JSHINT.errors=_.reject(JSHINT.errors,function(err){return ignored[err.line]}))}function warning(code,t,a,b,c,d){var ch,l,w,msg;if(/^W\\d{3}$/.test(code)){if(state.ignored[code])return;msg=messages.warnings[code]}else/E\\d{3}/.test(code)?msg=messages.errors[code]:/I\\d{3}/.test(code)&&(msg=messages.info[code]);return t=t||state.tokens.next||{},\"(end)\"===t.id&&(t=state.tokens.curr),l=t.line||0,ch=t.from||0,w={id:\"(error)\",raw:msg.desc,code:msg.code,evidence:state.lines[l-1]||\"\",line:l,character:ch,scope:JSHINT.scope,a:a,b:b,c:c,d:d},w.reason=supplant(msg.desc,w),JSHINT.errors.push(w),removeIgnoredMessages(),JSHINT.errors.length>=state.option.maxerr&&quit(\"E043\",l,ch),w}function warningAt(m,l,ch,a,b,c,d){return warning(m,{line:l,from:ch},a,b,c,d)}function error(m,t,a,b,c,d){warning(m,t,a,b,c,d)}function errorAt(m,l,ch,a,b,c,d){return error(m,{line:l,from:ch},a,b,c,d)}function addInternalSrc(elem,src){var i;return i={id:\"(internal)\",elem:elem,value:src},JSHINT.internals.push(i),i}function doOption(){var nt=state.tokens.next,body=nt.body.match(/(-\\s+)?[^\\s,:]+(?:\\s*:\\s*(-\\s+)?[^\\s,]+)?/g)||[],predef={};if(\"globals\"===nt.type){body.forEach(function(g,idx){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(\"-\"===key||!key.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}\"-\"===key.charAt(0)?(key=key.slice(1),val=!1,JSHINT.blacklist[key]=key,delete predefined[key]):predef[key]=\"true\"===val}),combine(predefined,predef);for(var key in predef)_.has(predef,key)&&(declared[key]=nt)}\"exported\"===nt.type&&body.forEach(function(e,idx){if(!e.length){if(idx>0&&idx===body.length-1)return;return error(\"E002\",nt),void 0}state.funct[\"(scope)\"].addExported(e)}),\"members\"===nt.type&&(membersOnly=membersOnly||{},body.forEach(function(m){var ch1=m.charAt(0),ch2=m.charAt(m.length-1);ch1!==ch2||'\"'!==ch1&&\"'\"!==ch1||(m=m.substr(1,m.length-2).replace('\\\\\"','\"')),membersOnly[m]=!1}));var numvals=[\"maxstatements\",\"maxparams\",\"maxdepth\",\"maxcomplexity\",\"maxerr\",\"maxlen\",\"indent\"];(\"jshint\"===nt.type||\"jslint\"===nt.type)&&(body.forEach(function(g){g=g.split(\":\");var key=(g[0]||\"\").trim(),val=(g[1]||\"\").trim();if(checkOption(key,nt))if(numvals.indexOf(key)>=0)if(\"false\"!==val){if(val=+val,\"number\"!=typeof val||!isFinite(val)||0>=val||Math.floor(val)!==val)return error(\"E032\",nt,g[1].trim()),void 0;state.option[key]=val}else state.option[key]=\"indent\"===key?4:!1;else{if(\"validthis\"===key)return state.funct[\"(global)\"]?void error(\"E009\"):\"true\"!==val&&\"false\"!==val?void error(\"E002\",nt):(state.option.validthis=\"true\"===val,void 0);if(\"quotmark\"!==key)if(\"shadow\"!==key)if(\"unused\"!==key)if(\"latedef\"!==key)if(\"ignore\"!==key)if(\"strict\"!==key){\"module\"===key&&(hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"module\"));var esversions={es3:3,es5:5,esnext:6};if(!_.has(esversions,key)){if(\"esversion\"===key){switch(val){case\"5\":state.inES5(!0)&&warning(\"I003\");case\"3\":case\"6\":state.option.moz=!1,state.option.esversion=+val;break;case\"2015\":state.option.moz=!1,state.option.esversion=6;break;default:error(\"E002\",nt)}return hasParsedCode(state.funct)||error(\"E055\",state.tokens.next,\"esversion\"),void 0}var match=/^([+-])(W\\d{3})$/g.exec(key);if(match)return state.ignored[match[2]]=\"-\"===match[1],void 0;var tn;return\"true\"===val||\"false\"===val?(\"jslint\"===nt.type?(tn=options.renamed[key]||key,state.option[tn]=\"true\"===val,void 0!==options.inverted[tn]&&(state.option[tn]=!state.option[tn])):state.option[key]=\"true\"===val,\"newcap\"===key&&(state.option[\"(explicitNewcap)\"]=!0),void 0):(error(\"E002\",nt),void 0)}switch(val){case\"true\":state.option.moz=!1,state.option.esversion=esversions[key];break;case\"false\":state.option.moz||(state.option.esversion=5);break;default:error(\"E002\",nt)}}else switch(val){case\"true\":state.option.strict=!0;break;case\"false\":state.option.strict=!1;break;case\"func\":case\"global\":case\"implied\":state.option.strict=val;break;default:error(\"E002\",nt)}else switch(val){case\"line\":state.ignoredLines[nt.line]=!0,removeIgnoredMessages();break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.latedef=!0;break;case\"false\":state.option.latedef=!1;break;case\"nofunc\":state.option.latedef=\"nofunc\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.unused=!0;break;case\"false\":state.option.unused=!1;break;case\"vars\":case\"strict\":state.option.unused=val;break;default:error(\"E002\",nt)}else switch(val){case\"true\":state.option.shadow=!0;break;case\"outer\":state.option.shadow=\"outer\";break;case\"false\":case\"inner\":state.option.shadow=\"inner\";break;default:error(\"E002\",nt)}else switch(val){case\"true\":case\"false\":state.option.quotmark=\"true\"===val;break;case\"double\":case\"single\":state.option.quotmark=val;break;default:error(\"E002\",nt)}}}),assume())}function peek(p){var t,i=p||0,j=lookahead.length;if(j>i)return lookahead[i];for(;i>=j;)t=lookahead[j],t||(t=lookahead[j]=lex.token()),j+=1;return t||\"(end)\"!==state.tokens.next.id?t:state.tokens.next}function peekIgnoreEOL(){var t,i=0;do t=peek(i++);while(\"(endline)\"===t.id);return t}function advance(id,t){switch(state.tokens.curr.id){case\"(number)\":\".\"===state.tokens.next.id&&warning(\"W005\",state.tokens.curr);break;case\"-\":(\"-\"===state.tokens.next.id||\"--\"===state.tokens.next.id)&&warning(\"W006\");break;case\"+\":(\"+\"===state.tokens.next.id||\"++\"===state.tokens.next.id)&&warning(\"W007\")}for(id&&state.tokens.next.id!==id&&(t?\"(end)\"===state.tokens.next.id?error(\"E019\",t,t.id):error(\"E020\",state.tokens.next,id,t.id,t.line,state.tokens.next.value):(\"(identifier)\"!==state.tokens.next.type||state.tokens.next.value!==id)&&warning(\"W116\",state.tokens.next,id,state.tokens.next.value)),state.tokens.prev=state.tokens.curr,state.tokens.curr=state.tokens.next;;){if(state.tokens.next=lookahead.shift()||lex.token(),state.tokens.next||quit(\"E041\",state.tokens.curr.line),\"(end)\"===state.tokens.next.id||\"(error)\"===state.tokens.next.id)return;if(state.tokens.next.check&&state.tokens.next.check(),state.tokens.next.isSpecial)\"falls through\"===state.tokens.next.type?state.tokens.curr.caseFallsThrough=!0:doOption();else if(\"(endline)\"!==state.tokens.next.id)break}}function isInfix(token){return token.infix||!token.identifier&&!token.template&&!!token.led}function isEndOfExpr(){var curr=state.tokens.curr,next=state.tokens.next;return\";\"===next.id||\"}\"===next.id||\":\"===next.id?!0:isInfix(next)===isInfix(curr)||\"yield\"===curr.id&&state.inMoz()?curr.line!==startLine(next):!1}function isBeginOfExpr(prev){return!prev.left&&\"unary\"!==prev.arity}function expression(rbp,initial){var left,isArray=!1,isObject=!1,isLetExpr=!1;state.nameStack.push(),initial||\"let\"!==state.tokens.next.value||\"(\"!==peek(0).value||(state.inMoz()||warning(\"W118\",state.tokens.next,\"let expressions\"),isLetExpr=!0,state.funct[\"(scope)\"].stack(),advance(\"let\"),advance(\"(\"),state.tokens.prev.fud(),advance(\")\")),\"(end)\"===state.tokens.next.id&&error(\"E006\",state.tokens.curr);var isDangerous=state.option.asi&&state.tokens.prev.line!==startLine(state.tokens.curr)&&_.contains([\"]\",\")\"],state.tokens.prev.id)&&_.contains([\"[\",\"(\"],state.tokens.curr.id);if(isDangerous&&warning(\"W014\",state.tokens.curr,state.tokens.curr.id),advance(),initial&&(state.funct[\"(verb)\"]=state.tokens.curr.value,state.tokens.curr.beginsStmt=!0),initial===!0&&state.tokens.curr.fud)left=state.tokens.curr.fud();else for(state.tokens.curr.nud?left=state.tokens.curr.nud():error(\"E030\",state.tokens.curr,state.tokens.curr.id);(state.tokens.next.lbp>rbp||\"(template)\"===state.tokens.next.type)&&!isEndOfExpr();)isArray=\"Array\"===state.tokens.curr.value,isObject=\"Object\"===state.tokens.curr.value,left&&(left.value||left.first&&left.first.value)&&(\"new\"!==left.value||left.first&&left.first.value&&\".\"===left.first.value)&&(isArray=!1,left.value!==state.tokens.curr.value&&(isObject=!1)),advance(),isArray&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W009\",state.tokens.curr),isObject&&\"(\"===state.tokens.curr.id&&\")\"===state.tokens.next.id&&warning(\"W010\",state.tokens.curr),left&&state.tokens.curr.led?left=state.tokens.curr.led(left):error(\"E033\",state.tokens.curr,state.tokens.curr.id);return isLetExpr&&state.funct[\"(scope)\"].unstack(),state.nameStack.pop(),left}function startLine(token){return token.startLine||token.line}function nobreaknonadjacent(left,right){left=left||state.tokens.curr,right=right||state.tokens.next,state.option.laxbreak||left.line===startLine(right)||warning(\"W014\",right,right.value)}function nolinebreak(t){t=t||state.tokens.curr,t.line!==startLine(state.tokens.next)&&warning(\"E022\",t,t.value)}function nobreakcomma(left,right){left.line!==startLine(right)&&(state.option.laxcomma||(comma.first&&(warning(\"I001\"),comma.first=!1),warning(\"W014\",left,right.value)))}function comma(opts){if(opts=opts||{},opts.peek?nobreakcomma(state.tokens.prev,state.tokens.curr):(nobreakcomma(state.tokens.curr,state.tokens.next),advance(\",\")),state.tokens.next.identifier&&(!opts.property||!state.inES5()))switch(state.tokens.next.value){case\"break\":case\"case\":case\"catch\":case\"continue\":case\"default\":case\"do\":case\"else\":case\"finally\":case\"for\":case\"if\":case\"in\":case\"instanceof\":case\"return\":case\"switch\":case\"throw\":case\"try\":case\"var\":case\"let\":case\"while\":case\"with\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}if(\"(punctuator)\"===state.tokens.next.type)switch(state.tokens.next.value){case\"}\":case\"]\":case\",\":if(opts.allowTrailing)return!0;case\")\":return error(\"E024\",state.tokens.next,state.tokens.next.value),!1}return!0}function symbol(s,p){var x=state.syntax[s];return x&&\"object\"==typeof x||(state.syntax[s]=x={id:s,lbp:p,value:s}),x}function delim(s){var x=symbol(s,0);return x.delim=!0,x}function stmt(s,f){var x=delim(s);return x.identifier=x.reserved=!0,x.fud=f,x}function blockstmt(s,f){var x=stmt(s,f);return x.block=!0,x}function reserveName(x){var c=x.id.charAt(0);return(c>=\"a\"&&\"z\">=c||c>=\"A\"&&\"Z\">=c)&&(x.identifier=x.reserved=!0),x}function prefix(s,f){var x=symbol(s,150);return reserveName(x),x.nud=\"function\"==typeof f?f:function(){return this.arity=\"unary\",this.right=expression(150),(\"++\"===this.id||\"--\"===this.id)&&(state.option.plusplus?warning(\"W016\",this,this.id):!this.right||this.right.identifier&&!isReserved(this.right)||\".\"===this.right.id||\"[\"===this.right.id||warning(\"W017\",this),this.right&&this.right.isMetaProperty?error(\"E031\",this):this.right&&this.right.identifier&&state.funct[\"(scope)\"].block.modify(this.right.value,this)),this},x}function type(s,f){var x=delim(s);return x.type=s,x.nud=f,x}function reserve(name,func){var x=type(name,func);return x.identifier=!0,x.reserved=!0,x}function FutureReservedWord(name,meta){var x=type(name,meta&&meta.nud||function(){return this});return meta=meta||{},meta.isFutureReservedWord=!0,x.value=name,x.identifier=!0,x.reserved=!0,x.meta=meta,x}function reservevar(s,v){return reserve(s,function(){return\"function\"==typeof v&&v(this),this})}function infix(s,f,p,w){var x=symbol(s,p);return reserveName(x),x.infix=!0,x.led=function(left){return w||nobreaknonadjacent(state.tokens.prev,state.tokens.curr),\"in\"!==s&&\"instanceof\"!==s||\"!\"!==left.id||warning(\"W018\",left,\"!\"),\"function\"==typeof f?f(left,this):(this.left=left,this.right=expression(p),this)},x}function application(s){var x=symbol(s,42);return x.led=function(left){return nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left,this.right=doFunction({type:\"arrow\",loneArg:left}),this},x}function relation(s,f){var x=symbol(s,100);return x.led=function(left){nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left;var right=this.right=expression(100);return isIdentifier(left,\"NaN\")||isIdentifier(right,\"NaN\")?warning(\"W019\",this):f&&f.apply(this,[left,right]),left&&right||quit(\"E041\",state.tokens.curr.line),\"!\"===left.id&&warning(\"W018\",left,\"!\"),\"!\"===right.id&&warning(\"W018\",right,\"!\"),this},x}function isPoorRelation(node){return node&&(\"(number)\"===node.type&&0===+node.value||\"(string)\"===node.type&&\"\"===node.value||\"null\"===node.type&&!state.option.eqnull||\"true\"===node.type||\"false\"===node.type||\"undefined\"===node.type)}function isTypoTypeof(left,right,state){var values;return state.option.notypeof?!1:left&&right?(values=state.inES6()?typeofValues.es6:typeofValues.es3,\"(identifier)\"===right.type&&\"typeof\"===right.value&&\"(string)\"===left.type?!_.contains(values,left.value):!1):!1}function isGlobalEval(left,state){var isGlobal=!1;return\"this\"===left.type&&null===state.funct[\"(context)\"]?isGlobal=!0:\"(identifier)\"===left.type&&(state.option.node&&\"global\"===left.value?isGlobal=!0:!state.option.browser||\"window\"!==left.value&&\"document\"!==left.value||(isGlobal=!0)),isGlobal}function findNativePrototype(left){function walkPrototype(obj){return\"object\"==typeof obj?\"prototype\"===obj.right?obj:walkPrototype(obj.left):void 0}function walkNative(obj){for(;!obj.identifier&&\"object\"==typeof obj.left;)obj=obj.left;return obj.identifier&&natives.indexOf(obj.value)>=0?obj.value:void 0}var natives=[\"Array\",\"ArrayBuffer\",\"Boolean\",\"Collator\",\"DataView\",\"Date\",\"DateTimeFormat\",\"Error\",\"EvalError\",\"Float32Array\",\"Float64Array\",\"Function\",\"Infinity\",\"Intl\",\"Int16Array\",\"Int32Array\",\"Int8Array\",\"Iterator\",\"Number\",\"NumberFormat\",\"Object\",\"RangeError\",\"ReferenceError\",\"RegExp\",\"StopIteration\",\"String\",\"SyntaxError\",\"TypeError\",\"Uint16Array\",\"Uint32Array\",\"Uint8Array\",\"Uint8ClampedArray\",\"URIError\"],prototype=walkPrototype(left);return prototype?walkNative(prototype):void 0}function checkLeftSideAssign(left,assignToken,options){var allowDestructuring=options&&options.allowDestructuring;if(assignToken=assignToken||left,state.option.freeze){var nativeObject=findNativePrototype(left);nativeObject&&warning(\"W121\",left,nativeObject)}return left.identifier&&!left.isMetaProperty&&state.funct[\"(scope)\"].block.reassign(left.value,left),\".\"===left.id?((!left.left||\"arguments\"===left.left.value&&!state.isStrict())&&warning(\"E031\",assignToken),state.nameStack.set(state.tokens.prev),!0):\"{\"===left.id||\"[\"===left.id?(allowDestructuring&&state.tokens.curr.left.destructAssign?state.tokens.curr.left.destructAssign.forEach(function(t){t.id&&state.funct[\"(scope)\"].block.modify(t.id,t.token)}):\"{\"!==left.id&&left.left?\"arguments\"!==left.left.value||state.isStrict()||warning(\"E031\",assignToken):warning(\"E031\",assignToken),\"[\"===left.id&&state.nameStack.set(left.right),!0):left.isMetaProperty?(error(\"E031\",assignToken),!0):left.identifier&&!isReserved(left)?(\"exception\"===state.funct[\"(scope)\"].labeltype(left.value)&&warning(\"W022\",left),state.nameStack.set(left),!0):(left===state.syntax[\"function\"]&&warning(\"W023\",state.tokens.curr),!1)}function assignop(s,f,p){var x=infix(s,\"function\"==typeof f?f:function(left,that){return that.left=left,left&&checkLeftSideAssign(left,that,{allowDestructuring:!0})?(that.right=expression(10),that):(error(\"E031\",that),void 0)},p);return x.exps=!0,x.assign=!0,x}function bitwise(s,f,p){var x=symbol(s,p);return reserveName(x),x.led=\"function\"==typeof f?f:function(left){return state.option.bitwise&&warning(\"W016\",this,this.id),this.left=left,this.right=expression(p),this},x}function bitwiseassignop(s){return assignop(s,function(left,that){return state.option.bitwise&&warning(\"W016\",that,that.id),left&&checkLeftSideAssign(left,that)?(that.right=expression(10),that):(error(\"E031\",that),void 0)},20)}function suffix(s){var x=symbol(s,150);return x.led=function(left){return state.option.plusplus?warning(\"W016\",this,this.id):left.identifier&&!isReserved(left)||\".\"===left.id||\"[\"===left.id||warning(\"W017\",this),left.isMetaProperty?error(\"E031\",this):left&&left.identifier&&state.funct[\"(scope)\"].block.modify(left.value,left),this.left=left,this},x}function optionalidentifier(fnparam,prop,preserve){if(state.tokens.next.identifier){preserve||advance();var curr=state.tokens.curr,val=state.tokens.curr.value;return isReserved(curr)?prop&&state.inES5()?val:fnparam&&\"undefined\"===val?val:(warning(\"W024\",state.tokens.curr,state.tokens.curr.id),val):val}}function identifier(fnparam,prop){var i=optionalidentifier(fnparam,prop,!1);if(i)return i;if(\"...\"===state.tokens.next.value){if(state.inES6(!0)||warning(\"W119\",state.tokens.next,\"spread/rest operator\",\"6\"),advance(),checkPunctuator(state.tokens.next,\"...\"))for(warning(\"E024\",state.tokens.next,\"...\");checkPunctuator(state.tokens.next,\"...\");)advance();return state.tokens.next.identifier?identifier(fnparam,prop):(warning(\"E024\",state.tokens.curr,\"...\"),void 0)}error(\"E030\",state.tokens.next,state.tokens.next.value),\";\"!==state.tokens.next.id&&advance()}function reachable(controlToken){var t,i=0;if(\";\"===state.tokens.next.id&&!controlToken.inBracelessBlock)for(;;){do t=peek(i),i+=1;while(\"(end)\"!==t.id&&\"(comment)\"===t.id);if(t.reach)return;if(\"(endline)\"!==t.id){if(\"function\"===t.id){state.option.latedef===!0&&warning(\"W026\",t);break}warning(\"W027\",t,t.value,controlToken.value);break}}}function parseFinalSemicolon(){if(\";\"!==state.tokens.next.id){if(state.tokens.next.isUnclosed)return advance();var sameLine=startLine(state.tokens.next)===state.tokens.curr.line&&\"(end)\"!==state.tokens.next.id,blockEnd=checkPunctuator(state.tokens.next,\"}\");sameLine&&!blockEnd?errorAt(\"E058\",state.tokens.curr.line,state.tokens.curr.character):state.option.asi||(blockEnd&&!state.option.lastsemic||!sameLine)&&warningAt(\"W033\",state.tokens.curr.line,state.tokens.curr.character)}else advance(\";\")}function statement(){var r,i=indent,t=state.tokens.next,hasOwnScope=!1;if(\";\"===t.id)return advance(\";\"),void 0;var res=isReserved(t);if(res&&t.meta&&t.meta.isFutureReservedWord&&\":\"===peek().id&&(warning(\"W024\",t,t.id),res=!1),t.identifier&&!res&&\":\"===peek().id&&(advance(),advance(\":\"),hasOwnScope=!0,state.funct[\"(scope)\"].stack(),state.funct[\"(scope)\"].block.addBreakLabel(t.value,{token:state.tokens.curr}),state.tokens.next.labelled||\"{\"===state.tokens.next.value||warning(\"W028\",state.tokens.next,t.value,state.tokens.next.value),state.tokens.next.label=t.value,t=state.tokens.next),\"{\"===t.id){var iscase=\"case\"===state.funct[\"(verb)\"]&&\":\"===state.tokens.curr.value;return block(!0,!0,!1,!1,iscase),void 0}return r=expression(0,!0),!r||r.identifier&&\"function\"===r.value||\"(punctuator)\"===r.type&&r.left&&r.left.identifier&&\"function\"===r.left.value||state.isStrict()||\"global\"!==state.option.strict||warning(\"E007\"),t.block||(state.option.expr||r&&r.exps?state.option.nonew&&r&&r.left&&\"(\"===r.id&&\"new\"===r.left.id&&warning(\"W031\",t):warning(\"W030\",state.tokens.curr),parseFinalSemicolon()),indent=i,hasOwnScope&&state.funct[\"(scope)\"].unstack(),r}function statements(){for(var p,a=[];!state.tokens.next.reach&&\"(end)\"!==state.tokens.next.id;)\";\"===state.tokens.next.id?(p=peek(),(!p||\"(\"!==p.id&&\"[\"!==p.id)&&warning(\"W032\"),advance(\";\")):a.push(statement());return a}function directives(){for(var i,p,pn;\"(string)\"===state.tokens.next.id;){if(p=peek(0),\"(endline)\"===p.id){i=1;do pn=peek(i++);while(\"(endline)\"===pn.id);if(\";\"===pn.id)p=pn;else{if(\"[\"===pn.value||\".\"===pn.value)break;state.option.asi&&\"(\"!==pn.value||warning(\"W033\",state.tokens.next)}}else{if(\".\"===p.id||\"[\"===p.id)break;\";\"!==p.id&&warning(\"W033\",p)}advance();var directive=state.tokens.curr.value;(state.directive[directive]||\"use strict\"===directive&&\"implied\"===state.option.strict)&&warning(\"W034\",state.tokens.curr,directive),state.directive[directive]=!0,\";\"===p.id&&advance(\";\")}state.isStrict()&&(state.option[\"(explicitNewcap)\"]||(state.option.newcap=!0),state.option.undef=!0)}function block(ordinary,stmt,isfunc,isfatarrow,iscase){var a,m,t,line,d,b=inblock,old_indent=indent;inblock=ordinary,t=state.tokens.next;var metrics=state.funct[\"(metrics)\"];if(metrics.nestedBlockDepth+=1,metrics.verifyMaxNestedBlockDepthPerFunction(),\"{\"===state.tokens.next.id){if(advance(\"{\"),state.funct[\"(scope)\"].stack(),line=state.tokens.curr.line,\"}\"!==state.tokens.next.id){for(indent+=state.option.indent;!ordinary&&state.tokens.next.from>indent;)indent+=state.option.indent;if(isfunc){m={};for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);directives(),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\"))}a=statements(),metrics.statementCount+=a.length,indent-=state.option.indent}advance(\"}\",t),isfunc&&(state.funct[\"(scope)\"].validateParams(),m&&(state.directive=m)),state.funct[\"(scope)\"].unstack(),indent=old_indent}else if(ordinary)state.funct[\"(noblockscopedvar)\"]=\"for\"!==state.tokens.next.id,state.funct[\"(scope)\"].stack(),(!stmt||state.option.curly)&&warning(\"W116\",state.tokens.next,\"{\",state.tokens.next.value),state.tokens.next.inBracelessBlock=!0,indent+=state.option.indent,a=[statement()],indent-=state.option.indent,state.funct[\"(scope)\"].unstack(),delete state.funct[\"(noblockscopedvar)\"];else if(isfunc){if(state.funct[\"(scope)\"].stack(),m={},!stmt||isfatarrow||state.inMoz()||error(\"W118\",state.tokens.curr,\"function closure expressions\"),!stmt)for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);expression(10),state.option.strict&&state.funct[\"(context)\"][\"(global)\"]&&(m[\"use strict\"]||state.isStrict()||warning(\"E007\")),state.funct[\"(scope)\"].unstack()}else error(\"E021\",state.tokens.next,\"{\",state.tokens.next.value);switch(state.funct[\"(verb)\"]){case\"break\":case\"continue\":case\"return\":case\"throw\":if(iscase)break;default:state.funct[\"(verb)\"]=null}return inblock=b,!ordinary||!state.option.noempty||a&&0!==a.length||warning(\"W035\",state.tokens.prev),metrics.nestedBlockDepth-=1,a}function countMember(m){membersOnly&&\"boolean\"!=typeof membersOnly[m]&&warning(\"W036\",state.tokens.curr,m),\"number\"==typeof member[m]?member[m]+=1:member[m]=1}function comprehensiveArrayExpression(){var res={};res.exps=!0,state.funct[\"(comparray)\"].stack();var reversed=!1;return\"for\"!==state.tokens.next.value&&(reversed=!0,state.inMoz()||warning(\"W116\",state.tokens.next,\"for\",state.tokens.next.value),state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"for\"),\"each\"===state.tokens.next.value&&(advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"define\"),res.left=expression(130),_.contains([\"in\",\"of\"],state.tokens.next.value)?advance():error(\"E045\",state.tokens.curr),state.funct[\"(comparray)\"].setState(\"generate\"),expression(10),advance(\")\"),\"if\"===state.tokens.next.value&&(advance(\"if\"),advance(\"(\"),state.funct[\"(comparray)\"].setState(\"filter\"),res.filter=expression(10),advance(\")\")),reversed||(state.funct[\"(comparray)\"].setState(\"use\"),res.right=expression(10)),advance(\"]\"),state.funct[\"(comparray)\"].unstack(),res}function isMethod(){return state.funct[\"(statement)\"]&&\"class\"===state.funct[\"(statement)\"].type||state.funct[\"(context)\"]&&\"class\"===state.funct[\"(context)\"][\"(verb)\"]}function isPropertyName(token){return token.identifier||\"(string)\"===token.id||\"(number)\"===token.id}function propertyName(preserveOrToken){var id,preserve=!0;return\"object\"==typeof preserveOrToken?id=preserveOrToken:(preserve=preserveOrToken,id=optionalidentifier(!1,!0,preserve)),id?\"object\"==typeof id&&(\"(string)\"===id.id||\"(identifier)\"===id.id?id=id.value:\"(number)\"===id.id&&(id=\"\"+id.value)):\"(string)\"===state.tokens.next.id?(id=state.tokens.next.value,preserve||advance()):\"(number)\"===state.tokens.next.id&&(id=\"\"+state.tokens.next.value,preserve||advance()),\"hasOwnProperty\"===id&&warning(\"W001\"),id}function functionparams(options){function addParam(addParamArgs){state.funct[\"(scope)\"].addParam.apply(state.funct[\"(scope)\"],addParamArgs)}var next,ident,t,paramsIds=[],tokens=[],pastDefault=!1,pastRest=!1,arity=0,loneArg=options&&options.loneArg;if(loneArg&&loneArg.identifier===!0)return state.funct[\"(scope)\"].addParam(loneArg.value,loneArg),{arity:1,params:[loneArg.value]};if(next=state.tokens.next,options&&options.parsedOpening||advance(\"(\"),\")\"===state.tokens.next.id)return advance(\")\"),void 0;for(;;){arity++;var currentParams=[];if(_.contains([\"{\",\"[\"],state.tokens.next.id)){tokens=destructuringPattern();for(t in tokens)t=tokens[t],t.id&&(paramsIds.push(t.id),currentParams.push([t.id,t.token]))}else if(checkPunctuator(state.tokens.next,\"...\")&&(pastRest=!0),ident=identifier(!0))paramsIds.push(ident),currentParams.push([ident,state.tokens.curr]);else for(;!checkPunctuators(state.tokens.next,[\",\",\")\"]);)advance();if(pastDefault&&\"=\"!==state.tokens.next.id&&error(\"W138\",state.tokens.current),\"=\"===state.tokens.next.id&&(state.inES6()||warning(\"W119\",state.tokens.next,\"default parameters\",\"6\"),advance(\"=\"),pastDefault=!0,expression(10)),currentParams.forEach(addParam),\",\"!==state.tokens.next.id)return advance(\")\",next),{arity:arity,params:paramsIds};pastRest&&warning(\"W131\",state.tokens.next),comma()}}function functor(name,token,overwrites){var funct={\"(name)\":name,\"(breakage)\":0,\"(loopage)\":0,\"(tokens)\":{},\"(properties)\":{},\"(catch)\":!1,\"(global)\":!1,\"(line)\":null,\"(character)\":null,\"(metrics)\":null,\"(statement)\":null,\"(context)\":null,\"(scope)\":null,\"(comparray)\":null,\"(generator)\":null,\"(arrow)\":null,\"(params)\":null};return token&&_.extend(funct,{\"(line)\":token.line,\"(character)\":token.character,\"(metrics)\":createMetrics(token)}),_.extend(funct,overwrites),funct[\"(context)\"]&&(funct[\"(scope)\"]=funct[\"(context)\"][\"(scope)\"],funct[\"(comparray)\"]=funct[\"(context)\"][\"(comparray)\"]),funct}function isFunctor(token){return\"(scope)\"in token}function hasParsedCode(funct){return funct[\"(global)\"]&&!funct[\"(verb)\"]}function doTemplateLiteral(left){function end(){if(state.tokens.curr.template&&state.tokens.curr.tail&&state.tokens.curr.context===ctx)return!0;var complete=state.tokens.next.template&&state.tokens.next.tail&&state.tokens.next.context===ctx;return complete&&advance(),complete||state.tokens.next.isUnclosed}var ctx=this.context,noSubst=this.noSubst,depth=this.depth;if(!noSubst)for(;!end();)!state.tokens.next.template||state.tokens.next.depth>depth?expression(0):advance();return{id:\"(template)\",type:\"(template)\",tag:left}}function doFunction(options){var f,token,name,statement,classExprBinding,isGenerator,isArrow,ignoreLoopFunc,oldOption=state.option,oldIgnored=state.ignored;options&&(name=options.name,statement=options.statement,classExprBinding=options.classExprBinding,isGenerator=\"generator\"===options.type,isArrow=\"arrow\"===options.type,ignoreLoopFunc=options.ignoreLoopFunc),state.option=Object.create(state.option),state.ignored=Object.create(state.ignored),state.funct=functor(name||state.nameStack.infer(),state.tokens.next,{\"(statement)\":statement,\"(context)\":state.funct,\"(arrow)\":isArrow,\"(generator)\":isGenerator}),f=state.funct,token=state.tokens.curr,token.funct=state.funct,functions.push(state.funct),state.funct[\"(scope)\"].stack(\"functionouter\");var internallyAccessibleName=name||classExprBinding;internallyAccessibleName&&state.funct[\"(scope)\"].block.add(internallyAccessibleName,classExprBinding?\"class\":\"function\",state.tokens.curr,!1),state.funct[\"(scope)\"].stack(\"functionparams\");var paramsInfo=functionparams(options);return paramsInfo?(state.funct[\"(params)\"]=paramsInfo.params,state.funct[\"(metrics)\"].arity=paramsInfo.arity,state.funct[\"(metrics)\"].verifyMaxParametersPerFunction()):state.funct[\"(metrics)\"].arity=0,isArrow&&(state.inES6(!0)||warning(\"W119\",state.tokens.curr,\"arrow function syntax (=>)\",\"6\"),options.loneArg||advance(\"=>\")),block(!1,!0,!0,isArrow),!state.option.noyield&&isGenerator&&\"yielded\"!==state.funct[\"(generator)\"]&&warning(\"W124\",state.tokens.curr),state.funct[\"(metrics)\"].verifyMaxStatementsPerFunction(),state.funct[\"(metrics)\"].verifyMaxComplexityPerFunction(),state.funct[\"(unusedOption)\"]=state.option.unused,state.option=oldOption,state.ignored=oldIgnored,state.funct[\"(last)\"]=state.tokens.curr.line,state.funct[\"(lastcharacter)\"]=state.tokens.curr.character,state.funct[\"(scope)\"].unstack(),state.funct[\"(scope)\"].unstack(),state.funct=state.funct[\"(context)\"],ignoreLoopFunc||state.option.loopfunc||!state.funct[\"(loopage)\"]||f[\"(isCapturing)\"]&&warning(\"W083\",token),f}function createMetrics(functionStartToken){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){state.option.maxstatements&&this.statementCount>state.option.maxstatements&&warning(\"W071\",functionStartToken,this.statementCount)\n},verifyMaxParametersPerFunction:function(){_.isNumber(state.option.maxparams)&&this.arity>state.option.maxparams&&warning(\"W072\",functionStartToken,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){state.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===state.option.maxdepth+1&&warning(\"W073\",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var max=state.option.maxcomplexity,cc=this.ComplexityCount;max&&cc>max&&warning(\"W074\",functionStartToken,cc)}}}function increaseComplexityCount(){state.funct[\"(metrics)\"].ComplexityCount+=1}function checkCondAssignment(expr){var id,paren;switch(expr&&(id=expr.id,paren=expr.paren,\",\"===id&&(expr=expr.exprs[expr.exprs.length-1])&&(id=expr.id,paren=paren||expr.paren)),id){case\"=\":case\"+=\":case\"-=\":case\"*=\":case\"%=\":case\"&=\":case\"|=\":case\"^=\":case\"/=\":paren||state.option.boss||warning(\"W084\")}}function checkProperties(props){if(state.inES5())for(var name in props)props[name]&&props[name].setterToken&&!props[name].getterToken&&warning(\"W078\",props[name].setterToken)}function metaProperty(name,c){if(checkPunctuator(state.tokens.next,\".\")){var left=state.tokens.curr.id;advance(\".\");var id=identifier();return state.tokens.curr.isMetaProperty=!0,name!==id?error(\"E057\",state.tokens.prev,left,id):c(),state.tokens.curr}}function destructuringPattern(options){var isAssignment=options&&options.assignment;return state.inES6()||warning(\"W104\",state.tokens.curr,isAssignment?\"destructuring assignment\":\"destructuring binding\",\"6\"),destructuringPatternRecursive(options)}function destructuringPatternRecursive(options){var ids,identifiers=[],openingParsed=options&&options.openingParsed,isAssignment=options&&options.assignment,recursiveOptions=isAssignment?{assignment:isAssignment}:null,firstToken=openingParsed?state.tokens.curr:state.tokens.next,nextInnerDE=function(){var ident;if(checkPunctuators(state.tokens.next,[\"[\",\"{\"])){ids=destructuringPatternRecursive(recursiveOptions);for(var id in ids)id=ids[id],identifiers.push({id:id.id,token:id.token})}else if(checkPunctuator(state.tokens.next,\",\"))identifiers.push({id:null,token:state.tokens.curr});else{if(!checkPunctuator(state.tokens.next,\"(\")){var is_rest=checkPunctuator(state.tokens.next,\"...\");if(isAssignment){var identifierToken=is_rest?peek(0):state.tokens.next;identifierToken.identifier||warning(\"E030\",identifierToken,identifierToken.value);var assignTarget=expression(155);assignTarget&&(checkLeftSideAssign(assignTarget),assignTarget.identifier&&(ident=assignTarget.value))}else ident=identifier();return ident&&identifiers.push({id:ident,token:state.tokens.curr}),is_rest}advance(\"(\"),nextInnerDE(),advance(\")\")}return!1},assignmentProperty=function(){var id;checkPunctuator(state.tokens.next,\"[\")?(advance(\"[\"),expression(10),advance(\"]\"),advance(\":\"),nextInnerDE()):\"(string)\"===state.tokens.next.id||\"(number)\"===state.tokens.next.id?(advance(),advance(\":\"),nextInnerDE()):(id=identifier(),checkPunctuator(state.tokens.next,\":\")?(advance(\":\"),nextInnerDE()):id&&(isAssignment&&checkLeftSideAssign(state.tokens.curr),identifiers.push({id:id,token:state.tokens.curr})))};if(checkPunctuator(firstToken,\"[\")){openingParsed||advance(\"[\"),checkPunctuator(state.tokens.next,\"]\")&&warning(\"W137\",state.tokens.curr);for(var element_after_rest=!1;!checkPunctuator(state.tokens.next,\"]\");)nextInnerDE()&&!element_after_rest&&checkPunctuator(state.tokens.next,\",\")&&(warning(\"W130\",state.tokens.next),element_after_rest=!0),checkPunctuator(state.tokens.next,\"=\")&&(checkPunctuator(state.tokens.prev,\"...\")?advance(\"]\"):advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"]\")||advance(\",\");advance(\"]\")}else if(checkPunctuator(firstToken,\"{\")){for(openingParsed||advance(\"{\"),checkPunctuator(state.tokens.next,\"}\")&&warning(\"W137\",state.tokens.curr);!checkPunctuator(state.tokens.next,\"}\")&&(assignmentProperty(),checkPunctuator(state.tokens.next,\"=\")&&(advance(\"=\"),\"undefined\"===state.tokens.next.id&&warning(\"W080\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\"}\")||(advance(\",\"),!checkPunctuator(state.tokens.next,\"}\"))););advance(\"}\")}return identifiers}function destructuringPatternMatch(tokens,value){var first=value.first;first&&_.zip(tokens,Array.isArray(first)?first:[first]).forEach(function(val){var token=val[0],value=val[1];token&&value?token.first=value:token&&token.first&&!value&&warning(\"W080\",token.first,token.first.value)})}function blockVariableStatement(type,statement,context){var tokens,lone,value,letblock,prefix=context&&context.prefix,inexport=context&&context.inexport,isLet=\"let\"===type,isConst=\"const\"===type;for(state.inES6()||warning(\"W104\",state.tokens.curr,type,\"6\"),isLet&&\"(\"===state.tokens.next.value?(state.inMoz()||warning(\"W118\",state.tokens.next,\"let block\"),advance(\"(\"),state.funct[\"(scope)\"].stack(),letblock=!0):state.funct[\"(noblockscopedvar)\"]&&error(\"E048\",state.tokens.curr,isConst?\"Const\":\"Let\"),statement.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),!prefix&&isConst&&\"=\"!==state.tokens.next.id&&warning(\"E012\",state.tokens.curr,state.tokens.curr.value);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],state.funct[\"(scope)\"].block.isGlobal()&&predefined[t.id]===!1&&warning(\"W079\",t.token,t.id),t.id&&!state.funct[\"(noblockscopedvar)\"]&&(state.funct[\"(scope)\"].addlabel(t.id,{type:type,token:t.token}),names.push(t.token),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.token.value,t.token)));if(\"=\"===state.tokens.next.id&&(advance(\"=\"),prefix||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),!prefix&&\"=\"===peek(0).id&&state.tokens.next.identifier&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),statement.first=statement.first.concat(names),\",\"!==state.tokens.next.id)break;comma()}return letblock&&(advance(\")\"),block(!0,!0),statement.block=!0,state.funct[\"(scope)\"].unstack()),statement}function classdef(isStatement){return state.inES6()||warning(\"W104\",state.tokens.curr,\"class\",\"6\"),isStatement?(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"class\",token:state.tokens.curr})):state.tokens.next.identifier&&\"extends\"!==state.tokens.next.value?(this.name=identifier(),this.namedExpr=!0):this.name=state.nameStack.infer(),classtail(this),this}function classtail(c){var wasInClassBody=state.inClassBody;\"extends\"===state.tokens.next.value&&(advance(\"extends\"),c.heritage=expression(10)),state.inClassBody=!0,advance(\"{\"),c.body=classbody(c),advance(\"}\"),state.inClassBody=wasInClassBody}function classbody(c){for(var name,isStatic,isGenerator,getset,computed,props=Object.create(null),staticProps=Object.create(null),i=0;\"}\"!==state.tokens.next.id;++i)if(name=state.tokens.next,isStatic=!1,isGenerator=!1,getset=null,\";\"!==name.id){if(\"*\"===name.id&&(isGenerator=!0,advance(\"*\"),name=state.tokens.next),\"[\"===name.id)name=computedPropertyName(),computed=!0;else{if(!isPropertyName(name)){warning(\"W052\",state.tokens.next,state.tokens.next.value||state.tokens.next.type),advance();continue}advance(),computed=!1,name.identifier&&\"static\"===name.value&&(checkPunctuator(state.tokens.next,\"*\")&&(isGenerator=!0,advance(\"*\")),(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,isStatic=!0,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())),!name.identifier||\"get\"!==name.value&&\"set\"!==name.value||(isPropertyName(state.tokens.next)||\"[\"===state.tokens.next.id)&&(computed=\"[\"===state.tokens.next.id,getset=name,name=state.tokens.next,\"[\"===state.tokens.next.id?name=computedPropertyName():advance())}if(!checkPunctuator(state.tokens.next,\"(\")){for(error(\"E054\",state.tokens.next,state.tokens.next.value);\"}\"!==state.tokens.next.id&&!checkPunctuator(state.tokens.next,\"(\");)advance();\"(\"!==state.tokens.next.value&&doFunction({statement:c})}if(computed||(getset?saveAccessor(getset.value,isStatic?staticProps:props,name.value,name,!0,isStatic):(\"constructor\"===name.value?state.nameStack.set(c):state.nameStack.set(name),saveProperty(isStatic?staticProps:props,name.value,name,!0,isStatic))),getset&&\"constructor\"===name.value){var propDesc=\"get\"===getset.value?\"class getter method\":\"class setter method\";error(\"E049\",name,propDesc,\"constructor\")}else\"prototype\"===name.value&&error(\"E049\",name,\"class method\",\"prototype\");propertyName(name),doFunction({statement:c,type:isGenerator?\"generator\":null,classExprBinding:c.namedExpr?c.name:null})}else warning(\"W032\"),advance(\";\");checkProperties(props)}function saveProperty(props,name,tkn,isClass,isStatic){var msg=[\"key\",\"class method\",\"static class method\"];msg=msg[(isClass||!1)+(isStatic||!1)],tkn.identifier&&(name=tkn.value),props[name]&&\"__proto__\"!==name?warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name].basic=!0,props[name].basictkn=tkn}function saveAccessor(accessorType,props,name,tkn,isClass,isStatic){var flagName=\"get\"===accessorType?\"getterToken\":\"setterToken\",msg=\"\";isClass?(isStatic&&(msg+=\"static \"),msg+=accessorType+\"ter method\"):msg=\"key\",state.tokens.curr.accessorType=accessorType,state.nameStack.set(tkn),props[name]?(props[name].basic||props[name][flagName])&&\"__proto__\"!==name&&warning(\"W075\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name][flagName]=tkn}function computedPropertyName(){advance(\"[\"),state.inES6()||warning(\"W119\",state.tokens.curr,\"computed property names\",\"6\");var value=expression(10);return advance(\"]\"),value}function checkPunctuators(token,values){return\"(punctuator)\"===token.type?_.contains(values,token.value):!1}function checkPunctuator(token,value){return\"(punctuator)\"===token.type&&token.value===value}function destructuringAssignOrJsonValue(){var block=lookupBlockType();block.notJson?(!state.inES6()&&block.isDestAssign&&warning(\"W104\",state.tokens.curr,\"destructuring assignment\",\"6\"),statements()):(state.option.laxbreak=!0,state.jsonMode=!0,jsonValue())}function jsonValue(){function jsonObject(){var o={},t=state.tokens.next;if(advance(\"{\"),\"}\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E026\",state.tokens.next,t.line);else{if(\"}\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id?error(\"E028\",state.tokens.next):\"(string)\"!==state.tokens.next.id&&warning(\"W095\",state.tokens.next,state.tokens.next.value)}if(o[state.tokens.next.value]===!0?warning(\"W075\",state.tokens.next,\"key\",state.tokens.next.value):\"__proto__\"===state.tokens.next.value&&!state.option.proto||\"__iterator__\"===state.tokens.next.value&&!state.option.iterator?warning(\"W096\",state.tokens.next,state.tokens.next.value):o[state.tokens.next.value]=!0,advance(),advance(\":\"),jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"}\")}function jsonArray(){var t=state.tokens.next;if(advance(\"[\"),\"]\"!==state.tokens.next.id)for(;;){if(\"(end)\"===state.tokens.next.id)error(\"E027\",state.tokens.next,t.line);else{if(\"]\"===state.tokens.next.id){warning(\"W094\",state.tokens.curr);break}\",\"===state.tokens.next.id&&error(\"E028\",state.tokens.next)}if(jsonValue(),\",\"!==state.tokens.next.id)break;advance(\",\")}advance(\"]\")}switch(state.tokens.next.id){case\"{\":jsonObject();break;case\"[\":jsonArray();break;case\"true\":case\"false\":case\"null\":case\"(number)\":case\"(string)\":advance();break;case\"-\":advance(\"-\"),advance(\"(number)\");break;default:error(\"E003\",state.tokens.next)}}var api,declared,functions,inblock,indent,lookahead,lex,member,membersOnly,predefined,stack,urls,bang={\"<\":!0,\"<=\":!0,\"==\":!0,\"===\":!0,\"!==\":!0,\"!=\":!0,\">\":!0,\">=\":!0,\"+\":!0,\"-\":!0,\"*\":!0,\"/\":!0,\"%\":!0},functionicity=[\"closure\",\"exception\",\"global\",\"label\",\"outer\",\"unused\",\"var\"],extraModules=[],emitter=new events.EventEmitter,typeofValues={};typeofValues.legacy=[\"xml\",\"unknown\"],typeofValues.es3=[\"undefined\",\"boolean\",\"number\",\"string\",\"function\",\"object\"],typeofValues.es3=typeofValues.es3.concat(typeofValues.legacy),typeofValues.es6=typeofValues.es3.concat(\"symbol\"),type(\"(number)\",function(){return this}),type(\"(string)\",function(){return this}),state.syntax[\"(identifier)\"]={type:\"(identifier)\",lbp:0,identifier:!0,nud:function(){var v=this.value;return\"=>\"===state.tokens.next.id?this:(state.funct[\"(comparray)\"].check(v)||state.funct[\"(scope)\"].block.use(v,state.tokens.curr),this)},led:function(){error(\"E033\",state.tokens.next,state.tokens.next.value)}};var baseTemplateSyntax={lbp:0,identifier:!1,template:!0};state.syntax[\"(template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template middle)\"]=_.extend({type:\"(template middle)\",middle:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(template tail)\"]=_.extend({type:\"(template tail)\",tail:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\"(no subst template)\"]=_.extend({type:\"(template)\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!0,tail:!0},baseTemplateSyntax),type(\"(regexp)\",function(){return this}),delim(\"(endline)\"),delim(\"(begin)\"),delim(\"(end)\").reach=!0,delim(\"(error)\").reach=!0,delim(\"}\").reach=!0,delim(\")\"),delim(\"]\"),delim('\"').reach=!0,delim(\"'\").reach=!0,delim(\";\"),delim(\":\").reach=!0,delim(\"#\"),reserve(\"else\"),reserve(\"case\").reach=!0,reserve(\"catch\"),reserve(\"default\").reach=!0,reserve(\"finally\"),reservevar(\"arguments\",function(x){state.isStrict()&&state.funct[\"(global)\"]&&warning(\"E008\",x)}),reservevar(\"eval\"),reservevar(\"false\"),reservevar(\"Infinity\"),reservevar(\"null\"),reservevar(\"this\",function(x){state.isStrict()&&!isMethod()&&!state.option.validthis&&(state.funct[\"(statement)\"]&&state.funct[\"(name)\"].charAt(0)>\"Z\"||state.funct[\"(global)\"])&&warning(\"W040\",x)}),reservevar(\"true\"),reservevar(\"undefined\"),assignop(\"=\",\"assign\",20),assignop(\"+=\",\"assignadd\",20),assignop(\"-=\",\"assignsub\",20),assignop(\"*=\",\"assignmult\",20),assignop(\"/=\",\"assigndiv\",20).nud=function(){error(\"E014\")},assignop(\"%=\",\"assignmod\",20),bitwiseassignop(\"&=\"),bitwiseassignop(\"|=\"),bitwiseassignop(\"^=\"),bitwiseassignop(\"<<=\"),bitwiseassignop(\">>=\"),bitwiseassignop(\">>>=\"),infix(\",\",function(left,that){var expr;if(that.exprs=[left],state.option.nocomma&&warning(\"W127\"),!comma({peek:!0}))return that;for(;;){if(!(expr=expression(10)))break;if(that.exprs.push(expr),\",\"!==state.tokens.next.value||!comma())break}return that},10,!0),infix(\"?\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(10),advance(\":\"),that[\"else\"]=expression(10),that},30);var orPrecendence=40;infix(\"||\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(orPrecendence),that},orPrecendence),infix(\"&&\",\"and\",50),bitwise(\"|\",\"bitor\",70),bitwise(\"^\",\"bitxor\",80),bitwise(\"&\",\"bitand\",90),relation(\"==\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));switch(!0){case!eqnull&&state.option.eqeqeq:this.from=this.character,warning(\"W116\",this,\"===\",\"==\");break;case isPoorRelation(left):warning(\"W041\",this,\"===\",left.value);break;case isPoorRelation(right):warning(\"W041\",this,\"===\",right.value);break;case isTypoTypeof(right,left,state):warning(\"W122\",this,right.value);break;case isTypoTypeof(left,right,state):warning(\"W122\",this,left.value)}return this}),relation(\"===\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!=\",function(left,right){var eqnull=state.option.eqnull&&(\"null\"===(left&&left.value)||\"null\"===(right&&right.value));return!eqnull&&state.option.eqeqeq?(this.from=this.character,warning(\"W116\",this,\"!==\",\"!=\")):isPoorRelation(left)?warning(\"W041\",this,\"!==\",left.value):isPoorRelation(right)?warning(\"W041\",this,\"!==\",right.value):isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"!==\",function(left,right){return isTypoTypeof(right,left,state)?warning(\"W122\",this,right.value):isTypoTypeof(left,right,state)&&warning(\"W122\",this,left.value),this}),relation(\"<\"),relation(\">\"),relation(\"<=\"),relation(\">=\"),bitwise(\"<<\",\"shiftleft\",120),bitwise(\">>\",\"shiftright\",120),bitwise(\">>>\",\"shiftrightunsigned\",120),infix(\"in\",\"in\",120),infix(\"instanceof\",\"instanceof\",120),infix(\"+\",function(left,that){var right;return that.left=left,that.right=right=expression(130),left&&right&&\"(string)\"===left.id&&\"(string)\"===right.id?(left.value+=right.value,left.character=right.character,!state.option.scripturl&®.javascriptURL.test(left.value)&&warning(\"W050\",left),left):that},130),prefix(\"+\",\"num\"),prefix(\"+++\",function(){return warning(\"W007\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"+++\",function(left){return warning(\"W007\"),this.left=left,this.right=expression(130),this},130),infix(\"-\",\"sub\",130),prefix(\"-\",\"neg\"),prefix(\"---\",function(){return warning(\"W006\"),this.arity=\"unary\",this.right=expression(150),this}),infix(\"---\",function(left){return warning(\"W006\"),this.left=left,this.right=expression(130),this},130),infix(\"*\",\"mult\",140),infix(\"/\",\"div\",140),infix(\"%\",\"mod\",140),suffix(\"++\"),prefix(\"++\",\"preinc\"),state.syntax[\"++\"].exps=!0,suffix(\"--\"),prefix(\"--\",\"predec\"),state.syntax[\"--\"].exps=!0,prefix(\"delete\",function(){var p=expression(10);return p?(\".\"!==p.id&&\"[\"!==p.id&&warning(\"W051\"),this.first=p,p.identifier&&!state.isStrict()&&(p.forgiveUndef=!0),this):this}).exps=!0,prefix(\"~\",function(){return state.option.bitwise&&warning(\"W016\",this,\"~\"),this.arity=\"unary\",this.right=expression(150),this}),prefix(\"...\",function(){return state.inES6(!0)||warning(\"W119\",this,\"spread/rest operator\",\"6\"),state.tokens.next.identifier||\"(string)\"===state.tokens.next.type||checkPunctuators(state.tokens.next,[\"[\",\"(\"])||error(\"E030\",state.tokens.next,state.tokens.next.value),expression(150),this}),prefix(\"!\",function(){return this.arity=\"unary\",this.right=expression(150),this.right||quit(\"E041\",this.line||0),bang[this.right.id]===!0&&warning(\"W018\",this,\"!\"),this}),prefix(\"typeof\",function(){var p=expression(150);return this.first=this.right=p,p||quit(\"E041\",this.line||0,this.character||0),p.identifier&&(p.forgiveUndef=!0),this}),prefix(\"new\",function(){var mp=metaProperty(\"target\",function(){state.inES6(!0)||warning(\"W119\",state.tokens.prev,\"new.target\",\"6\");for(var inFunction,c=state.funct;c&&(inFunction=!c[\"(global)\"],c[\"(arrow)\"]);)c=c[\"(context)\"];inFunction||warning(\"W136\",state.tokens.prev,\"new.target\")});if(mp)return mp;var i,c=expression(155);if(c&&\"function\"!==c.id)if(c.identifier)switch(c[\"new\"]=!0,c.value){case\"Number\":case\"String\":case\"Boolean\":case\"Math\":case\"JSON\":warning(\"W053\",state.tokens.prev,c.value);break;case\"Symbol\":state.inES6()&&warning(\"W053\",state.tokens.prev,c.value);break;case\"Function\":state.option.evil||warning(\"W054\");break;case\"Date\":case\"RegExp\":case\"this\":break;default:\"function\"!==c.id&&(i=c.value.substr(0,1),state.option.newcap&&(\"A\">i||i>\"Z\")&&!state.funct[\"(scope)\"].isPredefined(c.value)&&warning(\"W055\",state.tokens.curr))}else\".\"!==c.id&&\"[\"!==c.id&&\"(\"!==c.id&&warning(\"W056\",state.tokens.curr);else state.option.supernew||warning(\"W057\",this);return\"(\"===state.tokens.next.id||state.option.supernew||warning(\"W058\",state.tokens.curr,state.tokens.curr.value),this.first=this.right=c,this}),state.syntax[\"new\"].exps=!0,prefix(\"void\").exps=!0,infix(\".\",function(left,that){var m=identifier(!1,!0);return\"string\"==typeof m&&countMember(m),that.left=left,that.right=m,m&&\"hasOwnProperty\"===m&&\"=\"===state.tokens.next.value&&warning(\"W001\"),!left||\"arguments\"!==left.value||\"callee\"!==m&&\"caller\"!==m?state.option.evil||!left||\"document\"!==left.value||\"write\"!==m&&\"writeln\"!==m||warning(\"W060\",left):state.option.noarg?warning(\"W059\",left,m):state.isStrict()&&error(\"E008\"),state.option.evil||\"eval\"!==m&&\"execScript\"!==m||isGlobalEval(left,state)&&warning(\"W061\"),that},160,!0),infix(\"(\",function(left,that){state.option.immed&&left&&!left.immed&&\"function\"===left.id&&warning(\"W062\");var n=0,p=[];if(left&&\"(identifier)\"===left.type&&left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1===\"Array Number String Boolean Date Object Error Symbol\".indexOf(left.value)&&(\"Math\"===left.value?warning(\"W063\",left):state.option.newcap&&warning(\"W064\",left)),\")\"!==state.tokens.next.id)for(;p[p.length]=expression(10),n+=1,\",\"===state.tokens.next.id;)comma();return advance(\")\"),\"object\"==typeof left&&(state.inES5()||\"parseInt\"!==left.value||1!==n||warning(\"W065\",state.tokens.curr),state.option.evil||(\"eval\"===left.value||\"Function\"===left.value||\"execScript\"===left.value?(warning(\"W061\",left),p[0]&&\"(string)\"===[0].id&&addInternalSrc(left,p[0].value)):!p[0]||\"(string)\"!==p[0].id||\"setTimeout\"!==left.value&&\"setInterval\"!==left.value?!p[0]||\"(string)\"!==p[0].id||\".\"!==left.value||\"window\"!==left.left.value||\"setTimeout\"!==left.right&&\"setInterval\"!==left.right||(warning(\"W066\",left),addInternalSrc(left,p[0].value)):(warning(\"W066\",left),addInternalSrc(left,p[0].value))),left.identifier||\".\"===left.id||\"[\"===left.id||\"=>\"===left.id||\"(\"===left.id||\"&&\"===left.id||\"||\"===left.id||\"?\"===left.id||state.inES6()&&left[\"(name)\"]||warning(\"W067\",that)),that.left=left,that},155,!0).exps=!0,prefix(\"(\",function(){var pn1,ret,triggerFnExpr,first,last,pn=state.tokens.next,i=-1,parens=1,opening=state.tokens.curr,preceeding=state.tokens.prev,isNecessary=!state.option.singleGroups;do\"(\"===pn.value?parens+=1:\")\"===pn.value&&(parens-=1),i+=1,pn1=pn,pn=peek(i);while((0!==parens||\")\"!==pn1.value)&&\";\"!==pn.value&&\"(end)\"!==pn.type);if(\"function\"===state.tokens.next.id&&(triggerFnExpr=state.tokens.next.immed=!0),\"=>\"===pn.value)return doFunction({type:\"arrow\",parsedOpening:!0});var exprs=[];if(\")\"!==state.tokens.next.id)for(;exprs.push(expression(10)),\",\"===state.tokens.next.id;)state.option.nocomma&&warning(\"W127\"),comma();return advance(\")\",this),state.option.immed&&exprs[0]&&\"function\"===exprs[0].id&&\"(\"!==state.tokens.next.id&&\".\"!==state.tokens.next.id&&\"[\"!==state.tokens.next.id&&warning(\"W068\",this),exprs.length?(exprs.length>1?(ret=Object.create(state.syntax[\",\"]),ret.exprs=exprs,first=exprs[0],last=exprs[exprs.length-1],isNecessary||(isNecessary=preceeding.assign||preceeding.delim)):(ret=first=last=exprs[0],isNecessary||(isNecessary=opening.beginsStmt&&(\"{\"===ret.id||triggerFnExpr||isFunctor(ret))||triggerFnExpr&&(!isEndOfExpr()||\"}\"!==state.tokens.prev.id)||isFunctor(ret)&&!isEndOfExpr()||\"{\"===ret.id&&\"=>\"===preceeding.id||\"(number)\"===ret.type&&checkPunctuator(pn,\".\")&&/^\\d+$/.test(ret.value))),ret&&(!isNecessary&&(first.left||first.right||ret.exprs)&&(isNecessary=!isBeginOfExpr(preceeding)&&first.lbp<=preceeding.lbp||!isEndOfExpr()&&last.lbp\"),infix(\"[\",function(left,that){var s,e=expression(10);return e&&\"(string)\"===e.type&&(state.option.evil||\"eval\"!==e.value&&\"execScript\"!==e.value||isGlobalEval(left,state)&&warning(\"W061\"),countMember(e.value),!state.option.sub&®.identifier.test(e.value)&&(s=state.syntax[e.value],s&&isReserved(s)||warning(\"W069\",state.tokens.prev,e.value))),advance(\"]\",that),e&&\"hasOwnProperty\"===e.value&&\"=\"===state.tokens.next.value&&warning(\"W001\"),that.left=left,that.right=e,that},160,!0),prefix(\"[\",function(){var blocktype=lookupBlockType();if(blocktype.isCompArray)return state.option.esnext||state.inMoz()||warning(\"W118\",state.tokens.curr,\"array comprehension\"),comprehensiveArrayExpression();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;var b=state.tokens.curr.line!==startLine(state.tokens.next);for(this.first=[],b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));\"(end)\"!==state.tokens.next.id;){for(;\",\"===state.tokens.next.id;){if(!state.option.elision){if(state.inES5()){warning(\"W128\");do advance(\",\");while(\",\"===state.tokens.next.id);continue}warning(\"W070\")}advance(\",\")}if(\"]\"===state.tokens.next.id)break;if(this.first.push(expression(10)),\",\"!==state.tokens.next.id)break;if(comma({allowTrailing:!0}),\"]\"===state.tokens.next.id&&!state.inES5()){warning(\"W070\",state.tokens.curr);break}}return b&&(indent-=state.option.indent),advance(\"]\",this),this}),function(x){x.nud=function(){var b,f,i,p,t,nextVal,isGeneratorMethod=!1,props=Object.create(null);b=state.tokens.curr.line!==startLine(state.tokens.next),b&&(indent+=state.option.indent,state.tokens.next.from===indent+state.option.indent&&(indent+=state.option.indent));var blocktype=lookupBlockType();if(blocktype.isDestAssign)return this.destructAssign=destructuringPattern({openingParsed:!0,assignment:!0}),this;for(;\"}\"!==state.tokens.next.id;){if(nextVal=state.tokens.next.value,!state.tokens.next.identifier||\",\"!==peekIgnoreEOL().id&&\"}\"!==peekIgnoreEOL().id)if(\":\"===peek().id||\"get\"!==nextVal&&\"set\"!==nextVal){if(\"*\"===state.tokens.next.value&&\"(punctuator)\"===state.tokens.next.type?(state.inES6()||warning(\"W104\",state.tokens.next,\"generator functions\",\"6\"),advance(\"*\"),isGeneratorMethod=!0):isGeneratorMethod=!1,\"[\"===state.tokens.next.id)i=computedPropertyName(),state.nameStack.set(i);else if(state.nameStack.set(state.tokens.next),i=propertyName(),saveProperty(props,i,state.tokens.next),\"string\"!=typeof i)break;\"(\"===state.tokens.next.value?(state.inES6()||warning(\"W104\",state.tokens.curr,\"concise methods\",\"6\"),doFunction({type:isGeneratorMethod?\"generator\":null})):(advance(\":\"),expression(10))}else advance(nextVal),state.inES5()||error(\"E034\"),i=propertyName(),i||state.inES6()||error(\"E035\"),i&&saveAccessor(nextVal,props,i,state.tokens.curr),t=state.tokens.next,f=doFunction(),p=f[\"(params)\"],\"get\"===nextVal&&i&&p?warning(\"W076\",t,p[0],i):\"set\"!==nextVal||!i||p&&1===p.length||warning(\"W077\",t,i);else state.inES6()||warning(\"W104\",state.tokens.next,\"object short notation\",\"6\"),i=propertyName(!0),saveProperty(props,i,state.tokens.next),expression(10);if(countMember(i),\",\"!==state.tokens.next.id)break;comma({allowTrailing:!0,property:!0}),\",\"===state.tokens.next.id?warning(\"W070\",state.tokens.curr):\"}\"!==state.tokens.next.id||state.inES5()||warning(\"W070\",state.tokens.curr)}return b&&(indent-=state.option.indent),advance(\"}\",this),checkProperties(props),this},x.fud=function(){error(\"E036\",state.tokens.curr)}}(delim(\"{\"));var conststatement=stmt(\"const\",function(context){return blockVariableStatement(\"const\",this,context)});conststatement.exps=!0;var letstatement=stmt(\"let\",function(context){return blockVariableStatement(\"let\",this,context)});letstatement.exps=!0;var varstatement=stmt(\"var\",function(context){var tokens,lone,value,prefix=context&&context.prefix,inexport=context&&context.inexport,implied=context&&context.implied,report=!(context&&context.ignore);for(this.first=[];;){var names=[];_.contains([\"{\",\"[\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),prefix&&implied||!report||!state.option.varstmt||warning(\"W132\",this),this.first=this.first.concat(names);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],!implied&&state.funct[\"(global)\"]&&(predefined[t.id]===!1?warning(\"W079\",t.token,t.id):state.option.futurehostile===!1&&(!state.inES5()&&vars.ecmaIdentifiers[5][t.id]===!1||!state.inES6()&&vars.ecmaIdentifiers[6][t.id]===!1)&&warning(\"W129\",t.token,t.id)),t.id&&(\"for\"===implied?(state.funct[\"(scope)\"].has(t.id)||report&&warning(\"W088\",t.token,t.id),state.funct[\"(scope)\"].block.use(t.id,t.token)):(state.funct[\"(scope)\"].addlabel(t.id,{type:\"var\",token:t.token}),lone&&inexport&&state.funct[\"(scope)\"].setExported(t.id,t.token)),names.push(t.token)));if(\"=\"===state.tokens.next.id&&(state.nameStack.set(state.tokens.curr),advance(\"=\"),prefix||!report||state.funct[\"(loopage)\"]||\"undefined\"!==state.tokens.next.id||warning(\"W080\",state.tokens.prev,state.tokens.prev.value),\"=\"===peek(0).id&&state.tokens.next.identifier&&(!prefix&&report&&!state.funct[\"(params)\"]||-1===state.funct[\"(params)\"].indexOf(state.tokens.next.value))&&warning(\"W120\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),\",\"!==state.tokens.next.id)break;comma()}return this});varstatement.exps=!0,blockstmt(\"class\",function(){return classdef.call(this,!0)}),blockstmt(\"function\",function(context){var inexport=context&&context.inexport,generator=!1;\"*\"===state.tokens.next.value&&(advance(\"*\"),state.inES6({strict:!0})?generator=!0:warning(\"W119\",state.tokens.curr,\"function*\",\"6\")),inblock&&warning(\"W082\",state.tokens.curr);var i=optionalidentifier();return state.funct[\"(scope)\"].addlabel(i,{type:\"function\",token:state.tokens.curr}),void 0===i?warning(\"W025\"):inexport&&state.funct[\"(scope)\"].setExported(i,state.tokens.prev),doFunction({name:i,statement:this,type:generator?\"generator\":null,ignoreLoopFunc:inblock}),\"(\"===state.tokens.next.id&&state.tokens.next.line===state.tokens.curr.line&&error(\"E039\"),this}),prefix(\"function\",function(){var generator=!1;\"*\"===state.tokens.next.value&&(state.inES6()||warning(\"W119\",state.tokens.curr,\"function*\",\"6\"),advance(\"*\"),generator=!0);var i=optionalidentifier();return doFunction({name:i,type:generator?\"generator\":null}),this}),blockstmt(\"if\",function(){var t=state.tokens.next;increaseComplexityCount(),state.condition=!0,advance(\"(\");var expr=expression(0);checkCondAssignment(expr);var forinifcheck=null;state.option.forin&&state.forinifcheckneeded&&(state.forinifcheckneeded=!1,forinifcheck=state.forinifchecks[state.forinifchecks.length-1],forinifcheck.type=\"(punctuator)\"===expr.type&&\"!\"===expr.value?\"(negative)\":\"(positive)\"),advance(\")\",t),state.condition=!1;var s=block(!0,!0);return forinifcheck&&\"(negative)\"===forinifcheck.type&&s&&s[0]&&\"(identifier)\"===s[0].type&&\"continue\"===s[0].value&&(forinifcheck.type=\"(negative-with-continue)\"),\"else\"===state.tokens.next.id&&(advance(\"else\"),\"if\"===state.tokens.next.id||\"switch\"===state.tokens.next.id?statement():block(!0,!0)),this}),blockstmt(\"try\",function(){function doCatch(){if(advance(\"catch\"),advance(\"(\"),state.funct[\"(scope)\"].stack(\"catchparams\"),checkPunctuators(state.tokens.next,[\"[\",\"{\"])){var tokens=destructuringPattern();_.each(tokens,function(token){token.id&&state.funct[\"(scope)\"].addParam(token.id,token,\"exception\")})}else\"(identifier)\"!==state.tokens.next.type?warning(\"E030\",state.tokens.next,state.tokens.next.value):state.funct[\"(scope)\"].addParam(identifier(),state.tokens.curr,\"exception\");\"if\"===state.tokens.next.value&&(state.inMoz()||warning(\"W118\",state.tokens.curr,\"catch filter\"),advance(\"if\"),expression(0)),advance(\")\"),block(!1),state.funct[\"(scope)\"].unstack()}var b;for(block(!0);\"catch\"===state.tokens.next.id;)increaseComplexityCount(),b&&!state.inMoz()&&warning(\"W118\",state.tokens.next,\"multiple catch blocks\"),doCatch(),b=!0;return\"finally\"===state.tokens.next.id?(advance(\"finally\"),block(!0),void 0):(b||error(\"E021\",state.tokens.next,\"catch\",state.tokens.next.value),this)}),blockstmt(\"while\",function(){var t=state.tokens.next;return state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this}).labelled=!0,blockstmt(\"with\",function(){var t=state.tokens.next;return state.isStrict()?error(\"E010\",state.tokens.curr):state.option.withstmt||warning(\"W085\",state.tokens.curr),advance(\"(\"),expression(0),advance(\")\",t),block(!0,!0),this}),blockstmt(\"switch\",function(){var t=state.tokens.next,g=!1,noindent=!1;\nfor(state.funct[\"(breakage)\"]+=1,advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),t=state.tokens.next,advance(\"{\"),state.tokens.next.from===indent&&(noindent=!0),noindent||(indent+=state.option.indent),this.cases=[];;)switch(state.tokens.next.id){case\"case\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"case\":case\"continue\":case\"return\":case\"switch\":case\"throw\":break;default:state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"case\")}advance(\"case\"),this.cases.push(expression(0)),increaseComplexityCount(),g=!0,advance(\":\"),state.funct[\"(verb)\"]=\"case\";break;case\"default\":switch(state.funct[\"(verb)\"]){case\"yield\":case\"break\":case\"continue\":case\"return\":case\"throw\":break;default:this.cases.length&&(state.tokens.curr.caseFallsThrough||warning(\"W086\",state.tokens.curr,\"default\"))}advance(\"default\"),g=!0,advance(\":\");break;case\"}\":return noindent||(indent-=state.option.indent),advance(\"}\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(verb)\"]=void 0,void 0;case\"(end)\":return error(\"E023\",state.tokens.next,\"}\"),void 0;default:if(indent+=state.option.indent,g)switch(state.tokens.curr.id){case\",\":return error(\"E040\"),void 0;case\":\":g=!1,statements();break;default:return error(\"E025\",state.tokens.curr),void 0}else{if(\":\"!==state.tokens.curr.id)return error(\"E021\",state.tokens.next,\"case\",state.tokens.next.value),void 0;advance(\":\"),error(\"E024\",state.tokens.curr,\":\"),statements()}indent-=state.option.indent}return this}).labelled=!0,stmt(\"debugger\",function(){return state.option.debug||warning(\"W087\",this),this}).exps=!0,function(){var x=stmt(\"do\",function(){state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,increaseComplexityCount(),this.first=block(!0,!0),advance(\"while\");var t=state.tokens.next;return advance(\"(\"),checkCondAssignment(expression(0)),advance(\")\",t),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1,this});x.labelled=!0,x.exps=!0}(),blockstmt(\"for\",function(){var s,t=state.tokens.next,letscope=!1,foreachtok=null;\"each\"===t.value&&(foreachtok=t,advance(\"each\"),state.inMoz()||warning(\"W118\",state.tokens.curr,\"for each\")),increaseComplexityCount(),advance(\"(\");var nextop,comma,initializer,i=0,inof=[\"in\",\"of\"],level=0;checkPunctuators(state.tokens.next,[\"{\",\"[\"])&&++level;do{if(nextop=peek(i),++i,checkPunctuators(nextop,[\"{\",\"[\"])?++level:checkPunctuators(nextop,[\"}\",\"]\"])&&--level,0>level)break;0===level&&(!comma&&checkPunctuator(nextop,\",\")?comma=nextop:!initializer&&checkPunctuator(nextop,\"=\")&&(initializer=nextop))}while(level>0||!_.contains(inof,nextop.value)&&\";\"!==nextop.value&&\"(end)\"!==nextop.type);if(_.contains(inof,nextop.value)){state.inES6()||\"of\"!==nextop.value||warning(\"W104\",nextop,\"for of\",\"6\");var ok=!(initializer||comma);if(initializer&&error(\"W133\",comma,nextop.value,\"initializer is forbidden\"),comma&&error(\"W133\",comma,nextop.value,\"more than one ForBinding\"),\"var\"===state.tokens.next.id?(advance(\"var\"),state.tokens.curr.fud({prefix:!0})):\"let\"===state.tokens.next.id||\"const\"===state.tokens.next.id?(advance(state.tokens.next.id),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud({prefix:!0})):Object.create(varstatement).fud({prefix:!0,implied:\"for\",ignore:!ok}),advance(nextop.value),expression(20),advance(\")\",t),\"in\"===nextop.value&&state.option.forin&&(state.forinifcheckneeded=!0,void 0===state.forinifchecks&&(state.forinifchecks=[]),state.forinifchecks.push({type:\"(none)\"})),state.funct[\"(breakage)\"]+=1,state.funct[\"(loopage)\"]+=1,s=block(!0,!0),\"in\"===nextop.value&&state.option.forin){if(state.forinifchecks&&state.forinifchecks.length>0){var check=state.forinifchecks.pop();(s&&s.length>0&&(\"object\"!=typeof s[0]||\"if\"!==s[0].value)||\"(positive)\"===check.type&&s.length>1||\"(negative)\"===check.type)&&warning(\"W089\",this)}state.forinifcheckneeded=!1}state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}else{if(foreachtok&&error(\"E045\",foreachtok),\";\"!==state.tokens.next.id)if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud();else if(\"let\"===state.tokens.next.id)advance(\"let\"),letscope=!0,state.funct[\"(scope)\"].stack(),state.tokens.curr.fud();else for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();if(nolinebreak(state.tokens.curr),advance(\";\"),state.funct[\"(loopage)\"]+=1,\";\"!==state.tokens.next.id&&checkCondAssignment(expression(0)),nolinebreak(state.tokens.curr),advance(\";\"),\";\"===state.tokens.next.id&&error(\"E021\",state.tokens.next,\")\",\";\"),\")\"!==state.tokens.next.id)for(;expression(0,\"for\"),\",\"===state.tokens.next.id;)comma();advance(\")\",t),state.funct[\"(breakage)\"]+=1,block(!0,!0),state.funct[\"(breakage)\"]-=1,state.funct[\"(loopage)\"]-=1}return letscope&&state.funct[\"(scope)\"].unstack(),this}).labelled=!0,stmt(\"break\",function(){var v=state.tokens.next.value;return state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line!==startLine(state.tokens.next)?0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value):(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"continue\",function(){var v=state.tokens.next.value;return 0===state.funct[\"(breakage)\"]&&warning(\"W052\",state.tokens.next,this.value),state.funct[\"(loopage)\"]||warning(\"W052\",state.tokens.next,this.value),state.option.asi||nolinebreak(this),\";\"===state.tokens.next.id||state.tokens.next.reach||state.tokens.curr.line===startLine(state.tokens.next)&&(state.funct[\"(scope)\"].funct.hasBreakLabel(v)||warning(\"W090\",state.tokens.next,v),this.first=state.tokens.next,advance()),reachable(this),this}).exps=!0,stmt(\"return\",function(){return this.line===startLine(state.tokens.next)?\";\"===state.tokens.next.id||state.tokens.next.reach||(this.first=expression(0),!this.first||\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)):\"(punctuator)\"===state.tokens.next.type&&[\"[\",\"{\",\"+\",\"-\"].indexOf(state.tokens.next.value)>-1&&nolinebreak(this),reachable(this),this}).exps=!0,function(x){x.exps=!0,x.lbp=25}(prefix(\"yield\",function(){var prev=state.tokens.prev;state.inES6(!0)&&!state.funct[\"(generator)\"]?\"(catch)\"===state.funct[\"(name)\"]&&state.funct[\"(context)\"][\"(generator)\"]||error(\"E046\",state.tokens.curr,\"yield\"):state.inES6()||warning(\"W104\",state.tokens.curr,\"yield\",\"6\"),state.funct[\"(generator)\"]=\"yielded\";var delegatingYield=!1;return\"*\"===state.tokens.next.value&&(delegatingYield=!0,advance(\"*\")),this.line!==startLine(state.tokens.next)&&state.inMoz()?state.option.asi||nolinebreak(this):((delegatingYield||\";\"!==state.tokens.next.id&&!state.option.asi&&!state.tokens.next.reach&&state.tokens.next.nud)&&(nobreaknonadjacent(state.tokens.curr,state.tokens.next),this.first=expression(10),\"(punctuator)\"!==this.first.type||\"=\"!==this.first.value||this.first.paren||state.option.boss||warningAt(\"W093\",this.first.line,this.first.character)),state.inMoz()&&\")\"!==state.tokens.next.id&&(prev.lbp>30||!prev.assign&&!isEndOfExpr()||\"yield\"===prev.id)&&error(\"E050\",this)),this})),stmt(\"throw\",function(){return nolinebreak(this),this.first=expression(20),reachable(this),this}).exps=!0,stmt(\"import\",function(){if(state.inES6()||warning(\"W119\",state.tokens.curr,\"import\",\"6\"),\"(string)\"===state.tokens.next.type)return advance(\"(string)\"),this;if(state.tokens.next.identifier){if(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value)return advance(\"from\"),advance(\"(string)\"),this;advance(\",\")}if(\"*\"===state.tokens.next.id)advance(\"*\"),advance(\"as\"),state.tokens.next.identifier&&(this.name=identifier(),state.funct[\"(scope)\"].addlabel(this.name,{type:\"const\",token:state.tokens.curr}));else for(advance(\"{\");;){if(\"}\"===state.tokens.next.value){advance(\"}\");break}var importName;if(\"default\"===state.tokens.next.type?(importName=\"default\",advance(\"default\")):importName=identifier(),\"as\"===state.tokens.next.value&&(advance(\"as\"),importName=identifier()),state.funct[\"(scope)\"].addlabel(importName,{type:\"const\",token:state.tokens.curr}),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return advance(\"from\"),advance(\"(string)\"),this}).exps=!0,stmt(\"export\",function(){var token,identifier,ok=!0;if(state.inES6()||(warning(\"W119\",state.tokens.curr,\"export\",\"6\"),ok=!1),state.funct[\"(scope)\"].block.isGlobal()||(error(\"E053\",state.tokens.curr),ok=!1),\"*\"===state.tokens.next.value)return advance(\"*\"),advance(\"from\"),advance(\"(string)\"),this;if(\"default\"===state.tokens.next.type){state.nameStack.set(state.tokens.next),advance(\"default\");var exportType=state.tokens.next.id;return(\"function\"===exportType||\"class\"===exportType)&&(this.block=!0),token=peek(),expression(10),identifier=token.value,this.block&&(state.funct[\"(scope)\"].addlabel(identifier,{type:exportType,token:token}),state.funct[\"(scope)\"].setExported(identifier,token)),this}if(\"{\"===state.tokens.next.value){advance(\"{\");for(var exportedTokens=[];;){if(state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance(),exportedTokens.push(state.tokens.curr),\"as\"===state.tokens.next.value&&(advance(\"as\"),state.tokens.next.identifier||error(\"E030\",state.tokens.next,state.tokens.next.value),advance()),\",\"!==state.tokens.next.value){if(\"}\"===state.tokens.next.value){advance(\"}\");break}error(\"E024\",state.tokens.next,state.tokens.next.value);break}advance(\",\")}return\"from\"===state.tokens.next.value?(advance(\"from\"),advance(\"(string)\")):ok&&exportedTokens.forEach(function(token){state.funct[\"(scope)\"].setExported(token.value,token)}),this}if(\"var\"===state.tokens.next.id)advance(\"var\"),state.tokens.curr.fud({inexport:!0});else if(\"let\"===state.tokens.next.id)advance(\"let\"),state.tokens.curr.fud({inexport:!0});else if(\"const\"===state.tokens.next.id)advance(\"const\"),state.tokens.curr.fud({inexport:!0});else if(\"function\"===state.tokens.next.id)this.block=!0,advance(\"function\"),state.syntax[\"function\"].fud({inexport:!0});else if(\"class\"===state.tokens.next.id){this.block=!0,advance(\"class\");var classNameToken=state.tokens.next;state.syntax[\"class\"].fud(),state.funct[\"(scope)\"].setExported(classNameToken.value,classNameToken)}else error(\"E024\",state.tokens.next,state.tokens.next.value);return this}).exps=!0,FutureReservedWord(\"abstract\"),FutureReservedWord(\"boolean\"),FutureReservedWord(\"byte\"),FutureReservedWord(\"char\"),FutureReservedWord(\"class\",{es5:!0,nud:classdef}),FutureReservedWord(\"double\"),FutureReservedWord(\"enum\",{es5:!0}),FutureReservedWord(\"export\",{es5:!0}),FutureReservedWord(\"extends\",{es5:!0}),FutureReservedWord(\"final\"),FutureReservedWord(\"float\"),FutureReservedWord(\"goto\"),FutureReservedWord(\"implements\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"import\",{es5:!0}),FutureReservedWord(\"int\"),FutureReservedWord(\"interface\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"long\"),FutureReservedWord(\"native\"),FutureReservedWord(\"package\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"private\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"protected\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"public\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"short\"),FutureReservedWord(\"static\",{es5:!0,strictOnly:!0}),FutureReservedWord(\"super\",{es5:!0}),FutureReservedWord(\"synchronized\"),FutureReservedWord(\"transient\"),FutureReservedWord(\"volatile\");var lookupBlockType=function(){var pn,pn1,prev,i=-1,bracketStack=0,ret={};checkPunctuators(state.tokens.curr,[\"[\",\"{\"])&&(bracketStack+=1);do{if(prev=-1===i?state.tokens.curr:pn,pn=-1===i?state.tokens.next:peek(i),pn1=peek(i+1),i+=1,checkPunctuators(pn,[\"[\",\"{\"])?bracketStack+=1:checkPunctuators(pn,[\"]\",\"}\"])&&(bracketStack-=1),1===bracketStack&&pn.identifier&&\"for\"===pn.value&&!checkPunctuator(prev,\".\")){ret.isCompArray=!0,ret.notJson=!0;break}if(0===bracketStack&&checkPunctuators(pn,[\"}\",\"]\"])){if(\"=\"===pn1.value){ret.isDestAssign=!0,ret.notJson=!0;break}if(\".\"===pn1.value){ret.notJson=!0;break}}checkPunctuator(pn,\";\")&&(ret.isBlock=!0,ret.notJson=!0)}while(bracketStack>0&&\"(end)\"!==pn.id);return ret},arrayComprehension=function(){function declare(v){var l=_current.variables.filter(function(elt){return elt.value===v?(elt.undef=!1,v):void 0}).length;return 0!==l}function use(v){var l=_current.variables.filter(function(elt){return elt.value!==v||elt.undef?void 0:(elt.unused===!0&&(elt.unused=!1),v)}).length;return 0===l}var _current,CompArray=function(){this.mode=\"use\",this.variables=[]},_carrays=[];return{stack:function(){_current=new CompArray,_carrays.push(_current)},unstack:function(){_current.variables.filter(function(v){v.unused&&warning(\"W098\",v.token,v.raw_text||v.value),v.undef&&state.funct[\"(scope)\"].block.use(v.value,v.token)}),_carrays.splice(-1,1),_current=_carrays[_carrays.length-1]},setState:function(s){_.contains([\"use\",\"define\",\"generate\",\"filter\"],s)&&(_current.mode=s)},check:function(v){return _current?_current&&\"use\"===_current.mode?(use(v)&&_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!0,unused:!1}),!0):_current&&\"define\"===_current.mode?(declare(v)||_current.variables.push({funct:state.funct,token:state.tokens.curr,value:v,undef:!1,unused:!0}),!0):_current&&\"generate\"===_current.mode?(state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):_current&&\"filter\"===_current.mode?(use(v)&&state.funct[\"(scope)\"].block.use(v,state.tokens.curr),!0):!1:void 0}}},escapeRegex=function(str){return str.replace(/[-\\/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")},itself=function(s,o,g){function each(obj,cb){obj&&(Array.isArray(obj)||\"object\"!=typeof obj||(obj=Object.keys(obj)),obj.forEach(cb))}var i,k,x,reIgnoreStr,reIgnore,optionKeys,newOptionObj={},newIgnoredObj={};o=_.clone(o),state.reset(),o&&o.scope?JSHINT.scope=o.scope:(JSHINT.errors=[],JSHINT.undefs=[],JSHINT.internals=[],JSHINT.blacklist={},JSHINT.scope=\"(main)\"),predefined=Object.create(null),combine(predefined,vars.ecmaIdentifiers[3]),combine(predefined,vars.reservedVars),combine(predefined,g||{}),declared=Object.create(null);var exported=Object.create(null);if(o)for(each(o.predef||null,function(item){var slice,prop;\"-\"===item[0]?(slice=item.slice(1),JSHINT.blacklist[slice]=slice,delete predefined[slice]):(prop=Object.getOwnPropertyDescriptor(o.predef,item),predefined[item]=prop?prop.value:!1)}),each(o.exported||null,function(item){exported[item]=!0}),delete o.predef,delete o.exported,optionKeys=Object.keys(o),x=0;optionKeys.length>x;x++)if(/^-W\\d{3}$/g.test(optionKeys[x]))newIgnoredObj[optionKeys[x].slice(1)]=!0;else{var optionKey=optionKeys[x];newOptionObj[optionKey]=o[optionKey],(\"esversion\"===optionKey&&5===o[optionKey]||\"es5\"===optionKey&&o[optionKey])&&warning(\"I003\"),\"newcap\"===optionKeys[x]&&o[optionKey]===!1&&(newOptionObj[\"(explicitNewcap)\"]=!0)}state.option=newOptionObj,state.ignored=newIgnoredObj,state.option.indent=state.option.indent||4,state.option.maxerr=state.option.maxerr||50,indent=1;var scopeManagerInst=scopeManager(state,predefined,exported,declared);if(scopeManagerInst.on(\"warning\",function(ev){warning.apply(null,[ev.code,ev.token].concat(ev.data))}),scopeManagerInst.on(\"error\",function(ev){error.apply(null,[ev.code,ev.token].concat(ev.data))}),state.funct=functor(\"(global)\",null,{\"(global)\":!0,\"(scope)\":scopeManagerInst,\"(comparray)\":arrayComprehension(),\"(metrics)\":createMetrics(state.tokens.next)}),functions=[state.funct],urls=[],stack=null,member={},membersOnly=null,inblock=!1,lookahead=[],!isString(s)&&!Array.isArray(s))return errorAt(\"E004\",0),!1;api={get isJSON(){return state.jsonMode},getOption:function(name){return state.option[name]||null},getCache:function(name){return state.cache[name]},setCache:function(name,value){state.cache[name]=value},warn:function(code,data){warningAt.apply(null,[code,data.line,data.char].concat(data.data))},on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)}.bind(this))}},emitter.removeAllListeners(),(extraModules||[]).forEach(function(func){func(api)}),state.tokens.prev=state.tokens.curr=state.tokens.next=state.syntax[\"(begin)\"],o&&o.ignoreDelimiters&&(Array.isArray(o.ignoreDelimiters)||(o.ignoreDelimiters=[o.ignoreDelimiters]),o.ignoreDelimiters.forEach(function(delimiterPair){delimiterPair.start&&delimiterPair.end&&(reIgnoreStr=escapeRegex(delimiterPair.start)+\"[\\\\s\\\\S]*?\"+escapeRegex(delimiterPair.end),reIgnore=RegExp(reIgnoreStr,\"ig\"),s=s.replace(reIgnore,function(match){return match.replace(/./g,\" \")}))})),lex=new Lexer(s),lex.on(\"warning\",function(ev){warningAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"error\",function(ev){errorAt.apply(null,[ev.code,ev.line,ev.character].concat(ev.data))}),lex.on(\"fatal\",function(ev){quit(\"E041\",ev.line,ev.from)}),lex.on(\"Identifier\",function(ev){emitter.emit(\"Identifier\",ev)}),lex.on(\"String\",function(ev){emitter.emit(\"String\",ev)}),lex.on(\"Number\",function(ev){emitter.emit(\"Number\",ev)}),lex.start();for(var name in o)_.has(o,name)&&checkOption(name,state.tokens.curr);assume(),combine(predefined,g||{}),comma.first=!0;try{switch(advance(),state.tokens.next.id){case\"{\":case\"[\":destructuringAssignOrJsonValue();break;default:directives(),state.directive[\"use strict\"]&&\"global\"!==state.option.strict&&warning(\"W097\",state.tokens.prev),statements()}\"(end)\"!==state.tokens.next.id&&quit(\"E041\",state.tokens.curr.line),state.funct[\"(scope)\"].unstack()}catch(err){if(!err||\"JSHintError\"!==err.name)throw err;var nt=state.tokens.next||{};JSHINT.errors.push({scope:\"(main)\",raw:err.raw,code:err.code,reason:err.message,line:err.line||nt.line,character:err.character||nt.from},null)}if(\"(main)\"===JSHINT.scope)for(o=o||{},i=0;JSHINT.internals.length>i;i+=1)k=JSHINT.internals[i],o.scope=k.elem,itself(k.value,o,g);return 0===JSHINT.errors.length};return itself.addModule=function(func){extraModules.push(func)},itself.addModule(style.register),itself.data=function(){var fu,f,i,j,n,globals,data={functions:[],options:state.option};itself.errors.length&&(data.errors=itself.errors),state.jsonMode&&(data.json=!0);var impliedGlobals=state.funct[\"(scope)\"].getImpliedGlobals();for(impliedGlobals.length>0&&(data.implieds=impliedGlobals),urls.length>0&&(data.urls=urls),globals=state.funct[\"(scope)\"].getUsedOrDefinedGlobals(),globals.length>0&&(data.globals=globals),i=1;functions.length>i;i+=1){for(f=functions[i],fu={},j=0;functionicity.length>j;j+=1)fu[functionicity[j]]=[];for(j=0;functionicity.length>j;j+=1)0===fu[functionicity[j]].length&&delete fu[functionicity[j]];fu.name=f[\"(name)\"],fu.param=f[\"(params)\"],fu.line=f[\"(line)\"],fu.character=f[\"(character)\"],fu.last=f[\"(last)\"],fu.lastcharacter=f[\"(lastcharacter)\"],fu.metrics={complexity:f[\"(metrics)\"].ComplexityCount,parameters:f[\"(metrics)\"].arity,statements:f[\"(metrics)\"].statementCount},data.functions.push(fu)}var unuseds=state.funct[\"(scope)\"].getUnuseds();unuseds.length>0&&(data.unused=unuseds);for(n in member)if(\"number\"==typeof member[n]){data.member=member;break}return data},itself.jshint=itself,itself}();\"object\"==typeof exports&&exports&&(exports.JSHINT=JSHINT)},{\"../lodash\":\"/node_modules/jshint/lodash.js\",\"./lex.js\":\"/node_modules/jshint/src/lex.js\",\"./messages.js\":\"/node_modules/jshint/src/messages.js\",\"./options.js\":\"/node_modules/jshint/src/options.js\",\"./reg.js\":\"/node_modules/jshint/src/reg.js\",\"./scope-manager.js\":\"/node_modules/jshint/src/scope-manager.js\",\"./state.js\":\"/node_modules/jshint/src/state.js\",\"./style.js\":\"/node_modules/jshint/src/style.js\",\"./vars.js\":\"/node_modules/jshint/src/vars.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/lex.js\":[function(_dereq_,module,exports){\"use strict\";function asyncTrigger(){var _checks=[];return{push:function(fn){_checks.push(fn)},check:function(){for(var check=0;_checks.length>check;++check)_checks[check]();_checks.splice(0,_checks.length)}}}function Lexer(source){var lines=source;\"string\"==typeof lines&&(lines=lines.replace(/\\r\\n/g,\"\\n\").replace(/\\r/g,\"\\n\").split(\"\\n\")),lines[0]&&\"#!\"===lines[0].substr(0,2)&&(-1!==lines[0].indexOf(\"node\")&&(state.option.node=!0),lines[0]=\"\"),this.emitter=new events.EventEmitter,this.source=source,this.setLines(lines),this.prereg=!0,this.line=0,this.char=1,this.from=1,this.input=\"\",this.inComment=!1,this.context=[],this.templateStarts=[];for(var i=0;state.option.indent>i;i+=1)state.tab+=\" \";this.ignoreLinterErrors=!1}var _=_dereq_(\"../lodash\"),events=_dereq_(\"events\"),reg=_dereq_(\"./reg.js\"),state=_dereq_(\"./state.js\").state,unicodeData=_dereq_(\"../data/ascii-identifier-data.js\"),asciiIdentifierStartTable=unicodeData.asciiIdentifierStartTable,asciiIdentifierPartTable=unicodeData.asciiIdentifierPartTable,Token={Identifier:1,Punctuator:2,NumericLiteral:3,StringLiteral:4,Comment:5,Keyword:6,NullLiteral:7,BooleanLiteral:8,RegExp:9,TemplateHead:10,TemplateMiddle:11,TemplateTail:12,NoSubstTemplate:13},Context={Block:1,Template:2};Lexer.prototype={_lines:[],inContext:function(ctxType){return this.context.length>0&&this.context[this.context.length-1].type===ctxType},pushContext:function(ctxType){this.context.push({type:ctxType})},popContext:function(){return this.context.pop()},isContext:function(context){return this.context.length>0&&this.context[this.context.length-1]===context},currentContext:function(){return this.context.length>0&&this.context[this.context.length-1]},getLines:function(){return this._lines=state.lines,this._lines},setLines:function(val){this._lines=val,state.lines=this._lines},peek:function(i){return this.input.charAt(i||0)},skip:function(i){i=i||1,this.char+=i,this.input=this.input.slice(i)},on:function(names,listener){names.split(\" \").forEach(function(name){this.emitter.on(name,listener)}.bind(this))},trigger:function(){this.emitter.emit.apply(this.emitter,Array.prototype.slice.call(arguments))},triggerAsync:function(type,args,checks,fn){checks.push(function(){fn()&&this.trigger(type,args)}.bind(this))},scanPunctuator:function(){var ch2,ch3,ch4,ch1=this.peek();switch(ch1){case\".\":if(/^[0-9]$/.test(this.peek(1)))return null;if(\".\"===this.peek(1)&&\".\"===this.peek(2))return{type:Token.Punctuator,value:\"...\"};case\"(\":case\")\":case\";\":case\",\":case\"[\":case\"]\":case\":\":case\"~\":case\"?\":return{type:Token.Punctuator,value:ch1};case\"{\":return this.pushContext(Context.Block),{type:Token.Punctuator,value:ch1};case\"}\":return this.inContext(Context.Block)&&this.popContext(),{type:Token.Punctuator,value:ch1};case\"#\":return{type:Token.Punctuator,value:ch1};case\"\":return null}return ch2=this.peek(1),ch3=this.peek(2),ch4=this.peek(3),\">\"===ch1&&\">\"===ch2&&\">\"===ch3&&\"=\"===ch4?{type:Token.Punctuator,value:\">>>=\"}:\"=\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"===\"}:\"!\"===ch1&&\"=\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"!==\"}:\">\"===ch1&&\">\"===ch2&&\">\"===ch3?{type:Token.Punctuator,value:\">>>\"}:\"<\"===ch1&&\"<\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\"<<=\"}:\">\"===ch1&&\">\"===ch2&&\"=\"===ch3?{type:Token.Punctuator,value:\">>=\"}:\"=\"===ch1&&\">\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:ch1===ch2&&\"+-<>&|\".indexOf(ch1)>=0?{type:Token.Punctuator,value:ch1+ch2}:\"<>=!+-*%&|^\".indexOf(ch1)>=0?\"=\"===ch2?{type:Token.Punctuator,value:ch1+ch2}:{type:Token.Punctuator,value:ch1}:\"/\"===ch1?\"=\"===ch2?{type:Token.Punctuator,value:\"/=\"}:{type:Token.Punctuator,value:\"/\"}:null},scanComments:function(){function commentToken(label,body,opt){var special=[\"jshint\",\"jslint\",\"members\",\"member\",\"globals\",\"global\",\"exported\"],isSpecial=!1,value=label+body,commentType=\"plain\";return opt=opt||{},opt.isMultiline&&(value+=\"*/\"),body=body.replace(/\\n/g,\" \"),\"/*\"===label&®.fallsThrough.test(body)&&(isSpecial=!0,commentType=\"falls through\"),special.forEach(function(str){if(!isSpecial&&(\"//\"!==label||\"jshint\"===str)&&(\" \"===body.charAt(str.length)&&body.substr(0,str.length)===str&&(isSpecial=!0,label+=str,body=body.substr(str.length)),isSpecial||\" \"!==body.charAt(0)||\" \"!==body.charAt(str.length+1)||body.substr(1,str.length)!==str||(isSpecial=!0,label=label+\" \"+str,body=body.substr(str.length+1)),isSpecial))switch(str){case\"member\":commentType=\"members\";break;case\"global\":commentType=\"globals\";break;default:var options=body.split(\":\").map(function(v){return v.replace(/^\\s+/,\"\").replace(/\\s+$/,\"\")});if(2===options.length)switch(options[0]){case\"ignore\":switch(options[1]){case\"start\":self.ignoringLinterErrors=!0,isSpecial=!1;break;case\"end\":self.ignoringLinterErrors=!1,isSpecial=!1}}commentType=str}}),{type:Token.Comment,commentType:commentType,value:value,body:body,isSpecial:isSpecial,isMultiline:opt.isMultiline||!1,isMalformed:opt.isMalformed||!1}}var ch1=this.peek(),ch2=this.peek(1),rest=this.input.substr(2),startLine=this.line,startChar=this.char,self=this;if(\"*\"===ch1&&\"/\"===ch2)return this.trigger(\"error\",{code:\"E018\",line:startLine,character:startChar}),this.skip(2),null;if(\"/\"!==ch1||\"*\"!==ch2&&\"/\"!==ch2)return null;if(\"/\"===ch2)return this.skip(this.input.length),commentToken(\"//\",rest);var body=\"\";if(\"*\"===ch2){for(this.inComment=!0,this.skip(2);\"*\"!==this.peek()||\"/\"!==this.peek(1);)if(\"\"===this.peek()){if(body+=\"\\n\",!this.nextLine())return this.trigger(\"error\",{code:\"E017\",line:startLine,character:startChar}),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0,isMalformed:!0})}else body+=this.peek(),this.skip();return this.skip(2),this.inComment=!1,commentToken(\"/*\",body,{isMultiline:!0})}},scanKeyword:function(){var result=/^[a-zA-Z_$][a-zA-Z0-9_$]*/.exec(this.input),keywords=[\"if\",\"in\",\"do\",\"var\",\"for\",\"new\",\"try\",\"let\",\"this\",\"else\",\"case\",\"void\",\"with\",\"enum\",\"while\",\"break\",\"catch\",\"throw\",\"const\",\"yield\",\"class\",\"super\",\"return\",\"typeof\",\"delete\",\"switch\",\"export\",\"import\",\"default\",\"finally\",\"extends\",\"function\",\"continue\",\"debugger\",\"instanceof\"];return result&&keywords.indexOf(result[0])>=0?{type:Token.Keyword,value:result[0]}:null},scanIdentifier:function(){function isNonAsciiIdentifierStart(code){return code>256}function isNonAsciiIdentifierPart(code){return code>256}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function removeEscapeSequences(id){return id.replace(/\\\\u([0-9a-fA-F]{4})/g,function(m0,codepoint){return String.fromCharCode(parseInt(codepoint,16))})}var type,char,id=\"\",index=0,readUnicodeEscapeSequence=function(){if(index+=1,\"u\"!==this.peek(index))return null;var code,ch1=this.peek(index+1),ch2=this.peek(index+2),ch3=this.peek(index+3),ch4=this.peek(index+4);return isHexDigit(ch1)&&isHexDigit(ch2)&&isHexDigit(ch3)&&isHexDigit(ch4)?(code=parseInt(ch1+ch2+ch3+ch4,16),asciiIdentifierPartTable[code]||isNonAsciiIdentifierPart(code)?(index+=5,\"\\\\u\"+ch1+ch2+ch3+ch4):null):null}.bind(this),getIdentifierStart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierStartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierStart(code)?(index+=1,chr):null}.bind(this),getIdentifierPart=function(){var chr=this.peek(index),code=chr.charCodeAt(0);return 92===code?readUnicodeEscapeSequence():128>code?asciiIdentifierPartTable[code]?(index+=1,chr):null:isNonAsciiIdentifierPart(code)?(index+=1,chr):null}.bind(this);if(char=getIdentifierStart(),null===char)return null;for(id=char;char=getIdentifierPart(),null!==char;)id+=char;switch(id){case\"true\":case\"false\":type=Token.BooleanLiteral;break;case\"null\":type=Token.NullLiteral;break;default:type=Token.Identifier}return{type:type,value:removeEscapeSequences(id),text:id,tokenLength:id.length}},scanNumericLiteral:function(){function isDecimalDigit(str){return/^[0-9]$/.test(str)}function isOctalDigit(str){return/^[0-7]$/.test(str)}function isBinaryDigit(str){return/^[01]$/.test(str)}function isHexDigit(str){return/^[0-9a-fA-F]$/.test(str)}function isIdentifierStart(ch){return\"$\"===ch||\"_\"===ch||\"\\\\\"===ch||ch>=\"a\"&&\"z\">=ch||ch>=\"A\"&&\"Z\">=ch}var bad,index=0,value=\"\",length=this.input.length,char=this.peek(index),isAllowedDigit=isDecimalDigit,base=10,isLegacy=!1;if(\".\"!==char&&!isDecimalDigit(char))return null;if(\".\"!==char){for(value=this.peek(index),index+=1,char=this.peek(index),\"0\"===value&&((\"x\"===char||\"X\"===char)&&(isAllowedDigit=isHexDigit,base=16,index+=1,value+=char),(\"o\"===char||\"O\"===char)&&(isAllowedDigit=isOctalDigit,base=8,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Octal integer literal\",\"6\"]}),index+=1,value+=char),(\"b\"===char||\"B\"===char)&&(isAllowedDigit=isBinaryDigit,base=2,state.inES6(!0)||this.trigger(\"warning\",{code:\"W119\",line:this.line,character:this.char,data:[\"Binary integer literal\",\"6\"]}),index+=1,value+=char),isOctalDigit(char)&&(isAllowedDigit=isOctalDigit,base=8,isLegacy=!0,bad=!1,index+=1,value+=char),!isOctalDigit(char)&&isDecimalDigit(char)&&(index+=1,value+=char));length>index;){if(char=this.peek(index),isLegacy&&isDecimalDigit(char))bad=!0;else if(!isAllowedDigit(char))break;value+=char,index+=1}if(isAllowedDigit!==isDecimalDigit)return!isLegacy&&2>=value.length?{type:Token.NumericLiteral,value:value,isMalformed:!0}:length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isLegacy:isLegacy,isMalformed:!1}}if(\".\"===char)for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1;if(\"e\"===char||\"E\"===char){if(value+=char,index+=1,char=this.peek(index),(\"+\"===char||\"-\"===char)&&(value+=this.peek(index),index+=1),char=this.peek(index),!isDecimalDigit(char))return null;for(value+=char,index+=1;length>index&&(char=this.peek(index),isDecimalDigit(char));)value+=char,index+=1}return length>index&&(char=this.peek(index),isIdentifierStart(char))?null:{type:Token.NumericLiteral,value:value,base:base,isMalformed:!isFinite(value)}},scanEscapeSequence:function(checks){var allowNewLine=!1,jump=1;this.skip();var char=this.peek();switch(char){case\"'\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\'\"]},checks,function(){return state.jsonMode});break;case\"b\":char=\"\\\\b\";break;case\"f\":char=\"\\\\f\";break;case\"n\":char=\"\\\\n\";break;case\"r\":char=\"\\\\r\";break;case\"t\":char=\"\\\\t\";break;case\"0\":char=\"\\\\0\";var n=parseInt(this.peek(1),10);this.triggerAsync(\"warning\",{code:\"W115\",line:this.line,character:this.char},checks,function(){return n>=0&&7>=n&&state.isStrict()});break;case\"u\":var hexCode=this.input.substr(1,4),code=parseInt(hexCode,16);isNaN(code)&&this.trigger(\"warning\",{code:\"W052\",line:this.line,character:this.char,data:[\"u\"+hexCode]}),char=String.fromCharCode(code),jump=5;break;case\"v\":this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\v\"]},checks,function(){return state.jsonMode}),char=\"\u000b\";break;case\"x\":var x=parseInt(this.input.substr(1,2),16);this.triggerAsync(\"warning\",{code:\"W114\",line:this.line,character:this.char,data:[\"\\\\x-\"]},checks,function(){return state.jsonMode}),char=String.fromCharCode(x),jump=3;break;case\"\\\\\":char=\"\\\\\\\\\";break;case'\"':char='\\\\\"';break;case\"/\":break;case\"\":allowNewLine=!0,char=\"\"}return{\"char\":char,jump:jump,allowNewLine:allowNewLine}},scanTemplateLiteral:function(checks){var tokenType,ch,value=\"\",startLine=this.line,startChar=this.char,depth=this.templateStarts.length;if(!state.inES6(!0))return null;if(\"`\"===this.peek())tokenType=Token.TemplateHead,this.templateStarts.push({line:this.line,\"char\":this.char}),depth=this.templateStarts.length,this.skip(1),this.pushContext(Context.Template);else{if(!this.inContext(Context.Template)||\"}\"!==this.peek())return null;tokenType=Token.TemplateMiddle}for(;\"`\"!==this.peek();){for(;\"\"===(ch=this.peek());)if(value+=\"\\n\",!this.nextLine()){var startPos=this.templateStarts.pop();return this.trigger(\"error\",{code:\"E052\",line:startPos.line,character:startPos.char}),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,depth:depth,context:this.popContext()}}if(\"$\"===ch&&\"{\"===this.peek(1))return value+=\"${\",this.skip(2),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.currentContext()};\nif(\"\\\\\"===ch){var escape=this.scanEscapeSequence(checks);value+=escape.char,this.skip(escape.jump)}else\"`\"!==ch&&(value+=ch,this.skip(1))}return tokenType=tokenType===Token.TemplateHead?Token.NoSubstTemplate:Token.TemplateTail,this.skip(1),this.templateStarts.pop(),{type:tokenType,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,depth:depth,context:this.popContext()}},scanStringLiteral:function(checks){var quote=this.peek();if('\"'!==quote&&\"'\"!==quote)return null;this.triggerAsync(\"warning\",{code:\"W108\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&'\"'!==quote});var value=\"\",startLine=this.line,startChar=this.char,allowNewLine=!1;for(this.skip();this.peek()!==quote;)if(\"\"===this.peek()){if(allowNewLine?(allowNewLine=!1,this.triggerAsync(\"warning\",{code:\"W043\",line:this.line,character:this.char},checks,function(){return!state.option.multistr}),this.triggerAsync(\"warning\",{code:\"W042\",line:this.line,character:this.char},checks,function(){return state.jsonMode&&state.option.multistr})):this.trigger(\"warning\",{code:\"W112\",line:this.line,character:this.char}),!this.nextLine())return this.trigger(\"error\",{code:\"E029\",line:startLine,character:startChar}),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!0,quote:quote}}else{allowNewLine=!1;var char=this.peek(),jump=1;if(\" \">char&&this.trigger(\"warning\",{code:\"W113\",line:this.line,character:this.char,data:[\"\"]}),\"\\\\\"===char){var parsed=this.scanEscapeSequence(checks);char=parsed.char,jump=parsed.jump,allowNewLine=parsed.allowNewLine}value+=char,this.skip(jump)}return this.skip(),{type:Token.StringLiteral,value:value,startLine:startLine,startChar:startChar,isUnclosed:!1,quote:quote}},scanRegExp:function(){var terminated,index=0,length=this.input.length,char=this.peek(),value=char,body=\"\",flags=[],malformed=!1,isCharSet=!1,scanUnexpectedChars=function(){\" \">char&&(malformed=!0,this.trigger(\"warning\",{code:\"W048\",line:this.line,character:this.char})),\"<\"===char&&(malformed=!0,this.trigger(\"warning\",{code:\"W049\",line:this.line,character:this.char,data:[char]}))}.bind(this);if(!this.prereg||\"/\"!==char)return null;for(index+=1,terminated=!1;length>index;)if(char=this.peek(index),value+=char,body+=char,isCharSet)\"]\"===char&&(\"\\\\\"!==this.peek(index-1)||\"\\\\\"===this.peek(index-2))&&(isCharSet=!1),\"\\\\\"===char&&(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars()),index+=1;else{if(\"\\\\\"===char){if(index+=1,char=this.peek(index),body+=char,value+=char,scanUnexpectedChars(),\"/\"===char){index+=1;continue}if(\"[\"===char){index+=1;continue}}if(\"[\"!==char){if(\"/\"===char){body=body.substr(0,body.length-1),terminated=!0,index+=1;break}index+=1}else isCharSet=!0,index+=1}if(!terminated)return this.trigger(\"error\",{code:\"E015\",line:this.line,character:this.from}),void this.trigger(\"fatal\",{line:this.line,from:this.from});for(;length>index&&(char=this.peek(index),/[gim]/.test(char));)flags.push(char),value+=char,index+=1;try{RegExp(body,flags.join(\"\"))}catch(err){malformed=!0,this.trigger(\"error\",{code:\"E016\",line:this.line,character:this.char,data:[err.message]})}return{type:Token.RegExp,value:value,flags:flags,isMalformed:malformed}},scanNonBreakingSpaces:function(){return state.option.nonbsp?this.input.search(/(\\u00A0)/):-1},scanUnsafeChars:function(){return this.input.search(reg.unsafeChars)},next:function(checks){this.from=this.char;var start;if(/\\s/.test(this.peek()))for(start=this.char;/\\s/.test(this.peek());)this.from+=1,this.skip();var match=this.scanComments()||this.scanStringLiteral(checks)||this.scanTemplateLiteral(checks);return match?match:(match=this.scanRegExp()||this.scanPunctuator()||this.scanKeyword()||this.scanIdentifier()||this.scanNumericLiteral(),match?(this.skip(match.tokenLength||match.value.length),match):null)},nextLine:function(){var char;if(this.line>=this.getLines().length)return!1;this.input=this.getLines()[this.line],this.line+=1,this.char=1,this.from=1;var inputTrimmed=this.input.trim(),startsWith=function(){return _.some(arguments,function(prefix){return 0===inputTrimmed.indexOf(prefix)})},endsWith=function(){return _.some(arguments,function(suffix){return-1!==inputTrimmed.indexOf(suffix,inputTrimmed.length-suffix.length)})};if(this.ignoringLinterErrors===!0&&(startsWith(\"/*\",\"//\")||this.inComment&&endsWith(\"*/\")||(this.input=\"\")),char=this.scanNonBreakingSpaces(),char>=0&&this.trigger(\"warning\",{code:\"W125\",line:this.line,character:char+1}),this.input=this.input.replace(/\\t/g,state.tab),char=this.scanUnsafeChars(),char>=0&&this.trigger(\"warning\",{code:\"W100\",line:this.line,character:char}),!this.ignoringLinterErrors&&state.option.maxlen&&state.option.maxlen=0;--i){var scopeLabels=_scopeStack[i][\"(labels)\"];if(scopeLabels[labelName])return scopeLabels}}function usedSoFarInCurrentFunction(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(usages)\"][labelName])return current[\"(usages)\"][labelName];if(current===_currentFunctBody)break}return!1}function _checkOuterShadow(labelName,token){if(\"outer\"===state.option.shadow)for(var isGlobal=\"global\"===_currentFunctBody[\"(type)\"],isNewFunction=\"functionparams\"===_current[\"(type)\"],outsideCurrentFunction=!isGlobal,i=0;_scopeStack.length>i;i++){var stackItem=_scopeStack[i];isNewFunction||_scopeStack[i+1]!==_currentFunctBody||(outsideCurrentFunction=!1),outsideCurrentFunction&&stackItem[\"(labels)\"][labelName]&&warning(\"W123\",token,labelName),stackItem[\"(breakLabels)\"][labelName]&&warning(\"W123\",token,labelName)}}function _latedefWarning(type,labelName,token){state.option.latedef&&(state.option.latedef===!0&&\"function\"===type||\"function\"!==type)&&warning(\"W003\",token,labelName)}var _current,_scopeStack=[];_newScope(\"global\"),_current[\"(predefined)\"]=predefined;var _currentFunctBody=_current,usedPredefinedAndGlobals=Object.create(null),impliedGlobals=Object.create(null),unuseds=[],emitter=new events.EventEmitter,_getUnusedOption=function(unused_opt){return void 0===unused_opt&&(unused_opt=state.option.unused),unused_opt===!0&&(unused_opt=\"last-param\"),unused_opt},_warnUnused=function(name,tkn,type,unused_opt){var line=tkn.line,chr=tkn.from,raw_name=tkn.raw_text||name;unused_opt=_getUnusedOption(unused_opt);var warnable_types={vars:[\"var\"],\"last-param\":[\"var\",\"param\"],strict:[\"var\",\"param\",\"last-param\"]};unused_opt&&warnable_types[unused_opt]&&-1!==warnable_types[unused_opt].indexOf(type)&&warning(\"W098\",{line:line,from:chr},raw_name),(unused_opt||\"var\"===type)&&unuseds.push({name:name,line:line,character:chr})},scopeManagerInst={on:function(names,listener){names.split(\" \").forEach(function(name){emitter.on(name,listener)})},isPredefined:function(labelName){return!this.has(labelName)&&_.has(_scopeStack[0][\"(predefined)\"],labelName)},stack:function(type){var previousScope=_current;_newScope(type),type||\"functionparams\"!==previousScope[\"(type)\"]||(_current[\"(isFuncBody)\"]=!0,_current[\"(context)\"]=_currentFunctBody,_currentFunctBody=_current)},unstack:function(){var i,j,subScope=_scopeStack.length>1?_scopeStack[_scopeStack.length-2]:null,isUnstackingFunctionBody=_current===_currentFunctBody,isUnstackingFunctionParams=\"functionparams\"===_current[\"(type)\"],isUnstackingFunctionOuter=\"functionouter\"===_current[\"(type)\"],currentUsages=_current[\"(usages)\"],currentLabels=_current[\"(labels)\"],usedLabelNameList=Object.keys(currentUsages);for(currentUsages.__proto__&&-1===usedLabelNameList.indexOf(\"__proto__\")&&usedLabelNameList.push(\"__proto__\"),i=0;usedLabelNameList.length>i;i++){var usedLabelName=usedLabelNameList[i],usage=currentUsages[usedLabelName],usedLabel=currentLabels[usedLabelName];if(usedLabel){var usedLabelType=usedLabel[\"(type)\"];if(usedLabel[\"(useOutsideOfScope)\"]&&!state.option.funcscope){var usedTokens=usage[\"(tokens)\"];if(usedTokens)for(j=0;usedTokens.length>j;j++)usedLabel[\"(function)\"]===usedTokens[j][\"(function)\"]&&error(\"W038\",usedTokens[j],usedLabelName)}if(_current[\"(labels)\"][usedLabelName][\"(unused)\"]=!1,\"const\"===usedLabelType&&usage[\"(modified)\"])for(j=0;usage[\"(modified)\"].length>j;j++)error(\"E013\",usage[\"(modified)\"][j],usedLabelName);if((\"function\"===usedLabelType||\"class\"===usedLabelType)&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)error(\"W021\",usage[\"(reassigned)\"][j],usedLabelName,usedLabelType)}else if(isUnstackingFunctionOuter&&(state.funct[\"(isCapturing)\"]=!0),subScope)if(subScope[\"(usages)\"][usedLabelName]){var subScopeUsage=subScope[\"(usages)\"][usedLabelName];subScopeUsage[\"(modified)\"]=subScopeUsage[\"(modified)\"].concat(usage[\"(modified)\"]),subScopeUsage[\"(tokens)\"]=subScopeUsage[\"(tokens)\"].concat(usage[\"(tokens)\"]),subScopeUsage[\"(reassigned)\"]=subScopeUsage[\"(reassigned)\"].concat(usage[\"(reassigned)\"]),subScopeUsage[\"(onlyUsedSubFunction)\"]=!1}else subScope[\"(usages)\"][usedLabelName]=usage,isUnstackingFunctionBody&&(subScope[\"(usages)\"][usedLabelName][\"(onlyUsedSubFunction)\"]=!0);else if(\"boolean\"==typeof _current[\"(predefined)\"][usedLabelName]){if(delete declared[usedLabelName],usedPredefinedAndGlobals[usedLabelName]=marker,_current[\"(predefined)\"][usedLabelName]===!1&&usage[\"(reassigned)\"])for(j=0;usage[\"(reassigned)\"].length>j;j++)warning(\"W020\",usage[\"(reassigned)\"][j])}else if(usage[\"(tokens)\"])for(j=0;usage[\"(tokens)\"].length>j;j++){var undefinedToken=usage[\"(tokens)\"][j];undefinedToken.forgiveUndef||(state.option.undef&&!undefinedToken.ignoreUndef&&warning(\"W117\",undefinedToken,usedLabelName),impliedGlobals[usedLabelName]?impliedGlobals[usedLabelName].line.push(undefinedToken.line):impliedGlobals[usedLabelName]={name:usedLabelName,line:[undefinedToken.line]})}}if(subScope||Object.keys(declared).forEach(function(labelNotUsed){_warnUnused(labelNotUsed,declared[labelNotUsed],\"var\")}),subScope&&!isUnstackingFunctionBody&&!isUnstackingFunctionParams&&!isUnstackingFunctionOuter){var labelNames=Object.keys(currentLabels);for(i=0;labelNames.length>i;i++){var defLabelName=labelNames[i];currentLabels[defLabelName][\"(blockscoped)\"]||\"exception\"===currentLabels[defLabelName][\"(type)\"]||this.funct.has(defLabelName,{excludeCurrent:!0})||(subScope[\"(labels)\"][defLabelName]=currentLabels[defLabelName],\"global\"!==_currentFunctBody[\"(type)\"]&&(subScope[\"(labels)\"][defLabelName][\"(useOutsideOfScope)\"]=!0),delete currentLabels[defLabelName])}}_checkForUnused(),_scopeStack.pop(),isUnstackingFunctionBody&&(_currentFunctBody=_scopeStack[_.findLastIndex(_scopeStack,function(scope){return scope[\"(isFuncBody)\"]||\"global\"===scope[\"(type)\"]})]),_current=subScope},addParam:function(labelName,token,type){if(type=type||\"param\",\"exception\"===type){var previouslyDefinedLabelType=this.funct.labeltype(labelName);previouslyDefinedLabelType&&\"exception\"!==previouslyDefinedLabelType&&(state.option.node||warning(\"W002\",state.tokens.next,labelName))}if(_.has(_current[\"(labels)\"],labelName)?_current[\"(labels)\"][labelName].duplicated=!0:(_checkOuterShadow(labelName,token,type),_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":token,\"(unused)\":!0},_current[\"(params)\"].push(labelName)),_.has(_current[\"(usages)\"],labelName)){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}},validateParams:function(){if(\"global\"!==_currentFunctBody[\"(type)\"]){var isStrict=state.isStrict(),currentFunctParamScope=_currentFunctBody[\"(parent)\"];currentFunctParamScope[\"(params)\"]&¤tFunctParamScope[\"(params)\"].forEach(function(labelName){var label=currentFunctParamScope[\"(labels)\"][labelName];label&&label.duplicated&&(isStrict?warning(\"E011\",label[\"(token)\"],labelName):state.option.shadow!==!0&&warning(\"W004\",label[\"(token)\"],labelName))})}},getUsedOrDefinedGlobals:function(){var list=Object.keys(usedPredefinedAndGlobals);return usedPredefinedAndGlobals.__proto__===marker&&-1===list.indexOf(\"__proto__\")&&list.push(\"__proto__\"),list},getImpliedGlobals:function(){var values=_.values(impliedGlobals),hasProto=!1;return impliedGlobals.__proto__&&(hasProto=values.some(function(value){return\"__proto__\"===value.name}),hasProto||values.push(impliedGlobals.__proto__)),values},getUnuseds:function(){return unuseds},has:function(labelName){return Boolean(_getLabel(labelName))},labeltype:function(labelName){var scopeLabels=_getLabel(labelName);return scopeLabels?scopeLabels[labelName][\"(type)\"]:null},addExported:function(labelName){var globalLabels=_scopeStack[0][\"(labels)\"];if(_.has(declared,labelName))delete declared[labelName];else if(_.has(globalLabels,labelName))globalLabels[labelName][\"(unused)\"]=!1;else{for(var i=1;_scopeStack.length>i;i++){var scope=_scopeStack[i];if(scope[\"(type)\"])break;if(_.has(scope[\"(labels)\"],labelName)&&!scope[\"(labels)\"][labelName][\"(blockscoped)\"])return scope[\"(labels)\"][labelName][\"(unused)\"]=!1,void 0}exported[labelName]=!0}},setExported:function(labelName,token){this.block.use(labelName,token)\n},addlabel:function(labelName,opts){var type=opts.type,token=opts.token,isblockscoped=\"let\"===type||\"const\"===type||\"class\"===type,isexported=\"global\"===(isblockscoped?_current:_currentFunctBody)[\"(type)\"]&&_.has(exported,labelName);if(_checkOuterShadow(labelName,token,type),isblockscoped){var declaredInCurrentScope=_current[\"(labels)\"][labelName];if(declaredInCurrentScope||_current!==_currentFunctBody||\"global\"===_current[\"(type)\"]||(declaredInCurrentScope=!!_currentFunctBody[\"(parent)\"][\"(labels)\"][labelName]),!declaredInCurrentScope&&_current[\"(usages)\"][labelName]){var usage=_current[\"(usages)\"][labelName];usage[\"(onlyUsedSubFunction)\"]?_latedefWarning(type,labelName,token):warning(\"E056\",token,labelName,type)}declaredInCurrentScope?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&scopeManagerInst.funct.has(labelName)&&warning(\"W004\",token,labelName),scopeManagerInst.block.add(labelName,type,token,!isexported)}else{var declaredInCurrentFunctionScope=scopeManagerInst.funct.has(labelName);!declaredInCurrentFunctionScope&&usedSoFarInCurrentFunction(labelName)&&_latedefWarning(type,labelName,token),scopeManagerInst.funct.has(labelName,{onlyBlockscoped:!0})?warning(\"E011\",token,labelName):state.option.shadow!==!0&&declaredInCurrentFunctionScope&&\"__proto__\"!==labelName&&\"global\"!==_currentFunctBody[\"(type)\"]&&warning(\"W004\",token,labelName),scopeManagerInst.funct.add(labelName,type,token,!isexported),\"global\"===_currentFunctBody[\"(type)\"]&&(usedPredefinedAndGlobals[labelName]=marker)}},funct:{labeltype:function(labelName,options){for(var onlyBlockscoped=options&&options.onlyBlockscoped,excludeParams=options&&options.excludeParams,currentScopeIndex=_scopeStack.length-(options&&options.excludeCurrent?2:1),i=currentScopeIndex;i>=0;i--){var current=_scopeStack[i];if(current[\"(labels)\"][labelName]&&(!onlyBlockscoped||current[\"(labels)\"][labelName][\"(blockscoped)\"]))return current[\"(labels)\"][labelName][\"(type)\"];var scopeCheck=excludeParams?_scopeStack[i-1]:current;if(scopeCheck&&\"functionparams\"===scopeCheck[\"(type)\"])return null}return null},hasBreakLabel:function(labelName){for(var i=_scopeStack.length-1;i>=0;i--){var current=_scopeStack[i];if(current[\"(breakLabels)\"][labelName])return!0;if(\"functionparams\"===current[\"(type)\"])return!1}return!1},has:function(labelName,options){return Boolean(this.labeltype(labelName,options))},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!1,\"(function)\":_currentFunctBody,\"(unused)\":unused}}},block:{isGlobal:function(){return\"global\"===_current[\"(type)\"]},use:function(labelName,token){var paramScope=_currentFunctBody[\"(parent)\"];paramScope&¶mScope[\"(labels)\"][labelName]&&\"param\"===paramScope[\"(labels)\"][labelName][\"(type)\"]&&(scopeManagerInst.funct.has(labelName,{excludeParams:!0,onlyBlockscoped:!0})||(paramScope[\"(labels)\"][labelName][\"(unused)\"]=!1)),token&&(state.ignored.W117||state.option.undef===!1)&&(token.ignoreUndef=!0),_setupUsages(labelName),token&&(token[\"(function)\"]=_currentFunctBody,_current[\"(usages)\"][labelName][\"(tokens)\"].push(token))},reassign:function(labelName,token){this.modify(labelName,token),_current[\"(usages)\"][labelName][\"(reassigned)\"].push(token)},modify:function(labelName,token){_setupUsages(labelName),_current[\"(usages)\"][labelName][\"(modified)\"].push(token)},add:function(labelName,type,tok,unused){_current[\"(labels)\"][labelName]={\"(type)\":type,\"(token)\":tok,\"(blockscoped)\":!0,\"(unused)\":unused}},addBreakLabel:function(labelName,opts){var token=opts.token;scopeManagerInst.funct.hasBreakLabel(labelName)?warning(\"E011\",token,labelName):\"outer\"===state.option.shadow&&(scopeManagerInst.funct.has(labelName)?warning(\"W004\",token,labelName):_checkOuterShadow(labelName,token)),_current[\"(breakLabels)\"][labelName]=token}}};return scopeManagerInst};module.exports=scopeManager},{\"../lodash\":\"/node_modules/jshint/lodash.js\",events:\"/node_modules/browserify/node_modules/events/events.js\"}],\"/node_modules/jshint/src/state.js\":[function(_dereq_,module,exports){\"use strict\";var NameStack=_dereq_(\"./name-stack.js\"),state={syntax:{},isStrict:function(){return this.directive[\"use strict\"]||this.inClassBody||this.option.module||\"implied\"===this.option.strict},inMoz:function(){return this.option.moz},inES6:function(){return this.option.moz||this.option.esversion>=6},inES5:function(strict){return strict?!(this.option.esversion&&5!==this.option.esversion||this.option.moz):!this.option.esversion||this.option.esversion>=5||this.option.moz},reset:function(){this.tokens={prev:null,next:null,curr:null},this.option={},this.funct=null,this.ignored={},this.directive={},this.jsonMode=!1,this.jsonWarnings=[],this.lines=[],this.tab=\"\",this.cache={},this.ignoredLines={},this.forinifcheckneeded=!1,this.nameStack=new NameStack,this.inClassBody=!1}};exports.state=state},{\"./name-stack.js\":\"/node_modules/jshint/src/name-stack.js\"}],\"/node_modules/jshint/src/style.js\":[function(_dereq_,module,exports){\"use strict\";exports.register=function(linter){linter.on(\"Identifier\",function(data){linter.getOption(\"proto\")||\"__proto__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name,\"6\"]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"iterator\")||\"__iterator__\"===data.name&&linter.warn(\"W103\",{line:data.line,\"char\":data.char,data:[data.name]})}),linter.on(\"Identifier\",function(data){linter.getOption(\"camelcase\")&&data.name.replace(/^_+|_+$/g,\"\").indexOf(\"_\")>-1&&!data.name.match(/^[A-Z0-9_]*$/)&&linter.warn(\"W106\",{line:data.line,\"char\":data.from,data:[data.name]})}),linter.on(\"String\",function(data){var code,quotmark=linter.getOption(\"quotmark\");quotmark&&(\"single\"===quotmark&&\"'\"!==data.quote&&(code=\"W109\"),\"double\"===quotmark&&'\"'!==data.quote&&(code=\"W108\"),quotmark===!0&&(linter.getCache(\"quotmark\")||linter.setCache(\"quotmark\",data.quote),linter.getCache(\"quotmark\")!==data.quote&&(code=\"W110\")),code&&linter.warn(code,{line:data.line,\"char\":data.char}))}),linter.on(\"Number\",function(data){\".\"===data.value.charAt(0)&&linter.warn(\"W008\",{line:data.line,\"char\":data.char,data:[data.value]}),\".\"===data.value.substr(data.value.length-1)&&linter.warn(\"W047\",{line:data.line,\"char\":data.char,data:[data.value]}),/^00+/.test(data.value)&&linter.warn(\"W046\",{line:data.line,\"char\":data.char,data:[data.value]})}),linter.on(\"String\",function(data){var re=/^(?:javascript|jscript|ecmascript|vbscript|livescript)\\s*:/i;linter.getOption(\"scripturl\")||re.test(data.value)&&linter.warn(\"W107\",{line:data.line,\"char\":data.char})})}},{}],\"/node_modules/jshint/src/vars.js\":[function(_dereq_,module,exports){\"use strict\";exports.reservedVars={arguments:!1,NaN:!1},exports.ecmaIdentifiers={3:{Array:!1,Boolean:!1,Date:!1,decodeURI:!1,decodeURIComponent:!1,encodeURI:!1,encodeURIComponent:!1,Error:!1,eval:!1,EvalError:!1,Function:!1,hasOwnProperty:!1,isFinite:!1,isNaN:!1,Math:!1,Number:!1,Object:!1,parseInt:!1,parseFloat:!1,RangeError:!1,ReferenceError:!1,RegExp:!1,String:!1,SyntaxError:!1,TypeError:!1,URIError:!1},5:{JSON:!1},6:{Map:!1,Promise:!1,Proxy:!1,Reflect:!1,Set:!1,Symbol:!1,WeakMap:!1,WeakSet:!1}},exports.browser={Audio:!1,Blob:!1,addEventListener:!1,applicationCache:!1,atob:!1,blur:!1,btoa:!1,cancelAnimationFrame:!1,CanvasGradient:!1,CanvasPattern:!1,CanvasRenderingContext2D:!1,CSS:!1,clearInterval:!1,clearTimeout:!1,close:!1,closed:!1,Comment:!1,CustomEvent:!1,DOMParser:!1,defaultStatus:!1,Document:!1,document:!1,DocumentFragment:!1,Element:!1,ElementTimeControl:!1,Event:!1,event:!1,fetch:!1,FileReader:!1,FormData:!1,focus:!1,frames:!1,getComputedStyle:!1,HTMLElement:!1,HTMLAnchorElement:!1,HTMLBaseElement:!1,HTMLBlockquoteElement:!1,HTMLBodyElement:!1,HTMLBRElement:!1,HTMLButtonElement:!1,HTMLCanvasElement:!1,HTMLCollection:!1,HTMLDirectoryElement:!1,HTMLDivElement:!1,HTMLDListElement:!1,HTMLFieldSetElement:!1,HTMLFontElement:!1,HTMLFormElement:!1,HTMLFrameElement:!1,HTMLFrameSetElement:!1,HTMLHeadElement:!1,HTMLHeadingElement:!1,HTMLHRElement:!1,HTMLHtmlElement:!1,HTMLIFrameElement:!1,HTMLImageElement:!1,HTMLInputElement:!1,HTMLIsIndexElement:!1,HTMLLabelElement:!1,HTMLLayerElement:!1,HTMLLegendElement:!1,HTMLLIElement:!1,HTMLLinkElement:!1,HTMLMapElement:!1,HTMLMenuElement:!1,HTMLMetaElement:!1,HTMLModElement:!1,HTMLObjectElement:!1,HTMLOListElement:!1,HTMLOptGroupElement:!1,HTMLOptionElement:!1,HTMLParagraphElement:!1,HTMLParamElement:!1,HTMLPreElement:!1,HTMLQuoteElement:!1,HTMLScriptElement:!1,HTMLSelectElement:!1,HTMLStyleElement:!1,HTMLTableCaptionElement:!1,HTMLTableCellElement:!1,HTMLTableColElement:!1,HTMLTableElement:!1,HTMLTableRowElement:!1,HTMLTableSectionElement:!1,HTMLTemplateElement:!1,HTMLTextAreaElement:!1,HTMLTitleElement:!1,HTMLUListElement:!1,HTMLVideoElement:!1,history:!1,Image:!1,Intl:!1,length:!1,localStorage:!1,location:!1,matchMedia:!1,MessageChannel:!1,MessageEvent:!1,MessagePort:!1,MouseEvent:!1,moveBy:!1,moveTo:!1,MutationObserver:!1,name:!1,Node:!1,NodeFilter:!1,NodeList:!1,Notification:!1,navigator:!1,onbeforeunload:!0,onblur:!0,onerror:!0,onfocus:!0,onload:!0,onresize:!0,onunload:!0,open:!1,openDatabase:!1,opener:!1,Option:!1,parent:!1,performance:!1,print:!1,Range:!1,requestAnimationFrame:!1,removeEventListener:!1,resizeBy:!1,resizeTo:!1,screen:!1,scroll:!1,scrollBy:!1,scrollTo:!1,sessionStorage:!1,setInterval:!1,setTimeout:!1,SharedWorker:!1,status:!1,SVGAElement:!1,SVGAltGlyphDefElement:!1,SVGAltGlyphElement:!1,SVGAltGlyphItemElement:!1,SVGAngle:!1,SVGAnimateColorElement:!1,SVGAnimateElement:!1,SVGAnimateMotionElement:!1,SVGAnimateTransformElement:!1,SVGAnimatedAngle:!1,SVGAnimatedBoolean:!1,SVGAnimatedEnumeration:!1,SVGAnimatedInteger:!1,SVGAnimatedLength:!1,SVGAnimatedLengthList:!1,SVGAnimatedNumber:!1,SVGAnimatedNumberList:!1,SVGAnimatedPathData:!1,SVGAnimatedPoints:!1,SVGAnimatedPreserveAspectRatio:!1,SVGAnimatedRect:!1,SVGAnimatedString:!1,SVGAnimatedTransformList:!1,SVGAnimationElement:!1,SVGCSSRule:!1,SVGCircleElement:!1,SVGClipPathElement:!1,SVGColor:!1,SVGColorProfileElement:!1,SVGColorProfileRule:!1,SVGComponentTransferFunctionElement:!1,SVGCursorElement:!1,SVGDefsElement:!1,SVGDescElement:!1,SVGDocument:!1,SVGElement:!1,SVGElementInstance:!1,SVGElementInstanceList:!1,SVGEllipseElement:!1,SVGExternalResourcesRequired:!1,SVGFEBlendElement:!1,SVGFEColorMatrixElement:!1,SVGFEComponentTransferElement:!1,SVGFECompositeElement:!1,SVGFEConvolveMatrixElement:!1,SVGFEDiffuseLightingElement:!1,SVGFEDisplacementMapElement:!1,SVGFEDistantLightElement:!1,SVGFEFloodElement:!1,SVGFEFuncAElement:!1,SVGFEFuncBElement:!1,SVGFEFuncGElement:!1,SVGFEFuncRElement:!1,SVGFEGaussianBlurElement:!1,SVGFEImageElement:!1,SVGFEMergeElement:!1,SVGFEMergeNodeElement:!1,SVGFEMorphologyElement:!1,SVGFEOffsetElement:!1,SVGFEPointLightElement:!1,SVGFESpecularLightingElement:!1,SVGFESpotLightElement:!1,SVGFETileElement:!1,SVGFETurbulenceElement:!1,SVGFilterElement:!1,SVGFilterPrimitiveStandardAttributes:!1,SVGFitToViewBox:!1,SVGFontElement:!1,SVGFontFaceElement:!1,SVGFontFaceFormatElement:!1,SVGFontFaceNameElement:!1,SVGFontFaceSrcElement:!1,SVGFontFaceUriElement:!1,SVGForeignObjectElement:!1,SVGGElement:!1,SVGGlyphElement:!1,SVGGlyphRefElement:!1,SVGGradientElement:!1,SVGHKernElement:!1,SVGICCColor:!1,SVGImageElement:!1,SVGLangSpace:!1,SVGLength:!1,SVGLengthList:!1,SVGLineElement:!1,SVGLinearGradientElement:!1,SVGLocatable:!1,SVGMPathElement:!1,SVGMarkerElement:!1,SVGMaskElement:!1,SVGMatrix:!1,SVGMetadataElement:!1,SVGMissingGlyphElement:!1,SVGNumber:!1,SVGNumberList:!1,SVGPaint:!1,SVGPathElement:!1,SVGPathSeg:!1,SVGPathSegArcAbs:!1,SVGPathSegArcRel:!1,SVGPathSegClosePath:!1,SVGPathSegCurvetoCubicAbs:!1,SVGPathSegCurvetoCubicRel:!1,SVGPathSegCurvetoCubicSmoothAbs:!1,SVGPathSegCurvetoCubicSmoothRel:!1,SVGPathSegCurvetoQuadraticAbs:!1,SVGPathSegCurvetoQuadraticRel:!1,SVGPathSegCurvetoQuadraticSmoothAbs:!1,SVGPathSegCurvetoQuadraticSmoothRel:!1,SVGPathSegLinetoAbs:!1,SVGPathSegLinetoHorizontalAbs:!1,SVGPathSegLinetoHorizontalRel:!1,SVGPathSegLinetoRel:!1,SVGPathSegLinetoVerticalAbs:!1,SVGPathSegLinetoVerticalRel:!1,SVGPathSegList:!1,SVGPathSegMovetoAbs:!1,SVGPathSegMovetoRel:!1,SVGPatternElement:!1,SVGPoint:!1,SVGPointList:!1,SVGPolygonElement:!1,SVGPolylineElement:!1,SVGPreserveAspectRatio:!1,SVGRadialGradientElement:!1,SVGRect:!1,SVGRectElement:!1,SVGRenderingIntent:!1,SVGSVGElement:!1,SVGScriptElement:!1,SVGSetElement:!1,SVGStopElement:!1,SVGStringList:!1,SVGStylable:!1,SVGStyleElement:!1,SVGSwitchElement:!1,SVGSymbolElement:!1,SVGTRefElement:!1,SVGTSpanElement:!1,SVGTests:!1,SVGTextContentElement:!1,SVGTextElement:!1,SVGTextPathElement:!1,SVGTextPositioningElement:!1,SVGTitleElement:!1,SVGTransform:!1,SVGTransformList:!1,SVGTransformable:!1,SVGURIReference:!1,SVGUnitTypes:!1,SVGUseElement:!1,SVGVKernElement:!1,SVGViewElement:!1,SVGViewSpec:!1,SVGZoomAndPan:!1,Text:!1,TextDecoder:!1,TextEncoder:!1,TimeEvent:!1,top:!1,URL:!1,WebGLActiveInfo:!1,WebGLBuffer:!1,WebGLContextEvent:!1,WebGLFramebuffer:!1,WebGLProgram:!1,WebGLRenderbuffer:!1,WebGLRenderingContext:!1,WebGLShader:!1,WebGLShaderPrecisionFormat:!1,WebGLTexture:!1,WebGLUniformLocation:!1,WebSocket:!1,window:!1,Window:!1,Worker:!1,XDomainRequest:!1,XMLHttpRequest:!1,XMLSerializer:!1,XPathEvaluator:!1,XPathException:!1,XPathExpression:!1,XPathNamespace:!1,XPathNSResolver:!1,XPathResult:!1},exports.devel={alert:!1,confirm:!1,console:!1,Debug:!1,opera:!1,prompt:!1},exports.worker={importScripts:!0,postMessage:!0,self:!0,FileReaderSync:!0},exports.nonstandard={escape:!1,unescape:!1},exports.couch={require:!1,respond:!1,getRow:!1,emit:!1,send:!1,start:!1,sum:!1,log:!1,exports:!1,module:!1,provides:!1},exports.node={__filename:!1,__dirname:!1,GLOBAL:!1,global:!1,module:!1,acequire:!1,Buffer:!0,console:!0,exports:!0,process:!0,setTimeout:!0,clearTimeout:!0,setInterval:!0,clearInterval:!0,setImmediate:!0,clearImmediate:!0},exports.browserify={__filename:!1,__dirname:!1,global:!1,module:!1,acequire:!1,Buffer:!0,exports:!0,process:!0},exports.phantom={phantom:!0,acequire:!0,WebPage:!0,console:!0,exports:!0},exports.qunit={asyncTest:!1,deepEqual:!1,equal:!1,expect:!1,module:!1,notDeepEqual:!1,notEqual:!1,notPropEqual:!1,notStrictEqual:!1,ok:!1,propEqual:!1,QUnit:!1,raises:!1,start:!1,stop:!1,strictEqual:!1,test:!1,\"throws\":!1},exports.rhino={defineClass:!1,deserialize:!1,gc:!1,help:!1,importClass:!1,importPackage:!1,java:!1,load:!1,loadClass:!1,Packages:!1,print:!1,quit:!1,readFile:!1,readUrl:!1,runCommand:!1,seal:!1,serialize:!1,spawn:!1,sync:!1,toint32:!1,version:!1},exports.shelljs={target:!1,echo:!1,exit:!1,cd:!1,pwd:!1,ls:!1,find:!1,cp:!1,rm:!1,mv:!1,mkdir:!1,test:!1,cat:!1,sed:!1,grep:!1,which:!1,dirs:!1,pushd:!1,popd:!1,env:!1,exec:!1,chmod:!1,config:!1,error:!1,tempdir:!1},exports.typed={ArrayBuffer:!1,ArrayBufferView:!1,DataView:!1,Float32Array:!1,Float64Array:!1,Int16Array:!1,Int32Array:!1,Int8Array:!1,Uint16Array:!1,Uint32Array:!1,Uint8Array:!1,Uint8ClampedArray:!1},exports.wsh={ActiveXObject:!0,Enumerator:!0,GetObject:!0,ScriptEngine:!0,ScriptEngineBuildVersion:!0,ScriptEngineMajorVersion:!0,ScriptEngineMinorVersion:!0,VBArray:!0,WSH:!0,WScript:!0,XDomainRequest:!0},exports.dojo={dojo:!1,dijit:!1,dojox:!1,define:!1,require:!1},exports.jquery={$:!1,jQuery:!1},exports.mootools={$:!1,$$:!1,Asset:!1,Browser:!1,Chain:!1,Class:!1,Color:!1,Cookie:!1,Core:!1,Document:!1,DomReady:!1,DOMEvent:!1,DOMReady:!1,Drag:!1,Element:!1,Elements:!1,Event:!1,Events:!1,Fx:!1,Group:!1,Hash:!1,HtmlTable:!1,IFrame:!1,IframeShim:!1,InputValidator:!1,instanceOf:!1,Keyboard:!1,Locale:!1,Mask:!1,MooTools:!1,Native:!1,Options:!1,OverText:!1,Request:!1,Scroller:!1,Slick:!1,Slider:!1,Sortables:!1,Spinner:!1,Swiff:!1,Tips:!1,Type:!1,typeOf:!1,URI:!1,Window:!1},exports.prototypejs={$:!1,$$:!1,$A:!1,$F:!1,$H:!1,$R:!1,$break:!1,$continue:!1,$w:!1,Abstract:!1,Ajax:!1,Class:!1,Enumerable:!1,Element:!1,Event:!1,Field:!1,Form:!1,Hash:!1,Insertion:!1,ObjectRange:!1,PeriodicalExecuter:!1,Position:!1,Prototype:!1,Selector:!1,Template:!1,Toggle:!1,Try:!1,Autocompleter:!1,Builder:!1,Control:!1,Draggable:!1,Draggables:!1,Droppables:!1,Effect:!1,Sortable:!1,SortableObserver:!1,Sound:!1,Scriptaculous:!1},exports.yui={YUI:!1,Y:!1,YUI_config:!1},exports.mocha={mocha:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,context:!1,xcontext:!1,before:!1,after:!1,beforeEach:!1,afterEach:!1,suite:!1,test:!1,setup:!1,teardown:!1,suiteSetup:!1,suiteTeardown:!1},exports.jasmine={jasmine:!1,describe:!1,xdescribe:!1,it:!1,xit:!1,beforeEach:!1,afterEach:!1,setFixtures:!1,loadFixtures:!1,spyOn:!1,expect:!1,runs:!1,waitsFor:!1,waits:!1,beforeAll:!1,afterAll:!1,fail:!1,fdescribe:!1,fit:!1,pending:!1}},{}]},{},[\"/node_modules/jshint/src/jshint.js\"])}),ace.define(\"ace/mode/javascript_worker\",[\"require\",\"exports\",\"module\",\"ace/lib/oop\",\"ace/worker/mirror\",\"ace/mode/javascript/jshint\"],function(acequire,exports,module){\"use strict\";function startRegex(arr){return RegExp(\"^(\"+arr.join(\"|\")+\")\")}var oop=acequire(\"../lib/oop\"),Mirror=acequire(\"../worker/mirror\").Mirror,lint=acequire(\"./javascript/jshint\").JSHINT,disabledWarningsRe=startRegex([\"Bad for in variable '(.+)'.\",'Missing \"use strict\"']),errorsRe=startRegex([\"Unexpected\",\"Expected \",\"Confusing (plus|minus)\",\"\\\\{a\\\\} unterminated regular expression\",\"Unclosed \",\"Unmatched \",\"Unbegun comment\",\"Bad invocation\",\"Missing space after\",\"Missing operator at\"]),infoRe=startRegex([\"Expected an assignment\",\"Bad escapement of EOL\",\"Unexpected comma\",\"Unexpected space\",\"Missing radix parameter.\",\"A leading decimal point can\",\"\\\\['{a}'\\\\] is better written in dot notation.\",\"'{a}' used out of scope\"]),JavaScriptWorker=exports.JavaScriptWorker=function(sender){Mirror.call(this,sender),this.setTimeout(500),this.setOptions()};oop.inherits(JavaScriptWorker,Mirror),function(){this.setOptions=function(options){this.options=options||{esnext:!0,moz:!0,devel:!0,browser:!0,node:!0,laxcomma:!0,laxbreak:!0,lastsemic:!0,onevar:!1,passfail:!1,maxerr:100,expr:!0,multistr:!0,globalstrict:!0},this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.changeOptions=function(newOptions){oop.mixin(this.options,newOptions),this.doc.getValue()&&this.deferredUpdate.schedule(100)},this.isValidJS=function(str){try{eval(\"throw 0;\"+str)}catch(e){if(0===e)return!0}return!1},this.onUpdate=function(){var value=this.doc.getValue();if(value=value.replace(/^#!.*\\n/,\"\\n\"),!value)return this.sender.emit(\"annotate\",[]);var errors=[],maxErrorLevel=this.isValidJS(value)?\"warning\":\"error\";lint(value,this.options,this.options.globals);for(var results=lint.errors,errorAdded=!1,i=0;results.length>i;i++){var error=results[i];if(error){var raw=error.raw,type=\"warning\";if(\"Missing semicolon.\"==raw){var str=error.evidence.substr(error.character);str=str.charAt(str.search(/\\S/)),\"error\"==maxErrorLevel&&str&&/[\\w\\d{(['\"]/.test(str)?(error.reason='Missing \";\" before statement',type=\"error\"):type=\"info\"}else{if(disabledWarningsRe.test(raw))continue;infoRe.test(raw)?type=\"info\":errorsRe.test(raw)?(errorAdded=!0,type=maxErrorLevel):\"'{a}' is not defined.\"==raw?type=\"warning\":\"'{a}' is defined but never used.\"==raw&&(type=\"info\")}errors.push({row:error.line-1,column:error.character-1,text:error.reason,type:type,raw:raw})}}this.sender.emit(\"annotate\",errors)}}.call(JavaScriptWorker.prototype)}),ace.define(\"ace/lib/es5-shim\",[\"require\",\"exports\",\"module\"],function(){function Empty(){}function doesDefinePropertyWork(object){try{return Object.defineProperty(object,\"sentinel\",{}),\"sentinel\"in object}catch(exception){}}function toInteger(n){return n=+n,n!==n?n=0:0!==n&&n!==1/0&&n!==-(1/0)&&(n=(n>0||-1)*Math.floor(Math.abs(n))),n}Function.prototype.bind||(Function.prototype.bind=function(that){var target=this;if(\"function\"!=typeof target)throw new TypeError(\"Function.prototype.bind called on incompatible \"+target);var args=slice.call(arguments,1),bound=function(){if(this instanceof bound){var result=target.apply(this,args.concat(slice.call(arguments)));return Object(result)===result?result:this}return target.apply(that,args.concat(slice.call(arguments)))};return target.prototype&&(Empty.prototype=target.prototype,bound.prototype=new Empty,Empty.prototype=null),bound});var defineGetter,defineSetter,lookupGetter,lookupSetter,supportsAccessors,call=Function.prototype.call,prototypeOfArray=Array.prototype,prototypeOfObject=Object.prototype,slice=prototypeOfArray.slice,_toString=call.bind(prototypeOfObject.toString),owns=call.bind(prototypeOfObject.hasOwnProperty);if((supportsAccessors=owns(prototypeOfObject,\"__defineGetter__\"))&&(defineGetter=call.bind(prototypeOfObject.__defineGetter__),defineSetter=call.bind(prototypeOfObject.__defineSetter__),lookupGetter=call.bind(prototypeOfObject.__lookupGetter__),lookupSetter=call.bind(prototypeOfObject.__lookupSetter__)),2!=[1,2].splice(0).length)if(function(){function makeArray(l){var a=Array(l+2);return a[0]=a[1]=0,a}var lengthBefore,array=[];return array.splice.apply(array,makeArray(20)),array.splice.apply(array,makeArray(26)),lengthBefore=array.length,array.splice(5,0,\"XXX\"),lengthBefore+1==array.length,lengthBefore+1==array.length?!0:void 0}()){var array_splice=Array.prototype.splice;Array.prototype.splice=function(start,deleteCount){return arguments.length?array_splice.apply(this,[void 0===start?0:start,void 0===deleteCount?this.length-start:deleteCount].concat(slice.call(arguments,2))):[]}}else Array.prototype.splice=function(pos,removeCount){var length=this.length;pos>0?pos>length&&(pos=length):void 0==pos?pos=0:0>pos&&(pos=Math.max(length+pos,0)),length>pos+removeCount||(removeCount=length-pos);var removed=this.slice(pos,pos+removeCount),insert=slice.call(arguments,2),add=insert.length;if(pos===length)add&&this.push.apply(this,insert);else{var remove=Math.min(removeCount,length-pos),tailOldPos=pos+remove,tailNewPos=tailOldPos+add-remove,tailCount=length-tailOldPos,lengthAfterRemove=length-remove;if(tailOldPos>tailNewPos)for(var i=0;tailCount>i;++i)this[tailNewPos+i]=this[tailOldPos+i];else if(tailNewPos>tailOldPos)for(i=tailCount;i--;)this[tailNewPos+i]=this[tailOldPos+i];if(add&&pos===lengthAfterRemove)this.length=lengthAfterRemove,this.push.apply(this,insert);else for(this.length=lengthAfterRemove+add,i=0;add>i;++i)this[pos+i]=insert[i]}return removed};Array.isArray||(Array.isArray=function(obj){return\"[object Array]\"==_toString(obj)});var boxedString=Object(\"a\"),splitString=\"a\"!=boxedString[0]||!(0 in boxedString);if(Array.prototype.forEach||(Array.prototype.forEach=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,thisp=arguments[1],i=-1,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError;for(;length>++i;)i in self&&fun.call(thisp,self[i],i,object)}),Array.prototype.map||(Array.prototype.map=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=Array(length),thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(result[i]=fun.call(thisp,self[i],i,object));return result}),Array.prototype.filter||(Array.prototype.filter=function(fun){var value,object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,result=[],thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)i in self&&(value=self[i],fun.call(thisp,value,i,object)&&result.push(value));return result}),Array.prototype.every||(Array.prototype.every=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&!fun.call(thisp,self[i],i,object))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0,thisp=arguments[1];if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");for(var i=0;length>i;i++)if(i in self&&fun.call(thisp,self[i],i,object))return!0;return!1}),Array.prototype.reduce||(Array.prototype.reduce=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduce of empty array with no initial value\");var result,i=0;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i++];break}if(++i>=length)throw new TypeError(\"reduce of empty array with no initial value\")}for(;length>i;i++)i in self&&(result=fun.call(void 0,result,self[i],i,object));return result}),Array.prototype.reduceRight||(Array.prototype.reduceRight=function(fun){var object=toObject(this),self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):object,length=self.length>>>0;if(\"[object Function]\"!=_toString(fun))throw new TypeError(fun+\" is not a function\");if(!length&&1==arguments.length)throw new TypeError(\"reduceRight of empty array with no initial value\");var result,i=length-1;if(arguments.length>=2)result=arguments[1];else for(;;){if(i in self){result=self[i--];break}if(0>--i)throw new TypeError(\"reduceRight of empty array with no initial value\")}do i in this&&(result=fun.call(void 0,result,self[i],i,object));while(i--);return result}),Array.prototype.indexOf&&-1==[0,1].indexOf(1,2)||(Array.prototype.indexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=0;for(arguments.length>1&&(i=toInteger(arguments[1])),i=i>=0?i:Math.max(0,length+i);length>i;i++)if(i in self&&self[i]===sought)return i;return-1}),Array.prototype.lastIndexOf&&-1==[0,1].lastIndexOf(0,-3)||(Array.prototype.lastIndexOf=function(sought){var self=splitString&&\"[object String]\"==_toString(this)?this.split(\"\"):toObject(this),length=self.length>>>0;if(!length)return-1;var i=length-1;for(arguments.length>1&&(i=Math.min(i,toInteger(arguments[1]))),i=i>=0?i:length-Math.abs(i);i>=0;i--)if(i in self&&sought===self[i])return i;return-1}),Object.getPrototypeOf||(Object.getPrototypeOf=function(object){return object.__proto__||(object.constructor?object.constructor.prototype:prototypeOfObject)}),!Object.getOwnPropertyDescriptor){var ERR_NON_OBJECT=\"Object.getOwnPropertyDescriptor called on a non-object: \";Object.getOwnPropertyDescriptor=function(object,property){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT+object);if(owns(object,property)){var descriptor,getter,setter;if(descriptor={enumerable:!0,configurable:!0},supportsAccessors){var prototype=object.__proto__;object.__proto__=prototypeOfObject;var getter=lookupGetter(object,property),setter=lookupSetter(object,property);if(object.__proto__=prototype,getter||setter)return getter&&(descriptor.get=getter),setter&&(descriptor.set=setter),descriptor}return descriptor.value=object[property],descriptor}}}if(Object.getOwnPropertyNames||(Object.getOwnPropertyNames=function(object){return Object.keys(object)}),!Object.create){var createEmpty;createEmpty=null===Object.prototype.__proto__?function(){return{__proto__:null}}:function(){var empty={};for(var i in empty)empty[i]=null;return empty.constructor=empty.hasOwnProperty=empty.propertyIsEnumerable=empty.isPrototypeOf=empty.toLocaleString=empty.toString=empty.valueOf=empty.__proto__=null,empty},Object.create=function(prototype,properties){var object;if(null===prototype)object=createEmpty();else{if(\"object\"!=typeof prototype)throw new TypeError(\"typeof prototype[\"+typeof prototype+\"] != 'object'\");var Type=function(){};Type.prototype=prototype,object=new Type,object.__proto__=prototype}return void 0!==properties&&Object.defineProperties(object,properties),object}}if(Object.defineProperty){var definePropertyWorksOnObject=doesDefinePropertyWork({}),definePropertyWorksOnDom=\"undefined\"==typeof document||doesDefinePropertyWork(document.createElement(\"div\"));if(!definePropertyWorksOnObject||!definePropertyWorksOnDom)var definePropertyFallback=Object.defineProperty}if(!Object.defineProperty||definePropertyFallback){var ERR_NON_OBJECT_DESCRIPTOR=\"Property description must be an object: \",ERR_NON_OBJECT_TARGET=\"Object.defineProperty called on non-object: \",ERR_ACCESSORS_NOT_SUPPORTED=\"getters & setters can not be defined on this javascript engine\";Object.defineProperty=function(object,property,descriptor){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(ERR_NON_OBJECT_TARGET+object);if(\"object\"!=typeof descriptor&&\"function\"!=typeof descriptor||null===descriptor)throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR+descriptor);if(definePropertyFallback)try{return definePropertyFallback.call(Object,object,property,descriptor)}catch(exception){}if(owns(descriptor,\"value\"))if(supportsAccessors&&(lookupGetter(object,property)||lookupSetter(object,property))){var prototype=object.__proto__;object.__proto__=prototypeOfObject,delete object[property],object[property]=descriptor.value,object.__proto__=prototype}else object[property]=descriptor.value;else{if(!supportsAccessors)throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);owns(descriptor,\"get\")&&defineGetter(object,property,descriptor.get),owns(descriptor,\"set\")&&defineSetter(object,property,descriptor.set)}return object}}Object.defineProperties||(Object.defineProperties=function(object,properties){for(var property in properties)owns(properties,property)&&Object.defineProperty(object,property,properties[property]);return object}),Object.seal||(Object.seal=function(object){return object}),Object.freeze||(Object.freeze=function(object){return object});try{Object.freeze(function(){})}catch(exception){Object.freeze=function(freezeObject){return function(object){return\"function\"==typeof object?object:freezeObject(object)}}(Object.freeze)}if(Object.preventExtensions||(Object.preventExtensions=function(object){return object}),Object.isSealed||(Object.isSealed=function(){return!1}),Object.isFrozen||(Object.isFrozen=function(){return!1}),Object.isExtensible||(Object.isExtensible=function(object){if(Object(object)===object)throw new TypeError;for(var name=\"\";owns(object,name);)name+=\"?\";object[name]=!0;var returnValue=owns(object,name);return delete object[name],returnValue}),!Object.keys){var hasDontEnumBug=!0,dontEnums=[\"toString\",\"toLocaleString\",\"valueOf\",\"hasOwnProperty\",\"isPrototypeOf\",\"propertyIsEnumerable\",\"constructor\"],dontEnumsLength=dontEnums.length;for(var key in{toString:null})hasDontEnumBug=!1;Object.keys=function(object){if(\"object\"!=typeof object&&\"function\"!=typeof object||null===object)throw new TypeError(\"Object.keys called on a non-object\");var keys=[];for(var name in object)owns(object,name)&&keys.push(name);if(hasDontEnumBug)for(var i=0,ii=dontEnumsLength;ii>i;i++){var dontEnum=dontEnums[i];owns(object,dontEnum)&&keys.push(dontEnum)}return keys}}Date.now||(Date.now=function(){return(new Date).getTime()});var ws=\"\t\\n\u000b\\f\\r   ᠎              \\u2028\\u2029\";if(!String.prototype.trim||ws.trim()){ws=\"[\"+ws+\"]\";var trimBeginRegexp=RegExp(\"^\"+ws+ws+\"*\"),trimEndRegexp=RegExp(ws+ws+\"*$\");String.prototype.trim=function(){return(this+\"\").replace(trimBeginRegexp,\"\").replace(trimEndRegexp,\"\")}}var toObject=function(o){if(null==o)throw new TypeError(\"can't convert \"+o+\" to object\");return Object(o)}});"; + +/***/ }), +/* 72 */ +/***/ (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 */ +}() + + +/***/ }), +/* 73 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return checkIfConnectedToDarkweb; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return executeDarkwebTerminalCommand; }); +/* unused harmony export listAllDarkwebItems */ +/* unused harmony export buyDarkwebItem */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return parseDarkwebItemPrice; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DarkWebItems; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Terminal_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__ = __webpack_require__(26); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_StringHelperFunctions_js__ = __webpack_require__(6); + + + + + + + + + +/* DarkWeb.js */ +//Posts a "help" message if connected to DarkWeb +function checkIfConnectedToDarkweb() { + if (__WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__["a" /* SpecialServerIps */].hasOwnProperty("Darkweb Server")) { + var darkwebIp = __WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"]; + if (!Object(__WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__["c" /* isValidIPAddress */])(darkwebIp)) {return;} + if (darkwebIp == __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getCurrentServer().ip) { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Incorrect number of arguments. Usage: "); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("buy -l"); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("buy [item name]"); + return; + } + var arg = commandArray[1]; + if (arg == "-l") { + listAllDarkwebItems(); + } else { + buyDarkwebItem(arg); + } + break; + default: + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Command not found"); + break; + } +} + +function listAllDarkwebItems() { + for (var item in DarkWebItems) { + if (DarkWebItems.hasOwnProperty(item)) { + var item = DarkWebItems[item]; + //Convert string using toLocaleString + var split = item.split(" - "); + if (split.length == 3 && split[1].charAt(0) == '$') { + split[1] = split[1].slice(1); + split[1] = split[1].replace(/,/g, ''); + var price = parseFloat(split[1]); + if (isNaN(price)) { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(item); + return; + } + price = Object(__WEBPACK_IMPORTED_MODULE_5__utils_StringHelperFunctions_js__["c" /* formatNumber */])(price, 0); + split[1] = "$" + price.toString(); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(split.join(" - ")); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(item); + } + } + } + + var priceString = split[1]; + //Check for errors + if (priceString.length == 0 || priceString.charAt(0) != '$') { + return -1; + } + //Remove dollar sign and commas + priceString = priceString.slice(1); + priceString = priceString.replace(/,/g, ''); + + //Convert string to numeric + var price = parseFloat(priceString); + if (isNaN(price)) {return -1;} + else {return price;} +} + +function buyDarkwebItem(itemName) { + if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the BruteSSH.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the FTPCrack.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the relaySMTP.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the HTTPWorm.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the SQLInject.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV1); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the DeepscanV1.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase()) { + var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV2); + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the DeepscanV2.exe program. The new program " + + "can be found on your home computer."); + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); + } + } else { + Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Unrecognized item"); + } +} + +function parseDarkwebItemPrice(itemDesc) { + var split = itemDesc.split(" - "); + if (split.length == 3) { + var priceString = split[1]; + //Check for errors + if (priceString.length == 0 || priceString.charAt(0) != '$') { + return -1; + } + //Remove dollar sign and commas + priceString = priceString.slice(1); + priceString = priceString.replace(/,/g, ''); + + //Convert string to numeric + var price = parseFloat(priceString); + if (isNaN(price)) {return -1;} + else {return price;} + } else { + return -1; + } +} + +let DarkWebItems = { + BruteSSHProgram: "BruteSSH.exe - $500,000 - Opens up SSH Ports", + FTPCrackProgram: "FTPCrack.exe - $1,500,000 - Opens up FTP Ports", + RelaySMTPProgram: "relaySMTP.exe - $5,000,000 - Opens up SMTP Ports", + HTTPWormProgram: "HTTPWorm.exe - $30,000,000 - Opens up HTTP Ports", + SQLInjectProgram: "SQLInject.exe - $250,000,000 - Opens up SQL Ports", + DeepScanV1Program: "DeepscanV1.exe - $500,000 - Enables 'scan-analyze' with a depth up to 5", + DeepScanV2Program: "DeepscanV2.exe - $25,000,000 - Enables 'scan-analyze' with a depth up to 10", +} + + + + +/***/ }), +/* 74 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Aliases; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GlobalAliases; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return printAliases; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return parseAliasDeclaration; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return removeAlias; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return substituteAliases; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return loadAliases; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return loadGlobalAliases; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Terminal_js__ = __webpack_require__(24); + + +let Aliases = {}; +let GlobalAliases = {}; + +function loadAliases(saveString) { + if (saveString === "") { + Aliases = {}; + } else { + Aliases = JSON.parse(saveString); + } +} + +function loadGlobalAliases(saveString) { + if (saveString === "") { + GlobalAliases = {}; + } else { + GlobalAliases = JSON.parse(saveString); + } +} + +//Print all aliases to terminal +function printAliases() { + for (var name in Aliases) { + if (Aliases.hasOwnProperty(name)) { + Object(__WEBPACK_IMPORTED_MODULE_0__Terminal_js__["b" /* post */])("alias " + name + "=" + Aliases[name]); + } + } + for (var name in GlobalAliases) { + if (GlobalAliases.hasOwnProperty(name)) { + Object(__WEBPACK_IMPORTED_MODULE_0__Terminal_js__["b" /* post */])("global alias " + name + "=" + GlobalAliases[name]); + } + } +} + +//True if successful, false otherwise +function parseAliasDeclaration(dec,global=false) { + var re = /^([_|\w|!|%|,|@]+)="(.+)"$/; + var matches = dec.match(re); + if (matches == null || matches.length != 3) {return false;} + if (global){ + addGlobalAlias(matches[1],matches[2]); + } else { + addAlias(matches[1], matches[2]); + } + return true; +} + +function addAlias(name, value) { + if (name in GlobalAliases){ + delete GlobalAliases[name]; + } + Aliases[name] = value; +} + +function addGlobalAlias(name, value) { + if (name in Aliases){ + delete Aliases[name]; + } + GlobalAliases[name] = value; +} + +function getAlias(name) { + if (Aliases.hasOwnProperty(name)) { + return Aliases[name]; + } + return null; +} + +function getGlobalAlias(name) { + if (GlobalAliases.hasOwnProperty(name)) { + return GlobalAliases[name]; + } + return null; +} + +function removeAlias(name) { + if (Aliases.hasOwnProperty(name)) { + delete Aliases[name]; + return true; + } + if (GlobalAliases.hasOwnProperty(name)) { + delete GlobalAliases[name]; + return true; + } + return false; +} + +//Returns the original string with any aliases substituted in +//Aliases only applied to "whole words", one level deep +function substituteAliases(origCommand) { + var commandArray = origCommand.split(" "); + if (commandArray.length>0){ + var alias = getAlias(commandArray[0]); + if (alias != null) { + commandArray[0] = alias; + } else { + var alias = getGlobalAlias(commandArray[0]); + if (alias != null) { + commandArray[0] = alias; + } + } + for (var i = 0; i < commandArray.length; ++i) { + var alias = getGlobalAlias(commandArray[i]); + if (alias != null) { + commandArray[i] = alias; + } + } + } + return commandArray.join(" "); +} + + + + +/***/ }), +/* 75 */ +/***/ (function(module, exports) { + +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + + +/***/ }), +/* 76 */ +/***/ (function(module, exports, __webpack_require__) { + +/* + * This file is used by module bundlers (browserify/webpack/etc) when + * including a stream implementation. We use "readable-stream" to get a + * consistent behavior between nodejs versions but bundlers often have a shim + * for "stream". Using this shim greatly improve the compatibility and greatly + * reduce the final size of the bundle (only one stream implementation, not + * two). + */ +module.exports = __webpack_require__(127); + + +/***/ }), +/* 77 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +/**/ + +var processNextTick = __webpack_require__(48).nextTick; +/**/ + +module.exports = Readable; + +/**/ +var isArray = __webpack_require__(75); +/**/ + +/**/ +var Duplex; +/**/ + +Readable.ReadableState = ReadableState; + +/**/ +var EE = __webpack_require__(61).EventEmitter; + +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream = __webpack_require__(78); +/**/ + +/**/ + +var Buffer = __webpack_require__(49).Buffer; +var OurUint8Array = global.Uint8Array || function () {}; +function _uint8ArrayToBuffer(chunk) { + return Buffer.from(chunk); +} +function _isUint8Array(obj) { + return Buffer.isBuffer(obj) || obj instanceof OurUint8Array; +} + +/**/ + +/**/ +var util = __webpack_require__(36); +util.inherits = __webpack_require__(31); +/**/ + +/**/ +var debugUtil = __webpack_require__(128); +var debug = void 0; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var BufferList = __webpack_require__(129); +var destroyImpl = __webpack_require__(79); +var StringDecoder; + +util.inherits(Readable, Stream); + +var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume']; + +function prependListener(emitter, event, fn) { + // Sadly this is not cacheable as some libraries bundle their own + // event emitter implementation with them. + if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn); + + // This is a hack to make sure that our error handler is attached before any + // userland ones. NEVER DO THIS. This is here only because this code needs + // to continue to work with older versions of Node.js that do not include + // the prependListener() method. The goal is to eventually remove this hack. + if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]]; +} + +function ReadableState(options, stream) { + Duplex = Duplex || __webpack_require__(25); + + options = options || {}; + + // Duplex streams are both readable and writable, but share + // the same options object. + // However, some cases require setting options to different + // values for the readable and the writable sides of the duplex stream. + // These options can be provided separately as readableXXX and writableXXX. + var isDuplex = stream instanceof Duplex; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var readableHwm = options.readableHighWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + + if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm; + + // cast to ints. + this.highWaterMark = Math.floor(this.highWaterMark); + + // A linked list is used to store data chunks instead of an array because the + // linked list can remove elements from the beginning faster than + // array.shift() + this.buffer = new BufferList(); + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the event 'readable'/'data' is emitted + // immediately, or on a later tick. We set this to true at first, because + // any actions that shouldn't happen until "later" should generally also + // not happen before the first read call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // has it been destroyed + this.destroyed = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = __webpack_require__(81).StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +function Readable(options) { + Duplex = Duplex || __webpack_require__(25); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options) { + if (typeof options.read === 'function') this._read = options.read; + + if (typeof options.destroy === 'function') this._destroy = options.destroy; + } + + Stream.call(this); +} + +Object.defineProperty(Readable.prototype, 'destroyed', { + get: function () { + if (this._readableState === undefined) { + return false; + } + return this._readableState.destroyed; + }, + set: function (value) { + // we ignore the value if the stream + // has not been initialized yet + if (!this._readableState) { + return; + } + + // backward compatibility, the user is explicitly + // managing destroyed + this._readableState.destroyed = value; + } +}); + +Readable.prototype.destroy = destroyImpl.destroy; +Readable.prototype._undestroy = destroyImpl.undestroy; +Readable.prototype._destroy = function (err, cb) { + this.push(null); + cb(err); +}; + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + var skipChunkCheck; + + if (!state.objectMode) { + if (typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = Buffer.from(chunk, encoding); + encoding = ''; + } + skipChunkCheck = true; + } + } else { + skipChunkCheck = true; + } + + return readableAddChunk(this, chunk, encoding, false, skipChunkCheck); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + return readableAddChunk(this, chunk, null, true, false); +}; + +function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) { + var state = stream._readableState; + if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else { + var er; + if (!skipChunkCheck) er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) { + chunk = _uint8ArrayToBuffer(chunk); + } + + if (addToFront) { + if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true); + } else if (state.ended) { + stream.emit('error', new Error('stream.push() after EOF')); + } else { + state.reading = false; + if (state.decoder && !encoding) { + chunk = state.decoder.write(chunk); + if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state); + } else { + addChunk(stream, state, chunk, false); + } + } + } else if (!addToFront) { + state.reading = false; + } + } + + return needMoreData(state); +} + +function addChunk(stream, state, chunk, addToFront) { + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + maybeReadMore(stream, state); +} + +function chunkInvalid(state, chunk) { + var er; + if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = __webpack_require__(81).StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 to prevent increasing hwm excessively in + // tiny amounts + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function howMuchToRead(n, state) { + if (n <= 0 || state.length === 0 && state.ended) return 0; + if (state.objectMode) return 1; + if (n !== n) { + // Only flow one buffer at a time + if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length; + } + // If we're asking for more than the current hwm, then raise the hwm. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + if (n <= state.length) return n; + // Don't have enough + if (!state.ended) { + state.needReadable = true; + return 0; + } + return state.length; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + n = parseInt(n, 10); + var state = this._readableState; + var nOrig = n; + + if (n !== 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } else if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (!state.reading) n = howMuchToRead(nOrig, state); + } + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } else { + state.length -= n; + } + + if (state.length === 0) { + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (!state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended) endReadable(this); + } + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('_read() is not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : unpipe; + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable, unpipeInfo) { + debug('onunpipe'); + if (readable === src) { + if (unpipeInfo && unpipeInfo.hasUnpiped === false) { + unpipeInfo.hasUnpiped = true; + cleanup(); + } + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', unpipe); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + // If the user pushes more data while we're writing to dest then we'll end up + // in ondata again. However, we only want to increase awaitDrain once because + // dest will only emit one 'drain' event for the multiple writes. + // => Introduce a guard on increasing awaitDrain. + var increasedAwaitDrain = false; + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + increasedAwaitDrain = false; + var ret = dest.write(chunk); + if (false === ret && !increasedAwaitDrain) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + // => Check whether `dest` is still a piping destination. + if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + increasedAwaitDrain = true; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + + // Make sure our error handler is attached before userland ones. + prependListener(dest, 'error', onerror); + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + var unpipeInfo = { hasUnpiped: false }; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this, unpipeInfo); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var i = 0; i < len; i++) { + dests[i].emit('unpipe', this, unpipeInfo); + }return this; + } + + // try to find the right one. + var index = indexOf(state.pipes, dest); + if (index === -1) return this; + + state.pipes.splice(index, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this, unpipeInfo); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + if (ev === 'data') { + // Start flowing on next tick if stream isn't explicitly paused + if (this._readableState.flowing !== false) this.resume(); + } else if (ev === 'readable') { + var state = this._readableState; + if (!state.endEmitted && !state.readableListening) { + state.readableListening = state.needReadable = true; + state.emittedReadable = false; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + state.awaitDrain = 0; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + while (state.flowing && stream.read() !== null) {} +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var _this = this; + + var state = this._readableState; + var paused = false; + + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) _this.push(chunk); + } + + _this.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = _this.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + for (var n = 0; n < kProxyEvents.length; n++) { + stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n])); + } + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + this._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return this; +}; + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromList(n, state) { + // nothing buffered + if (state.length === 0) return null; + + var ret; + if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { + // read it all, truncate the list + if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length); + state.buffer.clear(); + } else { + // read part of list + ret = fromListPartial(n, state.buffer, state.decoder); + } + + return ret; +} + +// Extracts only enough buffered data to satisfy the amount requested. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function fromListPartial(n, list, hasStrings) { + var ret; + if (n < list.head.data.length) { + // slice is the same for buffers and strings + ret = list.head.data.slice(0, n); + list.head.data = list.head.data.slice(n); + } else if (n === list.head.data.length) { + // first chunk is a perfect match + ret = list.shift(); + } else { + // result spans more than one buffer + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); + } + return ret; +} + +// Copies a specified amount of characters from the list of buffered data +// chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBufferString(n, list) { + var p = list.head; + var c = 1; + var ret = p.data; + n -= ret.length; + while (p = p.next) { + var str = p.data; + var nb = n > str.length ? str.length : n; + if (nb === str.length) ret += str;else ret += str.slice(0, n); + n -= nb; + if (n === 0) { + if (nb === str.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = str.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +// Copies a specified amount of bytes from the list of buffered data chunks. +// This function is designed to be inlinable, so please take care when making +// changes to the function body. +function copyFromBuffer(n, list) { + var ret = Buffer.allocUnsafe(n); + var p = list.head; + var c = 1; + p.data.copy(ret); + n -= p.data.length; + while (p = p.next) { + var buf = p.data; + var nb = n > buf.length ? buf.length : n; + buf.copy(ret, ret.length - n, 0, nb); + n -= nb; + if (n === 0) { + if (nb === buf.length) { + ++c; + if (p.next) list.head = p.next;else list.head = list.tail = null; + } else { + list.head = p; + p.data = buf.slice(nb); + } + break; + } + ++c; + } + list.length -= c; + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(21), __webpack_require__(35))) + +/***/ }), +/* 78 */ +/***/ (function(module, exports, __webpack_require__) { + +module.exports = __webpack_require__(61).EventEmitter; + + +/***/ }), +/* 79 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +/**/ + +var processNextTick = __webpack_require__(48).nextTick; +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + processNextTick(emitErrorNT, this, err); + } + return this; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + processNextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); + } + }); + + return this; +} + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } +} + +function emitErrorNT(self, err) { + self.emit('error', err); +} + +module.exports = { + destroy: destroy, + undestroy: undestroy +}; + +/***/ }), +/* 80 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global) {var apply = Function.prototype.apply; + +// DOM APIs, for completeness + +exports.setTimeout = function() { + return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); +}; +exports.setInterval = function() { + return new Timeout(apply.call(setInterval, window, arguments), clearInterval); +}; +exports.clearTimeout = +exports.clearInterval = function(timeout) { + if (timeout) { + timeout.close(); + } +}; + +function Timeout(id, clearFn) { + this._id = id; + this._clearFn = clearFn; +} +Timeout.prototype.unref = Timeout.prototype.ref = function() {}; +Timeout.prototype.close = function() { + this._clearFn.call(window, this._id); +}; + +// Does not start the time, just sets up the members needed. +exports.enroll = function(item, msecs) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = msecs; +}; + +exports.unenroll = function(item) { + clearTimeout(item._idleTimeoutId); + item._idleTimeout = -1; +}; + +exports._unrefActive = exports.active = function(item) { + clearTimeout(item._idleTimeoutId); + + var msecs = item._idleTimeout; + if (msecs >= 0) { + item._idleTimeoutId = setTimeout(function onTimeout() { + if (item._onTimeout) + item._onTimeout(); + }, msecs); + } +}; + +// setimmediate attaches itself to the global object +__webpack_require__(131); +// On some exotic environments, it's not clear which object `setimmeidate` was +// able to install onto. Search each possibility in the same order as the +// `setimmediate` library. +exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) || + (typeof global !== "undefined" && global.setImmediate) || + (this && this.setImmediate); +exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) || + (typeof global !== "undefined" && global.clearImmediate) || + (this && this.clearImmediate); + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(21))) + +/***/ }), +/* 81 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var Buffer = __webpack_require__(49).Buffer; + +var isEncoding = Buffer.isEncoding || function (encoding) { + encoding = '' + encoding; + switch (encoding && encoding.toLowerCase()) { + case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw': + return true; + default: + return false; + } +}; + +function _normalizeEncoding(enc) { + if (!enc) return 'utf8'; + var retried; + while (true) { + switch (enc) { + case 'utf8': + case 'utf-8': + return 'utf8'; + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return 'utf16le'; + case 'latin1': + case 'binary': + return 'latin1'; + case 'base64': + case 'ascii': + case 'hex': + return enc; + default: + if (retried) return; // undefined + enc = ('' + enc).toLowerCase(); + retried = true; + } + } +}; + +// Do not cache `Buffer.isEncoding` when checking encoding names as some +// modules monkey-patch it to support additional encodings +function normalizeEncoding(enc) { + var nenc = _normalizeEncoding(enc); + if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); + return nenc || enc; +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. +exports.StringDecoder = StringDecoder; +function StringDecoder(encoding) { + this.encoding = normalizeEncoding(encoding); + var nb; + switch (this.encoding) { + case 'utf16le': + this.text = utf16Text; + this.end = utf16End; + nb = 4; + break; + case 'utf8': + this.fillLast = utf8FillLast; + nb = 4; + break; + case 'base64': + this.text = base64Text; + this.end = base64End; + nb = 3; + break; + default: + this.write = simpleWrite; + this.end = simpleEnd; + return; + } + this.lastNeed = 0; + this.lastTotal = 0; + this.lastChar = Buffer.allocUnsafe(nb); +} + +StringDecoder.prototype.write = function (buf) { + if (buf.length === 0) return ''; + var r; + var i; + if (this.lastNeed) { + r = this.fillLast(buf); + if (r === undefined) return ''; + i = this.lastNeed; + this.lastNeed = 0; + } else { + i = 0; + } + if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i); + return r || ''; +}; + +StringDecoder.prototype.end = utf8End; + +// Returns only complete characters in a Buffer +StringDecoder.prototype.text = utf8Text; + +// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer +StringDecoder.prototype.fillLast = function (buf) { + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length); + this.lastNeed -= buf.length; +}; + +// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a +// continuation byte. +function utf8CheckByte(byte) { + if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4; + return -1; +} + +// Checks at most 3 bytes at the end of a Buffer in order to detect an +// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4) +// needed to complete the UTF-8 character (if applicable) are returned. +function utf8CheckIncomplete(self, buf, i) { + var j = buf.length - 1; + if (j < i) return 0; + var nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 1; + return nb; + } + if (--j < i) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) self.lastNeed = nb - 2; + return nb; + } + if (--j < i) return 0; + nb = utf8CheckByte(buf[j]); + if (nb >= 0) { + if (nb > 0) { + if (nb === 2) nb = 0;else self.lastNeed = nb - 3; + } + return nb; + } + return 0; +} + +// Validates as many continuation bytes for a multi-byte UTF-8 character as +// needed or are available. If we see a non-continuation byte where we expect +// one, we "replace" the validated continuation bytes we've seen so far with +// UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding +// behavior. The continuation byte check is included three times in the case +// where all of the continuation bytes for a character exist in the same buffer. +// It is also done this way as a slight performance increase instead of using a +// loop. +function utf8CheckExtraBytes(self, buf, p) { + if ((buf[0] & 0xC0) !== 0x80) { + self.lastNeed = 0; + return '\ufffd'.repeat(p); + } + if (self.lastNeed > 1 && buf.length > 1) { + if ((buf[1] & 0xC0) !== 0x80) { + self.lastNeed = 1; + return '\ufffd'.repeat(p + 1); + } + if (self.lastNeed > 2 && buf.length > 2) { + if ((buf[2] & 0xC0) !== 0x80) { + self.lastNeed = 2; + return '\ufffd'.repeat(p + 2); + } + } + } +} + +// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer. +function utf8FillLast(buf) { + var p = this.lastTotal - this.lastNeed; + var r = utf8CheckExtraBytes(this, buf, p); + if (r !== undefined) return r; + if (this.lastNeed <= buf.length) { + buf.copy(this.lastChar, p, 0, this.lastNeed); + return this.lastChar.toString(this.encoding, 0, this.lastTotal); + } + buf.copy(this.lastChar, p, 0, buf.length); + this.lastNeed -= buf.length; +} + +// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a +// partial character, the character's bytes are buffered until the required +// number of bytes are available. +function utf8Text(buf, i) { + var total = utf8CheckIncomplete(this, buf, i); + if (!this.lastNeed) return buf.toString('utf8', i); + this.lastTotal = total; + var end = buf.length - (total - this.lastNeed); + buf.copy(this.lastChar, 0, end); + return buf.toString('utf8', i, end); +} + +// For UTF-8, a replacement character for each buffered byte of a (partial) +// character needs to be added to the output. +function utf8End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed); + return r; +} + +// UTF-16LE typically needs two bytes per character, but even if we have an even +// number of bytes available, we need to check if we end on a leading/high +// surrogate. In that case, we need to wait for the next two bytes in order to +// decode the last character properly. +function utf16Text(buf, i) { + if ((buf.length - i) % 2 === 0) { + var r = buf.toString('utf16le', i); + if (r) { + var c = r.charCodeAt(r.length - 1); + if (c >= 0xD800 && c <= 0xDBFF) { + this.lastNeed = 2; + this.lastTotal = 4; + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + return r.slice(0, -1); + } + } + return r; + } + this.lastNeed = 1; + this.lastTotal = 2; + this.lastChar[0] = buf[buf.length - 1]; + return buf.toString('utf16le', i, buf.length - 1); +} + +// For UTF-16LE we do not explicitly append special replacement characters if we +// end on a partial character, we simply let v8 handle that. +function utf16End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) { + var end = this.lastTotal - this.lastNeed; + return r + this.lastChar.toString('utf16le', 0, end); + } + return r; +} + +function base64Text(buf, i) { + var n = (buf.length - i) % 3; + if (n === 0) return buf.toString('base64', i); + this.lastNeed = 3 - n; + this.lastTotal = 3; + if (n === 1) { + this.lastChar[0] = buf[buf.length - 1]; + } else { + this.lastChar[0] = buf[buf.length - 2]; + this.lastChar[1] = buf[buf.length - 1]; + } + return buf.toString('base64', i, buf.length - n); +} + +function base64End(buf) { + var r = buf && buf.length ? this.write(buf) : ''; + if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed); + return r; +} + +// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex) +function simpleWrite(buf) { + return buf.toString(this.encoding); +} + +function simpleEnd(buf) { + return buf && buf.length ? this.write(buf) : ''; +} + +/***/ }), +/* 82 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + + + +module.exports = Transform; + +var Duplex = __webpack_require__(25); + +/**/ +var util = __webpack_require__(36); +util.inherits = __webpack_require__(31); +/**/ + +util.inherits(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); + } + + ts.writechunk = null; + ts.writecb = null; + + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + + cb(er); + + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); +} + +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; + + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); + + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); + + return stream.push(null); +} + +/***/ }), +/* 83 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var utils = __webpack_require__(3); +var support = __webpack_require__(20); +// private property +var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; + + +// public method for encoding +exports.encode = function(input) { + var output = []; + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var i = 0, len = input.length, remainingBytes = len; + + var isArray = utils.getTypeOf(input) !== "string"; + while (i < input.length) { + remainingBytes = len - i; + + if (!isArray) { + chr1 = input.charCodeAt(i++); + chr2 = i < len ? input.charCodeAt(i++) : 0; + chr3 = i < len ? input.charCodeAt(i++) : 0; + } else { + chr1 = input[i++]; + chr2 = i < len ? input[i++] : 0; + chr3 = i < len ? input[i++] : 0; + } + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64; + enc4 = remainingBytes > 2 ? (chr3 & 63) : 64; + + output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4)); + + } + + return output.join(""); +}; + +// public method for decoding +exports.decode = function(input) { + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0, resultIndex = 0; + + var dataUrlPrefix = "data:"; + + if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) { + // This is a common error: people give a data url + // (data:image/png;base64,iVBOR...) with a {base64: true} and + // wonders why things don't work. + // We can detect that the string input looks like a data url but we + // *can't* be sure it is one: removing everything up to the comma would + // be too dangerous. + throw new Error("Invalid base64 input, it looks like a data url."); + } + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + var totalLength = input.length * 3 / 4; + if(input.charAt(input.length - 1) === _keyStr.charAt(64)) { + totalLength--; + } + if(input.charAt(input.length - 2) === _keyStr.charAt(64)) { + totalLength--; + } + if (totalLength % 1 !== 0) { + // totalLength is not an integer, the length does not match a valid + // base64 content. That can happen if: + // - the input is not a base64 content + // - the input is *almost* a base64 content, with a extra chars at the + // beginning or at the end + // - the input uses a base64 variant (base64url for example) + throw new Error("Invalid base64 input, bad content length."); + } + var output; + if (support.uint8array) { + output = new Uint8Array(totalLength|0); + } else { + output = new Array(totalLength|0); + } + + while (i < input.length) { + + enc1 = _keyStr.indexOf(input.charAt(i++)); + enc2 = _keyStr.indexOf(input.charAt(i++)); + enc3 = _keyStr.indexOf(input.charAt(i++)); + enc4 = _keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output[resultIndex++] = chr1; + + if (enc3 !== 64) { + output[resultIndex++] = chr2; + } + if (enc4 !== 64) { + output[resultIndex++] = chr3; + } + + } + + return output; +}; + + +/***/ }), +/* 84 */ +/***/ (function(module, exports) { + +var core = module.exports = {version: '2.3.0'}; +if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef + +/***/ }), +/* 85 */ +/***/ (function(module, exports, __webpack_require__) { + +// optional / simple context binding +var aFunction = __webpack_require__(141); +module.exports = function(fn, that, length){ + aFunction(fn); + if(that === undefined)return fn; + switch(length){ + case 1: return function(a){ + return fn.call(that, a); + }; + case 2: return function(a, b){ + return fn.call(that, a, b); + }; + case 3: return function(a, b, c){ + return fn.call(that, a, b, c); + }; + } + return function(/* ...args */){ + return fn.apply(that, arguments); + }; +}; + +/***/ }), +/* 86 */ +/***/ (function(module, exports) { + +module.exports = function(exec){ + try { + return !!exec(); + } catch(e){ + return true; + } +}; + +/***/ }), +/* 87 */ +/***/ (function(module, exports, __webpack_require__) { + +var isObject = __webpack_require__(64) + , document = __webpack_require__(51).document + // in old IE typeof document.createElement is 'object' + , is = isObject(document) && isObject(document.createElement); +module.exports = function(it){ + return is ? document.createElement(it) : {}; +}; + +/***/ }), +/* 88 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* WEBPACK VAR INJECTION */(function(Buffer) { + +var utils = __webpack_require__(3); +var ConvertWorker = __webpack_require__(154); +var GenericWorker = __webpack_require__(10); +var base64 = __webpack_require__(83); +var support = __webpack_require__(20); +var external = __webpack_require__(37); + +var NodejsStreamOutputAdapter = null; +if (support.nodestream) { + try { + NodejsStreamOutputAdapter = __webpack_require__(155); + } catch(e) {} +} + +/** + * Apply the final transformation of the data. If the user wants a Blob for + * example, it's easier to work with an U8intArray and finally do the + * ArrayBuffer/Blob conversion. + * @param {String} type the name of the final type + * @param {String|Uint8Array|Buffer} content the content to transform + * @param {String} mimeType the mime type of the content, if applicable. + * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format. + */ +function transformZipOutput(type, content, mimeType) { + switch(type) { + case "blob" : + return utils.newBlob(utils.transformTo("arraybuffer", content), mimeType); + case "base64" : + return base64.encode(content); + default : + return utils.transformTo(type, content); + } +} + +/** + * Concatenate an array of data of the given type. + * @param {String} type the type of the data in the given array. + * @param {Array} dataArray the array containing the data chunks to concatenate + * @return {String|Uint8Array|Buffer} the concatenated data + * @throws Error if the asked type is unsupported + */ +function concat (type, dataArray) { + var i, index = 0, res = null, totalLength = 0; + for(i = 0; i < dataArray.length; i++) { + totalLength += dataArray[i].length; + } + switch(type) { + case "string": + return dataArray.join(""); + case "array": + return Array.prototype.concat.apply([], dataArray); + case "uint8array": + res = new Uint8Array(totalLength); + for(i = 0; i < dataArray.length; i++) { + res.set(dataArray[i], index); + index += dataArray[i].length; + } + return res; + case "nodebuffer": + return Buffer.concat(dataArray); + default: + throw new Error("concat : unsupported type '" + type + "'"); + } +} + +/** + * Listen a StreamHelper, accumulate its content and concatenate it into a + * complete block. + * @param {StreamHelper} helper the helper to use. + * @param {Function} updateCallback a callback called on each update. Called + * with one arg : + * - the metadata linked to the update received. + * @return Promise the promise for the accumulation. + */ +function accumulate(helper, updateCallback) { + return new external.Promise(function (resolve, reject){ + var dataArray = []; + var chunkType = helper._internalType, + resultType = helper._outputType, + mimeType = helper._mimeType; + helper + .on('data', function (data, meta) { + dataArray.push(data); + if(updateCallback) { + updateCallback(meta); + } + }) + .on('error', function(err) { + dataArray = []; + reject(err); + }) + .on('end', function (){ + try { + var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType); + resolve(result); + } catch (e) { + reject(e); + } + dataArray = []; + }) + .resume(); + }); +} + +/** + * An helper to easily use workers outside of JSZip. + * @constructor + * @param {Worker} worker the worker to wrap + * @param {String} outputType the type of data expected by the use + * @param {String} mimeType the mime type of the content, if applicable. + */ +function StreamHelper(worker, outputType, mimeType) { + var internalType = outputType; + switch(outputType) { + case "blob": + case "arraybuffer": + internalType = "uint8array"; + break; + case "base64": + internalType = "string"; + break; + } + + try { + // the type used internally + this._internalType = internalType; + // the type used to output results + this._outputType = outputType; + // the mime type + this._mimeType = mimeType; + utils.checkSupport(internalType); + this._worker = worker.pipe(new ConvertWorker(internalType)); + // the last workers can be rewired without issues but we need to + // prevent any updates on previous workers. + worker.lock(); + } catch(e) { + this._worker = new GenericWorker("error"); + this._worker.error(e); + } +} + +StreamHelper.prototype = { + /** + * Listen a StreamHelper, accumulate its content and concatenate it into a + * complete block. + * @param {Function} updateCb the update callback. + * @return Promise the promise for the accumulation. + */ + accumulate : function (updateCb) { + return accumulate(this, updateCb); + }, + /** + * Add a listener on an event triggered on a stream. + * @param {String} evt the name of the event + * @param {Function} fn the listener + * @return {StreamHelper} the current helper. + */ + on : function (evt, fn) { + var self = this; + + if(evt === "data") { + this._worker.on(evt, function (chunk) { + fn.call(self, chunk.data, chunk.meta); + }); + } else { + this._worker.on(evt, function () { + utils.delay(fn, arguments, self); + }); + } + return this; + }, + /** + * Resume the flow of chunks. + * @return {StreamHelper} the current helper. + */ + resume : function () { + utils.delay(this._worker.resume, [], this._worker); + return this; + }, + /** + * Pause the flow of chunks. + * @return {StreamHelper} the current helper. + */ + pause : function () { + this._worker.pause(); + return this; + }, + /** + * Return a nodejs stream for this helper. + * @param {Function} updateCb the update callback. + * @return {NodejsStreamOutputAdapter} the nodejs stream. + */ + toNodejsStream : function (updateCb) { + utils.checkSupport("nodestream"); + if (this._outputType !== "nodebuffer") { + // an object stream containing blob/arraybuffer/uint8array/string + // is strange and I don't know if it would be useful. + // I you find this comment and have a good usecase, please open a + // bug report ! + throw new Error(this._outputType + " is not supported by this method"); + } + + return new NodejsStreamOutputAdapter(this, { + objectMode : this._outputType !== "nodebuffer" + }, updateCb); + } +}; + + +module.exports = StreamHelper; + +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(34).Buffer)) + +/***/ }), +/* 89 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +exports.base64 = false; +exports.binary = false; +exports.dir = false; +exports.createFolders = true; +exports.date = null; +exports.compression = null; +exports.compressionOptions = null; +exports.comment = null; +exports.unixPermissions = null; +exports.dosPermissions = null; + + +/***/ }), +/* 90 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(3); +var GenericWorker = __webpack_require__(10); + +// the size of the generated chunks +// TODO expose this as a public variable +var DEFAULT_BLOCK_SIZE = 16 * 1024; + +/** + * A worker that reads a content and emits chunks. + * @constructor + * @param {Promise} dataP the promise of the data to split + */ +function DataWorker(dataP) { + GenericWorker.call(this, "DataWorker"); + var self = this; + this.dataIsReady = false; + this.index = 0; + this.max = 0; + this.data = null; + this.type = ""; + + this._tickScheduled = false; + + dataP.then(function (data) { + self.dataIsReady = true; + self.data = data; + self.max = data && data.length || 0; + self.type = utils.getTypeOf(data); + if(!self.isPaused) { + self._tickAndRepeat(); + } + }, function (e) { + self.error(e); + }); +} + +utils.inherits(DataWorker, GenericWorker); + +/** + * @see GenericWorker.cleanUp + */ +DataWorker.prototype.cleanUp = function () { + GenericWorker.prototype.cleanUp.call(this); + this.data = null; +}; + +/** + * @see GenericWorker.resume + */ +DataWorker.prototype.resume = function () { + if(!GenericWorker.prototype.resume.call(this)) { + return false; + } + + if (!this._tickScheduled && this.dataIsReady) { + this._tickScheduled = true; + utils.delay(this._tickAndRepeat, [], this); + } + return true; +}; + +/** + * Trigger a tick a schedule an other call to this function. + */ +DataWorker.prototype._tickAndRepeat = function() { + this._tickScheduled = false; + if(this.isPaused || this.isFinished) { + return; + } + this._tick(); + if(!this.isFinished) { + utils.delay(this._tickAndRepeat, [], this); + this._tickScheduled = true; + } +}; + +/** + * Read and push a chunk. + */ +DataWorker.prototype._tick = function() { + + if(this.isPaused || this.isFinished) { + return false; + } + + var size = DEFAULT_BLOCK_SIZE; + var data = null, nextIndex = Math.min(this.max, this.index + size); + if (this.index >= this.max) { + // EOF + return this.end(); + } else { + switch(this.type) { + case "string": + data = this.data.substring(this.index, nextIndex); + break; + case "uint8array": + data = this.data.subarray(this.index, nextIndex); + break; + case "array": + case "nodebuffer": + data = this.data.slice(this.index, nextIndex); + break; + } + this.index = nextIndex; + return this.push({ + data : data, + meta : { + percent : this.max ? this.index / this.max * 100 : 0 + } + }); + } +}; + +module.exports = DataWorker; + + +/***/ }), +/* 91 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(3); +var GenericWorker = __webpack_require__(10); + +/** + * A worker which calculate the total length of the data flowing through. + * @constructor + * @param {String} propName the name used to expose the length + */ +function DataLengthProbe(propName) { + GenericWorker.call(this, "DataLengthProbe for " + propName); + this.propName = propName; + this.withStreamInfo(propName, 0); +} +utils.inherits(DataLengthProbe, GenericWorker); + +/** + * @see GenericWorker.processChunk + */ +DataLengthProbe.prototype.processChunk = function (chunk) { + if(chunk) { + var length = this.streamInfo[this.propName] || 0; + this.streamInfo[this.propName] = length + chunk.data.length; + } + GenericWorker.prototype.processChunk.call(this, chunk); +}; +module.exports = DataLengthProbe; + + + +/***/ }), +/* 92 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var GenericWorker = __webpack_require__(10); +var crc32 = __webpack_require__(67); +var utils = __webpack_require__(3); + +/** + * A worker which calculate the crc32 of the data flowing through. + * @constructor + */ +function Crc32Probe() { + GenericWorker.call(this, "Crc32Probe"); + this.withStreamInfo("crc32", 0); +} +utils.inherits(Crc32Probe, GenericWorker); + +/** + * @see GenericWorker.processChunk + */ +Crc32Probe.prototype.processChunk = function (chunk) { + this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0); + this.push(chunk); +}; +module.exports = Crc32Probe; + + +/***/ }), +/* 93 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var GenericWorker = __webpack_require__(10); + +exports.STORE = { + magic: "\x00\x00", + compressWorker : function (compressionOptions) { + return new GenericWorker("STORE compression"); + }, + uncompressWorker : function () { + return new GenericWorker("STORE decompression"); + } +}; +exports.DEFLATE = __webpack_require__(158); + + +/***/ }), +/* 94 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// Note: adler32 takes 12% for level 0 and 2% for level 6. +// It isn't worth it to make additional optimizations as in original. +// Small size is preferable. + +// (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 adler32(adler, buf, len, pos) { + var s1 = (adler & 0xffff) |0, + s2 = ((adler >>> 16) & 0xffff) |0, + n = 0; + + while (len !== 0) { + // Set limit ~ twice less than 5552, to keep + // s2 in 31-bits, because we force signed ints. + // in other case %= will fail. + n = len > 2000 ? 2000 : len; + len -= n; + + do { + s1 = (s1 + buf[pos++]) |0; + s2 = (s2 + s1) |0; + } while (--n); + + s1 %= 65521; + s2 %= 65521; + } + + return (s1 | (s2 << 16)) |0; +} + + +module.exports = adler32; + + +/***/ }), +/* 95 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +// Note: we can't get significant speed boost here. +// So write code to minimize size - no pregenerated tables +// and array tools dependencies. + +// (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. + +// Use ordinary array, since untyped makes no boost here +function makeTable() { + var c, table = []; + + for (var n = 0; n < 256; n++) { + c = n; + for (var k = 0; k < 8; k++) { + c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1)); + } + table[n] = c; + } + + return table; +} + +// Create table on load. Just 255 signed longs. Not a problem. +var crcTable = makeTable(); + + +function crc32(crc, buf, len, pos) { + var t = crcTable, + end = pos + len; + + crc ^= -1; + + for (var i = pos; i < end; i++) { + crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF]; + } + + return (crc ^ (-1)); // >>> 0; +} + + +module.exports = crc32; + + +/***/ }), +/* 96 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// String encode/decode helpers + + + +var utils = __webpack_require__(22); + + +// Quick check if we can use fast array to bin string conversion +// +// - apply(Array) can fail on Android 2.2 +// - apply(Uint8Array) can fail on iOS 5.1 Safari +// +var STR_APPLY_OK = true; +var STR_APPLY_UIA_OK = true; + +try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; } +try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; } + + +// Table with utf8 lengths (calculated by first byte of sequence) +// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, +// because max possible codepoint is 0x10ffff +var _utf8len = new utils.Buf8(256); +for (var q = 0; q < 256; q++) { + _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1); +} +_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start + + +// convert string to array (typed, when possible) +exports.string2buf = function (str) { + var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0; + + // count binary size + for (m_pos = 0; m_pos < str_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4; + } + + // allocate buffer + buf = new utils.Buf8(buf_len); + + // convert + for (i = 0, m_pos = 0; i < buf_len; m_pos++) { + c = str.charCodeAt(m_pos); + if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) { + c2 = str.charCodeAt(m_pos + 1); + if ((c2 & 0xfc00) === 0xdc00) { + c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00); + m_pos++; + } + } + if (c < 0x80) { + /* one byte */ + buf[i++] = c; + } else if (c < 0x800) { + /* two bytes */ + buf[i++] = 0xC0 | (c >>> 6); + buf[i++] = 0x80 | (c & 0x3f); + } else if (c < 0x10000) { + /* three bytes */ + buf[i++] = 0xE0 | (c >>> 12); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } else { + /* four bytes */ + buf[i++] = 0xf0 | (c >>> 18); + buf[i++] = 0x80 | (c >>> 12 & 0x3f); + buf[i++] = 0x80 | (c >>> 6 & 0x3f); + buf[i++] = 0x80 | (c & 0x3f); + } + } + + return buf; +}; + +// Helper (used in 2 places) +function buf2binstring(buf, len) { + // use fallback for big arrays to avoid stack overflow + if (len < 65537) { + if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) { + return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len)); + } + } + + var result = ''; + for (var i = 0; i < len; i++) { + result += String.fromCharCode(buf[i]); + } + return result; +} + + +// Convert byte array to binary string +exports.buf2binstring = function (buf) { + return buf2binstring(buf, buf.length); +}; + + +// Convert binary string (typed, when possible) +exports.binstring2buf = function (str) { + var buf = new utils.Buf8(str.length); + for (var i = 0, len = buf.length; i < len; i++) { + buf[i] = str.charCodeAt(i); + } + return buf; +}; + + +// convert array to string +exports.buf2string = function (buf, max) { + var i, out, c, c_len; + var len = max || buf.length; + + // Reserve max possible length (2 words per char) + // NB: by unknown reasons, Array is significantly faster for + // String.fromCharCode.apply than Uint16Array. + var utf16buf = new Array(len * 2); + + for (out = 0, i = 0; i < len;) { + c = buf[i++]; + // quick process ascii + if (c < 0x80) { utf16buf[out++] = c; continue; } + + c_len = _utf8len[c]; + // skip 5 & 6 byte codes + if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; } + + // apply mask on first byte + c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; + // join the rest + while (c_len > 1 && i < len) { + c = (c << 6) | (buf[i++] & 0x3f); + c_len--; + } + + // terminated by end of string? + if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; } + + if (c < 0x10000) { + utf16buf[out++] = c; + } else { + c -= 0x10000; + utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff); + utf16buf[out++] = 0xdc00 | (c & 0x3ff); + } + } + + return buf2binstring(utf16buf, out); +}; + + +// Calculate max possible position in utf8 buffer, +// that will not break sequence. If that's not possible +// - (very small limits) return max size as is. +// +// buf[] - utf8 bytes array +// max - length limit (mandatory); +exports.utf8border = function (buf, max) { + var pos; + + max = max || buf.length; + if (max > buf.length) { max = buf.length; } + + // go back from last position, until start of sequence found + pos = max - 1; + while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; } + + // Very small and broken sequence, + // return max, because we should return something anyway. + if (pos < 0) { return max; } + + // If we came to start of buffer - that means buffer is too small, + // return max too. + if (pos === 0) { return max; } + + return (pos + _utf8len[buf[pos]] > max) ? pos : max; +}; + + +/***/ }), +/* 97 */ +/***/ (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 ZStream() { + /* next input byte */ + this.input = null; // JS specific, because we have no pointers + this.next_in = 0; + /* number of bytes available at input */ + this.avail_in = 0; + /* total number of input bytes read so far */ + this.total_in = 0; + /* next output byte should be put there */ + this.output = null; // JS specific, because we have no pointers + this.next_out = 0; + /* remaining free space at output */ + this.avail_out = 0; + /* total number of bytes output so far */ + this.total_out = 0; + /* last error message, NULL if no error */ + this.msg = ''/*Z_NULL*/; + /* not visible by applications */ + this.state = null; + /* best guess about the data type: binary or text */ + this.data_type = 2/*Z_UNKNOWN*/; + /* adler32 value of the uncompressed data */ + this.adler = 0; +} + +module.exports = ZStream; + + +/***/ }), +/* 98 */ +/***/ (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. + +module.exports = { + + /* Allowed flush values; see deflate() and inflate() below for details */ + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + + /* Return codes for the compression/decompression functions. Negative values + * are errors, positive values are used for special but normal events. + */ + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + //Z_MEM_ERROR: -4, + Z_BUF_ERROR: -5, + //Z_VERSION_ERROR: -6, + + /* compression levels */ + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + + + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + + /* Possible values of the data_type field (though see inflate()) */ + Z_BINARY: 0, + Z_TEXT: 1, + //Z_ASCII: 1, // = Z_TEXT (deprecated) + Z_UNKNOWN: 2, + + /* The deflate compression method */ + Z_DEFLATED: 8 + //Z_NULL: null // Use -1 or null inline, depending on var type +}; + + +/***/ }), +/* 99 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +exports.LOCAL_FILE_HEADER = "PK\x03\x04"; +exports.CENTRAL_FILE_HEADER = "PK\x01\x02"; +exports.CENTRAL_DIRECTORY_END = "PK\x05\x06"; +exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07"; +exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06"; +exports.DATA_DESCRIPTOR = "PK\x07\x08"; + + +/***/ }), +/* 100 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(3); +var support = __webpack_require__(20); +var ArrayReader = __webpack_require__(101); +var StringReader = __webpack_require__(172); +var NodeBufferReader = __webpack_require__(173); +var Uint8ArrayReader = __webpack_require__(103); + +/** + * Create a reader adapted to the data. + * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read. + * @return {DataReader} the data reader. + */ +module.exports = function (data) { + var type = utils.getTypeOf(data); + utils.checkSupport(type); + if (type === "string" && !support.uint8array) { + return new StringReader(data); + } + if (type === "nodebuffer") { + return new NodeBufferReader(data); + } + if (support.uint8array) { + return new Uint8ArrayReader(utils.transformTo("uint8array", data)); + } + return new ArrayReader(utils.transformTo("array", data)); +}; + + +/***/ }), +/* 101 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var DataReader = __webpack_require__(102); +var utils = __webpack_require__(3); + +function ArrayReader(data) { + DataReader.call(this, data); + for(var i = 0; i < this.data.length; i++) { + data[i] = data[i] & 0xFF; + } +} +utils.inherits(ArrayReader, DataReader); +/** + * @see DataReader.byteAt + */ +ArrayReader.prototype.byteAt = function(i) { + return this.data[this.zero + i]; +}; +/** + * @see DataReader.lastIndexOfSignature + */ +ArrayReader.prototype.lastIndexOfSignature = function(sig) { + var sig0 = sig.charCodeAt(0), + sig1 = sig.charCodeAt(1), + sig2 = sig.charCodeAt(2), + sig3 = sig.charCodeAt(3); + for (var i = this.length - 4; i >= 0; --i) { + if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) { + return i - this.zero; + } + } + + return -1; +}; +/** + * @see DataReader.readAndCheckSignature + */ +ArrayReader.prototype.readAndCheckSignature = function (sig) { + var sig0 = sig.charCodeAt(0), + sig1 = sig.charCodeAt(1), + sig2 = sig.charCodeAt(2), + sig3 = sig.charCodeAt(3), + data = this.readData(4); + return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3]; +}; +/** + * @see DataReader.readData + */ +ArrayReader.prototype.readData = function(size) { + this.checkOffset(size); + if(size === 0) { + return []; + } + var result = this.data.slice(this.zero + this.index, this.zero + this.index + size); + this.index += size; + return result; +}; +module.exports = ArrayReader; + + +/***/ }), +/* 102 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var utils = __webpack_require__(3); + +function DataReader(data) { + this.data = data; // type : see implementation + this.length = data.length; + this.index = 0; + this.zero = 0; +} +DataReader.prototype = { + /** + * Check that the offset will not go too far. + * @param {string} offset the additional offset to check. + * @throws {Error} an Error if the offset is out of bounds. + */ + checkOffset: function(offset) { + this.checkIndex(this.index + offset); + }, + /** + * Check that the specified index will not be too far. + * @param {string} newIndex the index to check. + * @throws {Error} an Error if the index is out of bounds. + */ + checkIndex: function(newIndex) { + if (this.length < this.zero + newIndex || newIndex < 0) { + throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?"); + } + }, + /** + * Change the index. + * @param {number} newIndex The new index. + * @throws {Error} if the new index is out of the data. + */ + setIndex: function(newIndex) { + this.checkIndex(newIndex); + this.index = newIndex; + }, + /** + * Skip the next n bytes. + * @param {number} n the number of bytes to skip. + * @throws {Error} if the new index is out of the data. + */ + skip: function(n) { + this.setIndex(this.index + n); + }, + /** + * Get the byte at the specified index. + * @param {number} i the index to use. + * @return {number} a byte. + */ + byteAt: function(i) { + // see implementations + }, + /** + * Get the next number with a given byte size. + * @param {number} size the number of bytes to read. + * @return {number} the corresponding number. + */ + readInt: function(size) { + var result = 0, + i; + this.checkOffset(size); + for (i = this.index + size - 1; i >= this.index; i--) { + result = (result << 8) + this.byteAt(i); + } + this.index += size; + return result; + }, + /** + * Get the next string with a given byte size. + * @param {number} size the number of bytes to read. + * @return {string} the corresponding string. + */ + readString: function(size) { + return utils.transformTo("string", this.readData(size)); + }, + /** + * Get raw data without conversion, bytes. + * @param {number} size the number of bytes to read. + * @return {Object} the raw data, implementation specific. + */ + readData: function(size) { + // see implementations + }, + /** + * Find the last occurence of a zip signature (4 bytes). + * @param {string} sig the signature to find. + * @return {number} the index of the last occurence, -1 if not found. + */ + lastIndexOfSignature: function(sig) { + // see implementations + }, + /** + * Read the signature (4 bytes) at the current position and compare it with sig. + * @param {string} sig the expected signature + * @return {boolean} true if the signature matches, false otherwise. + */ + readAndCheckSignature: function(sig) { + // see implementations + }, + /** + * Get the next date. + * @return {Date} the date. + */ + readDate: function() { + var dostime = this.readInt(4); + return new Date(Date.UTC( + ((dostime >> 25) & 0x7f) + 1980, // year + ((dostime >> 21) & 0x0f) - 1, // month + (dostime >> 16) & 0x1f, // day + (dostime >> 11) & 0x1f, // hour + (dostime >> 5) & 0x3f, // minute + (dostime & 0x1f) << 1)); // second + } +}; +module.exports = DataReader; + + +/***/ }), +/* 103 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var ArrayReader = __webpack_require__(101); +var utils = __webpack_require__(3); + +function Uint8ArrayReader(data) { + ArrayReader.call(this, data); +} +utils.inherits(Uint8ArrayReader, ArrayReader); +/** + * @see DataReader.readData + */ +Uint8ArrayReader.prototype.readData = function(size) { + this.checkOffset(size); + if(size === 0) { + // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of []. + return new Uint8Array(0); + } + var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size); + this.index += size; + return result; +}; +module.exports = Uint8ArrayReader; + + +/***/ }), +/* 104 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -53907,61 +62657,61 @@ process.umask = function() { return 0; }; //Contains the "information" property for all the Factions, which is just a description //of each faction let FactionInfo = { - //Endgame - IlluminatiInfo: "Humanity never changes. No matter how civilized society becomes, it will eventually fall back " + + //Endgame + IlluminatiInfo: "Humanity never changes. No matter how civilized society becomes, it will eventually fall back " + "into chaos. And from this chaos, we are the Invisible hand that guides them to order. ", - DaedalusInfo: "Yesterday we obeyed kings and bent our necks to emperors. Today we kneel only to truth.", + DaedalusInfo: "Yesterday we obeyed kings and bent our necks to emperors. Today we kneel only to truth.", - CovenantInfo: "Surrender yourself. Give up your empty individuality to become part of something great, something eternal. " + + CovenantInfo: "Surrender yourself. Give up your empty individuality to become part of something great, something eternal. " + "Become a slave. Submit your mind, body, and soul. Only then can you set yourself free.

" + "Only then can you discover immortality.", - //Megacorporations, each forms its own faction - ECorpInfo: "ECorp's mission is simple: to connect the world of today with the technology of tomorrow. " + - "With our wide range of Internet-related software and commercial hardware, ECorp makes the world's " + - "information universally accessible.", + //Megacorporations, each forms its own faction + ECorpInfo: "ECorp's mission is simple: to connect the world of today with the technology of tomorrow. " + + "With our wide range of Internet-related software and commercial hardware, ECorp makes the world's " + + "information universally accessible.", - MegaCorpInfo: "MegaCorp does things that others don't. We imagine. We create. We invent. We build things that " + - "others have never even dreamed of. Our work fills the world's needs for food, water, power, and " + - "transporation on an unprecendented scale, in ways that no other company can.

" + - "In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.", + MegaCorpInfo: "MegaCorp does things that others don't. We imagine. We create. We invent. We build things that " + + "others have never even dreamed of. Our work fills the world's needs for food, water, power, and " + + "transporation on an unprecendented scale, in ways that no other company can.

" + + "In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.", - BachmanAndAssociatesInfo: "Where Law and Business meet - thats where we are.

" + + BachmanAndAssociatesInfo: "Where Law and Business meet - thats where we are.

" + "Legal Insight - Business Instinct - Experience Innovation", - BladeIndustriesInfo: "Augmentation is salvation", + BladeIndustriesInfo: "Augmentation is salvation", - NWOInfo: "The human being created civilization not because of willingness but of a need to be assimilated into higher orders of structure and meaning.", + NWOInfo: "The human being created civilization not because of willingness but of a need to be assimilated into higher orders of structure and meaning.", - ClarkeIncorporatedInfo: "Unlocking the power of the genome", + ClarkeIncorporatedInfo: "Unlocking the power of the genome", - OmniTekIncorporatedInfo: "Simply put, our mission is to design and build robots that make a difference", + OmniTekIncorporatedInfo: "Simply put, our mission is to design and build robots that make a difference", - FourSigmaInfo: "The scientific method is the best way to approach investing. Big strategies backed up with big data. Driven by " + + FourSigmaInfo: "The scientific method is the best way to approach investing. Big strategies backed up with big data. Driven by " + "deep learning and innovative ideas. And improved by iteration. That's Four Sigma.", - KuaiGongInternationalInfo: "Dream big. Work hard. Make history.", + KuaiGongInternationalInfo: "Dream big. Work hard. Make history.", //Other Corporations FulcrumSecretTechnologiesInfo: "TODO", - //Hacker groups - BitRunnersInfo: "Our entire lives are controlled by bits. All of our actions, our thoughts, our personal information. "+ - "It's all transformed into bits, stored in bits, communicated through bits. It’s impossible for any person " + - "to move, to live, to operate at any level without the use of bits. " + - "And when a person moves, lives, and operates, they leave behind their bits, mere traces of seemingly " + - "meaningless fragments of information. But these bits can be reconstructed. Transformed. Used.

" + - "Those who run the bits, run the world", + //Hacker groups + BitRunnersInfo: "Our entire lives are controlled by bits. All of our actions, our thoughts, our personal information. "+ + "It's all transformed into bits, stored in bits, communicated through bits. It’s impossible for any person " + + "to move, to live, to operate at any level without the use of bits. " + + "And when a person moves, lives, and operates, they leave behind their bits, mere traces of seemingly " + + "meaningless fragments of information. But these bits can be reconstructed. Transformed. Used.

" + + "Those who run the bits, run the world", - BlackHandInfo: "The world, so afraid of strong government, now has no government. Only power - Digital power. Financial power. " + + BlackHandInfo: "The world, so afraid of strong government, now has no government. Only power - Digital power. Financial power. " + "Technological power. " + - "And those at the top rule with an invisible hand. They built a society where the rich get richer, " + - "and everyone else suffers.

" + - "So much pain. So many lives. Their darkness must end.", + "And those at the top rule with an invisible hand. They built a society where the rich get richer, " + + "and everyone else suffers.

" + + "So much pain. So many lives. Their darkness must end.", - NiteSecInfo: + NiteSecInfo: " __..__
" + " _.nITESECNIt.
" + " .-'NITESECNITESEc.
" + @@ -53998,22 +62748,22 @@ let FactionInfo = { " :bp.__.gNITESEC$$ :$ ;
" + " NITESECNITESECNIT $$b :
", - //City factions, essentially governments - ChongqingInfo: "Serve the people", - Sector12Info: "The City of the Future", - HongKongInfo: "Asia's World City", - AevumInfo: "The Silicon City", + //City factions, essentially governments + ChongqingInfo: "Serve the people", + Sector12Info: "The City of the Future", + HongKongInfo: "Asia's World City", + AevumInfo: "The Silicon City", IshimaInfo: "The East Asian Order of the Future", - VolhavenInfo: "Benefit, Honour, and Glory", + VolhavenInfo: "Benefit, Honour, and Glory", - //Criminal Organizations/Gangs - SpeakersForTheDeadInfo: "It is better to reign in hell than to serve in heaven.", + //Criminal Organizations/Gangs + SpeakersForTheDeadInfo: "It is better to reign in hell than to serve in heaven.", - DarkArmyInfo: "The World doesn't care about right or wrong. It's all about power.", + DarkArmyInfo: "The World doesn't care about right or wrong. It's all about power.", - TheSyndicateInfo: "Honor holds you back", + TheSyndicateInfo: "Honor holds you back", - SilhouetteInfo: "Corporations have filled the void of power left behind by the collapse of Western government. The issue is they've become so big " + + SilhouetteInfo: "Corporations have filled the void of power left behind by the collapse of Western government. The issue is they've become so big " + "that you don't know who they're working for. And if you're employed at one of these corporations, you don't even know who you're working " + "for.

" + "That's terror. Terror, fear, and corruption. All born into the system, all propagated by the system.", @@ -54022,16 +62772,16 @@ let FactionInfo = { SlumSnakesInfo: "Slum Snakes rule!", - //Earlygame factions - factions the player will prestige with early on that don't - //belong in other categories + //Earlygame factions - factions the player will prestige with early on that don't + //belong in other categories NetburnersInfo: "~~//*>H4CK|\|3T 8URN3R5**>?>\\~~", - TianDiHuiInfo: "Obey Heaven and Work Righteousness", + TianDiHuiInfo: "Obey Heaven and Work Righteousness", - CyberSecInfo: "The Internet is the first thing that humanity has built that humanity doesn’t understand, " + - "the largest experiment in anarchy that we have ever had. And as the world becomes increasingly " + - "dominated by the internet, society approaches the brink of total chaos. " + - "We serve only to protect society, to protect humanity, to protect the world from its imminent collapse.", + CyberSecInfo: "The Internet is the first thing that humanity has built that humanity doesn’t understand, " + + "the largest experiment in anarchy that we have ever had. And as the world becomes increasingly " + + "dominated by the internet, society approaches the brink of total chaos. " + + "We serve only to protect society, to protect humanity, to protect the world from its imminent collapse.", } @@ -54039,19 +62789,19 @@ let FactionInfo = { /***/ }), -/* 50 */ +/* 105 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return beginInfiltration; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__ = __webpack_require__(51); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__ = __webpack_require__(106); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__ = __webpack_require__(6); @@ -54589,7 +63339,7 @@ function updateInfiltrationButtons(inst, scenario) { "" + "Attempt to disable the security bots by hacking them. You have a " + Object(__WEBPACK_IMPORTED_MODULE_7__utils_StringHelperFunctions_js__["c" /* formatNumber */])(hackChance*100, 2) + "% chance of success. " + - "If you succeed, the security level will increase by 1%. If you fail, " + + "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" + @@ -54771,7 +63521,7 @@ function getInfiltrationDestroySecurityChance(inst) { //Hack security -//Success: 1%, Failure: 5% +//Success: 3%, Failure: 5% function attemptInfiltrationHack(inst) { var chance = getInfiltrationHackChance(inst); inst.gainHackingExp(inst.securityLevel / 40) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_exp_mult; @@ -54880,18 +63630,18 @@ function getInfiltrationEscapeChance(inst) { /***/ }), -/* 51 */ +/* 106 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return infiltrationBoxCreate; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_Faction_js__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_BitNode_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_Constants_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_Faction_js__ = __webpack_require__(12); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__StringHelperFunctions_js__ = __webpack_require__(6); @@ -55007,7 +63757,7 @@ function infiltrationBoxCreate(inst) { /***/ }), -/* 52 */ +/* 107 */ /***/ (function(module, exports, __webpack_require__) { /* ***** BEGIN LICENSE BLOCK ***** @@ -59190,7 +67940,7 @@ init(true);function init(packaged) { if (!global || !global.document) return; - options.packaged = packaged || acequire.packaged || module.packaged || (global.define && __webpack_require__(44).packaged); + options.packaged = packaged || acequire.packaged || module.packaged || (global.define && __webpack_require__(56).packaged); var scriptOptions = {}; var scriptUrl = ""; @@ -75217,7 +83967,7 @@ exports.config = acequire("./config"); exports.acequire = acequire; if (true) - exports.define = __webpack_require__(44); + exports.define = __webpack_require__(56); exports.edit = function(el) { if (typeof el == "string") { var _id = el; @@ -75284,7 +84034,7 @@ exports.version = "1.2.9"; module.exports = window.ace.acequire("ace/ace"); /***/ }), -/* 53 */ +/* 108 */ /***/ (function(module, exports, __webpack_require__) { ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) { @@ -76057,7 +84807,7 @@ oop.inherits(Mode, TextMode); }; this.createWorker = function(session) { - var worker = new WorkerClient(["ace"], __webpack_require__(45), "JavaScriptWorker"); + var worker = new WorkerClient(["ace"], __webpack_require__(71), "JavaScriptWorker"); worker.attachToDocument(session.getDocument()); worker.on("annotate", function(results) { @@ -76079,7 +84829,7 @@ exports.Mode = Mode; /***/ }), -/* 54 */ +/* 109 */ /***/ (function(module, exports, __webpack_require__) { ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(acequire, exports, module) { @@ -76874,7 +85624,7 @@ oop.inherits(Mode, TextMode); }; this.createWorker = function(session) { - var worker = new WorkerClient(["ace"], __webpack_require__(45), "JavaScriptWorker"); + var worker = new WorkerClient(["ace"], __webpack_require__(71), "JavaScriptWorker"); worker.attachToDocument(session.getDocument()); worker.on("annotate", function(results) { @@ -76896,7 +85646,7 @@ exports.Mode = Mode; /***/ }), -/* 55 */ +/* 110 */ /***/ (function(module, exports) { ace.define("ace/theme/chaos",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77058,7 +85808,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 56 */ +/* 111 */ /***/ (function(module, exports) { ace.define("ace/theme/chrome",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77192,7 +85942,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 57 */ +/* 112 */ /***/ (function(module, exports) { ace.define("ace/theme/monokai",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77303,7 +86053,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 58 */ +/* 113 */ /***/ (function(module, exports) { ace.define("ace/theme/solarized_dark",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77397,7 +86147,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 59 */ +/* 114 */ /***/ (function(module, exports) { ace.define("ace/theme/solarized_light",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77494,7 +86244,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 60 */ +/* 115 */ /***/ (function(module, exports) { ace.define("ace/theme/terminal",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77614,7 +86364,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 61 */ +/* 116 */ /***/ (function(module, exports) { ace.define("ace/theme/twilight",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77729,7 +86479,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 62 */ +/* 117 */ /***/ (function(module, exports) { ace.define("ace/theme/xcode",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) { @@ -77823,7 +86573,7 @@ dom.importCssString(exports.cssText, exports.cssClass); /***/ }), -/* 63 */ +/* 118 */ /***/ (function(module, exports) { ace.define("ace/keyboard/vim",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/dom","ace/lib/oop","ace/lib/keys","ace/lib/event","ace/search","ace/lib/useragent","ace/search_highlight","ace/commands/multi_select_commands","ace/mode/text","ace/multi_select"], function(acequire, exports, module) { @@ -83427,7 +92177,7 @@ dom.importCssString(".normal-mode .ace_cursor{\ /***/ }), -/* 64 */ +/* 119 */ /***/ (function(module, exports) { ace.define("ace/occur",["require","exports","module","ace/lib/oop","ace/range","ace/search","ace/edit_session","ace/search_highlight","ace/lib/dom"], function(acequire, exports, module) { @@ -84614,7 +93364,7 @@ exports.killRing = { /***/ }), -/* 65 */ +/* 120 */ /***/ (function(module, exports) { ace.define("ace/snippets",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/anchor","ace/keyboard/hash_handler","ace/tokenizer","ace/lib/dom","ace/editor"], function(acequire, exports, module) { @@ -86575,222 +95325,231 @@ acequire("../config").defineOptions(Editor.prototype, "editor", { /***/ }), -/* 66 */ +/* 121 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return checkIfConnectedToDarkweb; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return executeDarkwebTerminalCommand; }); -/* unused harmony export listAllDarkwebItems */ -/* unused harmony export buyDarkwebItem */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return parseDarkwebItemPrice; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DarkWebItems; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Terminal_js__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_StringHelperFunctions_js__ = __webpack_require__(5); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return TerminalHelpText; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return HelpTexts; }); +/* HelpText.js */ +let TerminalHelpText = + "Type 'help name' to learn more about the command 'name'

" + + 'alias [-g] [name="value"] Create or display Terminal aliases
' + + "analyze Get information about the current machine
" + + "buy [-l/program] Purchase a program through the Dark Web
" + + "cat [file] Display a .msg, .lit, or .txt file
" + + "check [script] [args...] Print a script's logs to Terminal
" + + "clear Clear all text on the terminal
" + + "cls See 'clear' command
" + + "connect [ip/hostname] Connects to a remote server
" + + "download [script/text file] Downloads scripts or text files to your computer
" + + "free Check the machine's memory (RAM) usage
" + + "hack Hack the current machine
" + + "help [command] Display this help text, or the help text for a command
" + + "home Connect to home computer
" + + "hostname Displays the hostname of the machine
" + + "ifconfig Displays the IP address of the machine
" + + "kill [script] [args...] Stops the specified script on the current server
" + + "killall Stops all running scripts on the current machine
" + + "ls [| grep pattern] Displays all files on the machine
" + + "lscpu Displays the number of CPU cores on the machine
" + + "mem [script] [-t] [n] Displays the amount of RAM required to run the script
" + + "nano [file] Text editor - Open up and edit a script or text file
" + + "ps Display all scripts that are currently running
" + + "rm [file] Delete a file from the server
" + + "run [name] [-t] [n] [args...] Execute a program or script
" + + "scan Prints all immediately-available network connections
" + + "scan-analyze [d] [-a] Prints info for all servers up to d nodes away
" + + "scp [file] [server] Copies a file to a destination server
" + + "sudov Shows whether you have root access on this computer
" + + "tail [script] [args...] Displays dynamic logs for the specified script
" + + "theme [preset] | bg txt hlgt Change the color scheme of the UI
" + + "top Displays all running scripts and their RAM usage
" + + 'unalias "[alias name]" Deletes the specified alias
'; +let HelpTexts = { + alias: 'alias [-g] [name="value"]
' + + "Create or display aliases. An alias enables a replacement of a word with another string. " + + "It can be used to abbreviate a commonly used command, or commonly used parts of a command. The NAME " + + "of an alias defines the word that will be replaced, while the VALUE defines what it will be replaced by. For example, " + + "you could create the alias 'nuke' for the Terminal command 'run NUKE.exe' using the following:

" + + 'alias nuke="run NUKE.exe"

' + + "Then, to run the NUKE.exe program you would just have to enter 'nuke' in Terminal rather than the full command. " + + "It is important to note that 'default' aliases will only be substituted for the first word of a Terminal command. For " + + "example, if the following alias was set:

" + + 'alias worm="HTTPWorm.exe"

' + + "and then you tried to run the following terminal command:

" + + "run worm

" + + "This would fail because the worm alias is not the first word of a Terminal command. To allow an alias to be substituted " + + "anywhere in a Terminal command, rather than just the first word, you must set it to be a global alias using the -g flag:

" + + 'alias -g worm="HTTPWorm.exe"

' + + "Now, the 'worm' alias will be substituted anytime it shows up as an individual word in a Terminal command.

" + + "Entering just the command 'alias' without any arguments prints the list of all defined aliases in the reusable form " + + "'alias NAME=VALUE' on the Terminal.

" + + "The 'unalias' command can be used to remove aliases.

", + analyze: "analze
" + + "Prints details and statistics about the current server. The information that is printed includes basic " + + "server details such as the hostname, whether the player has root access, what ports are opened/closed, and also " + + "hacking-related information such as an estimated chance to successfully hack, an estimate of how much money is " + + "available on the server, etc.", + buy: "buy [-l / program]
" + + "Purchase a program through the Dark Web. Requires a TOR router to use.

" + + "If this command is ran with the '-l' flag, it will display a list of all programs that can be bought through the " + + "dark web to the Terminal, as well as their costs.

" + + "Otherwise, the name of the program must be passed in as a parameter. This is name is NOT case-sensitive.", + cat: "cat [file]
" + + "Display message (.msg), literature (.lit), or text (.txt) files. Examples:

" + + "cat j1.msg
" + + "cat foo.lit
" + + "cat servers.txt", + check: "check [script name] [args...]
" + + "Print the logs of the script specified by the script name and arguments to the Terminal. Each argument must be separated by " + + "a space. Remember that a running script is uniquely " + + "identified both by its name and the arguments that are used to start it. So, if a script was ran with the following arguments:

" + + "run foo.script 1 2 foodnstuff

" + + "Then to run the 'check' command on this script you would have to pass the same arguments in:

" + + "check foo.script 1 2 foodnstuff", + clear: "clear
" + + "Clear the Terminal screen, deleting all of the text. Note that this does not delete the user's command history, so using the up " + + "and down arrow keys is still valid. Also note that this is permanent and there is no way to undo this. Synonymous with 'cls' command", + cls: "cls
" + + "Clear the Terminal screen, deleting all of the text. Note that this does not delete the user's command history, so using the up " + + "and down arrow keys is still valid. Also note that this is permanent and there is no way to undo this. Synonymous with 'clear' command", + connect: "connect [hostname/ip]
" + + "Connect to a remote server. The hostname or IP address of the remote server must be given as the argument " + + "to this command. Note that only servers that are immediately adjacent to the current server in the network can be connected to. To " + + "see which servers can be connected to, use the 'scan' command.", + download: "download [script/text file]
" + + "Downloads a script or text file to your computer (like your real life computer).
" + + "You can also download all of your scripts/text files as a zip file using the following Terminal commands:

" + + "Download all scripts and text files: download *
" + + "Download all scripts: download *.script
" + + "Download all text files: download *.txt
", + free: "free
" + + "Display's the memory usage on the current machine. Print the amount of RAM that is available on the current server as well as " + + "how much of it is being used.", + hack: "hack
" + + "Attempt to hack the current server. Requires root access in order to be run. See the wiki page for hacking mechanics
", + help: "help [command]
" + + "Display Terminal help information. Without arguments, 'help' prints a list of all valid Terminal commands and a brief " + + "description of their functionality. You can also pass the name of a Terminal command as an argument to 'help' to print " + + "more detailed information about the Terminal command. Examples:

" + + "help alias
" + + "help scan-analyze", + home: "home
" + + "Connect to your home computer. This will work no matter what server you are currently connected to.", + hostname: "hostname
" + + "Prints the hostname of the current server", + ifconfig: "ipconfig
" + + "Prints the IP address of the current server", + kill: "kill [script name] [args...]
" + + "Kill the script specified by the script name and arguments. Each argument must be separated by " + + "a space. Remember that a running script is uniquely identified by " + + "both its name and the arguments that are used to start it. So, if a script was ran with the following arguments:

" + + "run foo.script 1 sigma-cosmetics

" + + "Then to kill this script the same arguments would have to be used:

" + + "kill foo.script 1 sigma-cosmetics

" + + "Note that after issuing the 'kill' command for a script, it may take a while for the script to actually stop running. " + + "This will happen if the script is in the middle of a command such as grow() or weaken() that takes time to execute. " + + "The script will not be stopped/killed until after that time has elapsed.", + killall: "killall
" + + "Kills all scripts on the current server. " + + "Note that after the 'kill' command is issued for a script, it may take a while for the script to actually stop running. " + + "This will happen if the script is in the middle of a command such as grow() or weaken() that takes time to execute. " + + "The script will not be stopped/killed until after that time has elapsed.", + ls: "ls [| grep pattern]
" + + "The ls command, with no arguments, prints all files on the current server to the Terminal screen. " + + "This includes all scripts, programs, and message files. " + + "The files will be displayed in alphabetical order.

" + + "The '| grep pattern' optional parameter can be used to only display files whose filenames match the specified pattern. " + + "For example, if you wanted to only display files with the .script extension, you could use:

" + + "ls | grep .script

" + + "Alternatively, if you wanted to display all files with the word purchase in the filename, you could use:

" + + "ls | grep purchase", + mem: "mem [script name] [-t] [num threads]
" + + "Displays the amount of RAM needed to run the specified script with a single thread. The command can also be used to print " + + "the amount of RAM needed to run a script with multiple threads using the '-t' flag. If the '-t' flag is specified, then " + + "an argument for the number of threads must be passed in afterwards. Examples:

" + + "mem foo.script
" + + "mem foo.script -t 50
" + + "The first example above will print the amount of RAM needed to run 'foo.script' with a single thread. The second example " + + "above will print the amount of RAM needed to run 'foo.script' with 50 threads.", + nano: "nano [file name]
" + + "Opens up the specified file in the Text Editor. Only scripts (.script) or text files (.txt) can be " + + "edited using the Text Editor. If the file does not already exist, then a new, empty one " + + "will be created", + ps: "ps
" + + "Prints all scripts that are running on the current server", + rm: "rm [file]
" + + "Removes the specified file from the current server. A file can be a script, a program, or a message file.

" + + "WARNING: This is permanent and cannot be undone", + run: "run [file name] [-t] [num threads] [args...]
" + + "Execute a program or a script.

" + + "The '[-t]', '[num threads]', and '[args...]' arguments are only valid when running a script. The '-t' flag is used " + + "to indicate that the script should be run with the specified number of threads. If the flag is omitted, " + + "then the script will be run with a single thread by default. " + + "If the '-t' flag is used, then it MUST come immediately " + + "after the script name, and the [num threads] argument MUST come immediately afterwards.

" + + "[args...] represents a variable number of arguments that will be passed into the script. See the documentation " + + "about script arguments. Each specified argument must be separated by a space.

", + scan: "scan
" + + "Prints all immediately-available network connection. This will print a list of all servers that you can currently connect " + + "to using the 'connect' Terminal command.", + "scan-analyze": "scan-analyze [depth] [-a]
" + + "Prints detailed information about all servers up to [depth] nodes away on the network. Calling " + + "'scan-analyze 1' will display information for the same servers that are shown by the 'scan' Terminal " + + "command. This command also shows the relative paths to reach each server.

" + + "By default, the maximum depth that can be specified for 'scan-analyze' is 3. However, once you have " + + "the DeepscanV1.exe and DeepscanV2.exe programs, you can execute 'scan-analyze' with a depth up to " + + "5 and 10, respectively.

" + + "The information 'scan-analyze' displays about each server includes whether or not you have root access to it, " + + "its required hacking level, the number of open ports required to run NUKE.exe on it, and how much RAM " + + "it has.

" + + "By default, this command will not display servers that you have purchased. However, you can pass in the " + + "-a flag at the end of the command if you would like to enable that.", + scp: "scp [filename] [target server]
" + + "Copies the specified file from the current server to the target server. " + + "This command only works for script files (.script extension), literature files (.lit extension), " + + "and text files (.txt extension). " + + "The second argument passed in must be the hostname or IP of the target server.", + sudov: "sudov
" + + "Prints whether or not you have root access to the current machine", + tail: "tail [script name] [args...]
" + + "Displays dynamic logs for the script specified by the script name and arguments. Each argument must be separated " + + "by a space. Remember that a running script is uniquely identified by both its name and the arguments that were used " + + "to run it. So, if a script was ran with the following arguments:

" + + "run foo.script 10 50000

" + + "Then in order to check its logs with 'tail' the same arguments must be used:

" + + "tail foo.script 10 50000", + theme: "theme [preset] | [#background #text #highlight]
" + + "Change the color of the game's user interface

" + + "This command can be called with a preset theme. Currently, the supported presets are 'default', 'muted', and 'solarized'. " + + "However, you can also specify your own color scheme using hex values. To do so, you must specify three hex color values " + + "for the background color, the text color, and the highlight color. These hex values must be preceded by a pound sign (#) and " + + "must be either 3 or 6 digits. Example:

" + + "theme #ffffff #385 #235012

" + + "A color picker such as " + + "Google's " + + "can be used to get your desired hex color values

" + + "Themes are not saved, so when the game is closed and then re-opened or reloaded then it will revert back to the default theme.", + top: "top
" + + "Prints a list of all scripts running on the current server as well as their thread count and how much " + + "RAM they are using in total.", + unalias: 'unalias "[alias name]"
' + + "Deletes the specified alias. Note that the double quotation marks are required.

" + + "As an example, if an alias was declared using:

" + + 'alias r="run"

' + + "Then it could be removed using:

" + + 'unalias "r"

' + + "It is not necessary to differentiate between global and non-global aliases when using 'unalias'", - - - - - - - -/* DarkWeb.js */ -//Posts a "help" message if connected to DarkWeb -function checkIfConnectedToDarkweb() { - if (__WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__["a" /* SpecialServerIps */].hasOwnProperty("Darkweb Server")) { - var darkwebIp = __WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"]; - if (!Object(__WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__["c" /* isValidIPAddress */])(darkwebIp)) {return;} - if (darkwebIp == __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getCurrentServer().ip) { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* 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(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Incorrect number of arguments. Usage: "); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("buy -l"); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("buy [item name]"); - return; - } - var arg = commandArray[1]; - if (arg == "-l") { - listAllDarkwebItems(); - } else { - buyDarkwebItem(arg); - } - break; - default: - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Command not found"); - break; - } -} - -function listAllDarkwebItems() { - for (var item in DarkWebItems) { - if (DarkWebItems.hasOwnProperty(item)) { - var item = DarkWebItems[item]; - //Convert string using toLocaleString - var split = item.split(" - "); - if (split.length == 3 && split[1].charAt(0) == '$') { - split[1] = split[1].slice(1); - split[1] = split[1].replace(/,/g, ''); - var price = parseFloat(split[1]); - if (isNaN(price)) { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(item); - return; - } - price = Object(__WEBPACK_IMPORTED_MODULE_5__utils_StringHelperFunctions_js__["c" /* formatNumber */])(price, 0); - split[1] = "$" + price.toString(); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(split.join(" - ")); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])(item); - } - } - } - - var priceString = split[1]; - //Check for errors - if (priceString.length == 0 || priceString.charAt(0) != '$') { - return -1; - } - //Remove dollar sign and commas - priceString = priceString.slice(1); - priceString = priceString.replace(/,/g, ''); - - //Convert string to numeric - var price = parseFloat(priceString); - if (isNaN(price)) {return -1;} - else {return price;} -} - -function buyDarkwebItem(itemName) { - if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the BruteSSH.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the FTPCrack.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the relaySMTP.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the HTTPWorm.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the SQLInject.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV1); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the DeepscanV1.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else if (itemName.toLowerCase() == __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase()) { - var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_1__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__["a" /* Programs */].DeepscanV2); - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("You have purchased the DeepscanV2.exe program. The new program " + - "can be found on your home computer."); - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Not enough money to purchase " + itemName); - } - } else { - Object(__WEBPACK_IMPORTED_MODULE_3__Terminal_js__["b" /* post */])("Unrecognized item"); - } -} - -function parseDarkwebItemPrice(itemDesc) { - var split = itemDesc.split(" - "); - if (split.length == 3) { - var priceString = split[1]; - //Check for errors - if (priceString.length == 0 || priceString.charAt(0) != '$') { - return -1; - } - //Remove dollar sign and commas - priceString = priceString.slice(1); - priceString = priceString.replace(/,/g, ''); - - //Convert string to numeric - var price = parseFloat(priceString); - if (isNaN(price)) {return -1;} - else {return price;} - } else { - return -1; - } -} - -let DarkWebItems = { - BruteSSHProgram: "BruteSSH.exe - $500,000 - Opens up SSH Ports", - FTPCrackProgram: "FTPCrack.exe - $1,500,000 - Opens up FTP Ports", - RelaySMTPProgram: "relaySMTP.exe - $5,000,000 - Opens up SMTP Ports", - HTTPWormProgram: "HTTPWorm.exe - $30,000,000 - Opens up HTTP Ports", - SQLInjectProgram: "SQLInject.exe - $250,000,000 - Opens up SQL Ports", - DeepScanV1Program: "DeepscanV1.exe - $500,000 - Enables 'scan-analyze' with a depth up to 5", - DeepScanV2Program: "DeepscanV2.exe - $25,000,000 - Enables 'scan-analyze' with a depth up to 10", } /***/ }), -/* 67 */ +/* 122 */ /***/ (function(module, exports, __webpack_require__) { /** @@ -101483,109 +110242,10111 @@ let DarkWebItems = { /***/ }), -/* 68 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +/* 123 */ +/***/ (function(module, exports, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TextFile; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return getTextFile; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return createTextFile; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__ = __webpack_require__(8); - - -function TextFile(fn="", txt="") { - this.fn = fn.endsWith(".txt") ? fn : fn + ".txt"; - this.fn = this.fn.replace(/\s+/g, ''); - this.text = String(txt); -} - -TextFile.prototype.append = function(txt) { - this.text += String(txt); -} - -TextFile.prototype.write = function(txt) { - this.text = String(txt); -} - -TextFile.prototype.read = function() { - return this.txt; -} - -TextFile.prototype.show = function() { - Object(__WEBPACK_IMPORTED_MODULE_1__utils_DialogBox_js__["a" /* dialogBoxCreate */])(this.fn + "

" + this.text, true); -} - -TextFile.prototype.download = function() { - var filename = this.fn; - var file = new Blob([this.text], {type: 'text/plain'}); - if (window.navigator.msSaveOrOpenBlob) {// IE10+ - window.navigator.msSaveOrOpenBlob(file, filename); - } else { // Others - var a = document.createElement("a"), - url = URL.createObjectURL(file); - a.href = url; - a.download = this.fn; - document.body.appendChild(a); - a.click(); - setTimeout(function() { - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - }, 0); +/** + * Representation a of zip file in js + * @constructor + */ +function JSZip() { + // if this constructor is used without `new`, it adds `new` before itself: + if(!(this instanceof JSZip)) { + return new JSZip(); } -} -TextFile.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["b" /* Generic_toJSON */])("TextFile", this); -} + if(arguments.length) { + throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide."); + } -TextFile.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(TextFile, value.data); -} + // object containing the files : + // { + // "folder/" : {...}, + // "folder/data.txt" : {...} + // } + this.files = {}; -__WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["c" /* Reviver */].constructors.TextFile = TextFile; + this.comment = null; -function getTextFile(fn, server) { - if (!fn.endsWith(".txt")) {fn += ".txt";} - for (var i = 0; i < server.textFiles.length; ++i) { - if (server.textFiles[i].fn === fn) { - return server.textFiles[i]; + // Where we are in the hierarchy + this.root = ""; + this.clone = function() { + var newObj = new JSZip(); + for (var i in this) { + if (typeof this[i] !== "function") { + newObj[i] = this[i]; + } } - } - return null; + return newObj; + }; } +JSZip.prototype = __webpack_require__(124); +JSZip.prototype.loadAsync = __webpack_require__(170); +JSZip.support = __webpack_require__(20); +JSZip.defaults = __webpack_require__(89); -//Returns the TextFile object that was just created -function createTextFile(fn, txt, server) { - if (getTextFile(fn, server) !== null) { - console.log("ERROR: createTextFile failed because the specified " + - "server already has a text file with the same fn"); - return; - } - var file = new TextFile(fn, txt); - server.textFiles.push(file); - return file; -} - -function deleteTextFile(fn, server) { - if (!fn.endsWith(".txt")) {fn += ".txt";} - for (var i = 0; i < server.textFiles.length; ++i) { - if (server.textFiles[i].fn === fn) { - server.textFiles.splice(i, 1); - return true; - } - } - return false; -} +// TODO find a better way to handle this version, +// a require('package.json').version doesn't work with webpack, see #327 +JSZip.version = "3.1.5"; +JSZip.loadAsync = function (content, options) { + return new JSZip().loadAsync(content, options); +}; +JSZip.external = __webpack_require__(37); +module.exports = JSZip; /***/ }), -/* 69 */ +/* 124 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +var utf8 = __webpack_require__(30); +var utils = __webpack_require__(3); +var GenericWorker = __webpack_require__(10); +var StreamHelper = __webpack_require__(88); +var defaults = __webpack_require__(89); +var CompressedObject = __webpack_require__(66); +var ZipObject = __webpack_require__(156); +var generate = __webpack_require__(157); +var nodejsUtils = __webpack_require__(50); +var NodejsStreamInputAdapter = __webpack_require__(169); + + +/** + * Add a file in the current folder. + * @private + * @param {string} name the name of the file + * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file + * @param {Object} originalOptions the options of the file + * @return {Object} the new file. + */ +var fileAdd = function(name, data, originalOptions) { + // be sure sub folders exist + var dataType = utils.getTypeOf(data), + parent; + + + /* + * Correct options. + */ + + var o = utils.extend(originalOptions || {}, defaults); + o.date = o.date || new Date(); + if (o.compression !== null) { + o.compression = o.compression.toUpperCase(); + } + + if (typeof o.unixPermissions === "string") { + o.unixPermissions = parseInt(o.unixPermissions, 8); + } + + // UNX_IFDIR 0040000 see zipinfo.c + if (o.unixPermissions && (o.unixPermissions & 0x4000)) { + o.dir = true; + } + // Bit 4 Directory + if (o.dosPermissions && (o.dosPermissions & 0x0010)) { + o.dir = true; + } + + if (o.dir) { + name = forceTrailingSlash(name); + } + if (o.createFolders && (parent = parentFolder(name))) { + folderAdd.call(this, parent, true); + } + + var isUnicodeString = dataType === "string" && o.binary === false && o.base64 === false; + if (!originalOptions || typeof originalOptions.binary === "undefined") { + o.binary = !isUnicodeString; + } + + + var isCompressedEmpty = (data instanceof CompressedObject) && data.uncompressedSize === 0; + + if (isCompressedEmpty || o.dir || !data || data.length === 0) { + o.base64 = false; + o.binary = true; + data = ""; + o.compression = "STORE"; + dataType = "string"; + } + + /* + * Convert content to fit. + */ + + var zipObjectContent = null; + if (data instanceof CompressedObject || data instanceof GenericWorker) { + zipObjectContent = data; + } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) { + zipObjectContent = new NodejsStreamInputAdapter(name, data); + } else { + zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64); + } + + var object = new ZipObject(name, zipObjectContent, o); + this.files[name] = object; + /* + TODO: we can't throw an exception because we have async promises + (we can have a promise of a Date() for example) but returning a + promise is useless because file(name, data) returns the JSZip + object for chaining. Should we break that to allow the user + to catch the error ? + + return external.Promise.resolve(zipObjectContent) + .then(function () { + return object; + }); + */ +}; + +/** + * Find the parent folder of the path. + * @private + * @param {string} path the path to use + * @return {string} the parent folder, or "" + */ +var parentFolder = function (path) { + if (path.slice(-1) === '/') { + path = path.substring(0, path.length - 1); + } + var lastSlash = path.lastIndexOf('/'); + return (lastSlash > 0) ? path.substring(0, lastSlash) : ""; +}; + +/** + * Returns the path with a slash at the end. + * @private + * @param {String} path the path to check. + * @return {String} the path with a trailing slash. + */ +var forceTrailingSlash = function(path) { + // Check the name ends with a / + if (path.slice(-1) !== "/") { + path += "/"; // IE doesn't like substr(-1) + } + return path; +}; + +/** + * Add a (sub) folder in the current folder. + * @private + * @param {string} name the folder's name + * @param {boolean=} [createFolders] If true, automatically create sub + * folders. Defaults to false. + * @return {Object} the new folder. + */ +var folderAdd = function(name, createFolders) { + createFolders = (typeof createFolders !== 'undefined') ? createFolders : defaults.createFolders; + + name = forceTrailingSlash(name); + + // Does this folder already exist? + if (!this.files[name]) { + fileAdd.call(this, name, null, { + dir: true, + createFolders: createFolders + }); + } + return this.files[name]; +}; + +/** +* Cross-window, cross-Node-context regular expression detection +* @param {Object} object Anything +* @return {Boolean} true if the object is a regular expression, +* false otherwise +*/ +function isRegExp(object) { + return Object.prototype.toString.call(object) === "[object RegExp]"; +} + +// return the actual prototype of JSZip +var out = { + /** + * @see loadAsync + */ + load: function() { + throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); + }, + + + /** + * Call a callback function for each entry at this folder level. + * @param {Function} cb the callback function: + * function (relativePath, file) {...} + * It takes 2 arguments : the relative path and the file. + */ + forEach: function(cb) { + var filename, relativePath, file; + for (filename in this.files) { + if (!this.files.hasOwnProperty(filename)) { + continue; + } + file = this.files[filename]; + relativePath = filename.slice(this.root.length, filename.length); + if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root + cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn... + } + } + }, + + /** + * Filter nested files/folders with the specified function. + * @param {Function} search the predicate to use : + * function (relativePath, file) {...} + * It takes 2 arguments : the relative path and the file. + * @return {Array} An array of matching elements. + */ + filter: function(search) { + var result = []; + this.forEach(function (relativePath, entry) { + if (search(relativePath, entry)) { // the file matches the function + result.push(entry); + } + + }); + return result; + }, + + /** + * Add a file to the zip file, or search a file. + * @param {string|RegExp} name The name of the file to add (if data is defined), + * the name of the file to find (if no data) or a regex to match files. + * @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded + * @param {Object} o File options + * @return {JSZip|Object|Array} this JSZip object (when adding a file), + * a file (when searching by string) or an array of files (when searching by regex). + */ + file: function(name, data, o) { + if (arguments.length === 1) { + if (isRegExp(name)) { + var regexp = name; + return this.filter(function(relativePath, file) { + return !file.dir && regexp.test(relativePath); + }); + } + else { // text + var obj = this.files[this.root + name]; + if (obj && !obj.dir) { + return obj; + } else { + return null; + } + } + } + else { // more than one argument : we have data ! + name = this.root + name; + fileAdd.call(this, name, data, o); + } + return this; + }, + + /** + * Add a directory to the zip file, or search. + * @param {String|RegExp} arg The name of the directory to add, or a regex to search folders. + * @return {JSZip} an object with the new directory as the root, or an array containing matching folders. + */ + folder: function(arg) { + if (!arg) { + return this; + } + + if (isRegExp(arg)) { + return this.filter(function(relativePath, file) { + return file.dir && arg.test(relativePath); + }); + } + + // else, name is a new folder + var name = this.root + arg; + var newFolder = folderAdd.call(this, name); + + // Allow chaining by returning a new object with this folder as the root + var ret = this.clone(); + ret.root = newFolder.name; + return ret; + }, + + /** + * Delete a file, or a directory and all sub-files, from the zip + * @param {string} name the name of the file to delete + * @return {JSZip} this JSZip object + */ + remove: function(name) { + name = this.root + name; + var file = this.files[name]; + if (!file) { + // Look for any folders + if (name.slice(-1) !== "/") { + name += "/"; + } + file = this.files[name]; + } + + if (file && !file.dir) { + // file + delete this.files[name]; + } else { + // maybe a folder, delete recursively + var kids = this.filter(function(relativePath, file) { + return file.name.slice(0, name.length) === name; + }); + for (var i = 0; i < kids.length; i++) { + delete this.files[kids[i].name]; + } + } + + return this; + }, + + /** + * Generate the complete zip file + * @param {Object} options the options to generate the zip file : + * - compression, "STORE" by default. + * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob. + * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file + */ + generate: function(options) { + throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide."); + }, + + /** + * Generate the complete zip file as an internal stream. + * @param {Object} options the options to generate the zip file : + * - compression, "STORE" by default. + * - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob. + * @return {StreamHelper} the streamed zip file. + */ + generateInternalStream: function(options) { + var worker, opts = {}; + try { + opts = utils.extend(options || {}, { + streamFiles: false, + compression: "STORE", + compressionOptions : null, + type: "", + platform: "DOS", + comment: null, + mimeType: 'application/zip', + encodeFileName: utf8.utf8encode + }); + + opts.type = opts.type.toLowerCase(); + opts.compression = opts.compression.toUpperCase(); + + // "binarystring" is prefered but the internals use "string". + if(opts.type === "binarystring") { + opts.type = "string"; + } + + if (!opts.type) { + throw new Error("No output type specified."); + } + + utils.checkSupport(opts.type); + + // accept nodejs `process.platform` + if( + opts.platform === 'darwin' || + opts.platform === 'freebsd' || + opts.platform === 'linux' || + opts.platform === 'sunos' + ) { + opts.platform = "UNIX"; + } + if (opts.platform === 'win32') { + opts.platform = "DOS"; + } + + var comment = opts.comment || this.comment || ""; + worker = generate.generateWorker(this, opts, comment); + } catch (e) { + worker = new GenericWorker("error"); + worker.error(e); + } + return new StreamHelper(worker, opts.type || "string", opts.mimeType); + }, + /** + * Generate the complete zip file asynchronously. + * @see generateInternalStream + */ + generateAsync: function(options, onUpdate) { + return this.generateInternalStream(options).accumulate(onUpdate); + }, + /** + * Generate the complete zip file asynchronously. + * @see generateInternalStream + */ + generateNodeStream: function(options, onUpdate) { + options = options || {}; + if (!options.type) { + options.type = "nodebuffer"; + } + return this.generateInternalStream(options).toNodejsStream(onUpdate); + } +}; +module.exports = out; + + +/***/ }), +/* 125 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return (b64.length * 3 / 4) - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr((len * 3 / 4) - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0; i < l; i += 4) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + + +/***/ }), +/* 126 */ +/***/ (function(module, exports) { + +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + + +/***/ }), +/* 127 */ +/***/ (function(module, exports, __webpack_require__) { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +module.exports = Stream; + +var EE = __webpack_require__(61).EventEmitter; +var inherits = __webpack_require__(31); + +inherits(Stream, EE); +Stream.Readable = __webpack_require__(62); +Stream.Writable = __webpack_require__(134); +Stream.Duplex = __webpack_require__(135); +Stream.Transform = __webpack_require__(136); +Stream.PassThrough = __webpack_require__(137); + +// Backwards-compat with node 0.4.x +Stream.Stream = Stream; + + + +// old-style streams. Note that the pipe method (the only relevant +// part of this class) is overridden in the Readable class. + +function Stream() { + EE.call(this); +} + +Stream.prototype.pipe = function(dest, options) { + var source = this; + + function ondata(chunk) { + if (dest.writable) { + if (false === dest.write(chunk) && source.pause) { + source.pause(); + } + } + } + + source.on('data', ondata); + + function ondrain() { + if (source.readable && source.resume) { + source.resume(); + } + } + + dest.on('drain', ondrain); + + // If the 'end' option is not supplied, dest.end() will be called when + // source gets the 'end' or 'close' events. Only dest.end() once. + if (!dest._isStdio && (!options || options.end !== false)) { + source.on('end', onend); + source.on('close', onclose); + } + + var didOnEnd = false; + function onend() { + if (didOnEnd) return; + didOnEnd = true; + + dest.end(); + } + + + function onclose() { + if (didOnEnd) return; + didOnEnd = true; + + if (typeof dest.destroy === 'function') dest.destroy(); + } + + // don't leave dangling pipes when there are errors. + function onerror(er) { + cleanup(); + if (EE.listenerCount(this, 'error') === 0) { + throw er; // Unhandled stream error in pipe. + } + } + + source.on('error', onerror); + dest.on('error', onerror); + + // remove all the event listeners that were added. + function cleanup() { + source.removeListener('data', ondata); + dest.removeListener('drain', ondrain); + + source.removeListener('end', onend); + source.removeListener('close', onclose); + + source.removeListener('error', onerror); + dest.removeListener('error', onerror); + + source.removeListener('end', cleanup); + source.removeListener('close', cleanup); + + dest.removeListener('close', cleanup); + } + + source.on('end', cleanup); + source.on('close', cleanup); + + dest.on('close', cleanup); + + dest.emit('pipe', source); + + // Allow for unix-like usage: A.pipe(B).pipe(C) + return dest; +}; + + +/***/ }), +/* 128 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 129 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var Buffer = __webpack_require__(49).Buffer; +var util = __webpack_require__(130); + +function copyBuffer(src, target, offset) { + src.copy(target, offset); +} + +module.exports = function () { + function BufferList() { + _classCallCheck(this, BufferList); + + this.head = null; + this.tail = null; + this.length = 0; + } + + BufferList.prototype.push = function push(v) { + var entry = { data: v, next: null }; + if (this.length > 0) this.tail.next = entry;else this.head = entry; + this.tail = entry; + ++this.length; + }; + + BufferList.prototype.unshift = function unshift(v) { + var entry = { data: v, next: this.head }; + if (this.length === 0) this.tail = entry; + this.head = entry; + ++this.length; + }; + + BufferList.prototype.shift = function shift() { + if (this.length === 0) return; + var ret = this.head.data; + if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next; + --this.length; + return ret; + }; + + BufferList.prototype.clear = function clear() { + this.head = this.tail = null; + this.length = 0; + }; + + BufferList.prototype.join = function join(s) { + if (this.length === 0) return ''; + var p = this.head; + var ret = '' + p.data; + while (p = p.next) { + ret += s + p.data; + }return ret; + }; + + BufferList.prototype.concat = function concat(n) { + if (this.length === 0) return Buffer.alloc(0); + if (this.length === 1) return this.head.data; + var ret = Buffer.allocUnsafe(n >>> 0); + var p = this.head; + var i = 0; + while (p) { + copyBuffer(p.data, ret, i); + i += p.data.length; + p = p.next; + } + return ret; + }; + + return BufferList; +}(); + +if (util && util.inspect && util.inspect.custom) { + module.exports.prototype[util.inspect.custom] = function () { + var obj = util.inspect({ length: this.length }); + return this.constructor.name + ' ' + obj; + }; +} + +/***/ }), +/* 130 */ +/***/ (function(module, exports) { + +/* (ignored) */ + +/***/ }), +/* 131 */ +/***/ (function(module, exports, __webpack_require__) { + +/* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) { + "use strict"; + + if (global.setImmediate) { + return; + } + + var nextHandle = 1; // Spec says greater than zero + var tasksByHandle = {}; + var currentlyRunningATask = false; + var doc = global.document; + var registerImmediate; + + function setImmediate(callback) { + // Callback can either be a function or a string + if (typeof callback !== "function") { + callback = new Function("" + callback); + } + // Copy function arguments + var args = new Array(arguments.length - 1); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i + 1]; + } + // Store and register the task + var task = { callback: callback, args: args }; + tasksByHandle[nextHandle] = task; + registerImmediate(nextHandle); + return nextHandle++; + } + + function clearImmediate(handle) { + delete tasksByHandle[handle]; + } + + function run(task) { + var callback = task.callback; + var args = task.args; + switch (args.length) { + case 0: + callback(); + break; + case 1: + callback(args[0]); + break; + case 2: + callback(args[0], args[1]); + break; + case 3: + callback(args[0], args[1], args[2]); + break; + default: + callback.apply(undefined, args); + break; + } + } + + function runIfPresent(handle) { + // From the spec: "Wait until any invocations of this algorithm started before this one have completed." + // So if we're currently running a task, we'll need to delay this invocation. + if (currentlyRunningATask) { + // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a + // "too much recursion" error. + setTimeout(runIfPresent, 0, handle); + } else { + var task = tasksByHandle[handle]; + if (task) { + currentlyRunningATask = true; + try { + run(task); + } finally { + clearImmediate(handle); + currentlyRunningATask = false; + } + } + } + } + + function installNextTickImplementation() { + registerImmediate = function(handle) { + process.nextTick(function () { runIfPresent(handle); }); + }; + } + + function canUsePostMessage() { + // The test against `importScripts` prevents this implementation from being installed inside a web worker, + // where `global.postMessage` means something completely different and can't be used for this purpose. + if (global.postMessage && !global.importScripts) { + var postMessageIsAsynchronous = true; + var oldOnMessage = global.onmessage; + global.onmessage = function() { + postMessageIsAsynchronous = false; + }; + global.postMessage("", "*"); + global.onmessage = oldOnMessage; + return postMessageIsAsynchronous; + } + } + + function installPostMessageImplementation() { + // Installs an event handler on `global` for the `message` event: see + // * https://developer.mozilla.org/en/DOM/window.postMessage + // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages + + var messagePrefix = "setImmediate$" + Math.random() + "$"; + var onGlobalMessage = function(event) { + if (event.source === global && + typeof event.data === "string" && + event.data.indexOf(messagePrefix) === 0) { + runIfPresent(+event.data.slice(messagePrefix.length)); + } + }; + + if (global.addEventListener) { + global.addEventListener("message", onGlobalMessage, false); + } else { + global.attachEvent("onmessage", onGlobalMessage); + } + + registerImmediate = function(handle) { + global.postMessage(messagePrefix + handle, "*"); + }; + } + + function installMessageChannelImplementation() { + var channel = new MessageChannel(); + channel.port1.onmessage = function(event) { + var handle = event.data; + runIfPresent(handle); + }; + + registerImmediate = function(handle) { + channel.port2.postMessage(handle); + }; + } + + function installReadyStateChangeImplementation() { + var html = doc.documentElement; + registerImmediate = function(handle) { + // Create a