' + - 'Create and manage a gang for this Faction. ' + - 'Gangs will earn you money and faction reputation.' + - '
' + - '0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g " + 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 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 " + 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 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) + " 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. 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 " + 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 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 " + 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 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) + " 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. 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
");
}
- __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
" +
+ "" + 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
" +
- "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 " +
- " || (47Long 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 = "
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 + "
" +
- "
" +
- "
" +
- "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: "
" +
- "Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/s
" +
- "
" +
- "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 + "
" +
- "
" +
- "
" +
- "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 =
- "
" +
- "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
" +
- "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
" +
+ "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 " +
+ " || (47Long 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 = "
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 + "
" +
+ "
" +
+ "
" +
+ "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: "
" +
+ "Sell: " + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["c" /* formatNumber */])(product.data[city][2], 3) + "/s
" +
+ "
" +
+ "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 + "
" +
+ "
" +
+ "
" +
+ "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 =
+ "
" +
+ "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.column
" + 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.
+
+
+
+/*
" +
"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