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
\" +\r\n \"This is the first BitNode that you play through. It has no special \" +\r\n \"modifications or mechanics.
\" +\r\n \"Destroying this BitNode will give you Source-File 1, or if you already have \" +\r\n \"this Source-File it will upgrade its level up to a maximum of 3. This Source-File \" +\r\n \"lets the player start with 32GB of RAM on his/her home computer when entering a \" +\r\n \"new BitNode, and also increases all of the player's multipliers by:
\" +\r\n \"Level 1: 16%
\" +\r\n \"Level 2: 24%
\" +\r\n \"Level 3: 28%\");\r\n BitNodes[\"BitNode2\"] = new BitNode(2, \"Rise of the Underworld\", \"From the shadows, they rose\", //Gangs\r\n \"From the shadows, they rose.
Organized crime groups quickly filled the void of power \" +\r\n \"left behind from the collapse of Western government in the 2050's. As society and civlization broke down, \" +\r\n \"people quickly succumbed to the innate human impulse of evil and savagery. The organized crime \" +\r\n \"factions quickly rose to the top of the modern world.
\" +\r\n \"In this BitNode:
The maximum amount of money available on a server is significantly decreased
\" +\r\n \"The amount of money gained from crimes and Infiltration is tripled
\" +\r\n \"Certain Factions (Slum Snakes, Tetrads, The Syndicate, The Dark Army, Speakers for the Dead, \" +\r\n \"NiteSec, The Black Hand) give the player the ability to form and manage their own gangs. These gangs \" +\r\n \"will earn the player money and reputation with the corresponding Faction
\" +\r\n \"Every Augmentation in the game will be available through the Factions listed above
\" +\r\n \"For every Faction NOT listed above, reputation gains are halved
\" +\r\n \"You will no longer gain passive reputation with Factions
\" +\r\n \"Destroying this BitNode will give you Source-File 2, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File increases the player's crime success rate, \" +\r\n \"crime money, and charisma multipliers by:
\" +\r\n \"Level 1: 20%
\" +\r\n \"Level 2: 30%
\" +\r\n \"Level 3: 35%\");\r\n BitNodes[\"BitNode3\"] = new BitNode(3, \"Corporatocracy\", \"The Price of Civilization\",\r\n \"Our greatest illusion is that a healthy society can revolve around a \" +\r\n \"single-minded pursuit of wealth.
\" +\r\n \"Sometime in the early 21st century economic and political globalization turned \" +\r\n \"the world into a corporatocracy, and it never looked back. Now, the privileged \" +\r\n \"elite will happily bankrupt their own countrymen, decimate their own community, \" +\r\n \"and evict their neighbors from houses in their desperate bid to increase their wealth.
\" +\r\n \"In this BitNode you can create and manage your own corporation. Running a successful corporation \" +\r\n \"has the potential of generating massive profits. All other forms of income are reduced by 75%. Furthermore:
\" +\r\n \"The price and reputation cost of all Augmentations is tripled
\" +\r\n \"The starting and maximum amount of money on servers is reduced by 75%
\" +\r\n \"Server growth rate is reduced by 80%
\" +\r\n \"You will start out with $150b so that you can start your corporation
\" +\r\n \"You now only need 75 reputation with a faction in order to donate to it, rather than 150
\" +\r\n \"Destroying this BitNode will give you Source-File 3, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File lets you create corporations on other BitNodes (although \" +\r\n \"some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by:
\" +\r\n \"Level 1: 8%
\" +\r\n \"Level 2: 12%
\" +\r\n \"Level 3: 14%\");\r\n BitNodes[\"BitNode4\"] = new BitNode(4, \"The Singularity\", \"The Man and the Machine\", \"The Singularity has arrived. The human race is gone, replaced \" +\r\n \"by artificially superintelligent beings that are more machine than man.
\" +\r\n \"In this BitNode, progressing is significantly harder. Experience gain rates \" +\r\n \"for all stats are reduced. Most methods of earning money will now give significantly less.
\" +\r\n \"In this BitNode you will gain access to a new set of Netscript Functions known as Singularity Functions. \" +\r\n \"These functions allow you to control most aspects of the game through scripts, including working for factions/companies, \" +\r\n \"purchasing/installing Augmentations, and creating programs.
\" +\r\n \"Destroying this BitNode will give you Source-File 4, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File lets you access and use the Singularity \" +\r\n \"Functions in other BitNodes. Each level of this Source-File will open up more Singularity Functions \" +\r\n \"that you can use.\");\r\n BitNodes[\"BitNode5\"] = new BitNode(5, \"Artificial Intelligence\", \"Posthuman\", \"They said it couldn't be done. They said the human brain, \" +\r\n \"along with its consciousness and intelligence, couldn't be replicated. They said the complexity \" +\r\n \"of the brain results from unpredictable, nonlinear interactions that couldn't be modeled \" +\r\n \"by 1's and 0's. They were wrong.
\" +\r\n \"In this BitNode:
\" +\r\n \"The base security level of servers is doubled
\" +\r\n \"The starting money on servers is halved, but the maximum money remains the same
\" +\r\n \"Most methods of earning money now give significantly less
\" +\r\n \"Infiltration gives 50% more reputation and money
\" +\r\n \"Corporations have 50% lower valuations and are therefore less profitable
\" +\r\n \"Augmentations are more expensive
\" +\r\n \"Hacking experience gain rates are reduced
\" +\r\n \"Destroying this BitNode will give you Source-File 5, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File grants you a special new stat called Intelligence. \" +\r\n \"Intelligence is unique because it is permanent and persistent (it never gets reset back to 1). However \" +\r\n \"gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't know \" +\r\n \"when you gain experience and how much). Higher Intelligence levels will boost your production for many actions \" +\r\n \"in the game.
\" +\r\n \"In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function, \" +\r\n \"and will also raise all of your hacking-related multipliers by:
\" +\r\n \"Level 1: 4%
\" +\r\n \"Level 2: 6%
\" +\r\n \"Level 3: 7%\");\r\n BitNodes[\"BitNode6\"] = new BitNode(6, \"Bladeburners\", \"Like Tears in Rain\",\r\n \"In the middle of the 21st century, OmniTek Incorporated began designing and manufacturing advanced synthetic \" +\r\n \"androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth generation \" +\r\n \"of their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was \" +\r\n \"the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more intelligent \" +\r\n \"than the humans that had created them.
\" +\r\n \"In this BitNode you will be able to access the Bladeburner Division at the NSA, which provides a new mechanic \" +\r\n \"for progression. Furthermore:
\" +\r\n \"Hacking and Hacknet Nodes will be significantly less profitable
\" +\r\n \"Your hacking level is reduced by 50%
\" +\r\n \"Hacking experience gain from scripts is reduced by 75%
\" +\r\n \"Corporations have 80% lower valuations and are therefore less profitable
\" +\r\n \"Working for companies is 50% less profitable
\" +\r\n \"Crimes and Infiltration are 50% less profitable
\" +\r\n \"Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade \" +\r\n \"its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other \" +\r\n \"BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:
\" +\r\n \"Level 1: 8%
\" +\r\n \"Level 2: 12%
\" +\r\n \"Level 3: 14%\");\r\n BitNodes[\"BitNode7\"] = new BitNode(7, \"Hacktocracy\", \"COMING SOON\"); //Healthy Hacknet balancing mechanic\r\n BitNodes[\"BitNode8\"] = new BitNode(8, \"Ghost of Wall Street\", \"Money never sleeps\",\r\n \"You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.
\" +\r\n \"In this BitNode:
\" +\r\n \"You start with $100 million
\" +\r\n \"The only way to earn money is by trading on the stock market
\" +\r\n \"You start with a WSE membership and access to the TIX API
\" +\r\n \"You are able to short stocks and place different types of orders (limit/stop)
\" +\r\n \"You can immediately donate to factions to gain reputation
\" +\r\n \"Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File grants the following benefits:
\" +\r\n \"Level 1: Permanent access to WSE and TIX API
\" +\r\n \"Level 2: Ability to short stocks in other BitNodes
\" +\r\n \"Level 3: Ability to use limit/stop orders in other BitNodes
\" +\r\n \"This Source-File also increases your hacking growth multipliers by: \" +\r\n \"
Level 1: 8%
Level 2: 12%
Level 3: 14%\");\r\n BitNodes[\"BitNode9\"] = new BitNode(9, \"Do Androids Dream?\", \"COMING SOON\");\r\n BitNodes[\"BitNode10\"] = new BitNode(10, \"MegaCorp\", \"COMING SOON\"); //Not sure yet\r\n BitNodes[\"BitNode11\"] = new BitNode(11, \"The Big Crash\", \"Okay. Sell it all.\",\r\n \"The 2050s was defined by the massive amounts of violent civil unrest and anarchic rebellion that rose all around the world. It was this period \" +\r\n \"of disorder that eventually lead to the governmental reformation of many global superpowers, most notably \" +\r\n \"the USA and China. But just as the world was slowly beginning to recover from these dark times, financial catastrophe hit.
\" +\r\n \"In many countries, the high cost of trying to deal with the civil disorder bankrupted the governments. In all of this chaos and confusion, hackers \" +\r\n \"were able to steal billions of dollars from the world's largest electronic banks, prompting an international banking crisis as \" +\r\n \"governments were unable to bail out insolvent banks. Now, the world is slowly crumbling in the middle of the biggest economic crisis of all time.
\" +\r\n \"In this BitNode:
\" +\r\n \"The starting and maximum amount of money available on servers is significantly decreased
\" +\r\n \"The growth rate of servers is halved
\" +\r\n \"Weakening a server is twice as effective
\" +\r\n \"Company wages are decreased by 50%
\" +\r\n \"Corporation valuations are 99% lower and are therefore significantly less profitable
\" +\r\n \"Hacknet Node production is significantly decreased
\" +\r\n \"Crime and Infiltration are more lucrative
\" +\r\n \"Augmentations are twice as expensive
\" +\r\n \"Destroying this BitNode will give you Source-File 11, or if you already have this Source-File it will \" +\r\n \"upgrade its level up to a maximum of 3. This Source-File makes it so that company favor increases BOTH \" +\r\n \"the player's salary and reputation gain rate at that company by 1% per favor (rather than just the reputation gain). \" +\r\n \"This Source-File also increases the player's company salary and reputation gain multipliers by:
\" +\r\n \"Level 1: 24%
\" +\r\n \"Level 2: 36%
\" +\r\n \"Level 3: 42%\");\r\n BitNodes[\"BitNode12\"] = new BitNode(12, \"The Recursion\", \"Repeat.\",\r\n \"To iterate is human, to recurse divine.
\" +\r\n \"Every time this BitNode is destroyed, it becomes slightly harder. Destroying this BitNode will give your Souce-File 12, or \" +\r\n \"if you already have this Source-File it will upgrade its level. There is no maximum level for Source-File 12. Each level \" +\r\n \"of Source-File 12 will increase all of your multipliers by 1%.\");\r\n //Books: Frontera, Shiner\r\n BitNodes[\"BitNode13\"] = new BitNode(13, \"fOS\", \"COMING SOON\"); //Unlocks the new game mode and the rest of the BitNodes\r\n BitNodes[\"BitNode14\"] = new BitNode(14, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode15\"] = new BitNode(15, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode16\"] = new BitNode(16, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode17\"] = new BitNode(17, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode18\"] = new BitNode(18, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode19\"] = new BitNode(19, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode20\"] = new BitNode(20, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode21\"] = new BitNode(21, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode22\"] = new BitNode(22, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode23\"] = new BitNode(23, \"\", \"COMING SOON\");\r\n BitNodes[\"BitNode24\"] = new BitNode(24, \"\", \"COMING SOON\");\r\n}\r\n\r\nlet BitNodeMultipliers = {\r\n HackingLevelMultiplier: 1,\r\n\r\n ServerMaxMoney: 1,\r\n ServerStartingMoney: 1,\r\n ServerGrowthRate: 1,\r\n ServerWeakenRate: 1,\r\n ServerStartingSecurity: 1,\r\n\r\n ManualHackMoney: 1,\r\n ScriptHackMoney: 1,\r\n CompanyWorkMoney: 1,\r\n CrimeMoney: 1,\r\n HacknetNodeMoney: 1,\r\n\r\n CompanyWorkExpGain: 1,\r\n ClassGymExpGain: 1,\r\n FactionWorkExpGain: 1,\r\n HackExpGain: 1,\r\n CrimeExpGain: 1,\r\n\r\n FactionWorkRepGain: 1,\r\n FactionPassiveRepGain: 1,\r\n RepToDonateToFaction: 1,\r\n\r\n AugmentationRepCost: 1,\r\n AugmentationMoneyCost: 1,\r\n\r\n InfiltrationMoney: 1,\r\n InfiltrationRep: 1,\r\n\r\n CorporationValuation: 1,\r\n}\r\n\r\nfunction initBitNodeMultipliers() {\r\n if (Player.bitNodeN == null) {\r\n Player.bitNodeN = 1;\r\n }\r\n for (var mult in BitNodeMultipliers) {\r\n if (BitNodeMultipliers.hasOwnProperty(mult)) {\r\n BitNodeMultipliers[mult] = 1;\r\n }\r\n }\r\n\r\n switch (Player.bitNodeN) {\r\n case 1: //Source Genesis (every multiplier is 1)\r\n break;\r\n case 2: //Rise of the Underworld\r\n BitNodeMultipliers.ServerMaxMoney = 0.2;\r\n BitNodeMultipliers.ServerStartingMoney = 0.4;\r\n BitNodeMultipliers.CrimeMoney = 3;\r\n BitNodeMultipliers.InfiltrationMoney = 3;\r\n BitNodeMultipliers.FactionWorkRepGain = 0.5;\r\n BitNodeMultipliers.FactionPassiveRepGain = 0;\r\n break;\r\n case 3: //Corporatocracy\r\n BitNodeMultipliers.RepToDonateToFaction = 0.5;\r\n BitNodeMultipliers.AugmentationRepCost = 3;\r\n BitNodeMultipliers.AugmentationMoneyCost = 3;\r\n BitNodeMultipliers.ServerMaxMoney = 0.2;\r\n BitNodeMultipliers.ServerStartingMoney = 0.2;\r\n BitNodeMultipliers.ServerGrowthRate = 0.2;\r\n BitNodeMultipliers.ScriptHackMoney = 0.2;\r\n BitNodeMultipliers.CompanyWorkMoney = 0.25;\r\n BitNodeMultipliers.CrimeMoney = 0.25;\r\n BitNodeMultipliers.HacknetNodeMoney = 0.25;\r\n break;\r\n case 4: //The Singularity\r\n BitNodeMultipliers.ServerMaxMoney = 0.15;\r\n BitNodeMultipliers.ServerStartingMoney = 0.75;\r\n BitNodeMultipliers.ScriptHackMoney = 0.2;\r\n BitNodeMultipliers.CompanyWorkMoney = 0.1;\r\n BitNodeMultipliers.CrimeMoney = 0.2;\r\n BitNodeMultipliers.HacknetNodeMoney = 0.05;\r\n BitNodeMultipliers.CompanyWorkExpGain = 0.5;\r\n BitNodeMultipliers.ClassGymExpGain = 0.5;\r\n BitNodeMultipliers.FactionWorkExpGain = 0.5;\r\n BitNodeMultipliers.HackExpGain = 0.4;\r\n BitNodeMultipliers.CrimeExpGain = 0.5;\r\n BitNodeMultipliers.FactionWorkRepGain = 0.75;\r\n break;\r\n case 5: //Artificial intelligence\r\n BitNodeMultipliers.ServerMaxMoney = 2;\r\n BitNodeMultipliers.ServerStartingSecurity = 2;\r\n BitNodeMultipliers.ServerStartingMoney = 0.5;\r\n BitNodeMultipliers.ScriptHackMoney = 0.15;\r\n BitNodeMultipliers.HacknetNodeMoney = 0.2;\r\n BitNodeMultipliers.CrimeMoney = 0.5;\r\n BitNodeMultipliers.InfiltrationRep = 1.5;\r\n BitNodeMultipliers.InfiltrationMoney = 1.5;\r\n BitNodeMultipliers.AugmentationMoneyCost = 2;\r\n BitNodeMultipliers.HackExpGain = 0.5;\r\n BitNodeMultipliers.CorporationValuation = 0.5;\r\n break;\r\n case 6: //Bladeburner\r\n BitNodeMultipliers.HackingLevelMultiplier = 0.5;\r\n BitNodeMultipliers.ServerMaxMoney = 0.5;\r\n BitNodeMultipliers.ServerStartingMoney = 0.5;\r\n BitNodeMultipliers.ServerStartingSecurity = 1.5;\r\n BitNodeMultipliers.ScriptHackMoney = 0.5;\r\n BitNodeMultipliers.CompanyWorkMoney = 0.5;\r\n BitNodeMultipliers.CrimeMoney = 0.5;\r\n BitNodeMultipliers.InfiltrationMoney = 0.5;\r\n BitNodeMultipliers.CorporationValuation = 0.2;\r\n BitNodeMultipliers.HacknetNodeMoney = 0.2;\r\n BitNodeMultipliers.FactionPassiveRepGain = 0;\r\n BitNodeMultipliers.HackExpGain = 0.25;\r\n break;\r\n case 8: //Ghost of Wall Street\r\n BitNodeMultipliers.ScriptHackMoney = 0;\r\n BitNodeMultipliers.ManualHackMoney = 0;\r\n BitNodeMultipliers.CompanyWorkMoney = 0;\r\n BitNodeMultipliers.CrimeMoney = 0;\r\n BitNodeMultipliers.HacknetNodeMoney = 0;\r\n BitNodeMultipliers.InfiltrationMoney = 0;\r\n BitNodeMultipliers.RepToDonateToFaction = 0;\r\n BitNodeMultipliers.CorporationValuation = 0;\r\n break;\r\n case 11: //The Big Crash\r\n BitNodeMultipliers.ServerMaxMoney = 0.1;\r\n BitNodeMultipliers.ServerStartingMoney = 0.1;\r\n BitNodeMultipliers.ServerGrowthRate = 0.5;\r\n BitNodeMultipliers.ServerWeakenRate = 2;\r\n BitNodeMultipliers.CrimeMoney = 3;\r\n BitNodeMultipliers.CompanyWorkMoney = 0.5;\r\n BitNodeMultipliers.HacknetNodeMoney = 0.1;\r\n BitNodeMultipliers.AugmentationMoneyCost = 2;\r\n BitNodeMultipliers.InfiltrationMoney = 2.5;\r\n BitNodeMultipliers.InfiltrationRep = 2.5;\r\n BitNodeMultipliers.CorporationValuation = 0.01;\r\n break;\r\n case 12: //The Recursion\r\n let sf12Lvl = 0;\r\n for (let i = 0; i < Player.sourceFiles.length; i++) {\r\n if (Player.sourceFiles[i].n === 12) {\r\n sf12Lvl = Player.sourceFiles[i].lvl;\r\n }\r\n }\r\n const inc = Math.pow(1.01, sf12Lvl);\r\n const dec = Math.pow(0.99, sf12Lvl);\r\n BitNodeMultipliers.HackingLevelMultiplier = dec;\r\n\r\n BitNodeMultipliers.ServerMaxMoney = dec;\r\n BitNodeMultipliers.ServerStartingMoney = dec;\r\n BitNodeMultipliers.ServerGrowthRate = dec;\r\n BitNodeMultipliers.ServerWeakenRate = dec;\r\n\r\n //Does not scale, otherwise security might start at 300+\r\n BitNodeMultipliers.ServerStartingSecurity = 1.5;\r\n\r\n BitNodeMultipliers.ManualHackMoney = dec;\r\n BitNodeMultipliers.ScriptHackMoney = dec;\r\n BitNodeMultipliers.CompanyWorkMoney = dec;\r\n BitNodeMultipliers.CrimeMoney = dec;\r\n BitNodeMultipliers.HacknetNodeMoney = dec;\r\n\r\n BitNodeMultipliers.CompanyWorkExpGain = dec;\r\n BitNodeMultipliers.ClassGymExpGain = dec;\r\n BitNodeMultipliers.FactionWorkExpGain = dec;\r\n BitNodeMultipliers.HackExpGain = dec;\r\n BitNodeMultipliers.CrimeExpGain = dec;\r\n\r\n BitNodeMultipliers.FactionWorkRepGain = dec;\r\n BitNodeMultipliers.FactionPassiveRepGain = dec;\r\n BitNodeMultipliers.RepToDonateToFaction = inc;\r\n\r\n BitNodeMultipliers.AugmentationRepCost = inc;\r\n BitNodeMultipliers.AugmentationMoneyCost = inc;\r\n\r\n BitNodeMultipliers.InfiltrationMoney = dec;\r\n BitNodeMultipliers.InfiltrationRep = dec;\r\n\r\n BitNodeMultipliers.CorporationValuation = dec;\r\n default:\r\n console.log(\"WARNING: Player.bitNodeN invalid\");\r\n break;\r\n }\r\n}\r\n\r\nexport {initBitNodes,\r\n BitNode,\r\n BitNodes,\r\n BitNodeMultipliers,\r\n initBitNodeMultipliers};\r\n","import {AllServers} from \"../src/Server.js\";\r\n/* Functions to deal with manipulating IP addresses*/\r\n\r\n//Generate a random IP address\r\n//Will not return an IP address that already exists in the AllServers array\r\nfunction createRandomIp() {\r\n\tvar ip = createRandomByte(99) +'.' +\r\n\t\t\t createRandomByte(9) +'.' +\r\n\t\t\t createRandomByte(9) +'.' +\r\n\t\t \t createRandomByte(9);\r\n\r\n //If the Ip already exists, recurse to create a new one\r\n if (ipExists(ip)) {\r\n return createRandomIp();\r\n }\r\n\treturn ip;\r\n}\r\n\r\n//Returns true if the IP already exists in one of the game's servers\r\nfunction ipExists(ip) {\r\n for (var property in AllServers) {\r\n if (AllServers.hasOwnProperty(property)) {\r\n if (property == ip) {\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n}\r\n\r\nfunction createRandomByte(n=9) {\r\n\treturn Math.round(Math.random()*n);\r\n}\r\n\r\nfunction isValidIPAddress(ipaddress) {\r\n\tif (/^(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress))\r\n\t{\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nexport {createRandomIp, ipExists, isValidIPAddress};\r\n","import {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\n\r\n/* Holds IP of Special Servers */\r\nlet SpecialServerNames = {\r\n FulcrumSecretTechnologies: \"Fulcrum Secret Technologies Server\",\r\n CyberSecServer: \"CyberSec Server\",\r\n NiteSecServer: \"NiteSec Server\",\r\n TheBlackHandServer: \"The Black Hand Server\",\r\n BitRunnersServer: \"BitRunners Server\",\r\n TheDarkArmyServer: \"The Dark Army Server\",\r\n DaedalusServer: \"Daedalus Server\",\r\n WorldDaemon: \"w0r1d_d43m0n\",\r\n}\r\nfunction SpecialServerIpsMap() {}\r\n\r\nSpecialServerIpsMap.prototype.addIp = function(name, ip) {\r\n this[name] = ip;\r\n}\r\n\r\nSpecialServerIpsMap.prototype.toJSON = function() {\r\n return Generic_toJSON(\"SpecialServerIpsMap\", this);\r\n}\r\n\r\nSpecialServerIpsMap.fromJSON = function(value) {\r\n return Generic_fromJSON(SpecialServerIpsMap, value.data);\r\n}\r\n\r\nReviver.constructors.SpecialServerIpsMap = SpecialServerIpsMap;\r\n\r\nlet SpecialServerIps = new SpecialServerIpsMap();\r\n\r\nfunction prestigeSpecialServerIps() {\r\n for (var member in SpecialServerIps) {\r\n delete SpecialServerIps[member];\r\n }\r\n SpecialServerIps = null;\r\n SpecialServerIps = new SpecialServerIpsMap();\r\n}\r\n\r\nfunction loadSpecialServerIps(saveString) {\r\n SpecialServerIps = JSON.parse(saveString, Reviver);\r\n}\r\n\r\nfunction initSpecialServerIps() {\r\n SpecialServerIps = new SpecialServerIpsMap();\r\n}\r\n\r\nexport {SpecialServerNames, SpecialServerIps, SpecialServerIpsMap, loadSpecialServerIps,\r\n prestigeSpecialServerIps, initSpecialServerIps};\r\n","import {substituteAliases, printAliases,\r\n parseAliasDeclaration,\r\n removeAlias, GlobalAliases,\r\n Aliases} from \"./Alias.js\";\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Programs} from \"./CreateProgram.js\";\r\nimport {executeDarkwebTerminalCommand,\r\n checkIfConnectedToDarkweb} from \"./DarkWeb.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {FconfSettings, parseFconfSettings,\r\n createFconf} from \"./Fconf.js\";\r\nimport {TerminalHelpText, HelpTexts} from \"./HelpText.js\";\r\nimport {iTutorialNextStep, iTutorialSteps,\r\n iTutorialIsRunning,\r\n currITutorialStep} from \"./InteractiveTutorial.js\";\r\nimport {showLiterature} from \"./Literature.js\";\r\nimport {showMessage, Message} from \"./Message.js\";\r\nimport {scriptCalculateHackingTime,\r\n scriptCalculateGrowTime,\r\n scriptCalculateWeakenTime} from \"./NetscriptEvaluator.js\";\r\nimport {killWorkerScript, addWorkerScript} from \"./NetscriptWorker.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {hackWorldDaemon} from \"./RedPill.js\";\r\nimport {findRunningScript, RunningScript,\r\n AllServersMap, Script,\r\n isScriptFilename} from \"./Script.js\";\r\nimport {AllServers, GetServerByHostname,\r\n getServer, Server} from \"./Server.js\";\r\nimport {Settings} from \"./Settings.js\";\r\nimport {SpecialServerIps,\r\n SpecialServerNames} from \"./SpecialServerIps.js\";\r\nimport {TextFile, getTextFile,\r\n createTextFile} from \"./TextFile.js\";\r\n\r\nimport {containsAllStrings, longestCommonStart,\r\n formatNumber, isString} from \"../utils/StringHelperFunctions.js\";\r\nimport {addOffset, printArray} from \"../utils/HelperFunctions.js\";\r\nimport {logBoxCreate} from \"../utils/LogBox.js\";\r\nimport {yesNoBoxCreate,\r\n yesNoBoxGetYesButton,\r\n yesNoBoxGetNoButton, yesNoBoxClose} from \"../utils/YesNoBox.js\";\r\n\r\nimport * as JSZip from 'jszip';\r\nimport * as FileSaver from 'file-saver';\r\n\r\n/* Write text to terminal */\r\n//If replace is true then spaces are replaced with \" \"\r\nfunction post(input) {\r\n $(\"#terminal-input\").before(' ');\r\n\tupdateTerminalScroll();\r\n}\r\n\r\n//Same thing as post but the td cells have ids so they can be animated for the hack progress bar\r\nfunction hackProgressBarPost(input) {\r\n $(\"#terminal-input\").before('' + input + ' ');\r\n\tupdateTerminalScroll();\r\n}\r\n\r\nfunction hackProgressPost(input) {\r\n $(\"#terminal-input\").before('' + input + ' ');\r\n\tupdateTerminalScroll();\r\n}\r\n\r\n//Scroll to the bottom of the terminal's 'text area'\r\nfunction updateTerminalScroll() {\r\n\tvar element = document.getElementById(\"terminal-container\");\r\n\telement.scrollTop = element.scrollHeight;\r\n}\r\n\r\nfunction postNetburnerText() {\r\n\tpost(\"Bitburner v\" + CONSTANTS.Version);\r\n}\r\n\r\n\r\n//Key Codes\r\nvar KEY = {\r\n TAB: 9,\r\n ENTER: 13,\r\n CTRL: 17,\r\n UPARROW: 38,\r\n DOWNARROW: 40,\r\n A: 65,\r\n B: 66,\r\n C: 67,\r\n D: 68,\r\n E: 69,\r\n F: 70,\r\n H: 72,\r\n J: 74,\r\n K: 75,\r\n L: 76,\r\n M: 77,\r\n N: 78,\r\n O: 79,\r\n P: 80,\r\n R: 82,\r\n S: 83,\r\n U: 85,\r\n W: 87,\r\n}\r\n\r\n//Defines key commands in terminal\r\n$(document).keydown(function(event) {\r\n\t//Terminal\r\n\tif (Engine.currentPage == Engine.Page.Terminal) {\r\n var terminalInput = document.getElementById(\"terminal-input-text-box\");\r\n if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();}\r\n\r\n\t\tif (event.keyCode === KEY.ENTER) {\r\n event.preventDefault(); //Prevent newline from being entered in Script Editor\r\n\t\t\tvar command = $('input[class=terminal-input]').val();\r\n\t\t\tif (command.length > 0) {\r\n post(\r\n \"[\" +\r\n (FconfSettings.ENABLE_TIMESTAMPS ? Terminal.getTimestamp() + \" \" : \"\") +\r\n Player.getCurrentServer().hostname +\r\n \" ~]> \" + command\r\n );\r\n\r\n Terminal.resetTerminalInput(); //Clear input first\r\n\t\t\t\tTerminal.executeCommand(command);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (event.keyCode === KEY.C && event.ctrlKey) {\r\n if (Engine._actionInProgress) {\r\n //Cancel action\r\n post(\"Cancelling...\");\r\n \t\t\tEngine._actionInProgress = false;\r\n \t\t\tTerminal.finishAction(true);\r\n } else if (FconfSettings.ENABLE_BASH_HOTKEYS) {\r\n //Dont prevent default so it still copies\r\n Terminal.resetTerminalInput(); //Clear Terminal\r\n }\r\n\t\t}\r\n\r\n if (event.keyCode === KEY.L && event.ctrlKey) {\r\n event.preventDefault();\r\n Terminal.executeCommand(\"clear\"); //Clear screen\r\n }\r\n\r\n //Ctrl p same as up arrow\r\n //Ctrl n same as down arrow\r\n\r\n if (event.keyCode === KEY.UPARROW ||\r\n (FconfSettings.ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)) {\r\n if (FconfSettings.ENABLE_BASH_HOTKEYS) {event.preventDefault();}\r\n //Cycle through past commands\r\n if (terminalInput == null) {return;}\r\n var i = Terminal.commandHistoryIndex;\r\n var len = Terminal.commandHistory.length;\r\n\r\n if (len == 0) {return;}\r\n if (i < 0 || i > len) {\r\n Terminal.commandHistoryIndex = len;\r\n }\r\n\r\n if (i != 0) {\r\n --Terminal.commandHistoryIndex;\r\n }\r\n var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex];\r\n terminalInput.value = prevCommand;\r\n setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0);\r\n }\r\n\r\n if (event.keyCode === KEY.DOWNARROW ||\r\n (FconfSettings.ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)) {\r\n if (FconfSettings.ENABLE_BASH_HOTKEYS) {event.preventDefault();}\r\n //Cycle through past commands\r\n if (terminalInput == null) {return;}\r\n var i = Terminal.commandHistoryIndex;\r\n var len = Terminal.commandHistory.length;\r\n\r\n if (len == 0) {return;}\r\n if (i < 0 || i > len) {\r\n Terminal.commandHistoryIndex = len;\r\n }\r\n\r\n //Latest command, put nothing\r\n if (i == len || i == len-1) {\r\n Terminal.commandHistoryIndex = len;\r\n terminalInput.value = \"\";\r\n } else {\r\n ++Terminal.commandHistoryIndex;\r\n var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex];\r\n terminalInput.value = prevCommand;\r\n }\r\n }\r\n\r\n if (event.keyCode === KEY.TAB) {\r\n //Autocomplete\r\n if (terminalInput == null) {return;}\r\n var input = terminalInput.value;\r\n if (input == \"\") {return;}\r\n input = input.trim();\r\n input = input.replace(/\\s\\s+/g, ' ');\r\n\r\n var commandArray = input.split(\" \");\r\n var index = commandArray.length - 2;\r\n if (index < -1) {index = 0;}\r\n var allPos = determineAllPossibilitiesForTabCompletion(input, index);\r\n if (allPos.length == 0) {return;}\r\n\r\n var arg = \"\";\r\n var command = \"\";\r\n if (commandArray.length == 0) {return;}\r\n if (commandArray.length == 1) {command = commandArray[0];}\r\n else if (commandArray.length == 2) {\r\n command = commandArray[0];\r\n arg = commandArray[1];\r\n } else if (commandArray.length == 3) {\r\n command = commandArray[0] + \" \" + commandArray[1];\r\n arg = commandArray[2];\r\n } else {\r\n arg = commandArray.pop();\r\n command = commandArray.join(\" \");\r\n }\r\n\r\n tabCompletion(command, arg, allPos);\r\n }\r\n\r\n //Extra Bash Emulation Hotkeys, must be enabled through .fconf\r\n if (FconfSettings.ENABLE_BASH_HOTKEYS) {\r\n if (event.keyCode === KEY.A && event.ctrlKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"home\");\r\n }\r\n\r\n if (event.keyCode === KEY.E && event.ctrlKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"end\");\r\n }\r\n\r\n if (event.keyCode === KEY.B && event.ctrlKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"prevchar\");\r\n }\r\n\r\n if (event.keyCode === KEY.B && event.altKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"prevword\");\r\n }\r\n\r\n if (event.keyCode === KEY.F && event.ctrlKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"nextchar\");\r\n }\r\n\r\n if (event.keyCode === KEY.F && event.altKey) {\r\n event.preventDefault();\r\n Terminal.moveTextCursor(\"nextword\");\r\n }\r\n\r\n\r\n if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) {\r\n Terminal.modifyInput(\"backspace\");\r\n event.preventDefault();\r\n }\r\n\r\n //TODO AFTER THIS:\r\n\r\n //alt + d deletes word after cursor\r\n //^w deletes word before cursor\r\n //^k clears line after cursor\r\n //^u clears line before cursor\r\n }\r\n\t}\r\n});\r\n\r\n//Keep terminal in focus\r\nlet terminalCtrlPressed = false, shiftKeyPressed = false;\r\n$(document).ready(function() {\r\n\tif (Engine.currentPage === Engine.Page.Terminal) {\r\n\t\t$('.terminal-input').focus();\r\n\t}\r\n});\r\n$(document).keydown(function(e) {\r\n\tif (Engine.currentPage == Engine.Page.Terminal) {\r\n\t\tif (e.which == 17) {\r\n\t\t\tterminalCtrlPressed = true;\r\n\t\t} else if (e.shiftKey) {\r\n shiftKeyPressed = true;\r\n } else if (terminalCtrlPressed || shiftKeyPressed) {\r\n\t\t\t//Don't focus\r\n\t\t} else {\r\n var inputTextBox = document.getElementById(\"terminal-input-text-box\");\r\n if (inputTextBox != null) {inputTextBox.focus();}\r\n\r\n\t\t\tterminalCtrlPressed = false;\r\n shiftKeyPressed = false;\r\n\t\t}\r\n\t}\r\n})\r\n$(document).keyup(function(e) {\r\n\tif (Engine.currentPage == Engine.Page.Terminal) {\r\n\t\tif (e.which == 17) {\r\n\t\t\tterminalCtrlPressed = false;\r\n\t\t}\r\n if (e.shiftKey) {\r\n shiftKeyPressed = false;\r\n }\r\n\t}\r\n})\r\n\r\n//Implements a tab completion feature for terminal\r\n// command - Command (first arg only)\r\n// arg - Incomplete argument string that the function will try to complete, or will display\r\n// a series of possible options for\r\n// allPossibilities - Array of strings containing all possibilities that the\r\n// string can complete to\r\n// index - index of argument that is being \"tab completed\". By default is 0, the first argument\r\nfunction tabCompletion(command, arg, allPossibilities, index=0) {\r\n if (!(allPossibilities.constructor === Array)) {return;}\r\n if (!containsAllStrings(allPossibilities)) {return;}\r\n\r\n if (!command.startsWith(\"./\")) {\r\n command = command.toLowerCase();\r\n }\r\n\r\n //Remove all options in allPossibilities that do not match the current string\r\n //that we are attempting to autocomplete\r\n if (arg == \"\") {\r\n for (var i = allPossibilities.length-1; i >= 0; --i) {\r\n if (!allPossibilities[i].toLowerCase().startsWith(command.toLowerCase())) {\r\n allPossibilities.splice(i, 1);\r\n }\r\n }\r\n } else {\r\n for (var i = allPossibilities.length-1; i >= 0; --i) {\r\n if (!allPossibilities[i].toLowerCase().startsWith(arg.toLowerCase())) {\r\n allPossibilities.splice(i, 1);\r\n }\r\n }\r\n }\r\n\r\n var val = \"\";\r\n if (allPossibilities.length == 0) {\r\n return;\r\n } else if (allPossibilities.length == 1) {\r\n if (arg == \"\") {\r\n //Autocomplete command\r\n val = allPossibilities[0] + \" \";\r\n } else {\r\n val = command + \" \" + allPossibilities[0];\r\n }\r\n document.getElementById(\"terminal-input-text-box\").value = val;\r\n document.getElementById(\"terminal-input-text-box\").focus();\r\n } else {\r\n var longestStartSubstr = longestCommonStart(allPossibilities);\r\n //If the longest common starting substring of remaining possibilities is the same\r\n //as whatevers already in terminal, just list all possible options. Otherwise,\r\n //change the input in the terminal to the longest common starting substr\r\n var allOptionsStr = \"\";\r\n for (var i = 0; i < allPossibilities.length; ++i) {\r\n allOptionsStr += allPossibilities[i];\r\n allOptionsStr += \" \";\r\n }\r\n if (arg == \"\") {\r\n if (longestStartSubstr == command) {\r\n post(\"> \" + command);\r\n post(allOptionsStr);\r\n } else {\r\n document.getElementById(\"terminal-input-text-box\").value = longestStartSubstr;\r\n document.getElementById(\"terminal-input-text-box\").focus();\r\n }\r\n } else {\r\n if (longestStartSubstr == arg) {\r\n //List all possible options\r\n post(\"> \" + command + \" \" + arg);\r\n post(allOptionsStr);\r\n } else {\r\n document.getElementById(\"terminal-input-text-box\").value = command + \" \" + longestStartSubstr;\r\n document.getElementById(\"terminal-input-text-box\").focus();\r\n }\r\n }\r\n\r\n }\r\n}\r\n\r\nfunction determineAllPossibilitiesForTabCompletion(input, index=0) {\r\n var allPos = [];\r\n allPos = allPos.concat(Object.keys(GlobalAliases));\r\n var currServ = Player.getCurrentServer();\r\n input = input.toLowerCase();\r\n\r\n //If the command starts with './' and the index == -1, then the user\r\n //has input ./partialexecutablename so autocomplete the script or program\r\n //Put './' in front of each script/executable\r\n if (input.startsWith(\"./\") && index == -1) {\r\n //All programs and scripts\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(\"./\" + currServ.scripts[i].filename);\r\n }\r\n\r\n //Programs are on home computer\r\n var homeComputer = Player.getHomeComputer();\r\n for(var i = 0; i < homeComputer.programs.length; ++i) {\r\n allPos.push(\"./\" + homeComputer.programs[i]);\r\n }\r\n return allPos;\r\n }\r\n\r\n //Autocomplete the command\r\n if (index == -1) {\r\n return [\"alias\", \"analyze\", \"cat\", \"check\", \"clear\", \"cls\", \"connect\", \"download\", \"free\",\r\n \"hack\", \"help\", \"home\", \"hostname\", \"ifconfig\", \"kill\", \"killall\",\r\n \"ls\", \"lscpu\", \"mem\", \"nano\", \"ps\", \"rm\", \"run\", \"scan\", \"scan-analyze\",\r\n \"scp\", \"sudov\", \"tail\", \"theme\", \"top\"].concat(Object.keys(Aliases)).concat(Object.keys(GlobalAliases));\r\n }\r\n\r\n if (input.startsWith (\"buy \")) {\r\n return [Programs.BruteSSHProgram, Programs.FTPCrackProgram, Programs.RelaySMTPProgram,\r\n Programs.HTTPWormProgram, Programs.SQLInjectProgram, Programs.DeepscanV1,\r\n Programs.DeepscanV2].concat(Object.keys(GlobalAliases));\r\n }\r\n\r\n if (input.startsWith(\"scp \") && index == 1) {\r\n for (var iphostname in AllServers) {\r\n if (AllServers.hasOwnProperty(iphostname)) {\r\n allPos.push(AllServers[iphostname].ip);\r\n allPos.push(AllServers[iphostname].hostname);\r\n }\r\n }\r\n }\r\n\r\n if (input.startsWith(\"scp \") && index == 0) {\r\n //All Scripts and lit files\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n for (var i = 0; i < currServ.messages.length; ++i) {\r\n if (!(currServ.messages[i] instanceof Message)) {\r\n allPos.push(currServ.messages[i]);\r\n }\r\n }\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n allPos.push(currServ.textFiles[i].fn);\r\n }\r\n }\r\n\r\n if (input.startsWith(\"connect \") || input.startsWith(\"telnet \")) {\r\n //All network connections\r\n for (var i = 0; i < currServ.serversOnNetwork.length; ++i) {\r\n var serv = AllServers[currServ.serversOnNetwork[i]];\r\n if (serv == null) {continue;}\r\n allPos.push(serv.ip); //IP\r\n allPos.push(serv.hostname); //Hostname\r\n }\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"kill \") || input.startsWith(\"tail \") ||\r\n input.startsWith(\"mem \") || input.startsWith(\"check \")) {\r\n //All Scripts\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"nano \")) {\r\n //Scripts and text files and .fconf\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n allPos.push(currServ.textFiles[i].fn);\r\n }\r\n allPos.push(\".fconf\");\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"rm \")) {\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n for (var i = 0; i < currServ.programs.length; ++i) {\r\n allPos.push(currServ.programs[i]);\r\n }\r\n for (var i = 0; i < currServ.messages.length; ++i) {\r\n if (!(currServ.messages[i] instanceof Message) && isString(currServ.messages[i]) &&\r\n currServ.messages[i].endsWith(\".lit\")) {\r\n allPos.push(currServ.messages[i]);\r\n }\r\n }\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n allPos.push(currServ.textFiles[i].fn);\r\n }\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"run \")) {\r\n //All programs and scripts\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n\r\n //Programs are on home computer\r\n var homeComputer = Player.getHomeComputer();\r\n for(var i = 0; i < homeComputer.programs.length; ++i) {\r\n allPos.push(homeComputer.programs[i]);\r\n }\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"cat \")) {\r\n for (var i = 0; i < currServ.messages.length; ++i) {\r\n if (currServ.messages[i] instanceof Message) {\r\n allPos.push(currServ.messages[i].filename);\r\n } else {\r\n allPos.push(currServ.messages[i]);\r\n }\r\n }\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n allPos.push(currServ.textFiles[i].fn);\r\n }\r\n return allPos;\r\n }\r\n\r\n if (input.startsWith(\"download \")) {\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n allPos.push(currServ.textFiles[i].fn);\r\n }\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n allPos.push(currServ.scripts[i].filename);\r\n }\r\n }\r\n return allPos;\r\n}\r\n\r\nlet Terminal = {\r\n //Flags to determine whether the player is currently running a hack or an analyze\r\n hackFlag: false,\r\n analyzeFlag: false,\r\n\r\n commandHistory: [],\r\n commandHistoryIndex: 0,\r\n\r\n resetTerminalInput: function() {\r\n document.getElementById(\"terminal-input-td\").innerHTML =\r\n \"' + input + '
\" +\r\n \"Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode \" +\r\n \"and select a new one.\");\r\n\r\n break;\r\n\t\t\tdefault:\r\n\t\t\t\tpost(\"Invalid executable. Cannot be run\");\r\n\t\t\t\treturn;\r\n\t\t}\r\n\t},\r\n\r\n\trunScript: function(scriptName) {\r\n\t\tvar server = Player.getCurrentServer();\r\n\r\n var numThreads = 1;\r\n var args = [];\r\n var results = scriptName.split(\" \");\r\n if (results.length <= 0) {\r\n post(\"This is a bug. Please contact developer\");\r\n }\r\n scriptName = results[0];\r\n if (results.length > 1) {\r\n if (results.length >= 3 && results[1] == \"-t\") {\r\n numThreads = Math.round(Number(results[2]));\r\n if (isNaN(numThreads) || numThreads < 1) {\r\n post(\"Invalid number of threads specified. Number of threads must be greater than 0\");\r\n return;\r\n }\r\n for (var i = 3; i < results.length; ++i) {\r\n var arg = results[i];\r\n\r\n //Forced string\r\n if ((arg.startsWith(\"'\") && arg.endsWith(\"'\")) ||\r\n (arg.startsWith('\"') && arg.endsWith('\"'))) {\r\n args.push(arg.slice(1, -1));\r\n continue;\r\n }\r\n //Number\r\n var tempNum = Number(arg);\r\n if (!isNaN(tempNum)) {\r\n args.push(tempNum);\r\n continue;\r\n }\r\n //Otherwise string\r\n args.push(arg);\r\n }\r\n } else {\r\n for (var i = 1; i < results.length; ++i) {\r\n var arg = results[i];\r\n\r\n //Forced string\r\n if ((arg.startsWith(\"'\") && arg.endsWith(\"'\")) ||\r\n (arg.startsWith('\"') && arg.endsWith('\"'))) {\r\n args.push(arg.slice(1, -1));\r\n continue;\r\n }\r\n //Number\r\n var tempNum = Number(arg);\r\n if (!isNaN(tempNum)) {\r\n args.push(tempNum);\r\n continue;\r\n }\r\n //Otherwise string\r\n args.push(arg);\r\n }\r\n }\r\n }\r\n\r\n\r\n //Check if this script is already running\r\n if (findRunningScript(scriptName, args, server) != null) {\r\n post(\"ERROR: This script is already running. Cannot run multiple instances\");\r\n return;\r\n }\r\n\r\n\t\t//Check if the script exists and if it does run it\r\n\t\tfor (var i = 0; i < server.scripts.length; i++) {\r\n\t\t\tif (server.scripts[i].filename == scriptName) {\r\n\t\t\t\t//Check for admin rights and that there is enough RAM availble to run\r\n var script = server.scripts[i];\r\n\t\t\t\tvar ramUsage = script.ramUsage * numThreads * Math.pow(CONSTANTS.MultithreadingRAMCost, numThreads-1);\r\n\t\t\t\tvar ramAvailable = server.maxRam - server.ramUsed;\r\n\r\n\t\t\t\tif (server.hasAdminRights == false) {\r\n\t\t\t\t\tpost(\"Need root access to run script\");\r\n\t\t\t\t\treturn;\r\n\t\t\t\t} else if (ramUsage > ramAvailable){\r\n\t\t\t\t\tpost(\"This machine does not have enough RAM to run this script with \" +\r\n numThreads + \" threads. Script requires \" + ramUsage + \"GB of RAM\");\r\n\t\t\t\t\treturn;\r\n\t\t\t\t} else {\r\n\t\t\t\t\t//Able to run script\r\n\t\t\t\t\tpost(\"Running script with \" + numThreads + \" thread(s) and args: \" + printArray(args) + \".\");\r\n post(\"May take a few seconds to start up the process...\");\r\n var runningScriptObj = new RunningScript(script, args);\r\n runningScriptObj.threads = numThreads;\r\n\t\t\t\t\tserver.runningScripts.push(runningScriptObj);\r\n\r\n\t\t\t\t\taddWorkerScript(runningScriptObj, server);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tpost(\"ERROR: No such script\");\r\n\t}\r\n};\r\n\r\nexport {postNetburnerText, post, Terminal, KEY};\r\n","import {BitNodeMultipliers} from \"./BitNode.js\";\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Factions, getNextNeurofluxLevel,\r\n factionExists} from \"./Faction.js\";\r\nimport {hasBladeburnerSF} from \"./NetscriptFunctions.js\";\r\nimport {addWorkerScript} from \"./NetscriptWorker.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {prestigeAugmentation} from \"./Prestige.js\";\r\nimport {saveObject} from \"./SaveObject.js\";\r\nimport {Script, RunningScript} from \"./Script.js\";\r\nimport {Server} from \"./Server.js\";\r\nimport {SourceFiles} from \"./SourceFile.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {createElement, createAccordionElement,\r\n removeChildrenFromElement, clearObject} from \"../utils/HelperFunctions.js\";\r\nimport {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\nimport {isString} from \"../utils/StringHelperFunctions.js\";\r\n\r\n//Augmentations\r\nfunction Augmentation(params) {\r\n if (params.name == null || params.info == null || params.moneyCost == null || params.repCost == null) {\r\n dialogBoxCreate(\"ERROR Creating Augmentations. This is a bug please contact game dev\");\r\n return;\r\n }\r\n this.name = params.name;\r\n this.info = params.info;\r\n this.owned = false;\r\n this.prereqs = params.prereqs ? params.prereqs : [];\r\n\r\n //Price and reputation base requirements (can change based on faction multipliers)\r\n this.baseRepRequirement = params.repCost * CONSTANTS.AugmentationRepMultiplier * BitNodeMultipliers.AugmentationRepCost;\r\n this.baseCost = params.moneyCost * CONSTANTS.AugmentationCostMultiplier * BitNodeMultipliers.AugmentationMoneyCost;\r\n\r\n //Level - Only applicable for some augmentations\r\n // NeuroFlux Governor\r\n this.level = 0;\r\n}\r\n\r\n//Takes in an array of faction names and adds this augmentation to all of those factions\r\nAugmentation.prototype.addToFactions = function(factionList) {\r\n for (var i = 0; i < factionList.length; ++i) {\r\n var faction = Factions[factionList[i]];\r\n if (faction == null) {\r\n throw new Error(\"In Augmentation.addToFactions(), could not find faction with this name:\" + factionList[i]);\r\n continue;\r\n }\r\n faction.augmentations.push(this.name);\r\n }\r\n}\r\n\r\nAugmentation.prototype.addToAllFactions = function() {\r\n for (var fac in Factions) {\r\n if (Factions.hasOwnProperty(fac)) {\r\n var facObj = Factions[fac];\r\n if (facObj == null) {\r\n console.log(\"ERROR: Invalid faction object\");\r\n continue;\r\n }\r\n facObj.augmentations.push(this.name);\r\n }\r\n }\r\n}\r\n\r\nAugmentation.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Augmentation\", this);\r\n}\r\n\r\nAugmentation.fromJSON = function(value) {\r\n return Generic_fromJSON(Augmentation, value.data);\r\n}\r\n\r\nReviver.constructors.Augmentation = Augmentation;\r\n\r\nlet Augmentations = {}\r\n\r\nfunction AddToAugmentations(aug) {\r\n var name = aug.name;\r\n Augmentations[name] = aug;\r\n}\r\n\r\nlet AugmentationNames = {\r\n Targeting1: \"Augmented Targeting I\",\r\n Targeting2: \"Augmented Targeting II\",\r\n Targeting3: \"Augmented Targeting III\",\r\n SyntheticHeart: \"Synthetic Heart\",\r\n SynfibrilMuscle: \"Synfibril Muscle\",\r\n CombatRib1: \"Combat Rib I\",\r\n CombatRib2: \"Combat Rib II\",\r\n CombatRib3: \"Combat Rib III\",\r\n NanofiberWeave: \"Nanofiber Weave\",\r\n SubdermalArmor: \"NEMEAN Subdermal Weave\",\r\n WiredReflexes: \"Wired Reflexes\",\r\n GrapheneBoneLacings: \"Graphene Bone Lacings\",\r\n BionicSpine: \"Bionic Spine\",\r\n GrapheneBionicSpine: \"Graphene Bionic Spine Upgrade\",\r\n BionicLegs: \"Bionic Legs\",\r\n GrapheneBionicLegs: \"Graphene Bionic Legs Upgrade\",\r\n SpeechProcessor: \"Speech Processor Implant\",\r\n TITN41Injection: \"TITN-41 Gene-Modification Injection\",\r\n EnhancedSocialInteractionImplant: \"Enhanced Social Interaction Implant\",\r\n BitWire: \"BitWire\",\r\n ArtificialBioNeuralNetwork: \"Artificial Bio-neural Network Implant\",\r\n ArtificialSynapticPotentiation: \"Artificial Synaptic Potentiation\",\r\n EnhancedMyelinSheathing: \"Enhanced Myelin Sheathing\",\r\n SynapticEnhancement: \"Synaptic Enhancement Implant\",\r\n NeuralRetentionEnhancement: \"Neural-Retention Enhancement\",\r\n DataJack: \"DataJack\",\r\n ENM: \"Embedded Netburner Module\",\r\n ENMCore: \"Embedded Netburner Module Core Implant\",\r\n ENMCoreV2: \"Embedded Netburner Module Core V2 Upgrade\",\r\n ENMCoreV3: \"Embedded Netburner Module Core V3 Upgrade\",\r\n ENMAnalyzeEngine: \"Embedded Netburner Module Analyze Engine\",\r\n ENMDMA: \"Embedded Netburner Module Direct Memory Access Upgrade\",\r\n Neuralstimulator: \"Neuralstimulator\",\r\n NeuralAccelerator: \"Neural Accelerator\",\r\n CranialSignalProcessorsG1: \"Cranial Signal Processors - Gen I\",\r\n CranialSignalProcessorsG2: \"Cranial Signal Processors - Gen II\",\r\n CranialSignalProcessorsG3: \"Cranial Signal Processors - Gen III\",\r\n CranialSignalProcessorsG4: \"Cranial Signal Processors - Gen IV\",\r\n CranialSignalProcessorsG5: \"Cranial Signal Processors - Gen V\",\r\n NeuronalDensification: \"Neuronal Densification\",\r\n NuoptimalInjectorImplant: \"Nuoptimal Nootropic Injector Implant\",\r\n SpeechEnhancement: \"Speech Enhancement\",\r\n FocusWire: \"FocusWire\",\r\n PCDNI: \"PC Direct-Neural Interface\",\r\n PCDNIOptimizer: \"PC Direct-Neural Interface Optimization Submodule\",\r\n PCDNINeuralNetwork: \"PC Direct-Neural Interface NeuroNet Injector\",\r\n ADRPheromone1: \"ADR-V1 Pheromone Gene\",\r\n ADRPheromone2: \"ADR-V2 Pheromone Gene\",\r\n HacknetNodeCPUUpload: \"Hacknet Node CPU Architecture Neural-Upload\",\r\n HacknetNodeCacheUpload: \"Hacknet Node Cache Architecture Neural-Upload\",\r\n HacknetNodeNICUpload: \"Hacknet Node NIC Architecture Neural-Upload\",\r\n HacknetNodeKernelDNI: \"Hacknet Node Kernel Direct-Neural Interface\",\r\n HacknetNodeCoreDNI: \"Hacknet Node Core Direct-Neural Interface\",\r\n NeuroFluxGovernor: \"NeuroFlux Governor\",\r\n Neurotrainer1: \"Neurotrainer I\",\r\n Neurotrainer2: \"Neurotrainer II\",\r\n Neurotrainer3: \"Neurotrainer III\",\r\n Hypersight: \"HyperSight Corneal Implant\",\r\n LuminCloaking1: \"LuminCloaking-V1 Skin Implant\",\r\n LuminCloaking2: \"LuminCloaking-V2 Skin Implant\",\r\n HemoRecirculator: \"HemoRecirculator\",\r\n SmartSonar: \"SmartSonar Implant\",\r\n PowerRecirculator: \"Power Recirculation Core\",\r\n QLink: \"QLink\",\r\n TheRedPill: \"The Red Pill\",\r\n SPTN97: \"SPTN-97 Gene Modification\",\r\n HiveMind: \"ECorp HVMind Implant\",\r\n CordiARCReactor: \"CordiARC Fusion Reactor\",\r\n SmartJaw: \"SmartJaw\",\r\n Neotra: \"Neotra\",\r\n Xanipher: \"Xanipher\",\r\n nextSENS: \"nextSENS Gene Modification\",\r\n OmniTekInfoLoad: \"OmniTek InfoLoad\",\r\n PhotosyntheticCells: \"Photosynthetic Cells\",\r\n Neurolink: \"BitRunners Neurolink\",\r\n TheBlackHand: \"The Black Hand\",\r\n CRTX42AA: \"CRTX42-AA Gene Modification\",\r\n Neuregen: \"Neuregen Gene Modification\",\r\n CashRoot: \"CashRoot Starter Kit\",\r\n NutriGen: \"NutriGen Implant\",\r\n INFRARet: \"INFRARET Enhancement\",\r\n DermaForce: \"DermaForce Particle Barrier\",\r\n GrapheneBrachiBlades: \"Graphene BranchiBlades Upgrade\",\r\n GrapheneBionicArms: \"Graphene Bionic Arms Upgrade\",\r\n BrachiBlades: \"BrachiBlades\",\r\n BionicArms: \"Bionic Arms\",\r\n SNA: \"Social Negotiation Assistant (S.N.A)\",\r\n EsperEyewear: \"EsperTech Bladeburner Eyewear\",\r\n EMS4Recombination: \"EMS-4 Recombination\",\r\n OrionShoulder: \"ORION-MKIV Shoulder\",\r\n HyperionV1: \"Hyperion Plasma Cannon V1\",\r\n HyperionV2: \"Hyperion Plasma Cannon V2\",\r\n GolemSerum: \"GOLEM Serum\",\r\n VangelisVirus: \"Vangelis Virus\",\r\n VangelisVirus3: \"Vangelis Virus 3.0\",\r\n INTERLINKED: \"I.N.T.E.R.L.I.N.K.E.D\",\r\n BladeRunner: \"Blade's Runners\",\r\n BladeArmor: \"BLADE-51b Tesla Armor\",\r\n BladeArmorPowerCells: \"BLADE-51b Tesla Armor: Power Cells Upgrade\",\r\n BladeArmorEnergyShielding: \"BLADE-51b Tesla Armor: Energy Shielding Upgrade\",\r\n BladeArmorUnibeam: \"BLADE-51b Tesla Armor: Unibeam Upgrade\",\r\n BladeArmorOmnibeam: \"BLADE-51b Tesla Armor: Omnibeam Upgrade\",\r\n BladeArmorIPU: \"BLADE-51b Tesla Armor: IPU Upgrade\",\r\n\r\n //Wasteland Augs\r\n //PepBoy: \"P.E.P-Boy\", Plasma Energy Projection System\r\n //PepBoyForceField Generates plasma force fields\r\n //PepBoyBlasts Generate high density plasma concussive blasts\r\n //PepBoyDataStorage STore more data on pep boy,\r\n}\r\n\r\nfunction initAugmentations() {\r\n for (var name in Factions) {\r\n if (Factions.hasOwnProperty(name)) {\r\n Factions[name].augmentations = [];\r\n }\r\n }\r\n\r\n //Reset Augmentations\r\n clearObject(Augmentations);\r\n\r\n //Combat stat augmentations\r\n var HemoRecirculator = new Augmentation({\r\n name:AugmentationNames.HemoRecirculator, moneyCost: 9e6, repCost:4e3,\r\n info:\"A heart implant that greatly increases the body's ability to effectively use and pump \" +\r\n \"blood.
This augmentation increases all of the player's combat stats by 8%.\"\r\n });\r\n HemoRecirculator.addToFactions([\"Tetrads\", \"The Dark Army\", \"The Syndicate\"]);\r\n if (augmentationExists(AugmentationNames.HemoRecirculator)) {\r\n delete Augmentations[AugmentationNames.HemoRecirculator];\r\n }\r\n AddToAugmentations(HemoRecirculator);\r\n\r\n var Targeting1 = new Augmentation({\r\n name:AugmentationNames.Targeting1, moneyCost:3e6, repCost:2e3,\r\n info:\"This cranial implant is embedded within the player's inner ear structure and optic nerves. It regulates and enhances the user's \" +\r\n \"balance and hand-eye coordination. It is also capable of augmenting reality by projecting digital information \" +\r\n \"directly onto the retina. These enhancements allow the player to better lock-on and keep track of enemies.
\" +\r\n \"This augmentation increases the player's dexterity by 10%.\"\r\n });\r\n Targeting1.addToFactions([\"Slum Snakes\", \"The Dark Army\", \"The Syndicate\", \"Sector-12\", \"Volhaven\", \"Ishima\",\r\n \"OmniTek Incorporated\", \"KuaiGong International\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.Targeting1)) {\r\n delete Augmentations[AugmentationNames.Targeting1];\r\n }\r\n AddToAugmentations(Targeting1);\r\n\r\n var Targeting2 = new Augmentation({\r\n name:AugmentationNames.Targeting2, moneyCost:8.5e6, repCost:3.5e3,\r\n info:\"This is an upgrade of the Augmented Targeting I cranial implant, which is capable of augmenting reality \" +\r\n \"and enhances the user's balance and hand-eye coordination.
This upgrade increases the player's dexterity \" +\r\n \"by an additional 20%.\",\r\n prereqs:[AugmentationNames.Targeting1]\r\n });\r\n Targeting2.addToFactions([\"The Dark Army\", \"The Syndicate\", \"Sector-12\", \"Volhaven\", \"Ishima\",\r\n \"OmniTek Incorporated\", \"KuaiGong International\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.Targeting2)) {\r\n delete Augmentations[AugmentationNames.Targeting2];\r\n }\r\n AddToAugmentations(Targeting2);\r\n\r\n var Targeting3 = new Augmentation({\r\n name:AugmentationNames.Targeting3, moneyCost:23e6, repCost:11e3,\r\n info:\"This is an upgrade of the Augmented Targeting II cranial implant, which is capable of augmenting reality \" +\r\n \"and enhances the user's balance and hand-eye coordination.
This upgrade increases the player's dexterity \" +\r\n \"by an additional 30%.\",\r\n prereqs:[AugmentationNames.Targeting2]\r\n });\r\n Targeting3.addToFactions([\"The Dark Army\", \"The Syndicate\", \"OmniTek Incorporated\",\r\n \"KuaiGong International\", \"Blade Industries\", \"The Covenant\"]);\r\n if (augmentationExists(AugmentationNames.Targeting3)) {\r\n delete Augmentations[AugmentationNames.Targeting3];\r\n }\r\n AddToAugmentations(Targeting3);\r\n\r\n var SyntheticHeart = new Augmentation({\r\n name:AugmentationNames.SyntheticHeart, moneyCost:575e6, repCost:300e3,\r\n info:\"This advanced artificial heart, created from plasteel and graphene, is capable of pumping more blood \" +\r\n \"at much higher efficiencies than a normal human heart.
This augmentation increases the player's agility \" +\r\n \"and strength by 50%\"\r\n });\r\n SyntheticHeart.addToFactions([\"KuaiGong International\", \"Fulcrum Secret Technologies\", \"Speakers for the Dead\",\r\n \"NWO\", \"The Covenant\", \"Daedalus\", \"Illuminati\"]);\r\n if (augmentationExists(AugmentationNames.SyntheticHeart)) {\r\n delete Augmentations[AugmentationNames.SyntheticHeart];\r\n }\r\n AddToAugmentations(SyntheticHeart);\r\n\r\n var SynfibrilMuscle = new Augmentation({\r\n name:AugmentationNames.SynfibrilMuscle, repCost:175e3, moneyCost:225e6,\r\n info:\"The myofibrils in human muscles are injected with special chemicals that react with the proteins inside \" +\r\n \"the myofibrils, altering their underlying structure. The end result is muscles that are stronger and more elastic. \" +\r\n \"Scientists have named these artificially enhanced units 'synfibrils'.
This augmentation increases the player's \" +\r\n \"strength and defense by 30%.\"\r\n });\r\n SynfibrilMuscle.addToFactions([\"KuaiGong International\", \"Fulcrum Secret Technologies\", \"Speakers for the Dead\",\r\n \"NWO\", \"The Covenant\", \"Daedalus\", \"Illuminati\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.SynfibrilMuscle)) {\r\n delete Augmentations[AugmentationNames.SynfibrilMuscle];\r\n }\r\n AddToAugmentations(SynfibrilMuscle)\r\n\r\n var CombatRib1 = new Augmentation({\r\n name:AugmentationNames.CombatRib1, repCost:3e3, moneyCost:4750000,\r\n info:\"The human body's ribs are replaced with artificial ribs that automatically and continuously release cognitive \" +\r\n \"and performance-enhancing drugs into the bloodstream, improving the user's abilities in combat.
\" +\r\n \"This augmentation increases the player's strength and defense by 10%.\"\r\n });\r\n CombatRib1.addToFactions([\"Slum Snakes\", \"The Dark Army\", \"The Syndicate\", \"Sector-12\", \"Volhaven\", \"Ishima\",\r\n \"OmniTek Incorporated\", \"KuaiGong International\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.CombatRib1)) {\r\n delete Augmentations[AugmentationNames.CombatRib1];\r\n }\r\n AddToAugmentations(CombatRib1);\r\n\r\n var CombatRib2 = new Augmentation({\r\n name:AugmentationNames.CombatRib2, repCost:7.5e3, moneyCost:13e6,\r\n info:\"This is an upgrade to the Combat Rib I augmentation, and is capable of releasing even more potent combat-enhancing \" +\r\n \"drugs into the bloodstream.
This upgrade increases the player's strength and defense by an additional 14%.\",\r\n prereqs:[AugmentationNames.CombatRib1]\r\n });\r\n CombatRib2.addToFactions([\"The Dark Army\", \"The Syndicate\", \"Sector-12\", \"Volhaven\", \"Ishima\",\r\n \"OmniTek Incorporated\", \"KuaiGong International\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.CombatRib2)) {\r\n delete Augmentations[AugmentationNames.CombatRib2];\r\n }\r\n AddToAugmentations(CombatRib2);\r\n\r\n var CombatRib3 = new Augmentation({\r\n name:AugmentationNames.CombatRib3, repCost:14e3, moneyCost:24e6,\r\n info:\"This is an upgrade to the Combat Rib II augmentation, and is capable of releasing even more potent combat-enhancing \" +\r\n \"drugs into the bloodstream
. This upgrade increases the player's strength and defense by an additional 18%.\",\r\n prereqs:[AugmentationNames.CombatRib2],\r\n });\r\n CombatRib3.addToFactions([\"The Dark Army\", \"The Syndicate\", \"OmniTek Incorporated\",\r\n \"KuaiGong International\", \"Blade Industries\", \"The Covenant\"]);\r\n if (augmentationExists(AugmentationNames.CombatRib3)) {\r\n delete Augmentations[AugmentationNames.CombatRib3];\r\n }\r\n AddToAugmentations(CombatRib3);\r\n\r\n var NanofiberWeave = new Augmentation({\r\n name:AugmentationNames.NanofiberWeave, repCost:15e3, moneyCost:25e6,\r\n info:\"Synthetic nanofibers are woven into the skin's extracellular matrix using electrospinning. \" +\r\n \"This improves the skin's ability to regenerate itself and protect the body from external stresses and forces.
\" +\r\n \"This augmentation increases the player's strength and defense by 20%.\"\r\n });\r\n NanofiberWeave.addToFactions([\"Tian Di Hui\", \"The Syndicate\", \"The Dark Army\", \"Speakers for the Dead\",\r\n \"Blade Industries\", \"Fulcrum Secret Technologies\", \"OmniTek Incorporated\"]);\r\n if (augmentationExists(AugmentationNames.NanofiberWeave)) {\r\n delete Augmentations[AugmentationNames.NanofiberWeave];\r\n }\r\n AddToAugmentations(NanofiberWeave);\r\n\r\n var SubdermalArmor = new Augmentation({\r\n name:AugmentationNames.SubdermalArmor, repCost:350e3, moneyCost:650e6,\r\n info:\"The NEMEAN Subdermal Weave is a thin, light-weight, graphene plating that houses a dilatant fluid. \" +\r\n \"The material is implanted underneath the skin, and is the most advanced form of defensive enhancement \" +\r\n \"that has ever been created. The dilatant fluid, despite being thin and light, is extremely effective \" +\r\n \"at stopping piercing blows and reducing blunt trauma. The properties of graphene allow the plating to \" +\r\n \"mitigate damage from any fire-related or electrical traumas.
\" +\r\n \"This augmentation increases the player's defense by 120%.\"\r\n });\r\n SubdermalArmor.addToFactions([\"The Syndicate\", \"Fulcrum Secret Technologies\", \"Illuminati\", \"Daedalus\",\r\n \"The Covenant\"]);\r\n if (augmentationExists(AugmentationNames.SubdermalArmor)) {\r\n delete Augmentations[AugmentationNames.SubdermalArmor];\r\n }\r\n AddToAugmentations(SubdermalArmor);\r\n\r\n var WiredReflexes = new Augmentation({\r\n name:AugmentationNames.WiredReflexes, repCost:500, moneyCost:500e3,\r\n info:\"Synthetic nerve-enhancements are injected into all major parts of the somatic nervous system, \" +\r\n \"supercharging the body's ability to send signals through neurons. This results in increased reflex speed.
\" +\r\n \"This augmentation increases the player's agility and dexterity by 5%.\"\r\n });\r\n WiredReflexes.addToFactions([\"Tian Di Hui\", \"Slum Snakes\", \"Sector-12\", \"Volhaven\", \"Aevum\", \"Ishima\",\r\n \"The Syndicate\", \"The Dark Army\", \"Speakers for the Dead\"]);\r\n if (augmentationExists(AugmentationNames.WiredReflexes)) {\r\n delete Augmentations[AugmentationNames.WiredReflexes];\r\n }\r\n AddToAugmentations(WiredReflexes);\r\n\r\n var GrapheneBoneLacings = new Augmentation({\r\n name:AugmentationNames.GrapheneBoneLacings, repCost:450e3, moneyCost:850e6,\r\n info:\"A graphene-based material is grafted and fused into the user's bones, significantly increasing \" +\r\n \"their density and tensile strength.
\" +\r\n \"This augmentation increases the player's strength and defense by 70%.\"\r\n });\r\n GrapheneBoneLacings.addToFactions([\"Fulcrum Secret Technologies\", \"The Covenant\"]);\r\n if (augmentationExists(AugmentationNames.GrapheneBoneLacings)) {\r\n delete Augmentations[AugmentationNames.GrapheneBoneLacings];\r\n }\r\n AddToAugmentations(GrapheneBoneLacings);\r\n\r\n var BionicSpine = new Augmentation({\r\n name:AugmentationNames.BionicSpine, repCost:18e3, moneyCost:25e6,\r\n info:\"An artificial spine created from plasteel and carbon fibers that completely replaces the organic spine. \" +\r\n \"Not only is the Bionic Spine physically stronger than a human spine, but it is also capable of digitally \" +\r\n \"stimulating and regulating the neural signals that are sent and received by the spinal cord. This results in \" +\r\n \"greatly improved senses and reaction speeds.
\" +\r\n \"This augmentation increases all of the player's combat stats by 15%.\"\r\n });\r\n BionicSpine.addToFactions([\"Speakers for the Dead\", \"The Syndicate\", \"KuaiGong International\",\r\n \"OmniTek Incorporated\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.BionicSpine)) {\r\n delete Augmentations[AugmentationNames.BionicSpine];\r\n }\r\n AddToAugmentations(BionicSpine);\r\n\r\n var GrapheneBionicSpine = new Augmentation({\r\n name:AugmentationNames.GrapheneBionicSpine, repCost:650e3, moneyCost:1200e6,\r\n info:\"An upgrade to the Bionic Spine augmentation. It fuses the implant with an advanced graphene \" +\r\n \"material to make it much stronger and lighter.
\" +\r\n \"This augmentation increases all of the player's combat stats by 60%.\",\r\n prereqs:[AugmentationNames.BionicSpine],\r\n });\r\n GrapheneBionicSpine.addToFactions([\"Fulcrum Secret Technologies\", \"ECorp\"]);\r\n if (augmentationExists(AugmentationNames.GrapheneBionicSpine)) {\r\n delete Augmentations[AugmentationNames.GrapheneBionicSpine];\r\n }\r\n AddToAugmentations(GrapheneBionicSpine);\r\n\r\n var BionicLegs = new Augmentation({\r\n name:AugmentationNames.BionicLegs, repCost:60e3, moneyCost:75e6,\r\n info:\"Cybernetic legs created from plasteel and carbon fibers that completely replace the user's organic legs.
\" +\r\n \"This augmentation increases the player's agility by 60%.\"\r\n });\r\n BionicLegs.addToFactions([\"Speakers for the Dead\", \"The Syndicate\", \"KuaiGong International\",\r\n \"OmniTek Incorporated\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.BionicLegs)) {\r\n delete Augmentations[AugmentationNames.BionicLegs];\r\n }\r\n AddToAugmentations(BionicLegs);\r\n\r\n var GrapheneBionicLegs = new Augmentation({\r\n name:AugmentationNames.GrapheneBionicLegs, repCost:300e3, moneyCost:900e6,\r\n info:\"An upgrade to the Bionic Legs augmentation. It fuses the implant with an advanced graphene \" +\r\n \"material to make it much stronger and lighter.
\" +\r\n \"This augmentation increases the player's agility by an additional 150%.\",\r\n prereqs:[AugmentationNames.BionicLegs],\r\n });\r\n GrapheneBionicLegs.addToFactions([\"MegaCorp\", \"ECorp\", \"Fulcrum Secret Technologies\"]);\r\n if (augmentationExists(AugmentationNames.GrapheneBionicLegs)) {\r\n delete Augmentations[AugmentationNames.GrapheneBionicLegs];\r\n }\r\n AddToAugmentations(GrapheneBionicLegs);\r\n\r\n //Labor stat augmentations\r\n var SpeechProcessor = new Augmentation({\r\n name:AugmentationNames.SpeechProcessor, repCost:3e3, moneyCost:10e6,\r\n info:\"A cochlear implant with an embedded computer that analyzes incoming speech. \" +\r\n \"The embedded computer processes characteristics of incoming speech, such as tone \" +\r\n \"and inflection, to pick up on subtle cues and aid in social interactions.
\" +\r\n \"This augmentation increases the player's charisma by 20%.\"\r\n });\r\n SpeechProcessor.addToFactions([\"Tian Di Hui\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Aevum\",\r\n \"Ishima\", \"Volhaven\", \"Silhouette\"]);\r\n if (augmentationExists(AugmentationNames.SpeechProcessor)) {\r\n delete Augmentations[AugmentationNames.SpeechProcessor];\r\n }\r\n AddToAugmentations(SpeechProcessor);\r\n\r\n let TITN41Injection = new Augmentation({\r\n name:AugmentationNames.TITN41Injection, repCost:10e3, moneyCost:38e6,\r\n info:\"TITN is a series of viruses that targets and alters the sequences of human DNA in genes that \" +\r\n \"control personality. The TITN-41 strain alters these genes so that the subject becomes more \" +\r\n \"outgoing and socialable.
\" +\r\n \"This augmentation increases the player's charisma and charisma experience gain rate by 15%\"\r\n });\r\n TITN41Injection.addToFactions([\"Silhouette\"]);\r\n if (augmentationExists(AugmentationNames.TITN41Injection)) {\r\n delete Augmentations[AugmentationNames.TITN41Injection];\r\n }\r\n AddToAugmentations(TITN41Injection);\r\n\r\n var EnhancedSocialInteractionImplant = new Augmentation({\r\n name:AugmentationNames.EnhancedSocialInteractionImplant, repCost:150e3, moneyCost:275e6,\r\n info:\"A cranial implant that greatly assists in the user's ability to analyze social situations \" +\r\n \"and interactions. The system uses a wide variety of factors such as facial expression, body \" +\r\n \"language, and the voice's tone/inflection to determine the best course of action during social\" +\r\n \"situations. The implant also uses deep learning software to continuously learn new behavior\" +\r\n \"patterns and how to best respond.
\" +\r\n \"This augmentation increases the player's charisma and charisma experience gain rate by 60%.\"\r\n });\r\n EnhancedSocialInteractionImplant.addToFactions([\"Bachman & Associates\", \"NWO\", \"Clarke Incorporated\",\r\n \"OmniTek Incorporated\", \"Four Sigma\"]);\r\n if (augmentationExists(AugmentationNames.EnhancedSocialInteractionImplant)) {\r\n delete Augmentations[AugmentationNames.EnhancedSocialInteractionImplant];\r\n }\r\n AddToAugmentations(EnhancedSocialInteractionImplant);\r\n\r\n //Hacking augmentations\r\n var BitWire = new Augmentation({\r\n name:AugmentationNames.BitWire, repCost:1500, moneyCost:2e6,\r\n info: \"A small brain implant embedded in the cerebrum. This regulates and improves the brain's computing \" +\r\n \"capabilities.
This augmentation increases the player's hacking skill by 5%\"\r\n });\r\n BitWire.addToFactions([\"CyberSec\", \"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.BitWire)) {\r\n delete Augmentations[AugmentationNames.BitWire];\r\n }\r\n AddToAugmentations(BitWire);\r\n\r\n var ArtificialBioNeuralNetwork = new Augmentation({\r\n name:AugmentationNames.ArtificialBioNeuralNetwork, repCost:110e3, moneyCost:600e6,\r\n info:\"A network consisting of millions of nanoprocessors is embedded into the brain. \" +\r\n \"The network is meant to mimick the way a biological brain solves a problem, which each \" +\r\n \"nanoprocessor acting similar to the way a neuron would in a neural network. However, these \" +\r\n \"nanoprocessors are programmed to perform computations much faster than organic neurons, \" +\r\n \"allowing its user to solve much more complex problems at a much faster rate.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 3%
\" +\r\n \"Increases the amount of money the player's gains from hacking by 15%
\" +\r\n \"Increases the player's hacking skill by 12%\"\r\n });\r\n ArtificialBioNeuralNetwork.addToFactions([\"BitRunners\", \"Fulcrum Secret Technologies\"]);\r\n if (augmentationExists(AugmentationNames.ArtificialBioNeuralNetwork)) {\r\n delete Augmentations[AugmentationNames.ArtificialBioNeuralNetwork];\r\n }\r\n AddToAugmentations(ArtificialBioNeuralNetwork);\r\n\r\n var ArtificialSynapticPotentiation = new Augmentation({\r\n name:AugmentationNames.ArtificialSynapticPotentiation, repCost:2500, moneyCost:16e6,\r\n info:\"The body is injected with a chemical that artificially induces synaptic potentiation, \" +\r\n \"otherwise known as the strengthening of synapses. This results in a enhanced cognitive abilities.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the player's hacking chance by 5%
\" +\r\n \"Increases the player's hacking experience gain rate by 5%\"\r\n });\r\n ArtificialSynapticPotentiation.addToFactions([\"The Black Hand\", \"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.ArtificialSynapticPotentiation)) {\r\n delete Augmentations[AugmentationNames.ArtificialSynapticPotentiation];\r\n }\r\n AddToAugmentations(ArtificialSynapticPotentiation);\r\n\r\n var EnhancedMyelinSheathing = new Augmentation({\r\n name:AugmentationNames.EnhancedMyelinSheathing, repCost:40e3, moneyCost:275e6,\r\n info:\"Electrical signals are used to induce a new, artificial form of myelinogensis in the human body. \" +\r\n \"This process results in the proliferation of new, synthetic myelin sheaths in the nervous \" +\r\n \"system. These myelin sheaths can propogate neuro-signals much faster than their organic \" +\r\n \"counterparts, leading to greater processing speeds and better brain function.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 3%
\" +\r\n \"Increases the player's hacking skill by 8%
\" +\r\n \"Increases the player's hacking experience gain rate by 10%\"\r\n });\r\n EnhancedMyelinSheathing.addToFactions([\"Fulcrum Secret Technologies\", \"BitRunners\", \"The Black Hand\"]);\r\n if (augmentationExists(AugmentationNames.EnhancedMyelinSheathing)) {\r\n delete Augmentations[AugmentationNames.EnhancedMyelinSheathing];\r\n }\r\n AddToAugmentations(EnhancedMyelinSheathing);\r\n\r\n var SynapticEnhancement = new Augmentation({\r\n name:AugmentationNames.SynapticEnhancement, repCost:800, moneyCost:1.5e6,\r\n info:\"A small cranial implant that continuously uses weak electric signals to stimulate the brain and \" +\r\n \"induce stronger synaptic activity. This improves the user's cognitive abilities.
\" +\r\n \"This augmentation increases the player's hacking speed by 3%.\"\r\n });\r\n SynapticEnhancement.addToFactions([\"CyberSec\"]);\r\n if (augmentationExists(AugmentationNames.SynapticEnhancement)) {\r\n delete Augmentations[AugmentationNames.SynapticEnhancement];\r\n }\r\n AddToAugmentations(SynapticEnhancement);\r\n\r\n var NeuralRetentionEnhancement = new Augmentation({\r\n name:AugmentationNames.NeuralRetentionEnhancement, repCost:8e3, moneyCost:50e6,\r\n info:\"Chemical injections are used to permanently alter and strengthen the brain's neuronal \" +\r\n \"circuits, strengthening its ability to retain information.
\" +\r\n \"This augmentation increases the player's hacking experience gain rate by 25%.\"\r\n });\r\n NeuralRetentionEnhancement.addToFactions([\"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.NeuralRetentionEnhancement)) {\r\n delete Augmentations[AugmentationNames.NeuralRetentionEnhancement];\r\n }\r\n AddToAugmentations(NeuralRetentionEnhancement);\r\n\r\n var DataJack = new Augmentation({\r\n name:AugmentationNames.DataJack, repCost:45e3, moneyCost:90e6,\r\n info:\"A brain implant that provides an interface for direct, wireless communication between a computer's main \" +\r\n \"memory and the mind. This implant allows the user to not only access a computer's memory, but also alter \" +\r\n \"and delete it.
\" +\r\n \"This augmentation increases the amount of money the player gains from hacking by 25%\"\r\n });\r\n DataJack.addToFactions([\"BitRunners\", \"The Black Hand\", \"NiteSec\", \"Chongqing\", \"New Tokyo\"]);\r\n if (augmentationExists(AugmentationNames.DataJack)) {\r\n delete Augmentations[AugmentationNames.DataJack];\r\n }\r\n AddToAugmentations(DataJack);\r\n\r\n var ENM = new Augmentation({\r\n name:AugmentationNames.ENM, repCost:6e3, moneyCost:50e6,\r\n info:\"A thin device embedded inside the arm containing a wireless module capable of connecting \" +\r\n \"to nearby networks. Once connected, the Netburner Module is capable of capturing and \" +\r\n \"processing all of the traffic on that network. By itself, the Embedded Netburner Module does \" +\r\n \"not do much, but a variety of very powerful upgrades can be installed that allow you to fully \" +\r\n \"control the traffic on a network.
\" +\r\n \"This augmentation increases the player's hacking skill by 8%\"\r\n });\r\n ENM.addToFactions([\"BitRunners\", \"The Black Hand\", \"NiteSec\", \"ECorp\", \"MegaCorp\",\r\n \"Fulcrum Secret Technologies\", \"NWO\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.ENM)) {\r\n delete Augmentations[AugmentationNames.ENM];\r\n }\r\n AddToAugmentations(ENM);\r\n\r\n var ENMCore = new Augmentation({\r\n name:AugmentationNames.ENMCore, repCost:100e3, moneyCost:500e6,\r\n info:\"The Core library is an implant that upgrades the firmware of the Embedded Netburner Module. \" +\r\n \"This upgrade allows the Embedded Netburner Module to generate its own data on a network.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 3%
\" +\r\n \"Increases the amount of money the player gains from hacking by 10%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 3%
\" +\r\n \"Increases the player's hacking experience gain rate by 7%
\" +\r\n \"Increases the player's hacking skill by 7%\",\r\n prereqs:[AugmentationNames.ENM]\r\n });\r\n ENMCore.addToFactions([\"BitRunners\", \"The Black Hand\", \"ECorp\", \"MegaCorp\",\r\n \"Fulcrum Secret Technologies\", \"NWO\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.ENMCore)) {\r\n delete Augmentations[AugmentationNames.ENMCore];\r\n }\r\n AddToAugmentations(ENMCore);\r\n\r\n var ENMCoreV2 = new Augmentation({\r\n name:AugmentationNames.ENMCoreV2, repCost:400e3, moneyCost:900e6,\r\n info:\"The Core V2 library is an implant that upgrades the firmware of the Embedded Netburner Module. \" +\r\n \"This upgraded firmware allows the Embedded Netburner Module to control the information on \" +\r\n \"a network by re-routing traffic, spoofing IP addresses, or altering the data inside network \" +\r\n \"packets.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 5%
\" +\r\n \"Increases the amount of money the player gains from hacking by 30%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 5%
\" +\r\n \"Increases the player's hacking experience gain rate by 15%
\" +\r\n \"Increases the player's hacking skill by 8%\",\r\n prereqs:[AugmentationNames.ENMCore]\r\n });\r\n ENMCoreV2.addToFactions([\"BitRunners\", \"ECorp\", \"MegaCorp\", \"Fulcrum Secret Technologies\", \"NWO\",\r\n \"Blade Industries\", \"OmniTek Incorporated\", \"KuaiGong International\"]);\r\n if (augmentationExists(AugmentationNames.ENMCoreV2)) {\r\n delete Augmentations[AugmentationNames.ENMCoreV2];\r\n }\r\n AddToAugmentations(ENMCoreV2);\r\n\r\n var ENMCoreV3 = new Augmentation({\r\n name:AugmentationNames.ENMCoreV3, repCost:700e3, moneyCost:1500e6,\r\n info:\"The Core V3 library is an implant that upgrades the firmware of the Embedded Netburner Module. \" +\r\n \"This upgraded firmware allows the Embedded Netburner Module to seamlessly inject code into \" +\r\n \"any device on a network.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 5%
\" +\r\n \"Increases the amount of money the player gains from hacking by 40%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 10%
\" +\r\n \"Increases the player's hacking experience gain rate by 25%
\" +\r\n \"Increases the player's hacking skill by 10%\",\r\n prereqs:[AugmentationNames.ENMCoreV2],\r\n });\r\n ENMCoreV3.addToFactions([\"ECorp\", \"MegaCorp\", \"Fulcrum Secret Technologies\", \"NWO\",\r\n \"Daedalus\", \"The Covenant\", \"Illuminati\"]);\r\n if (augmentationExists(AugmentationNames.ENMCoreV3)) {\r\n delete Augmentations[AugmentationNames.ENMCoreV3];\r\n }\r\n AddToAugmentations(ENMCoreV3);\r\n\r\n var ENMAnalyzeEngine = new Augmentation({\r\n name:AugmentationNames.ENMAnalyzeEngine, repCost:250e3, moneyCost:1200e6,\r\n info:\"Installs the Analyze Engine for the Embedded Netburner Module, which is a CPU cluster \" +\r\n \"that vastly outperforms the Netburner Module's native single-core processor.
\" +\r\n \"This augmentation increases the player's hacking speed by 10%.\",\r\n prereqs:[AugmentationNames.ENM],\r\n });\r\n ENMAnalyzeEngine.addToFactions([\"ECorp\", \"MegaCorp\", \"Fulcrum Secret Technologies\", \"NWO\",\r\n \"Daedalus\", \"The Covenant\", \"Illuminati\"]);\r\n if (augmentationExists(AugmentationNames.ENMAnalyzeEngine)) {\r\n delete Augmentations[AugmentationNames.ENMAnalyzeEngine];\r\n }\r\n AddToAugmentations(ENMAnalyzeEngine);\r\n\r\n var ENMDMA = new Augmentation({\r\n name:AugmentationNames.ENMDMA, repCost:400e3, moneyCost:1400e6,\r\n info:\"This implant installs a Direct Memory Access (DMA) controller into the \" +\r\n \"Embedded Netburner Module. This allows the Module to send and receive data \" +\r\n \"directly to and from the main memory of devices on a network.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of money the player gains from hacking by 40%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 20%\",\r\n prereqs:[AugmentationNames.ENM],\r\n });\r\n ENMDMA.addToFactions([\"ECorp\", \"MegaCorp\", \"Fulcrum Secret Technologies\", \"NWO\",\r\n \"Daedalus\", \"The Covenant\", \"Illuminati\"]);\r\n if (augmentationExists(AugmentationNames.ENMDMA)) {\r\n delete Augmentations[AugmentationNames.ENMDMA];\r\n }\r\n AddToAugmentations(ENMDMA);\r\n\r\n var Neuralstimulator = new Augmentation({\r\n name:AugmentationNames.Neuralstimulator, repCost:20e3, moneyCost:600e6,\r\n info:\"A cranial implant that intelligently stimulates certain areas of the brain \" +\r\n \"in order to improve cognitive functions
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 10%
\" +\r\n \"Increases the player's hacking experience gain rate by 12%\"\r\n });\r\n Neuralstimulator.addToFactions([\"The Black Hand\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Aevum\",\r\n \"Ishima\", \"Volhaven\", \"Bachman & Associates\", \"Clarke Incorporated\",\r\n \"Four Sigma\"]);\r\n if (augmentationExists(AugmentationNames.Neuralstimulator)) {\r\n delete Augmentations[AugmentationNames.Neuralstimulator];\r\n }\r\n AddToAugmentations(Neuralstimulator);\r\n\r\n var NeuralAccelerator = new Augmentation({\r\n name:AugmentationNames.NeuralAccelerator, repCost:80e3, moneyCost:350e6,\r\n info:\"A microprocessor that accelerates the processing \" +\r\n \"speed of biological neural networks. This is a cranial implant that is embedded inside the brain.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking skill by 10%
\" +\r\n \"Increases the player's hacking experience gain rate by 15%
\" +\r\n \"Increases the amount of money the player gains from hacking by 20%\"\r\n });\r\n NeuralAccelerator.addToFactions([\"BitRunners\"]);\r\n if (augmentationExists(AugmentationNames.NeuralAccelerator)) {\r\n delete Augmentations[AugmentationNames.NeuralAccelerator];\r\n }\r\n AddToAugmentations(NeuralAccelerator);\r\n\r\n var CranialSignalProcessorsG1 = new Augmentation({\r\n name:AugmentationNames.CranialSignalProcessorsG1, repCost:4e3, moneyCost:14e6,\r\n info:\"The first generation of Cranial Signal Processors. Cranial Signal Processors \" +\r\n \"are a set of specialized microprocessors that are attached to \" +\r\n \"neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations \" +\r\n \"so that the brain doesn't have to.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 1%
\" +\r\n \"Increases the player's hacking skill by 5%\"\r\n });\r\n CranialSignalProcessorsG1.addToFactions([\"CyberSec\"]);\r\n if (augmentationExists(AugmentationNames.CranialSignalProcessorsG1)) {\r\n delete Augmentations[AugmentationNames.CranialSignalProcessorsG1];\r\n }\r\n AddToAugmentations(CranialSignalProcessorsG1);\r\n\r\n var CranialSignalProcessorsG2 = new Augmentation({\r\n name:AugmentationNames.CranialSignalProcessorsG2, repCost:7500, moneyCost:25e6,\r\n info:\"The second generation of Cranial Signal Processors. Cranial Signal Processors \" +\r\n \"are a set of specialized microprocessors that are attached to \" +\r\n \"neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations \" +\r\n \"so that the brain doesn't have to.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 5%
\" +\r\n \"Increases the player's hacking skill by 7%\"\r\n });\r\n CranialSignalProcessorsG2.addToFactions([\"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.CranialSignalProcessorsG2)) {\r\n delete Augmentations[AugmentationNames.CranialSignalProcessorsG2];\r\n }\r\n AddToAugmentations(CranialSignalProcessorsG2);\r\n\r\n var CranialSignalProcessorsG3 = new Augmentation({\r\n name:AugmentationNames.CranialSignalProcessorsG3, repCost:20e3, moneyCost:110e6,\r\n info:\"The third generation of Cranial Signal Processors. Cranial Signal Processors \" +\r\n \"are a set of specialized microprocessors that are attached to \" +\r\n \"neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations \" +\r\n \"so that the brain doesn't have to.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the amount of money the player gains from hacking by 15%
\" +\r\n \"Increases the player's hacking skill by 9%\"\r\n });\r\n CranialSignalProcessorsG3.addToFactions([\"NiteSec\", \"The Black Hand\"]);\r\n if (augmentationExists(AugmentationNames.CranialSignalProcessorsG3)) {\r\n delete Augmentations[AugmentationNames.CranialSignalProcessorsG3];\r\n }\r\n AddToAugmentations(CranialSignalProcessorsG3);\r\n\r\n var CranialSignalProcessorsG4 = new Augmentation({\r\n name:AugmentationNames.CranialSignalProcessorsG4, repCost:50e3, moneyCost:220e6,\r\n info:\"The fourth generation of Cranial Signal Processors. Cranial Signal Processors \" +\r\n \"are a set of specialized microprocessors that are attached to \" +\r\n \"neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations \" +\r\n \"so that the brain doesn't have to.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the amount of money the player gains from hacking by 20%
\" +\r\n \"Increases the amount of money the player can inject into servers using grow() by 25%\"\r\n });\r\n CranialSignalProcessorsG4.addToFactions([\"The Black Hand\"]);\r\n if (augmentationExists(AugmentationNames.CranialSignalProcessorsG4)) {\r\n delete Augmentations[AugmentationNames.CranialSignalProcessorsG4];\r\n }\r\n AddToAugmentations(CranialSignalProcessorsG4);\r\n\r\n var CranialSignalProcessorsG5 = new Augmentation({\r\n name:AugmentationNames.CranialSignalProcessorsG5, repCost:100e3, moneyCost:450e6,\r\n info:\"The fifth generation of Cranial Signal Processors. Cranial Signal Processors \" +\r\n \"are a set of specialized microprocessors that are attached to \" +\r\n \"neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations \" +\r\n \"so that the brain doesn't have to.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking skill by 30%
\" +\r\n \"Increases the amount of money the player gains from hacking by 25%
\" +\r\n \"Increases the amount of money the player can inject into servers using grow() by 75%\"\r\n });\r\n CranialSignalProcessorsG5.addToFactions([\"BitRunners\"]);\r\n if (augmentationExists(AugmentationNames.CranialSignalProcessorsG5)) {\r\n delete Augmentations[AugmentationNames.CranialSignalProcessorsG5];\r\n }\r\n AddToAugmentations(CranialSignalProcessorsG5);\r\n\r\n var NeuronalDensification = new Augmentation({\r\n name:AugmentationNames.NeuronalDensification, repCost:75e3, moneyCost:275e6,\r\n info:\"The brain is surgically re-engineered to have increased neuronal density \" +\r\n \"by decreasing the neuron gap junction. Then, the body is genetically modified \" +\r\n \"to enhance the production and capabilities of its neural stem cells.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking skill by 15%
\" +\r\n \"Increases the player's hacking experience gain rate by 10%
\"+\r\n \"Increases the player's hacking speed by 3%\"\r\n });\r\n NeuronalDensification.addToFactions([\"Clarke Incorporated\"]);\r\n if (augmentationExists(AugmentationNames.NeuronalDensification)) {\r\n delete Augmentations[AugmentationNames.NeuronalDensification];\r\n }\r\n AddToAugmentations(NeuronalDensification);\r\n\r\n //Work Augmentations\r\n var NuoptimalInjectorImplant = new Augmentation({\r\n name:AugmentationNames.NuoptimalInjectorImplant, repCost:2e3, moneyCost:4e6,\r\n info:\"This torso implant automatically injects nootropic supplements into \" +\r\n \"the bloodstream to improve memory, increase focus, and provide other \" +\r\n \"cognitive enhancements.
\" +\r\n \"This augmentation increases the amount of reputation the player gains \" +\r\n \"when working for a company by 20%.\"\r\n });\r\n NuoptimalInjectorImplant.addToFactions([\"Tian Di Hui\", \"Volhaven\", \"New Tokyo\", \"Chongqing\", \"Ishima\",\r\n \"Clarke Incorporated\", \"Four Sigma\", \"Bachman & Associates\"]);\r\n if (augmentationExists(AugmentationNames.NuoptimalInjectorImplant)) {\r\n delete Augmentations[AugmentationNames.NuoptimalInjectorImplant];\r\n }\r\n AddToAugmentations(NuoptimalInjectorImplant);\r\n\r\n var SpeechEnhancement = new Augmentation({\r\n name:AugmentationNames.SpeechEnhancement, repCost:1e3, moneyCost:2.5e6,\r\n info:\"An advanced neural implant that improves your speaking abilities, making \" +\r\n \"you more convincing and likable in conversations and overall improving your \" +\r\n \"social interactions.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's charisma by 10%
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 10%\"\r\n });\r\n SpeechEnhancement.addToFactions([\"Tian Di Hui\", \"Speakers for the Dead\", \"Four Sigma\", \"KuaiGong International\",\r\n \"Clarke Incorporated\", \"Four Sigma\", \"Bachman & Associates\"]);\r\n if (augmentationExists(AugmentationNames.SpeechEnhancement)) {\r\n delete Augmentations[AugmentationNames.SpeechEnhancement];\r\n }\r\n AddToAugmentations(SpeechEnhancement);\r\n\r\n var FocusWire = new Augmentation({\r\n name:AugmentationNames.FocusWire, repCost:30e3, moneyCost:180e6,\r\n info:\"A cranial implant that stops procrastination by blocking specific neural pathways \" +\r\n \"in the brain.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all experience gains by 5%
\" +\r\n \"Increases the amount of money the player gains from working by 20%
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 10%\"\r\n });\r\n FocusWire.addToFactions([\"Bachman & Associates\", \"Clarke Incorporated\", \"Four Sigma\", \"KuaiGong International\"]);\r\n if (augmentationExists(AugmentationNames.FocusWire)) {\r\n delete Augmentations[AugmentationNames.FocusWire];\r\n }\r\n AddToAugmentations(FocusWire)\r\n\r\n var PCDNI = new Augmentation({\r\n name:AugmentationNames.PCDNI, repCost:150e3, moneyCost:750e6,\r\n info:\"Installs a Direct-Neural Interface jack into your arm that is compatible with most \" +\r\n \"computers. Connecting to a computer through this jack allows you to interface with \" +\r\n \"it using the brain's electrochemical signals.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 30%
\" +\r\n \"Increases the player's hacking skill by 8%\"\r\n });\r\n PCDNI.addToFactions([\"Four Sigma\", \"OmniTek Incorporated\", \"ECorp\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.PCDNI)) {\r\n delete Augmentations[AugmentationNames.PCDNI];\r\n }\r\n AddToAugmentations(PCDNI);\r\n\r\n var PCDNIOptimizer = new Augmentation({\r\n name:AugmentationNames.PCDNIOptimizer, repCost:200e3, moneyCost:900e6,\r\n info:\"This is a submodule upgrade to the PC Direct-Neural Interface augmentation. It \" +\r\n \"improves the performance of the interface and gives the user more control options \" +\r\n \"to the connected computer.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 75%
\" +\r\n \"Increases the player's hacking skill by 10%\",\r\n prereqs:[AugmentationNames.PCDNI],\r\n });\r\n PCDNIOptimizer.addToFactions([\"Fulcrum Secret Technologies\", \"ECorp\", \"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.PCDNIOptimizer)) {\r\n delete Augmentations[AugmentationNames.PCDNIOptimizer];\r\n }\r\n AddToAugmentations(PCDNIOptimizer);\r\n\r\n var PCDNINeuralNetwork = new Augmentation({\r\n name:AugmentationNames.PCDNINeuralNetwork, repCost:600e3, moneyCost:1500e6,\r\n info:\"This is an additional installation that upgrades the functionality of the \" +\r\n \"PC Direct-Neural Interface augmentation. When connected to a computer, \" +\r\n \"The NeuroNet Injector upgrade allows the user to use his/her own brain's \" +\r\n \"processing power to aid the computer in computational tasks.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 100%
\" +\r\n \"Increases the player's hacking skill by 10%
\" +\r\n \"Increases the player's hacking speed by 5%\",\r\n prereqs:[AugmentationNames.PCDNI],\r\n });\r\n PCDNINeuralNetwork.addToFactions([\"Fulcrum Secret Technologies\"]);\r\n if (augmentationExists(AugmentationNames.PCDNINeuralNetwork)) {\r\n delete Augmentations[AugmentationNames.PCDNINeuralNetwork];\r\n }\r\n AddToAugmentations(PCDNINeuralNetwork);\r\n\r\n var ADRPheromone1 = new Augmentation({\r\n name:AugmentationNames.ADRPheromone1, repCost:1500, moneyCost:3.5e6,\r\n info:\"The body is genetically re-engineered so that it produces the ADR-V1 pheromone, \" +\r\n \"an artificial pheromone discovered by scientists. The ADR-V1 pheromone, when excreted, \" +\r\n \"triggers feelings of admiration and approval in other people.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of reputation the player gains when working for a company by 10%
\" +\r\n \"Increases the amount of reputation the player gains for a faction by 10%\"\r\n });\r\n ADRPheromone1.addToFactions([\"Tian Di Hui\", \"The Syndicate\", \"NWO\", \"MegaCorp\", \"Four Sigma\"]);\r\n if (augmentationExists(AugmentationNames.ADRPheromone1)) {\r\n delete Augmentations[AugmentationNames.ADRPheromone1];\r\n }\r\n AddToAugmentations(ADRPheromone1);\r\n\r\n var ADRPheromone2 = new Augmentation({\r\n name:AugmentationNames.ADRPheromone2, repCost:25e3, moneyCost:110e6,\r\n info:\"The body is genetically re-engineered so that it produces the ADR-V2 pheromone, \" +\r\n \"which is similar to but more potent than ADR-V1. This pheromone, when excreted, \" +\r\n \"triggers feelings of admiration, approval, and respect in others.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of reputation the player gains for a faction and company by 20%.\"\r\n });\r\n ADRPheromone2.addToFactions([\"Silhouette\", \"Four Sigma\", \"Bachman & Associates\", \"Clarke Incorporated\"]);\r\n if (augmentationExists(AugmentationNames.ADRPheromone2)) {\r\n delete Augmentations[AugmentationNames.ADRPheromone2];\r\n }\r\n AddToAugmentations(ADRPheromone2);\r\n\r\n //HacknetNode Augmentations\r\n var HacknetNodeCPUUpload = new Augmentation({\r\n name:AugmentationNames.HacknetNodeCPUUpload, repCost:1500, moneyCost:2.2e6,\r\n info:\"Uploads the architecture and design details of a Hacknet Node's CPU into \" +\r\n \"the brain. This allows the user to engineer custom hardware and software \" +\r\n \"for the Hacknet Node that provides better performance.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of money produced by Hacknet Nodes by 15%
\" +\r\n \"Decreases the cost of purchasing a Hacknet Node by 15%\"\r\n });\r\n HacknetNodeCPUUpload.addToFactions([\"Netburners\"]);\r\n if (augmentationExists(AugmentationNames.HacknetNodeCPUUpload)) {\r\n delete Augmentations[AugmentationNames.HacknetNodeCPUUpload];\r\n }\r\n AddToAugmentations(HacknetNodeCPUUpload);\r\n\r\n var HacknetNodeCacheUpload = new Augmentation({\r\n name:AugmentationNames.HacknetNodeCacheUpload, repCost:1e3, moneyCost:1.1e6,\r\n info:\"Uploads the architecture and design details of a Hacknet Node's main-memory cache \" +\r\n \"into the brain. This allows the user to engineer custom cache hardware for the \" +\r\n \"Hacknet Node that offers better performance.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of money produced by Hacknet Nodes by 10%
\" +\r\n \"Decreases the cost of leveling up a Hacknet Node by 15%\"\r\n });\r\n HacknetNodeCacheUpload.addToFactions([\"Netburners\"]);\r\n if (augmentationExists(AugmentationNames.HacknetNodeCacheUpload)) {\r\n delete Augmentations[AugmentationNames.HacknetNodeCacheUpload];\r\n }\r\n AddToAugmentations(HacknetNodeCacheUpload);\r\n\r\n var HacknetNodeNICUpload = new Augmentation({\r\n name:AugmentationNames.HacknetNodeNICUpload, repCost:750, moneyCost:900e3,\r\n info:\"Uploads the architecture and design details of a Hacknet Node's Network Interface Card (NIC) \" +\r\n \"into the brain. This allows the user to engineer a custom NIC for the Hacknet Node that \" +\r\n \"offers better performance.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of money produced by Hacknet Nodes by 10%
\" +\r\n \"Decreases the cost of purchasing a Hacknet Node by 10%\"\r\n });\r\n HacknetNodeNICUpload.addToFactions([\"Netburners\"]);\r\n if (augmentationExists(AugmentationNames.HacknetNodeNICUpload)) {\r\n delete Augmentations[AugmentationNames.HacknetNodeNICUpload];\r\n }\r\n AddToAugmentations(HacknetNodeNICUpload);\r\n\r\n var HacknetNodeKernelDNI = new Augmentation({\r\n name:AugmentationNames.HacknetNodeKernelDNI, repCost:3e3, moneyCost:8e6,\r\n info:\"Installs a Direct-Neural Interface jack into the arm that is capable of connecting to a \" +\r\n \"Hacknet Node. This lets the user access and manipulate the Node's kernel using the mind's \" +\r\n \"electrochemical signals.
\" +\r\n \"This augmentation increases the amount of money produced by Hacknet Nodes by 25%.\"\r\n });\r\n HacknetNodeKernelDNI.addToFactions([\"Netburners\"]);\r\n if (augmentationExists(AugmentationNames.HacknetNodeKernelDNI)) {\r\n delete Augmentations[AugmentationNames.HacknetNodeKernelDNI];\r\n }\r\n AddToAugmentations(HacknetNodeKernelDNI);\r\n\r\n var HacknetNodeCoreDNI = new Augmentation({\r\n name:AugmentationNames.HacknetNodeCoreDNI, repCost:5e3, moneyCost:12e6,\r\n info:\"Installs a Direct-Neural Interface jack into the arm that is capable of connecting \" +\r\n \"to a Hacknet Node. This lets the user access and manipulate the Node's processing logic using \" +\r\n \"the mind's electrochemical signals.
\" +\r\n \"This augmentation increases the amount of money produced by Hacknet Nodes by 45%.\"\r\n });\r\n HacknetNodeCoreDNI.addToFactions([\"Netburners\"]);\r\n if (augmentationExists(AugmentationNames.HacknetNodeCoreDNI)) {\r\n delete Augmentations[AugmentationNames.HacknetNodeCoreDNI];\r\n }\r\n AddToAugmentations(HacknetNodeCoreDNI);\r\n\r\n //Misc/Hybrid augmentations\r\n var NeuroFluxGovernor = new Augmentation({\r\n name:AugmentationNames.NeuroFluxGovernor, repCost:500, moneyCost: 750e3,\r\n info:\"A device that is embedded in the back of the neck. The NeuroFlux Governor \" +\r\n \"monitors and regulates nervous impulses coming to and from the spinal column, \" +\r\n \"essentially 'governing' the body. By doing so, it improves the functionality of the \" +\r\n \"body's nervous system.
\" +\r\n \"This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation \" +\r\n \"increases ALL of the player's multipliers by 1%\"\r\n });\r\n var nextLevel = getNextNeurofluxLevel();\r\n NeuroFluxGovernor.level = nextLevel - 1;\r\n mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level);\r\n NeuroFluxGovernor.baseRepRequirement = 500 * mult * CONSTANTS.AugmentationRepMultiplier * BitNodeMultipliers.AugmentationRepCost;\r\n NeuroFluxGovernor.baseCost = 750e3 * mult * CONSTANTS.AugmentationCostMultiplier * BitNodeMultipliers.AugmentationMoneyCost;\r\n if (augmentationExists(AugmentationNames.NeuroFluxGovernor)) {\r\n delete Augmentations[AugmentationNames.NeuroFluxGovernor];\r\n }\r\n NeuroFluxGovernor.addToAllFactions();\r\n AddToAugmentations(NeuroFluxGovernor);\r\n\r\n var Neurotrainer1 = new Augmentation({\r\n name:AugmentationNames.Neurotrainer1, repCost:400, moneyCost:800e3,\r\n info:\"A decentralized cranial implant that improves the brain's ability to learn. It is \" +\r\n \"installed by releasing millions of nanobots into the human brain, each of which \" +\r\n \"attaches to a different neural pathway to enhance the brain's ability to retain \" +\r\n \"and retrieve information.
\" +\r\n \"This augmentation increases the player's experience gain rate for all stats by 10%\"\r\n });\r\n Neurotrainer1.addToFactions([\"CyberSec\"]);\r\n if (augmentationExists(AugmentationNames.Neurotrainer1)) {\r\n delete Augmentations[AugmentationNames.Neurotrainer1];\r\n }\r\n AddToAugmentations(Neurotrainer1);\r\n\r\n var Neurotrainer2 = new Augmentation({\r\n name:AugmentationNames.Neurotrainer2, repCost:4e3, moneyCost:9e6,\r\n info:\"A decentralized cranial implant that improves the brain's ability to learn. This \" +\r\n \"is a more powerful version of the Neurotrainer I augmentation, but it does not \" +\r\n \"require Neurotrainer I to be installed as a prerequisite.
\" +\r\n \"This augmentation increases the player's experience gain rate for all stats by 15%\"\r\n });\r\n Neurotrainer2.addToFactions([\"BitRunners\", \"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.Neurotrainer2)) {\r\n delete Augmentations[AugmentationNames.Neurotrainer2];\r\n }\r\n AddToAugmentations(Neurotrainer2);\r\n\r\n var Neurotrainer3 = new Augmentation({\r\n name:AugmentationNames.Neurotrainer3, repCost:10e3, moneyCost:26e6,\r\n info:\"A decentralized cranial implant that improves the brain's ability to learn. This \" +\r\n \"is a more powerful version of the Neurotrainer I and Neurotrainer II augmentation, \" +\r\n \"but it does not require either of them to be installed as a prerequisite.
\" +\r\n \"This augmentation increases the player's experience gain rate for all stats by 20%\"\r\n });\r\n Neurotrainer3.addToFactions([\"NWO\", \"Four Sigma\"]);\r\n if (augmentationExists(AugmentationNames.Neurotrainer3)) {\r\n delete Augmentations[AugmentationNames.Neurotrainer3];\r\n }\r\n AddToAugmentations(Neurotrainer3);\r\n\r\n var Hypersight = new Augmentation({\r\n name:AugmentationNames.Hypersight, repCost:60e3, moneyCost:550e6,\r\n info:\"A bionic eye implant that grants sight capabilities far beyond those of a natural human. \" +\r\n \"Embedded circuitry within the implant provides the ability to detect heat and movement \" +\r\n \"through solid objects such as wells, thus providing 'x-ray vision'-like capabilities.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's dexterity by 40%
\" +\r\n \"Increases the player's hacking speed by 3%
\" +\r\n \"Increases the amount of money the player gains from hacking by 10%\"\r\n });\r\n Hypersight.addToFactions([\"Blade Industries\", \"KuaiGong International\"]);\r\n if (augmentationExists(AugmentationNames.Hypersight)) {\r\n delete Augmentations[AugmentationNames.Hypersight];\r\n }\r\n AddToAugmentations(Hypersight);\r\n\r\n var LuminCloaking1 = new Augmentation({\r\n name:AugmentationNames.LuminCloaking1, repCost:600, moneyCost:1e6,\r\n info:\"A skin implant that reinforces the skin with highly-advanced synthetic cells. These \" +\r\n \"cells, when powered, have a negative refractive index. As a result, they bend light \" +\r\n \"around the skin, making the user much harder to see from the naked eye.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's agility by 5%
\" +\r\n \"Increases the amount of money the player gains from crimes by 10%\"\r\n });\r\n LuminCloaking1.addToFactions([\"Slum Snakes\", \"Tetrads\"]);\r\n if (augmentationExists(AugmentationNames.LuminCloaking1)) {\r\n delete Augmentations[AugmentationNames.LuminCloaking1];\r\n }\r\n AddToAugmentations(LuminCloaking1);\r\n\r\n var LuminCloaking2 = new Augmentation({\r\n name:AugmentationNames.LuminCloaking2, repCost:2e3, moneyCost:6e6,\r\n info:\"This is a more advanced version of the LuminCloaking-V2 augmentation. This skin implant \" +\r\n \"reinforces the skin with highly-advanced synthetic cells. These \" +\r\n \"cells, when powered, are capable of not only bending light but also of bending heat, \" +\r\n \"making the user more resilient as well as stealthy.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's agility by 10%
\" +\r\n \"Increases the player's defense by 10%
\" +\r\n \"Increases the amount of money the player gains from crimes by 25%\"\r\n });\r\n LuminCloaking2.addToFactions([\"Slum Snakes\", \"Tetrads\"]);\r\n if (augmentationExists(AugmentationNames.LuminCloaking2)) {\r\n delete Augmentations[AugmentationNames.LuminCloaking2];\r\n }\r\n AddToAugmentations(LuminCloaking2);\r\n\r\n var SmartSonar = new Augmentation({\r\n name:AugmentationNames.SmartSonar, repCost:9e3, moneyCost:15e6,\r\n info:\"A cochlear implant that helps the player detect and locate enemies \" +\r\n \"using sound propagation.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's dexterity by 10%
\" +\r\n \"Increases the player's dexterity experience gain rate by 15%
\" +\r\n \"Increases the amount of money the player gains from crimes by 25%\"\r\n });\r\n SmartSonar.addToFactions([\"Slum Snakes\"]);\r\n if (augmentationExists(AugmentationNames.SmartSonar)) {\r\n delete Augmentations[AugmentationNames.SmartSonar];\r\n }\r\n AddToAugmentations(SmartSonar);\r\n\r\n var PowerRecirculator = new Augmentation({\r\n name:AugmentationNames.PowerRecirculator, repCost:10e3, moneyCost:36e6,\r\n info:\"The body's nerves are attached with polypyrrole nanocircuits that \" +\r\n \"are capable of capturing wasted energy (in the form of heat) \" +\r\n \"and converting it back into usable power.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's stats by 5%
\" +\r\n \"Increases the player's experience gain rate for all stats by 10%\"\r\n });\r\n PowerRecirculator.addToFactions([\"Tetrads\", \"The Dark Army\", \"The Syndicate\", \"NWO\"]);\r\n if (augmentationExists(AugmentationNames.PowerRecirculator)) {\r\n delete Augmentations[AugmentationNames.PowerRecirculator];\r\n }\r\n AddToAugmentations(PowerRecirculator);\r\n\r\n //Unique AUGS (Each Faction gets one unique augmentation)\r\n //Factions that already have unique augs up to this point:\r\n // Slum Snakes, CyberSec, Netburners, Fulcrum Secret Technologies,\r\n // Silhouette\r\n\r\n\t//Illuminati\r\n var QLink = new Augmentation({\r\n name:AugmentationNames.QLink, repCost:750e3, moneyCost:1300e6,\r\n info:\"A brain implant that wirelessly connects you to the Illuminati's \" +\r\n \"quantum supercomputer, allowing you to access and use its incredible \" +\r\n \"computing power.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking speed by 10%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 30%
\" +\r\n \"Increases the amount of money the player gains from hacking by 100%\"\r\n });\r\n QLink.addToFactions([\"Illuminati\"]);\r\n if (augmentationExists(AugmentationNames.QLink)) {\r\n delete Augmentations[AugmentationNames.QLink];\r\n }\r\n AddToAugmentations(QLink);\r\n\r\n\t//Daedalus\r\n var RedPill = new Augmentation({\r\n name:AugmentationNames.TheRedPill, repCost:1e6, moneyCost:0,\r\n info:\"It's time to leave the cave\"\r\n });\r\n RedPill.addToFactions([\"Daedalus\"]);\r\n if (augmentationExists(AugmentationNames.TheRedPill)) {\r\n delete Augmentations[AugmentationNames.TheRedPill];\r\n }\r\n AddToAugmentations(RedPill);\r\n\r\n\t//Covenant\r\n var SPTN97 = new Augmentation({\r\n name:AugmentationNames.SPTN97, repCost:500e3, moneyCost:975e6,\r\n info:\"The SPTN-97 gene is injected into the genome. The SPTN-97 gene is an \" +\r\n \"artificially-synthesized gene that was developed by DARPA to create \" +\r\n \"super-soldiers through genetic modification. The gene was outlawed in \" +\r\n \"2056.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's combat stats by 75%
\" +\r\n \"Increases the player's hacking skill by 15%\"\r\n });\r\n SPTN97.addToFactions([\"The Covenant\"]);\r\n if (augmentationExists(AugmentationNames.SPTN97)) {\r\n delete Augmentations[AugmentationNames.SPTN97];\r\n }\r\n AddToAugmentations(SPTN97);\r\n\r\n\t//ECorp\r\n var HiveMind = new Augmentation({\r\n name:AugmentationNames.HiveMind, repCost:600e3, moneyCost:1100e6,\r\n info:\"A brain implant developed by ECorp. They do not reveal what \" +\r\n \"exactly the implant does, but they promise that it will greatly \" +\r\n \"enhance your abilities.\"\r\n });\r\n HiveMind.addToFactions([\"ECorp\"]);\r\n if (augmentationExists(AugmentationNames.HiveMind)) {\r\n delete Augmentations[AugmentationNames.HiveMind];\r\n }\r\n AddToAugmentations(HiveMind);\r\n\r\n\t//MegaCorp\r\n var CordiARCReactor = new Augmentation({\r\n name:AugmentationNames.CordiARCReactor, repCost:450e3, moneyCost:1000e6,\r\n info:\"The thoracic cavity is equipped with a small chamber designed \" +\r\n \"to hold and sustain hydrogen plasma. The plasma is used to generate \" +\r\n \"fusion power through nuclear fusion, providing limitless amount of clean \" +\r\n \"energy for the body.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's combat stats by 35%
\" +\r\n \"Increases all of the player's combat stat experience gain rate by 35%\"\r\n });\r\n CordiARCReactor.addToFactions([\"MegaCorp\"]);\r\n if (augmentationExists(AugmentationNames.CordiARCReactor)) {\r\n delete Augmentations[AugmentationNames.CordiARCReactor];\r\n }\r\n AddToAugmentations(CordiARCReactor);\r\n\r\n\t//BachmanAndAssociates\r\n var SmartJaw = new Augmentation({\r\n name:AugmentationNames.SmartJaw, repCost:150e3, moneyCost:550e6,\r\n info:\"A bionic jaw that contains advanced hardware and software \" +\r\n \"capable of psychoanalyzing and profiling the personality of \" +\r\n \"others using optical imaging software.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's charisma by 50%.
\" +\r\n \"Increases the player's charisma experience gain rate by 50%
\" +\r\n \"Increases the amount of reputation the player gains for a company by 25%
\" +\r\n \"Increases the amount of reputation the player gains for a faction by 25%\"\r\n });\r\n SmartJaw.addToFactions([\"Bachman & Associates\"]);\r\n if (augmentationExists(AugmentationNames.SmartJaw)) {\r\n delete Augmentations[AugmentationNames.SmartJaw];\r\n }\r\n AddToAugmentations(SmartJaw);\r\n\r\n\t//BladeIndustries\r\n var Neotra = new Augmentation({\r\n name:AugmentationNames.Neotra, repCost:225e3, moneyCost:575e6,\r\n info:\"A highly-advanced techno-organic drug that is injected into the skeletal \" +\r\n \"and integumentary system. The drug permanently modifies the DNA of the \" +\r\n \"body's skin and bone cells, granting them the ability to repair \" +\r\n \"and restructure themselves.
\" +\r\n \"This augmentation increases the player's strength and defense by 55%\"\r\n });\r\n Neotra.addToFactions([\"Blade Industries\"]);\r\n if (augmentationExists(AugmentationNames.Neotra)) {\r\n delete Augmentations[AugmentationNames.Neotra];\r\n }\r\n AddToAugmentations(Neotra);\r\n\r\n\t//NWO\r\n var Xanipher = new Augmentation({\r\n name:AugmentationNames.Xanipher, repCost:350e3, moneyCost:850e6,\r\n info:\"A concoction of advanced nanobots that is orally ingested into the \" +\r\n \"body. These nanobots induce physiological change and significantly \" +\r\n \"improve the body's functionining in all aspects.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's stats by 20%
\" +\r\n \"Increases the player's experience gain rate for all stats by 15%\"\r\n });\r\n Xanipher.addToFactions([\"NWO\"]);\r\n if (augmentationExists(AugmentationNames.Xanipher)) {\r\n delete Augmentations[AugmentationNames.Xanipher];\r\n }\r\n AddToAugmentations(Xanipher);\r\n\r\n //ClarkeIncorporated\r\n var nextSENS = new Augmentation({\r\n name:AugmentationNames.nextSENS, repCost:175e3, moneyCost:385e6,\r\n info:\"The body is genetically re-engineered to maintain a state \" +\r\n \"of negligible senescence, preventing the body from \" +\r\n \"deteriorating with age.
\" +\r\n \"This augmentation increases all of the player's stats by 20%\"\r\n });\r\n nextSENS.addToFactions([\"Clarke Incorporated\"]);\r\n if (augmentationExists(AugmentationNames.nextSENS)) {\r\n delete Augmentations[AugmentationNames.nextSENS];\r\n }\r\n AddToAugmentations(nextSENS);\r\n\r\n\t//OmniTekIncorporated\r\n var OmniTekInfoLoad = new Augmentation({\r\n name:AugmentationNames.OmniTekInfoLoad, repCost:250e3, moneyCost:575e6,\r\n info:\"OmniTek's data and information repository is uploaded \" +\r\n \"into your brain, enhancing your programming and \" +\r\n \"hacking abilities.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking skill by 20%
\" +\r\n \"Increases the player's hacking experience gain rate by 25%\"\r\n });\r\n OmniTekInfoLoad.addToFactions([\"OmniTek Incorporated\"]);\r\n if (augmentationExists(AugmentationNames.OmniTekInfoLoad)) {\r\n delete Augmentations[AugmentationNames.OmniTekInfoLoad];\r\n }\r\n AddToAugmentations(OmniTekInfoLoad);\r\n\r\n\t//FourSigma\r\n //TODO Later when Intelligence is added in . Some aug that greatly increases int\r\n\r\n\t//KuaiGongInternational\r\n var PhotosyntheticCells = new Augmentation({\r\n name:AugmentationNames.PhotosyntheticCells, repCost:225e3, moneyCost:550e6,\r\n info:\"Chloroplasts are added to epidermal stem cells and are applied \" +\r\n \"to the body using a skin graft. The result is photosynthetic \" +\r\n \"skin cells, allowing users to generate their own energy \" +\r\n \"and nutrition using solar power.
\" +\r\n \"This augmentation increases the player's strength, defense, and agility by 40%\"\r\n });\r\n PhotosyntheticCells.addToFactions([\"KuaiGong International\"]);\r\n if (augmentationExists(AugmentationNames.PhotosyntheticCells)) {\r\n delete Augmentations[AugmentationNames.PhotosyntheticCells];\r\n }\r\n AddToAugmentations(PhotosyntheticCells);\r\n\r\n\t//BitRunners\r\n var Neurolink = new Augmentation({\r\n name:AugmentationNames.Neurolink, repCost:350e3, moneyCost:875e6,\r\n info:\"A brain implant that provides a high-bandwidth, direct neural link between your \" +\r\n \"mind and BitRunners' data servers, which reportedly contain \" +\r\n \"the largest database of hacking tools and information in the world.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's hacking skill by 15%
\" +\r\n \"Increases the player's hacking experience gain rate by 20%
\" +\r\n \"Increases the player's chance of successfully performing a hack by 10%
\" +\r\n \"Increases the player's hacking speed by 5%
\" +\r\n \"Lets the player start with the FTPCrack.exe and relaySMTP.exe programs after a reset\"\r\n });\r\n Neurolink.addToFactions([\"BitRunners\"]);\r\n if (augmentationExists(AugmentationNames.Neurolink)) {\r\n delete Augmentations[AugmentationNames.Neurolink];\r\n }\r\n AddToAugmentations(Neurolink);\r\n\r\n\t//BlackHand\r\n var TheBlackHand = new Augmentation({\r\n name:AugmentationNames.TheBlackHand, repCost:40e3, moneyCost:110e6,\r\n info:\"A highly advanced bionic hand. This prosthetic not only \" +\r\n \"enhances strength and dexterity but it is also embedded \" +\r\n \"with hardware and firmware that lets the user connect to, access and hack \" +\r\n \"devices and machines just by touching them.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's strength and dexterity by 15%
\" +\r\n \"Increases the player's hacking skill by 10%
\" +\r\n \"Increases the player's hacking speed by 2%
\" +\r\n \"Increases the amount of money the player gains from hacking by 10%\"\r\n });\r\n TheBlackHand.addToFactions([\"The Black Hand\"]);\r\n if (augmentationExists(AugmentationNames.TheBlackHand)) {\r\n delete Augmentations[AugmentationNames.TheBlackHand];\r\n }\r\n AddToAugmentations(TheBlackHand);\r\n\r\n\t//NiteSec\r\n var CRTX42AA = new Augmentation({\r\n name:AugmentationNames.CRTX42AA, repCost:18e3, moneyCost:45e6,\r\n info:\"The CRTX42-AA gene is injected into the genome. \" +\r\n \"The CRTX42-AA is an artificially-synthesized gene that targets the visual and prefrontal \" +\r\n \"cortex and improves cognitive abilities.
\" +\r\n \"This augmentation:
\" +\r\n \"Improves the player's hacking skill by 8%
\" +\r\n \"Improves the player's hacking experience gain rate by 15%\"\r\n });\r\n CRTX42AA.addToFactions([\"NiteSec\"]);\r\n if (augmentationExists(AugmentationNames.CRTX42AA)) {\r\n delete Augmentations[AugmentationNames.CRTX42AA];\r\n }\r\n AddToAugmentations(CRTX42AA);\r\n\r\n\t//Chongqing\r\n var Neuregen = new Augmentation({\r\n name:AugmentationNames.Neuregen, repCost:15e3, moneyCost:75e6,\r\n info:\"A drug that genetically modifies the neurons in the brain. \" +\r\n \"The result is that these neurons never die and continuously \" +\r\n \"regenerate and strengthen themselves.
\" +\r\n \"This augmentation increases the player's hacking experience gain rate by 40%\"\r\n });\r\n Neuregen.addToFactions([\"Chongqing\"]);\r\n if (augmentationExists(AugmentationNames.Neuregen)) {\r\n delete Augmentations[AugmentationNames.Neuregen];\r\n }\r\n AddToAugmentations(Neuregen);\r\n\r\n\t//Sector12\r\n var CashRoot = new Augmentation({\r\n name:AugmentationNames.CashRoot, repCost:5e3, moneyCost:25e6,\r\n info:\"A collection of digital assets saved on a small chip. The chip is implanted \" +\r\n \"into your wrist. A small jack in the chip allows you to connect it to a computer \" +\r\n \"and upload the assets.
\" +\r\n \"This augmentation:
\" +\r\n \"Lets the player start with $1,000,000 after a reset
\" +\r\n \"Lets the player start with the BruteSSH.exe program after a reset\"\r\n });\r\n CashRoot.addToFactions([\"Sector-12\"]);\r\n if (augmentationExists(AugmentationNames.CashRoot)) {\r\n delete Augmentations[AugmentationNames.CashRoot];\r\n }\r\n AddToAugmentations(CashRoot);\r\n\r\n\t//NewTokyo\r\n var NutriGen = new Augmentation({\r\n name:AugmentationNames.NutriGen, repCost:2500, moneyCost:500e3,\r\n info:\"A thermo-powered artificial nutrition generator. Endogenously \" +\r\n \"synthesizes glucose, amino acids, and vitamins and redistributes them \" +\r\n \"across the body. The device is powered by the body's naturally wasted \" +\r\n \"energy in the form of heat.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's experience gain rate for all combat stats by 20%\"\r\n });\r\n NutriGen.addToFactions([\"New Tokyo\"]);\r\n if (augmentationExists(AugmentationNames.NutriGen)) {\r\n delete Augmentations[AugmentationNames.NutriGen];\r\n }\r\n AddToAugmentations(NutriGen);\r\n\r\n\t//Aevum\r\n //TODO Later Something that lets you learn advanced math...this increases int\r\n //and profits as a trader/from trading\r\n\r\n //Ishima\r\n var INFRARet = new Augmentation({\r\n name:AugmentationNames.INFRARet, repCost:3e3, moneyCost:6e6,\r\n info:\"A retina implant consisting of a tiny chip that sits behind the \" +\r\n \"retina. This implant lets people visually detect infrared radiation.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's crime success rate by 25%
\" +\r\n \"Increases the amount of money the player gains from crimes by 10%
\" +\r\n \"Increases the player's dexterity by 10%\"\r\n });\r\n INFRARet.addToFactions([\"Ishima\"]);\r\n if (augmentationExists(AugmentationNames.INFRARet)) {\r\n delete Augmentations[AugmentationNames.INFRARet];\r\n }\r\n AddToAugmentations(INFRARet);\r\n\r\n\t//Volhaven\r\n var DermaForce = new Augmentation({\r\n name:AugmentationNames.DermaForce, repCost:6e3, moneyCost:10e6,\r\n info:\"A synthetic skin is grafted onto the body. The skin consists of \" +\r\n \"millions of nanobots capable of projecting high-density muon beams, \" +\r\n \"creating an energy barrier around the user.
\" +\r\n \"This augmentation increases the player's defense by 40%\"\r\n });\r\n DermaForce.addToFactions([\"Volhaven\"]);\r\n if (augmentationExists(AugmentationNames.DermaForce)) {\r\n delete Augmentations[AugmentationNames.DermaForce];\r\n }\r\n AddToAugmentations(DermaForce);\r\n\r\n\t//SpeakersForTheDead\r\n var GrapheneBrachiBlades = new Augmentation({\r\n name:AugmentationNames.GrapheneBrachiBlades, repCost:90e3, moneyCost:500e6,\r\n info:\"An upgrade to the BrachiBlades augmentation. It infuses \" +\r\n \"the retractable blades with an advanced graphene material \" +\r\n \"to make them much stronger and lighter.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's strength and defense by 40%
\" +\r\n \"Increases the player's crime success rate by 10%
\" +\r\n \"Increases the amount of money the player gains from crimes by 30%\",\r\n prereqs:[AugmentationNames.BrachiBlades],\r\n });\r\n GrapheneBrachiBlades.addToFactions([\"Speakers for the Dead\"]);\r\n if (augmentationExists(AugmentationNames.GrapheneBrachiBlades)) {\r\n delete Augmentations[AugmentationNames.GrapheneBrachiBlades];\r\n }\r\n AddToAugmentations(GrapheneBrachiBlades);\r\n\r\n\t//DarkArmy\r\n var GrapheneBionicArms = new Augmentation({\r\n name:AugmentationNames.GrapheneBionicArms, repCost:200e3, moneyCost:750e6,\r\n info:\"An upgrade to the Bionic Arms augmentation. It infuses the \" +\r\n \"prosthetic arms with an advanced graphene material \" +\r\n \"to make them much stronger and lighter.
\" +\r\n \"This augmentation increases the player's strength and dexterity by 85%\",\r\n prereqs:[AugmentationNames.BionicArms],\r\n });\r\n GrapheneBionicArms.addToFactions([\"The Dark Army\"]);\r\n if (augmentationExists(AugmentationNames.GrapheneBionicArms)) {\r\n delete Augmentations[AugmentationNames.GrapheneBionicArms];\r\n }\r\n AddToAugmentations(GrapheneBionicArms);\r\n\r\n\t//TheSyndicate\r\n var BrachiBlades = new Augmentation({\r\n name:AugmentationNames.BrachiBlades, repCost:5e3, moneyCost:18e6,\r\n info:\"A set of retractable plasteel blades are implanted in the arm, underneath the skin. \" +\r\n \"
This augmentation:
\" +\r\n \"Increases the player's strength and defense by 15%
\" +\r\n \"Increases the player's crime success rate by 10%
\" +\r\n \"Increases the amount of money the player gains from crimes by 15%\"\r\n });\r\n BrachiBlades.addToFactions([\"The Syndicate\"]);\r\n if (augmentationExists(AugmentationNames.BrachiBlades)) {\r\n delete Augmentations[AugmentationNames.BrachiBlades];\r\n }\r\n AddToAugmentations(BrachiBlades);\r\n\r\n //Tetrads\r\n var BionicArms = new Augmentation({\r\n name:AugmentationNames.BionicArms, repCost:25e3, moneyCost:55e6,\r\n info:\"Cybernetic arms created from plasteel and carbon fibers that completely replace \" +\r\n \"the user's organic arms.
\" +\r\n \"This augmentation increases the user's strength and dexterity by 30%\"\r\n });\r\n BionicArms.addToFactions([\"Tetrads\"]);\r\n if (augmentationExists(AugmentationNames.BionicArms)) {\r\n delete Augmentations[AugmentationNames.BionicArms];\r\n }\r\n AddToAugmentations(BionicArms);\r\n\r\n\t//TianDiHui\r\n var SNA = new Augmentation({\r\n name:AugmentationNames.SNA, repCost:2500, moneyCost:6e6,\r\n info:\"A cranial implant that affects the user's personality, making them better \" +\r\n \"at negotiation in social situations.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the amount of money the player earns at a company by 10%
\" +\r\n \"Increases the amount of reputation the player gains when working for a \" +\r\n \"company or faction by 15%\"\r\n });\r\n SNA.addToFactions([\"Tian Di Hui\"]);\r\n if (augmentationExists(AugmentationNames.SNA)) {\r\n delete Augmentations[AugmentationNames.SNA];\r\n }\r\n AddToAugmentations(SNA);\r\n\r\n //For BitNode-2, add all Augmentations to crime/evil factions.\r\n //Do this before adding special Augmentations that become available in later BitNodes\r\n if (Player.bitNodeN === 2) {\r\n console.log(\"Adding all augmentations to crime factions for Bit node 2\");\r\n Factions[\"Slum Snakes\"].addAllAugmentations();\r\n Factions[\"Tetrads\"].addAllAugmentations();\r\n Factions[\"The Syndicate\"].addAllAugmentations();\r\n Factions[\"The Dark Army\"].addAllAugmentations();\r\n Factions[\"Speakers for the Dead\"].addAllAugmentations();\r\n Factions[\"NiteSec\"].addAllAugmentations();\r\n Factions[\"The Black Hand\"].addAllAugmentations();\r\n }\r\n\r\n //Special Bladeburner Augmentations\r\n var BladeburnersFactionName = \"Bladeburners\";\r\n if (factionExists(BladeburnersFactionName)) {\r\n var EsperEyewear = new Augmentation({\r\n name:AugmentationNames.EsperEyewear, repCost:500, moneyCost:33e6,\r\n info:\"Ballistic-grade protective and retractable eyewear that was designed specially \" +\r\n \"for Bladeburner units. This \" +\r\n \"is implanted by installing a mechanical frame in the skull's orbit. \" +\r\n \"This frame interfaces with the brain and allows the user to \" +\r\n \"automatically extrude and extract the eyewear. The eyewear protects \" +\r\n \"against debris, shrapnel, laser, flash, and gas. It is also \" +\r\n \"embedded with a data processing chip that can be programmed to display an \" +\r\n \"AR HUD and assist the user in field missions.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 3%
\" +\r\n \"Increases the player's dexterity by 3%\"\r\n });\r\n EsperEyewear.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(EsperEyewear);\r\n\r\n var EMS4Recombination = new Augmentation({\r\n name:AugmentationNames.EMS4Recombination, repCost: 1e3, moneyCost:55e6,\r\n info:\"A DNA recombination of the EMS-4 Gene. This genetic engineering \" +\r\n \"technique was originally used on Bladeburners during the Synthoid uprising \" +\r\n \"to induce wakefulness and concentration, suppress fear, reduce empathy, and \" +\r\n \"improve reflexes and memory-recall among other things.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's sucess chance in Bladeburner contracts/operations by 3%
\" +\r\n \"Increases the player's effectiveness in Bladeburner Field Analysis by 5%
\" +\r\n \"Increases the player's Bladeburner stamina gain rate by 1%\"\r\n });\r\n EMS4Recombination.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(EMS4Recombination);\r\n\r\n var OrionShoulder = new Augmentation({\r\n name:AugmentationNames.OrionShoulder, repCost:2.5e3, moneyCost:110e6,\r\n info:\"A bionic shoulder augmentation for the right shoulder. Using cybernetics, \" +\r\n \"the ORION-MKIV shoulder enhances the strength and dexterity \" +\r\n \"of the user's right arm. It also provides protection due to its \" +\r\n \"crystallized graphene plating.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's defense by 5%.
\" +\r\n \"Increases the player's strength and dexterity by 3%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 4%\"\r\n });\r\n OrionShoulder.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(OrionShoulder);\r\n\r\n var HyperionV1 = new Augmentation({\r\n name:AugmentationNames.HyperionV1, repCost: 5e3, moneyCost:550e6,\r\n info:\"A pair of mini plasma cannons embedded into the hands. The Hyperion is capable \" +\r\n \"of rapidly firing bolts of high-density plasma. The weapon is meant to \" +\r\n \"be used against augmented enemies as the ionized \" +\r\n \"nature of the plasma disrupts the electrical systems of Augmentations. However, \" +\r\n \"it can also be effective against non-augmented enemies due to its high temperature \" +\r\n \"and concussive force.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 5%\"\r\n });\r\n HyperionV1.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(HyperionV1);\r\n\r\n var HyperionV2 = new Augmentation({\r\n name:AugmentationNames.HyperionV2, repCost:10e3, moneyCost:1.1e9,\r\n info:\"A pair of mini plasma cannons embedded into the hands. This augmentation \" +\r\n \"is more advanced and powerful than the original V1 model. This V2 model is \" +\r\n \"more power-efficiency, more accurate, and can fire plasma bolts at a much \" +\r\n \"higher velocity than the V1 model.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 7%\",\r\n prereqs:[AugmentationNames.HyperionV1]\r\n });\r\n HyperionV2.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(HyperionV2);\r\n\r\n var GolemSerum = new Augmentation({\r\n name:AugmentationNames.GolemSerum, repCost:12.5e3, moneyCost:2.2e9,\r\n info:\"A serum that permanently enhances many aspects of a human's capabilities, \" +\r\n \"including strength, speed, immune system performance, and mitochondrial efficiency. The \" +\r\n \"serum was originally developed by the Chinese military in an attempt to \" +\r\n \"create super soldiers.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's combat stats by 5%
\" +\r\n \"Increases the player's Bladeburner stamina gain rate by 5%
\"\r\n });\r\n GolemSerum.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(GolemSerum);\r\n\r\n var VangelisVirus = new Augmentation({\r\n name:AugmentationNames.VangelisVirus, repCost:7.5e3, moneyCost:550e6,\r\n info:\"A synthetic symbiotic virus that is injected into the human brain tissue. The Vangelis virus \" +\r\n \"heightens the senses and focus of its host, and also enhances its intuition.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's effectiveness in Bladeburner Field Analysis by 10%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 4%
\" +\r\n \"Increases the player's dexterity experience gain rate by 5%\"\r\n });\r\n VangelisVirus.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(VangelisVirus);\r\n\r\n var VangelisVirus3 = new Augmentation({\r\n name:AugmentationNames.VangelisVirus3, repCost:15e3, moneyCost:2.2e9,\r\n info:\"An improved version of Vangelis, a synthetic symbiotic virus that is \" +\r\n \"injected into the human brain tissue. On top of the benefits of the original \" +\r\n \"virus, this also grants an accelerated healing factor and enhanced \" +\r\n \"agility/reflexes.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's effectiveness in Bladeburner Field Analysis by 15%
\" +\r\n \"Increases the player's defense and dexterity experience gain rate by 5%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 5%\",\r\n prereqs:[AugmentationNames.VangelisVirus]\r\n });\r\n VangelisVirus3.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(VangelisVirus3);\r\n\r\n var INTERLINKED = new Augmentation({\r\n name:AugmentationNames.INTERLINKED, repCost:10e3, moneyCost:1.1e9,\r\n info:\"The DNA is genetically modified to enhance the human's body \" +\r\n \"extracellular matrix (ECM). This improves the ECM's ability to \" +\r\n \"structurally support the body and grants heightened strength and \" +\r\n \"durability.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's experience gain rate for all combat stats by 4%
\" +\r\n \"Increases the player's Bladeburner max stamina by 10%\"\r\n });\r\n INTERLINKED.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(INTERLINKED);\r\n\r\n var BladeRunner = new Augmentation({\r\n name:AugmentationNames.BladeRunner, repCost:8e3, moneyCost:1.65e9,\r\n info:\"A cybernetic foot augmentation that was specially created for Bladeburners \" +\r\n \"during the Synthoid Uprising. The organic musculature of the human foot \" +\r\n \"is enhanced with flexible carbon nanotube matrices that are controlled by \" +\r\n \"intelligent servo-motors.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's agility by 5%
\" +\r\n \"Increases the player's Bladeburner max stamina by 5%
\" +\r\n \"Increases the player's Bladeburner stamina gain rate by 5%
\"\r\n });\r\n BladeRunner.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeRunner);\r\n\r\n var BladeArmor = new Augmentation({\r\n name:AugmentationNames.BladeArmor, repCost:5e3, moneyCost:275e6,\r\n info:\"A powered exoskeleton suit (exosuit) designed as armor for Bladeburner units. This \" +\r\n \"exoskeleton is incredibly adaptable and can protect the wearer from blunt, piercing, \" +\r\n \"concussive, thermal, chemical, and electric trauma. It also enhances the user's \" +\r\n \"strength and agility.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases all of the player's combat stats by 2%
\" +\r\n \"Increases the player's Bladeburner stamina gain rate by 2%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 3%\",\r\n });\r\n BladeArmor.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmor);\r\n\r\n var BladeArmorPowerCells = new Augmentation({\r\n name:AugmentationNames.BladeArmorPowerCells, repCost:7.5e3, moneyCost:550e6,\r\n info:\"Upgrades the BLADE-51b Tesla Armor with Ion Power Cells, which are capable of \" +\r\n \"more efficiently storing and using power.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 5%\" +\r\n \"Increases the player's Bladeburner stamina gain rate by 2%
\" +\r\n \"Increases the player's Bladeburner max stamina by 5%
\",\r\n prereqs:[AugmentationNames.BladeArmor]\r\n });\r\n BladeArmorPowerCells.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmorPowerCells);\r\n\r\n var BladeArmorEnergyShielding = new Augmentation({\r\n name:AugmentationNames.BladeArmorEnergyShielding, repCost:8.5e3, moneyCost:1.1e9,\r\n info:\"Upgrades the BLADE-51b Tesla Armor with a plasma energy propulsion system \" +\r\n \"that is capable of projecting an energy shielding force field.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's defense by 5%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 6%\",\r\n prereqs:[AugmentationNames.BladeArmor]\r\n });\r\n BladeArmorEnergyShielding.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmorEnergyShielding);\r\n\r\n var BladeArmorUnibeam = new Augmentation({\r\n name:AugmentationNames.BladeArmorUnibeam, repCost:12.5e3, moneyCost:3.3e9,\r\n info:\"Upgrades the BLADE-51b Tesla Armor with a concentrated deuterium-fluoride laser \" +\r\n \"weapon. It's precision an accuracy makes it useful for quickly neutralizing \" +\r\n \"threats while keeping casualties to a minimum.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 8%\",\r\n prereqs:[AugmentationNames.BladeArmor]\r\n });\r\n BladeArmorUnibeam.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmorUnibeam);\r\n\r\n var BladeArmorOmnibeam = new Augmentation({\r\n name:AugmentationNames.BladeArmorOmnibeam, repCost:25e3, moneyCost:5.5e9,\r\n info:\"Upgrades the BLADE-51b Tesla Armor Unibeam augmentation to use \" +\r\n \"multiple-fiber system. The upgraded weapon uses multiple fiber laser \" +\r\n \"modules that combine together to form a single, more powerful beam of up to \" +\r\n \"2000MW.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 10%\",\r\n prereqs:[AugmentationNames.BladeArmorUnibeam]\r\n });\r\n BladeArmorOmnibeam.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmorOmnibeam);\r\n\r\n var BladeArmorIPU = new Augmentation({\r\n name:AugmentationNames.BladeArmorIPU, repCost: 6e3, moneyCost:220e6,\r\n info:\"Upgrades the BLADE-51b Tesla Armor with an AI Information Processing \" +\r\n \"Unit that was specially designed to analyze Synthoid related data and \" +\r\n \"information.
\" +\r\n \"This augmentation:
\" +\r\n \"Increases the player's effectiveness in Bladeburner Field Analysis by 15%
\" +\r\n \"Increases the player's success chance in Bladeburner contracts/operations by 2%\",\r\n prereqs:[AugmentationNames.BladeArmor]\r\n });\r\n BladeArmorIPU.addToFactions([BladeburnersFactionName]);\r\n resetAugmentation(BladeArmorIPU);\r\n }\r\n\r\n //Update costs based on how many have been purchased\r\n var mult = Math.pow(CONSTANTS.MultipleAugMultiplier, Player.queuedAugmentations.length);\r\n for (var name in Augmentations) {\r\n if (Augmentations.hasOwnProperty(name)) {\r\n Augmentations[name].baseCost *= mult;\r\n }\r\n }\r\n\r\n Player.reapplyAllAugmentations();\r\n\r\n\r\n}\r\n\r\n//Resets an Augmentation during (re-initizliation)\r\nfunction resetAugmentation(newAugObject) {\r\n if (!(newAugObject instanceof Augmentation)) {\r\n throw new Error(\"Invalid argument 'newAugObject' passed into resetAugmentation\");\r\n }\r\n var name = newAugObject.name;\r\n if (augmentationExists(name)) {\r\n delete Augmentations[name];\r\n }\r\n AddToAugmentations(newAugObject);\r\n}\r\n\r\nfunction applyAugmentation(aug, reapply=false) {\r\n Augmentations[aug.name].owned = true;\r\n switch(aug.name) {\r\n //Combat stat augmentations\r\n case AugmentationNames.Targeting1:\r\n Player.dexterity_mult *= 1.10;\r\n break;\r\n case AugmentationNames.Targeting2:\r\n Player.dexterity_mult *= 1.20;\r\n break;\r\n case AugmentationNames.Targeting3:\r\n Player.dexterity_mult *= 1.30;\r\n break;\r\n case AugmentationNames.SyntheticHeart: //High level\r\n Player.agility_mult *= 1.5;\r\n Player.strength_mult *= 1.5;\r\n break;\r\n case AugmentationNames.SynfibrilMuscle: //Medium-high level\r\n Player.strength_mult *= 1.3;\r\n Player.defense_mult *= 1.3;\r\n break;\r\n case AugmentationNames.CombatRib1:\r\n Player.strength_mult *= 1.1;\r\n Player.defense_mult *= 1.1;\r\n break;\r\n case AugmentationNames.CombatRib2:\r\n Player.strength_mult *= 1.14;\r\n Player.defense_mult *= 1.14;\r\n break;\r\n case AugmentationNames.CombatRib3:\r\n Player.strength_mult *= 1.18;\r\n Player.defense_mult *= 1.18;\r\n break;\r\n case AugmentationNames.NanofiberWeave: //Med level\r\n Player.strength_mult *= 1.2;\r\n Player.defense_mult *= 1.2;\r\n break;\r\n case AugmentationNames.SubdermalArmor: //High level\r\n Player.defense_mult *= 2.2;\r\n break;\r\n case AugmentationNames.WiredReflexes: //Low level\r\n Player.agility_mult *= 1.05;\r\n Player.dexterity_mult *= 1.05;\r\n break;\r\n case AugmentationNames.GrapheneBoneLacings: //High level\r\n Player.strength_mult *= 1.7;\r\n Player.defense_mult *= 1.7;\r\n break;\r\n case AugmentationNames.BionicSpine: //Med level\r\n Player.strength_mult *= 1.15;\r\n Player.defense_mult *= 1.15;\r\n Player.agility_mult *= 1.15;\r\n Player.dexterity_mult *= 1.15;\r\n break;\r\n case AugmentationNames.GrapheneBionicSpine: //High level\r\n Player.strength_mult *= 1.6;\r\n Player.defense_mult *= 1.6;\r\n Player.agility_mult *= 1.6;\r\n Player.dexterity_mult *= 1.6;\r\n break;\r\n case AugmentationNames.BionicLegs: //Med level\r\n Player.agility_mult *= 1.6;\r\n break;\r\n case AugmentationNames.GrapheneBionicLegs: //High level\r\n Player.agility_mult *= 2.5;\r\n break;\r\n\r\n //Labor stats augmentations\r\n case AugmentationNames.EnhancedSocialInteractionImplant: //Med-high level\r\n Player.charisma_mult *= 1.6;\r\n Player.charisma_exp_mult *= 1.6;\r\n break;\r\n case AugmentationNames.TITN41Injection:\r\n Player.charisma_mult *= 1.15;\r\n Player.charisma_exp_mult *= 1.15;\r\n break;\r\n case AugmentationNames.SpeechProcessor: //Med level\r\n Player.charisma_mult *= 1.2;\r\n break;\r\n\r\n //Hacking augmentations\r\n case AugmentationNames.BitWire:\r\n Player.hacking_mult *= 1.05;\r\n break;\r\n case AugmentationNames.ArtificialBioNeuralNetwork: //Med level\r\n Player.hacking_speed_mult *= 1.03;\r\n Player.hacking_money_mult *= 1.15;\r\n Player.hacking_mult *= 1.12;\r\n break;\r\n case AugmentationNames.ArtificialSynapticPotentiation: //Med level\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_chance_mult *= 1.05;\r\n Player.hacking_exp_mult *= 1.05;\r\n break;\r\n case AugmentationNames.EnhancedMyelinSheathing: //Med level\r\n Player.hacking_speed_mult *= 1.03;\r\n Player.hacking_exp_mult *= 1.1;\r\n Player.hacking_mult *= 1.08;\r\n break;\r\n case AugmentationNames.SynapticEnhancement: //Low Level\r\n Player.hacking_speed_mult *= 1.03;\r\n break;\r\n case AugmentationNames.NeuralRetentionEnhancement: //Med level\r\n Player.hacking_exp_mult *= 1.25;\r\n break;\r\n case AugmentationNames.DataJack: //Med low level\r\n Player.hacking_money_mult *= 1.25;\r\n break;\r\n case AugmentationNames.ENM: //Medium level\r\n Player.hacking_mult *= 1.08;\r\n break;\r\n case AugmentationNames.ENMCore: //Medium level\r\n Player.hacking_speed_mult *= 1.03;\r\n Player.hacking_money_mult *= 1.1;\r\n Player.hacking_chance_mult *= 1.03;\r\n Player.hacking_exp_mult *= 1.07;\r\n Player.hacking_mult *= 1.07;\r\n break;\r\n case AugmentationNames.ENMCoreV2: //Medium high level\r\n Player.hacking_speed_mult *= 1.05;\r\n Player.hacking_money_mult *= 1.3;\r\n Player.hacking_chance_mult *= 1.05;\r\n Player.hacking_exp_mult *= 1.15;\r\n Player.hacking_mult *= 1.08;\r\n break;\r\n case AugmentationNames.ENMCoreV3: //High level\r\n Player.hacking_speed_mult *= 1.05;\r\n Player.hacking_money_mult *= 1.4;\r\n Player.hacking_chance_mult *= 1.1;\r\n Player.hacking_exp_mult *= 1.25;\r\n Player.hacking_mult *= 1.1;\r\n break;\r\n case AugmentationNames.ENMAnalyzeEngine: //High level\r\n Player.hacking_speed_mult *= 1.1;\r\n break;\r\n case AugmentationNames.ENMDMA: //High level\r\n Player.hacking_money_mult *= 1.4;\r\n Player.hacking_chance_mult *= 1.2;\r\n break;\r\n case AugmentationNames.Neuralstimulator: //Medium Level\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_chance_mult *= 1.1;\r\n Player.hacking_exp_mult *= 1.12;\r\n break;\r\n case AugmentationNames.NeuralAccelerator:\r\n Player.hacking_mult *= 1.1;\r\n Player.hacking_exp_mult *= 1.15;\r\n Player.hacking_money_mult *= 1.2;\r\n break;\r\n case AugmentationNames.CranialSignalProcessorsG1:\r\n Player.hacking_speed_mult *= 1.01;\r\n Player.hacking_mult *= 1.05;\r\n break;\r\n case AugmentationNames.CranialSignalProcessorsG2:\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_chance_mult *= 1.05;\r\n Player.hacking_mult *= 1.07;\r\n break;\r\n case AugmentationNames.CranialSignalProcessorsG3:\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_money_mult *= 1.15;\r\n Player.hacking_mult *= 1.09;\r\n break;\r\n case AugmentationNames.CranialSignalProcessorsG4:\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_money_mult *= 1.2;\r\n Player.hacking_grow_mult *= 1.25;\r\n break;\r\n case AugmentationNames.CranialSignalProcessorsG5:\r\n Player.hacking_mult *= 1.3;\r\n Player.hacking_money_mult *= 1.25;\r\n Player.hacking_grow_mult *= 1.75;\r\n break;\r\n case AugmentationNames.NeuronalDensification:\r\n Player.hacking_mult *= 1.15;\r\n Player.hacking_exp_mult *= 1.1;\r\n Player.hacking_speed_mult *= 1.03;\r\n break;\r\n\r\n //Work augmentations\r\n case AugmentationNames.NuoptimalInjectorImplant: //Low medium level\r\n Player.company_rep_mult *= 1.2;\r\n break;\r\n case AugmentationNames.SpeechEnhancement: //Low level\r\n Player.company_rep_mult *= 1.1;\r\n Player.charisma_mult *= 1.1;\r\n break;\r\n case AugmentationNames.FocusWire: //Med level\r\n Player.hacking_exp_mult *= 1.05;\r\n Player.strength_exp_mult *= 1.05;\r\n Player.defense_exp_mult *= 1.05;\r\n Player.dexterity_exp_mult *= 1.05;\r\n Player.agility_exp_mult *= 1.05;\r\n Player.charisma_exp_mult *= 1.05;\r\n Player.company_rep_mult *= 1.1;\r\n Player.work_money_mult *= 1.2;\r\n break;\r\n case AugmentationNames.PCDNI: //Med level\r\n Player.company_rep_mult *= 1.3;\r\n Player.hacking_mult *= 1.08;\r\n break;\r\n case AugmentationNames.PCDNIOptimizer: //High level\r\n Player.company_rep_mult *= 1.75;\r\n Player.hacking_mult *= 1.1;\r\n break;\r\n case AugmentationNames.PCDNINeuralNetwork: //High level\r\n Player.company_rep_mult *= 2;\r\n Player.hacking_mult *= 1.1;\r\n Player.hacking_speed_mult *= 1.05;\r\n break;\r\n case AugmentationNames.ADRPheromone1:\r\n Player.company_rep_mult *= 1.1;\r\n Player.faction_rep_mult *= 1.1;\r\n break;\r\n case AugmentationNames.ADRPheromone2:\r\n Player.company_rep_mult *= 1.2;\r\n Player.faction_rep_mult *= 1.2;\r\n break;\r\n\r\n //Hacknet Node Augmentations\r\n case AugmentationNames.HacknetNodeCPUUpload:\r\n Player.hacknet_node_money_mult *= 1.15;\r\n Player.hacknet_node_purchase_cost_mult *= 0.85;\r\n break;\r\n case AugmentationNames.HacknetNodeCacheUpload:\r\n Player.hacknet_node_money_mult *= 1.10;\r\n Player.hacknet_node_level_cost_mult *= 0.85;\r\n break;\r\n case AugmentationNames.HacknetNodeNICUpload:\r\n Player.hacknet_node_money_mult *= 1.1;\r\n Player.hacknet_node_purchase_cost_mult *= 0.9;\r\n break;\r\n case AugmentationNames.HacknetNodeKernelDNI:\r\n Player.hacknet_node_money_mult *= 1.25;\r\n break;\r\n case AugmentationNames.HacknetNodeCoreDNI:\r\n Player.hacknet_node_money_mult *= 1.45;\r\n break;\r\n\r\n //Misc augmentations\r\n case AugmentationNames.NeuroFluxGovernor:\r\n Player.hacking_chance_mult *= 1.01;\r\n Player.hacking_speed_mult *= 1.01;\r\n Player.hacking_money_mult *= 1.01;\r\n Player.hacking_grow_mult *= 1.01;\r\n Player.hacking_mult *= 1.01;\r\n\r\n Player.strength_mult *= 1.01;\r\n Player.defense_mult *= 1.01;\r\n Player.dexterity_mult *= 1.01;\r\n Player.agility_mult *= 1.01;\r\n Player.charisma_mult *= 1.01;\r\n\r\n Player.hacking_exp_mult *= 1.01;\r\n Player.strength_exp_mult *= 1.01;\r\n Player.defense_exp_mult *= 1.01;\r\n Player.dexterity_exp_mult *= 1.01;\r\n Player.agility_exp_mult *= 1.01;\r\n Player.charisma_exp_mult *= 1.01;\r\n\r\n Player.company_rep_mult *= 1.01;\r\n Player.faction_rep_mult *= 1.01;\r\n\r\n Player.crime_money_mult *= 1.01;\r\n Player.crime_success_mult *= 1.01;\r\n\r\n Player.hacknet_node_money_mult *= 1.01;\r\n Player.hacknet_node_purchase_cost_mult *= 0.99;\r\n Player.hacknet_node_ram_cost_mult *= 0.99;\r\n Player.hacknet_node_core_cost_mult *= 0.99;\r\n Player.hacknet_node_level_cost_mult *= 0.99;\r\n\r\n Player.work_money_mult *= 1.01;\r\n\r\n if (!reapply) {\r\n Augmentations[aug.name].level = aug.level;\r\n for (var i = 0; i < Player.augmentations.length; ++i) {\r\n if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {\r\n Player.augmentations[i].level = aug.level;\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n case AugmentationNames.Neurotrainer1: //Low Level\r\n Player.hacking_exp_mult *= 1.1;\r\n Player.strength_exp_mult *= 1.1;\r\n Player.defense_exp_mult *= 1.1;\r\n Player.dexterity_exp_mult *= 1.1;\r\n Player.agility_exp_mult *= 1.1;\r\n Player.charisma_exp_mult *= 1.1;\r\n break;\r\n case AugmentationNames.Neurotrainer2: //Medium level\r\n Player.hacking_exp_mult *= 1.15;\r\n Player.strength_exp_mult *= 1.15;\r\n Player.defense_exp_mult *= 1.15;\r\n Player.dexterity_exp_mult *= 1.15;\r\n Player.agility_exp_mult *= 1.15;\r\n Player.charisma_exp_mult *= 1.15;\r\n break;\r\n case AugmentationNames.Neurotrainer3: //High Level\r\n Player.hacking_exp_mult *= 1.2;\r\n Player.strength_exp_mult *= 1.2;\r\n Player.defense_exp_mult *= 1.2;\r\n Player.dexterity_exp_mult *= 1.2;\r\n Player.agility_exp_mult *= 1.2;\r\n Player.charisma_exp_mult *= 1.2;\r\n break;\r\n case AugmentationNames.Hypersight: //Medium high level\r\n Player.dexterity_mult *= 1.4;\r\n Player.hacking_speed_mult *= 1.03;\r\n Player.hacking_money_mult *= 1.1;\r\n break;\r\n case AugmentationNames.LuminCloaking1:\r\n Player.agility_mult *= 1.05;\r\n Player.crime_money_mult *= 1.1;\r\n break;\r\n case AugmentationNames.LuminCloaking2:\r\n Player.agility_mult *= 1.1;\r\n Player.defense_mult *= 1.1;\r\n Player.crime_money_mult *= 1.25;\r\n break;\r\n case AugmentationNames.HemoRecirculator:\r\n Player.strength_mult *= 1.08;\r\n Player.defense_mult *= 1.08;\r\n Player.agility_mult *= 1.08;\r\n Player.dexterity_mult *= 1.08;\r\n break;\r\n case AugmentationNames.SmartSonar:\r\n Player.dexterity_mult *= 1.1;\r\n Player.dexterity_exp_mult *= 1.15;\r\n Player.crime_money_mult *= 1.25;\r\n break;\r\n case AugmentationNames.PowerRecirculator:\r\n Player.hacking_mult *= 1.05;\r\n Player.strength_mult *= 1.05;\r\n Player.defense_mult *= 1.05;\r\n Player.dexterity_mult *= 1.05;\r\n Player.agility_mult *= 1.05;\r\n Player.charisma_mult *= 1.05;\r\n Player.hacking_exp_mult *= 1.1;\r\n Player.strength_exp_mult *= 1.1;\r\n Player.defense_exp_mult *= 1.1;\r\n Player.dexterity_exp_mult *= 1.1;\r\n Player.agility_exp_mult *= 1.1;\r\n Player.charisma_exp_mult *= 1.1;\r\n break;\r\n //Unique augmentations (for factions)\r\n case AugmentationNames.QLink:\r\n Player.hacking_speed_mult *= 1.1;\r\n Player.hacking_chance_mult *= 1.3;\r\n Player.hacking_money_mult *= 2;\r\n break;\r\n case AugmentationNames.TheRedPill:\r\n break;\r\n case AugmentationNames.SPTN97:\r\n Player.strength_mult *= 1.75;\r\n Player.defense_mult *= 1.75;\r\n Player.dexterity_mult *= 1.75;\r\n Player.agility_mult *= 1.75;\r\n Player.hacking_mult *= 1.15;\r\n break;\r\n case AugmentationNames.HiveMind:\r\n Player.hacking_grow_mult *= 3;\r\n break;\r\n case AugmentationNames.CordiARCReactor:\r\n Player.strength_mult *= 1.35;\r\n Player.defense_mult *= 1.35;\r\n Player.dexterity_mult *= 1.35;\r\n Player.agility_mult *= 1.35;\r\n Player.strength_exp_mult *= 1.35;\r\n Player.defense_exp_mult *= 1.35;\r\n Player.dexterity_exp_mult *= 1.35;\r\n Player.agility_exp_mult *= 1.35;\r\n break;\r\n case AugmentationNames.SmartJaw:\r\n Player.charisma_mult *= 1.5;\r\n Player.charisma_exp_mult *= 1.5;\r\n Player.company_rep_mult *= 1.25;\r\n Player.faction_rep_mult *= 1.25;\r\n break;\r\n case AugmentationNames.Neotra:\r\n Player.strength_mult *= 1.55;\r\n Player.defense_mult *= 1.55;\r\n break;\r\n case AugmentationNames.Xanipher:\r\n Player.hacking_mult *= 1.2;\r\n Player.strength_mult *= 1.2;\r\n Player.defense_mult *= 1.2;\r\n Player.dexterity_mult *= 1.2;\r\n Player.agility_mult *= 1.2;\r\n Player.charisma_mult *= 1.2;\r\n Player.hacking_exp_mult *= 1.15;\r\n Player.strength_exp_mult *= 1.15;\r\n Player.defense_exp_mult *= 1.15;\r\n Player.dexterity_exp_mult *= 1.15;\r\n Player.agility_exp_mult *= 1.15;\r\n Player.charisma_exp_mult *= 1.15;\r\n break;\r\n case AugmentationNames.nextSENS:\r\n Player.hacking_mult *= 1.2;\r\n Player.strength_mult *= 1.2;\r\n Player.defense_mult *= 1.2;\r\n Player.dexterity_mult *= 1.2;\r\n Player.agility_mult *= 1.2;\r\n Player.charisma_mult *= 1.2;\r\n break;\r\n case AugmentationNames.OmniTekInfoLoad:\r\n Player.hacking_mult *= 1.2;\r\n Player.hacking_exp_mult *= 1.25;\r\n break;\r\n case AugmentationNames.PhotosyntheticCells:\r\n Player.strength_mult *= 1.4;\r\n Player.defense_mult *= 1.4;\r\n Player.agility_mult *= 1.4;\r\n break;\r\n case AugmentationNames.Neurolink:\r\n Player.hacking_mult *= 1.15;\r\n Player.hacking_exp_mult *= 1.2;\r\n Player.hacking_chance_mult *= 1.1;\r\n Player.hacking_speed_mult *= 1.05;\r\n break;\r\n case AugmentationNames.TheBlackHand:\r\n Player.strength_mult *= 1.15;\r\n Player.dexterity_mult *= 1.15;\r\n Player.hacking_mult *= 1.1;\r\n Player.hacking_speed_mult *= 1.02;\r\n Player.hacking_money_mult *= 1.1;\r\n break;\r\n case AugmentationNames.CRTX42AA:\r\n Player.hacking_mult *= 1.08;\r\n Player.hacking_exp_mult *= 1.15;\r\n break;\r\n case AugmentationNames.Neuregen:\r\n Player.hacking_exp_mult *= 1.4;\r\n break;\r\n case AugmentationNames.CashRoot:\r\n break;\r\n case AugmentationNames.NutriGen:\r\n Player.strength_exp_mult *= 1.2;\r\n Player.defense_exp_mult *= 1.2;\r\n Player.dexterity_exp_mult *= 1.2;\r\n Player.agility_exp_mult *= 1.2;\r\n break;\r\n case AugmentationNames.INFRARet:\r\n Player.crime_success_mult *= 1.25;\r\n Player.crime_money_mult *= 1.1;\r\n Player.dexterity_mult *= 1.1;\r\n break;\r\n case AugmentationNames.DermaForce:\r\n Player.defense_mult *= 1.4;\r\n break;\r\n case AugmentationNames.GrapheneBrachiBlades:\r\n Player.strength_mult *= 1.4;\r\n Player.defense_mult *= 1.4;\r\n Player.crime_success_mult *= 1.1;\r\n Player.crime_money_mult *= 1.3;\r\n break;\r\n case AugmentationNames.GrapheneBionicArms:\r\n Player.strength_mult *= 1.85;\r\n Player.dexterity_mult *= 1.85;\r\n break;\r\n case AugmentationNames.BrachiBlades:\r\n Player.strength_mult *= 1.15;\r\n Player.defense_mult *= 1.15;\r\n Player.crime_success_mult *= 1.1;\r\n Player.crime_money_mult *= 1.15;\r\n break;\r\n case AugmentationNames.BionicArms:\r\n Player.strength_mult *= 1.3;\r\n Player.dexterity_mult *= 1.3;\r\n break;\r\n case AugmentationNames.SNA:\r\n Player.work_money_mult *= 1.1;\r\n Player.company_rep_mult *= 1.15;\r\n Player.faction_rep_mult *= 1.15;\r\n break;\r\n\r\n //Bladeburner augmentations\r\n case AugmentationNames.EsperEyewear:\r\n Player.bladeburner_success_chance_mult *= 1.03;\r\n Player.dexterity_mult *= 1.03;\r\n break;\r\n case AugmentationNames.EMS4Recombination:\r\n Player.bladeburner_success_chance_mult *= 1.03;\r\n Player.bladeburner_analysis_mult *= 1.05;\r\n Player.bladeburner_stamina_gain_mult *= 1.01;\r\n break;\r\n case AugmentationNames.OrionShoulder:\r\n Player.defense_mult *= 1.05;\r\n Player.strength_mult *= 1.03;\r\n Player.dexterity_mult *= 1.03;\r\n Player.bladeburner_success_chance_mult *= 1.04;\r\n break;\r\n case AugmentationNames.HyperionV1:\r\n Player.bladeburner_success_chance_mult *= 1.05;\r\n break;\r\n case AugmentationNames.HyperionV2:\r\n Player.bladeburner_success_chance_mult *= 1.07;\r\n break;\r\n case AugmentationNames.GolemSerum:\r\n Player.strength_mult *= 1.05;\r\n Player.defense_mult *= 1.05;\r\n Player.dexterity_mult *= 1.05;\r\n Player.agility_mult *= 1.05;\r\n Player.bladeburner_stamina_gain_mult *= 1.05;\r\n break;\r\n case AugmentationNames.VangelisVirus:\r\n Player.dexterity_exp_mult *= 1.05;\r\n Player.bladeburner_analysis_mult *= 1.1;\r\n Player.bladeburner_success_chance_mult *= 1.04;\r\n break;\r\n case AugmentationNames.VangelisVirus3:\r\n Player.defense_exp_mult *= 1.05;\r\n Player.dexterity_exp_mult *= 1.05;\r\n Player.bladeburner_analysis_mult *= 1.15;\r\n Player.bladeburner_success_chance_mult *= 1.05;\r\n break;\r\n case AugmentationNames.INTERLINKED:\r\n Player.strength_exp_mult *= 1.04;\r\n Player.defense_exp_mult *= 1.04;\r\n Player.dexterity_exp_mult *= 1.04;\r\n Player.agility_exp_mult *= 1.04;\r\n Player.bladeburner_max_stamina_mult *= 1.1;\r\n break;\r\n case AugmentationNames.BladeRunner:\r\n Player.agility_mult *= 1.05;\r\n Player.bladeburner_max_stamina_mult *= 1.05;\r\n Player.bladeburner_stamina_gain_mult *= 1.05;\r\n break;\r\n case AugmentationNames.BladeArmor:\r\n Player.strength_mult *= 1.02;\r\n Player.defense_mult *= 1.02;\r\n Player.dexterity_mult *= 1.02;\r\n Player.agility_mult *= 1.02;\r\n Player.bladeburner_stamina_gain_mult *= 1.02;\r\n Player.bladeburner_success_chance_mult *= 1.03;\r\n break;\r\n case AugmentationNames.BladeArmorPowerCells:\r\n Player.bladeburner_success_chance_mult *= 1.05;\r\n Player.bladeburner_stamina_gain_mult *= 1.02;\r\n Player.bladeburner_max_stamina_mult *= 1.05;\r\n break;\r\n case AugmentationNames.BladeArmorEnergyShielding:\r\n Player.defense_mult *= 1.05;\r\n Player.bladeburner_success_chance_mult *= 1.06;\r\n break;\r\n case AugmentationNames.BladeArmorUnibeam:\r\n Player.bladeburner_success_chance_mult *= 1.08;\r\n break;\r\n case AugmentationNames.BladeArmorOmnibeam:\r\n Player.bladeburner_success_chance_mult *= 1.1;\r\n break;\r\n case AugmentationNames.BladeArmorIPU:\r\n Player.bladeburner_analysis_mult *= 1.15;\r\n Player.bladeburner_success_chance_mult *= 1.02;\r\n break;\r\n default:\r\n throw new Error(\"ERROR: No such augmentation!\");\r\n return;\r\n }\r\n\r\n if (aug.name == AugmentationNames.NeuroFluxGovernor) {\r\n for (var i = 0; i < Player.augmentations.length; ++i) {\r\n if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {\r\n //Already have this aug, just upgrade the level\r\n return;\r\n }\r\n }\r\n }\r\n\r\n if (!reapply) {\r\n var ownedAug = new PlayerOwnedAugmentation(aug.name);\r\n Player.augmentations.push(ownedAug);\r\n }\r\n}\r\n\r\nfunction PlayerOwnedAugmentation(name) {\r\n this.name = name;\r\n this.level = 1;\r\n}\r\n\r\nfunction installAugmentations(cbScript=null) {\r\n if (Player.queuedAugmentations.length == 0) {\r\n dialogBoxCreate(\"You have not purchased any Augmentations to install!\");\r\n return false;\r\n }\r\n var augmentationList = \"\";\r\n for (var i = 0; i < Player.queuedAugmentations.length; ++i) {\r\n var aug = Augmentations[Player.queuedAugmentations[i].name];\r\n if (aug == null) {\r\n console.log(\"ERROR. Invalid augmentation\");\r\n continue;\r\n }\r\n applyAugmentation(Player.queuedAugmentations[i]);\r\n augmentationList += (aug.name + \"
\");\r\n }\r\n Player.queuedAugmentations = [];\r\n dialogBoxCreate(\"You slowly drift to sleep as scientists put you under in order \" +\r\n \"to install the following Augmentations:
\" + augmentationList +\r\n \"
You wake up in your home...you feel different...\");\r\n prestigeAugmentation();\r\n\r\n //Run a script after prestiging\r\n if (cbScript && isString(cbScript)) {\r\n var home = Player.getHomeComputer();\r\n for (var i = 0; i < home.scripts.length; ++i) {\r\n if (home.scripts[i].filename === cbScript) {\r\n var script = home.scripts[i];\r\n var ramUsage = script.ramUsage;\r\n var ramAvailable = home.maxRam - home.ramUsed;\r\n if (ramUsage > ramAvailable) {\r\n return; //Not enough RAM\r\n }\r\n var runningScriptObj = new RunningScript(script, []); //No args\r\n runningScriptObj.threads = 1; //Only 1 thread\r\n home.runningScripts.push(runningScriptObj);\r\n addWorkerScript(runningScriptObj, home);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction augmentationExists(name) {\r\n return Augmentations.hasOwnProperty(name);\r\n}\r\n\r\n//Used for testing balance\r\nfunction giveAllAugmentations() {\r\n for (var name in Augmentations) {\r\n var aug = Augmentations[name];\r\n if (aug == null) {continue;}\r\n var ownedAug = new PlayerOwnedAugmentation(name);\r\n Player.augmentations.push(ownedAug);\r\n }\r\n Player.reapplyAllAugmentations();\r\n}\r\n\r\nfunction displayAugmentationsContent() {\r\n removeChildrenFromElement(Engine.Display.augmentationsContent);\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"h1\", {\r\n innerText:\"Purchased Augmentations\",\r\n }));\r\n\r\n //Bladeburner text, once mechanic is unlocked\r\n var bladeburnerText = \"\\n\";\r\n if (Player.bitNodeN === 6 || hasBladeburnerSF) {\r\n bladeburnerText = \"Bladeburner Progress\\n\\n\";\r\n }\r\n\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"pre\", {\r\n width:\"70%\", whiteSpace:\"pre-wrap\", display:\"block\",\r\n innerText:\"Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.\\n\" +\r\n \"WARNING: Installing your Augmentations resets most of your progress, including:\\n\\n\" +\r\n \"Stats/Skill levels and Experience\\n\" +\r\n \"Money\\n\" +\r\n \"Scripts on every computer but your home computer\\n\" +\r\n \"Purchased servers\\n\" +\r\n \"Hacknet Nodes\\n\" +\r\n \"Faction/Company reputation\\n\" +\r\n \"Stocks\\n\" +\r\n bladeburnerText +\r\n \"Installing Augmentations lets you start over with the perks and benefits granted by all \" +\r\n \"of the Augmentations you have ever installed. Also, you will keep any scripts and RAM/Core upgrades \" +\r\n \"on your home computer (but you will lose all programs besides NUKE.exe).\"\r\n }));\r\n\r\n //Install Augmentations button\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button\", innerText:\"Install Augmentations\",\r\n tooltip:\"'I never asked for this'\",\r\n clickListener:()=>{\r\n installAugmentations();\r\n return false;\r\n }\r\n }));\r\n\r\n //Backup button\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button flashing-button\", innerText:\"Backup Save (Export)\",\r\n tooltip:\"It's always a good idea to backup/export your save!\",\r\n clickListener:()=>{\r\n saveObject.exportGame();\r\n return false;\r\n }\r\n }));\r\n\r\n //Purchased/queued augmentations list\r\n var queuedAugmentationsList = createElement(\"ul\", {class:\"augmentations-list\"});\r\n\r\n for (var i = 0; i < Player.queuedAugmentations.length; ++i) {\r\n var augName = Player.queuedAugmentations[i].name;\r\n var aug = Augmentations[augName];\r\n\r\n var displayName = augName;\r\n if (augName === AugmentationNames.NeuroFluxGovernor) {\r\n displayName += \" - Level \" + (Player.queuedAugmentations[i].level);\r\n }\r\n\r\n var accordion = createAccordionElement({hdrText:displayName, panelText:aug.info});\r\n queuedAugmentationsList.appendChild(accordion[0]);\r\n }\r\n Engine.Display.augmentationsContent.appendChild(queuedAugmentationsList);\r\n\r\n //Installed augmentations list\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"h1\", {\r\n innerText:\"Installed Augmentations\", marginTop:\"8px\",\r\n }));\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"p\", {\r\n width:\"70%\", whiteSpace:\"pre-wrap\",\r\n innerText:\"List of all Augmentations (including Source Files) that have been \" +\r\n \"installed. You have gained the effects of these Augmentations.\"\r\n }));\r\n\r\n var augmentationsList = createElement(\"ul\", {class:\"augmentations-list\"});\r\n\r\n //Expand/Collapse All buttons\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button\", fontSize:\"14px\", innerText:\"Expand All\", display:\"inline-block\",\r\n clickListener:()=>{\r\n var allHeaders = augmentationsList.getElementsByClassName(\"accordion-header\");\r\n for (var i = 0; i < allHeaders.length; ++i) {\r\n if (!allHeaders[i].classList.contains(\"active\")) {allHeaders[i].click();}\r\n }\r\n }\r\n }));\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button\", fontSize:\"14px\", innerText:\"Collapse All\", display:\"inline-block\",\r\n clickListener:()=>{\r\n var allHeaders = augmentationsList.getElementsByClassName(\"accordion-header\");\r\n for (var i = 0; i < allHeaders.length; ++i) {\r\n if (allHeaders[i].classList.contains(\"active\")) {allHeaders[i].click();}\r\n }\r\n }\r\n }));\r\n\r\n //Sort Buttons\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button\", fontSize:\"14px\", innerText:\"Sort in Order\",\r\n tooltip:\"Sorts the Augmentations alphabetically and Source Files in numerical order (1, 2, 3,...)\",\r\n clickListener:()=>{\r\n removeChildrenFromElement(augmentationsList);\r\n\r\n //Create a copy of Player's Source Files and augs array and sort them\r\n var sourceFiles = Player.sourceFiles.slice();\r\n var augs = Player.augmentations.slice();\r\n sourceFiles.sort((sf1, sf2)=>{\r\n return sf1.n - sf2.n;\r\n });\r\n augs.sort((aug1, aug2)=>{\r\n return aug1.name <= aug2.name ? -1 : 1;\r\n });\r\n displaySourceFiles(augmentationsList, sourceFiles);\r\n displayAugmentations(augmentationsList, augs);\r\n }\r\n }));\r\n\r\n Engine.Display.augmentationsContent.appendChild(createElement(\"a\", {\r\n class:\"a-link-button\", fontSize:\"14px\", innerText:\"Sort by Acquirement Time\",\r\n tooltip:\"Sorts the Augmentations and Source Files based on when you acquired them (same as default)\",\r\n clickListener:()=>{\r\n removeChildrenFromElement(augmentationsList);\r\n displaySourceFiles(augmentationsList, Player.sourceFiles);\r\n displayAugmentations(augmentationsList, Player.augmentations);\r\n }\r\n }));\r\n\r\n //Source Files - Temporary...Will probably put in a separate pane Later\r\n displaySourceFiles(augmentationsList, Player.sourceFiles);\r\n displayAugmentations(augmentationsList, Player.augmentations);\r\n Engine.Display.augmentationsContent.appendChild(augmentationsList);\r\n}\r\n\r\n//Creates the accordion elements to display Augmentations\r\n// @listElement - List DOM element to append accordion elements to\r\n// @augs - Array of Augmentation objects\r\nfunction displayAugmentations(listElement, augs) {\r\n for (var i = 0; i < augs.length; ++i) {\r\n var augName = augs[i].name;\r\n var aug = Augmentations[augName];\r\n\r\n var displayName = augName;\r\n if (augName === AugmentationNames.NeuroFluxGovernor) {\r\n displayName += \" - Level \" + (augs[i].level);\r\n }\r\n var accordion = createAccordionElement({hdrText:displayName, panelText:aug.info});\r\n listElement.appendChild(accordion[0]);\r\n }\r\n}\r\n\r\n//Creates the accordion elements to display Source Files\r\n// @listElement - List DOM element to append accordion elements to\r\n// @sourceFiles - Array of Source File objects\r\nfunction displaySourceFiles(listElement, sourceFiles) {\r\n for (var i = 0; i < sourceFiles.length; ++i) {\r\n var srcFileKey = \"SourceFile\" + sourceFiles[i].n;\r\n var sourceFileObject = SourceFiles[srcFileKey];\r\n if (sourceFileObject == null) {\r\n console.log(\"ERROR: Invalid source file number: \" + sourceFiles[i].n);\r\n continue;\r\n }\r\n const maxLevel = sourceFiles[i].n == 12 ? \"∞\" : \"3\";\r\n var accordion = createAccordionElement({\r\n hdrText:sourceFileObject.name + \"
\" + \"Level \" + (sourceFiles[i].lvl) + \" / \"+maxLevel,\r\n panelText:sourceFileObject.info\r\n });\r\n\r\n listElement.appendChild(accordion[0]);\r\n }\r\n}\r\n\r\n\r\nexport {AugmentationNames, Augmentations, PlayerOwnedAugmentation, installAugmentations,\r\n initAugmentations, applyAugmentation, augmentationExists, Augmentation,\r\n displayAugmentationsContent};\r\n","import {addActiveScriptsItem,\r\n deleteActiveScriptsItem,\r\n updateActiveScriptsItems} from \"./ActiveScriptsUI.js\";\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Environment} from \"./NetscriptEnvironment.js\";\r\nimport {evaluate, isScriptErrorMessage,\r\n makeRuntimeRejectMsg,\r\n killNetscriptDelay} from \"./NetscriptEvaluator.js\";\r\nimport {executeJSScript} from \"./NetscriptJSEvaluator.js\";\r\nimport {NetscriptPort} from \"./NetscriptPort.js\";\r\nimport {AllServers} from \"./Server.js\";\r\nimport {Settings} from \"./Settings.js\";\r\n\r\nimport {parse} from \"../utils/acorn.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {compareArrays, printArray} from \"../utils/HelperFunctions.js\";\r\n\r\nfunction WorkerScript(runningScriptObj) {\r\n\tthis.name \t\t\t= runningScriptObj.filename;\r\n\tthis.running \t\t= false;\r\n\tthis.serverIp \t\t= null;\r\n\tthis.code \t\t\t= runningScriptObj.scriptRef.code;\r\n\tthis.env \t\t\t= new Environment(this);\r\n this.env.set(\"args\", runningScriptObj.args.slice());\r\n\tthis.output\t\t\t= \"\";\r\n\tthis.ramUsage\t\t= 0;\r\n\tthis.scriptRef\t\t= runningScriptObj;\r\n this.errorMessage = \"\";\r\n this.args = runningScriptObj.args.slice();\r\n this.delay = null;\r\n this.fnWorker = null; //Workerscript for a function call\r\n this.checkingRam = false;\r\n this.loadedFns = {}; //Stores names of fns that are \"loaded\" by this script, thus using RAM. Used for static RAM evaluation\r\n this.disableLogs = {}; //Stores names of fns that should have logs disabled\r\n\r\n //Properties used for dynamic RAM evaluation\r\n this.dynamicRamUsage = 1.4;\r\n this.dynamicLoadedFns = {};\r\n}\r\n\r\n//Returns the server on which the workerScript is running\r\nWorkerScript.prototype.getServer = function() {\r\n\treturn AllServers[this.serverIp];\r\n}\r\n\r\n//Returns the Script object for the underlying script\r\nWorkerScript.prototype.getScript = function() {\r\n let server = this.getServer();\r\n for (var i = 0; i < server.scripts.length; ++i) {\r\n if (server.scripts[i].filename === this.name) {\r\n return server.scripts[i];\r\n }\r\n }\r\n console.log(\"ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong\");\r\n return null;\r\n}\r\n\r\nWorkerScript.prototype.shouldLog = function(fn) {\r\n return (this.disableLogs.ALL == null && this.disableLogs[fn] == null);\r\n}\r\n\r\nWorkerScript.prototype.log = function(txt) {\r\n this.scriptRef.log(txt);\r\n}\r\n\r\n//Array containing all scripts that are running across all servers, to easily run them all\r\nlet workerScripts \t\t\t= [];\r\n\r\nvar NetscriptPorts = [];\r\nfor (var i = 0; i < CONSTANTS.NumNetscriptPorts; ++i) {\r\n NetscriptPorts.push(new NetscriptPort());\r\n}\r\n\r\nfunction prestigeWorkerScripts() {\r\n for (var i = 0; i < workerScripts.length; ++i) {\r\n deleteActiveScriptsItem(workerScripts[i]);\r\n workerScripts[i].env.stopFlag = true;\r\n }\r\n updateActiveScriptsItems(5000); //Force UI to update\r\n workerScripts.length = 0;\r\n}\r\n\r\n// JS script promises need a little massaging to have the same guarantees as netscript\r\n// promises. This does said massaging and kicks the script off. It returns a promise\r\n// that resolves or rejects when the corresponding worker script is done.\r\nfunction startJsScript(workerScript) {\r\n workerScript.running = true;\r\n\r\n // The name of the currently running netscript function, to prevent concurrent\r\n // calls to hack, grow, etc.\r\n let runningFn = null;\r\n\r\n // We need to go through the environment and wrap each function in such a way that it\r\n // can be called at most once at a time. This will prevent situations where multiple\r\n // hack promises are outstanding, for example.\r\n function wrap(propName, f) {\r\n // This function unfortunately cannot be an async function, because we don't\r\n // know if the original one was, and there's no way to tell.\r\n return function (...args) {\r\n // Wrap every netscript function with a check for the stop flag.\r\n // This prevents cases where we never stop because we are only calling\r\n // netscript functions that don't check this.\r\n // This is not a problem for legacy Netscript because it also checks the\r\n // stop flag in the evaluator.\r\n if (workerScript.env.stopFlag) {throw workerScript;}\r\n\r\n if (propName === \"sleep\") return f(...args); // OK for multiple simultaneous calls to sleep.\r\n\r\n const msg = \"Concurrent calls to Netscript functions not allowed! \" +\r\n \"Did you forget to await hack(), grow(), or some other \" +\r\n \"promise-returning function? (Currently running: %s tried to run: %s)\"\r\n if (runningFn) {\r\n workerScript.errorMessage = makeRuntimeRejectMsg(workerScript, sprintf(msg, runningFn, propName), null)\r\n throw workerScript;\r\n }\r\n runningFn = propName;\r\n let result = f(...args);\r\n if (result && result.finally !== undefined) {\r\n return result.finally(function () {\r\n runningFn = null;\r\n });\r\n } else {\r\n runningFn = null;\r\n return result;\r\n }\r\n }\r\n };\r\n\r\n for (let prop in workerScript.env.vars) {\r\n if (typeof workerScript.env.vars[prop] !== \"function\") continue;\r\n workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);\r\n }\r\n\r\n // Note: the environment that we pass to the JS script only needs to contain the functions visible\r\n // to that script, which env.vars does at this point.\r\n return executeJSScript(workerScript.getServer().scripts,\r\n workerScript).then(function (mainReturnValue) {\r\n if (mainReturnValue === undefined) return workerScript;\r\n return [mainReturnValue, workerScript];\r\n }).catch(e => {\r\n if (e instanceof Error) {\r\n workerScript.errorMessage = makeRuntimeRejectMsg(\r\n workerScript, e.message + (e.stack && (\"\\nstack:\\n\" + e.stack.toString()) || \"\"));\r\n throw workerScript;\r\n } else if (isScriptErrorMessage(e)) {\r\n workerScript.errorMessage = e;\r\n throw workerScript;\r\n }\r\n throw e; // Don't know what to do with it, let's rethrow.\r\n });\r\n}\r\n\r\n//Loop through workerScripts and run every script that is not currently running\r\nfunction runScriptsLoop() {\r\n var scriptDeleted = false;\r\n\r\n //Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing\r\n for (var i = workerScripts.length - 1; i >= 0; i--) {\r\n if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {\r\n scriptDeleted = true;\r\n //Delete script from the runningScripts array on its host serverIp\r\n var ip = workerScripts[i].serverIp;\r\n var name = workerScripts[i].name;\r\n\r\n //Free RAM\r\n AllServers[ip].ramUsed -= workerScripts[i].ramUsage;\r\n\r\n //Delete script from Active Scripts\r\n deleteActiveScriptsItem(workerScripts[i]);\r\n\r\n for (var j = 0; j < AllServers[ip].runningScripts.length; j++) {\r\n if (AllServers[ip].runningScripts[j].filename == name &&\r\n compareArrays(AllServers[ip].runningScripts[j].args, workerScripts[i].args)) {\r\n AllServers[ip].runningScripts.splice(j, 1);\r\n break;\r\n }\r\n }\r\n\r\n //Delete script from workerScripts\r\n workerScripts.splice(i, 1);\r\n }\r\n }\r\n if (scriptDeleted) {updateActiveScriptsItems();} //Force Update\r\n\r\n\r\n\t//Run any scripts that haven't been started\r\n\tfor (var i = 0; i < workerScripts.length; i++) {\r\n\t\t//If it isn't running, start the script\r\n\t\tif (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {\r\n let p = null; // p is the script's result promise.\r\n if (workerScripts[i].name.endsWith(\".js\") || workerScripts[i].name.endsWith(\".ns\")) {\r\n p = startJsScript(workerScripts[i]);\r\n } else {\r\n try {\r\n var ast = parse(workerScripts[i].code, {sourceType:\"module\"});\r\n //console.log(ast);\r\n } catch (e) {\r\n console.log(\"Error parsing script: \" + workerScripts[i].name);\r\n dialogBoxCreate(\"Syntax ERROR in \" + workerScripts[i].name + \":
\" + e);\r\n workerScripts[i].env.stopFlag = true;\r\n continue;\r\n }\r\n workerScripts[i].running = true;\r\n p = evaluate(ast, workerScripts[i]);\r\n }\r\n\r\n\t\t\t//Once the code finishes (either resolved or rejected, doesnt matter), set its\r\n\t\t\t//running status to false\r\n\t\t\tp.then(function(w) {\r\n\t\t\t\tconsole.log(\"Stopping script \" + w.name + \" because it finished running naturally\");\r\n\t\t\t\tw.running = false;\r\n\t\t\t\tw.env.stopFlag = true;\r\n w.scriptRef.log(\"Script finished running\");\r\n\t\t\t}).catch(function(w) {\r\n\t\t\t\tif (w instanceof Error) {\r\n dialogBoxCreate(\"Script runtime unknown error. This is a bug please contact game developer\");\r\n\t\t\t\t\tconsole.log(\"ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: \" + w.toString());\r\n return;\r\n } else if (w.constructor === Array && w.length === 2 && w[0] === \"RETURNSTATEMENT\") {\r\n //Script ends with a return statement\r\n console.log(\"Script returning with value: \" + w[1]);\r\n //TODO maybe do something with this in the future\r\n return;\r\n } else if (w instanceof WorkerScript) {\r\n if (isScriptErrorMessage(w.errorMessage)) {\r\n var errorTextArray = w.errorMessage.split(\"|\");\r\n if (errorTextArray.length != 4) {\r\n console.log(\"ERROR: Something wrong with Error text in evaluator...\");\r\n console.log(\"Error text: \" + errorText);\r\n return;\r\n }\r\n var serverIp = errorTextArray[1];\r\n var scriptName = errorTextArray[2];\r\n var errorMsg = errorTextArray[3];\r\n\r\n dialogBoxCreate(\"Script runtime error:
Server Ip: \" + serverIp +\r\n \"
Script name: \" + scriptName +\r\n \"
Args:\" + printArray(w.args) + \"
\" + errorMsg);\r\n w.scriptRef.log(\"Script crashed with runtime error\");\r\n } else {\r\n w.scriptRef.log(\"Script killed\");\r\n }\r\n\t\t\t\t\tw.running = false;\r\n\t\t\t\t\tw.env.stopFlag = true;\r\n\r\n\t\t\t\t} else if (isScriptErrorMessage(w)) {\r\n dialogBoxCreate(\"Script runtime unknown error. This is a bug please contact game developer\");\r\n\t\t\t\t\tconsole.log(\"ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: \" + w.toString());\r\n return;\r\n } else {\r\n dialogBoxCreate(\"An unknown script died for an unknown reason. This is a bug please contact game dev\");\r\n console.log(w);\r\n }\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tsetTimeout(runScriptsLoop, 6000);\r\n}\r\n\r\n//Queues a script to be killed by settings its stop flag to true. Then, the code will reject\r\n//all of its promises recursively, and when it does so it will no longer be running.\r\n//The runScriptsLoop() will then delete the script from worker scripts\r\nfunction killWorkerScript(runningScriptObj, serverIp) {\r\n\tfor (var i = 0; i < workerScripts.length; i++) {\r\n\t\tif (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&\r\n compareArrays(workerScripts[i].args, runningScriptObj.args)) {\r\n\t\t\tworkerScripts[i].env.stopFlag = true;\r\n killNetscriptDelay(workerScripts[i]);\r\n //Recursively kill all functions\r\n var curr = workerScripts[i];\r\n while (curr.fnWorker) {\r\n curr.fnWorker.env.stopFlag = true;\r\n killNetscriptDelay(curr.fnWorker);\r\n curr = curr.fnWorker;\r\n }\r\n return true;\r\n\t\t}\r\n\t}\r\n return false;\r\n}\r\n\r\n//Queues a script to be run\r\nfunction addWorkerScript(runningScriptObj, server) {\r\n\tvar filename = runningScriptObj.filename;\r\n\r\n\t//Update server's ram usage\r\n var threads = 1;\r\n if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {\r\n threads = runningScriptObj.threads;\r\n } else {\r\n runningScriptObj.threads = 1;\r\n }\r\n var ramUsage = runningScriptObj.scriptRef.ramUsage * threads\r\n * Math.pow(CONSTANTS.MultithreadingRAMCost, threads-1);\r\n var ramAvailable = server.maxRam - server.ramUsed;\r\n if (ramUsage > ramAvailable) {\r\n dialogBoxCreate(\"Not enough RAM to run script \" + runningScriptObj.filename + \" with args \" +\r\n printArray(runningScriptObj.args) + \". This likely occurred because you re-loaded \" +\r\n \"the game and the script's RAM usage increased (either because of an update to the game or \" +\r\n \"your changes to the script.)\");\r\n return;\r\n }\r\n\tserver.ramUsed += ramUsage;\r\n\r\n\t//Create the WorkerScript\r\n\tvar s = new WorkerScript(runningScriptObj);\r\n\ts.serverIp \t= server.ip;\r\n\ts.ramUsage \t= ramUsage;\r\n\r\n\t//Add the WorkerScript to the Active Scripts list\r\n\taddActiveScriptsItem(s);\r\n\r\n\t//Add the WorkerScript\r\n\tworkerScripts.push(s);\r\n\treturn;\r\n}\r\n\r\n//Updates the online running time stat of all running scripts\r\nfunction updateOnlineScriptTimes(numCycles = 1) {\r\n\tvar time = (numCycles * Engine._idleSpeed) / 1000; //seconds\r\n\tfor (var i = 0; i < workerScripts.length; ++i) {\r\n\t\tworkerScripts[i].scriptRef.onlineRunningTime += time;\r\n\t}\r\n}\r\n\r\nexport {WorkerScript, workerScripts, NetscriptPorts, runScriptsLoop,\r\n killWorkerScript, addWorkerScript, updateOnlineScriptTimes,\r\n prestigeWorkerScripts};\r\n","import {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Locations} from \"./Location.js\";\r\nimport {hasWallStreetSF, wallStreetSFLvl} from \"./NetscriptFunctions.js\";\r\nimport {WorkerScript} from \"./NetscriptWorker.js\";\r\nimport {Player} from \"./Player.js\";\r\n\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {clearEventListeners, getRandomInt,\r\n removeElementById,\r\n clearEventListenersEl} from \"../utils/HelperFunctions.js\";\r\nimport {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\nimport numeral from \"numeral/min/numeral.min\";\r\nimport {formatNumber} from \"../utils/StringHelperFunctions.js\";\r\nimport {yesNoBoxCreate, yesNoTxtInpBoxCreate,\r\n yesNoBoxGetYesButton, yesNoBoxGetNoButton,\r\n yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton,\r\n yesNoTxtInpBoxGetInput, yesNoBoxClose,\r\n yesNoTxtInpBoxClose, yesNoBoxOpen} from \"../utils/YesNoBox.js\";\r\n\r\nlet StockPriceCap = 1e9; //Put a limit on how high a price can go\r\n\r\nfunction Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {\r\n this.symbol = symbol;\r\n this.name = name;\r\n this.price = initPrice;\r\n\r\n this.playerShares = 0;\r\n this.playerAvgPx = 0;\r\n this.playerShortShares = 0;\r\n this.playerAvgShortPx = 0;\r\n this.mv = mv;\r\n this.b = b;\r\n this.otlkMag = otlkMag;\r\n\r\n this.posTxtEl = null;\r\n}\r\n\r\nStock.prototype.toJSON = function() {\r\n\treturn Generic_toJSON(\"Stock\", this);\r\n}\r\n\r\nStock.fromJSON = function(value) {\r\n\treturn Generic_fromJSON(Stock, value.data);\r\n}\r\n\r\nReviver.constructors.Stock = Stock;\r\n\r\nvar OrderTypes = {\r\n LimitBuy: \"Limit Buy Order\",\r\n LimitSell: \"Limit Sell Order\",\r\n StopBuy: \"Stop Buy Order\",\r\n StopSell: \"Stop Sell Order\"\r\n}\r\n\r\nvar PositionTypes = {\r\n Long: \"L\",\r\n Short: \"S\"\r\n}\r\n\r\nfunction placeOrder(stock, shares, price, type, position, workerScript=null) {\r\n var tixApi = (workerScript instanceof WorkerScript);\r\n var order = new Order(stock, shares, price, type, position);\r\n if (isNaN(shares) || isNaN(price)) {\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"ERROR: Invalid numeric value provided for either 'shares' or 'price' argument\");\r\n } else {\r\n dialogBoxCreate(\"ERROR: Invalid numeric value provided for either 'shares' or 'price' argument\");\r\n }\r\n return false;\r\n }\r\n if (StockMarket[\"Orders\"] == null) {\r\n var orders = {};\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;}\r\n orders[stock.symbol] = [];\r\n }\r\n }\r\n StockMarket[\"Orders\"] = orders;\r\n }\r\n StockMarket[\"Orders\"][stock.symbol].push(order);\r\n //Process to see if it should be executed immediately\r\n processOrders(order.stock, order.type, order.pos);\r\n updateStockOrderList(order.stock);\r\n return true;\r\n}\r\n\r\n//Returns true if successfully cancels an order, false otherwise\r\nfunction cancelOrder(params, workerScript=null) {\r\n var tixApi = (workerScript instanceof WorkerScript);\r\n if (StockMarket[\"Orders\"] == null) {return false;}\r\n if (params.order && params.order instanceof Order) {\r\n var order = params.order;\r\n //An 'Order' object is passed in\r\n var stockOrders = StockMarket[\"Orders\"][order.stock.symbol];\r\n for (var i = 0; i < stockOrders.length; ++i) {\r\n if (order == stockOrders[i]) {\r\n stockOrders.splice(i, 1);\r\n updateStockOrderList(order.stock);\r\n return true;\r\n }\r\n }\r\n return false;\r\n } else if (params.stock && params.shares && params.price && params.type &&\r\n params.pos && params.stock instanceof Stock) {\r\n //Order properties are passed in. Need to look for the order\r\n var stockOrders = StockMarket[\"Orders\"][params.stock.symbol];\r\n var orderTxt = params.stock.symbol + \" - \" + params.shares + \" @ \" +\r\n numeral(params.price).format('$0.000a');\r\n for (var i = 0; i < stockOrders.length; ++i) {\r\n var order = stockOrders[i];\r\n if (params.shares === order.shares &&\r\n params.price === order.price &&\r\n params.type === order.type &&\r\n params.pos === order.pos) {\r\n stockOrders.splice(i, 1);\r\n updateStockOrderList(order.stock);\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"Successfully cancelled order: \" + orderTxt);\r\n }\r\n return true;\r\n }\r\n }\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"Failed to cancel order: \" + orderTxt);\r\n }\r\n return false;\r\n }\r\n return false;\r\n}\r\n\r\nfunction executeOrder(order) {\r\n var stock = order.stock;\r\n var orderBook = StockMarket[\"Orders\"];\r\n var stockOrders = orderBook[stock.symbol];\r\n var res = true;\r\n console.log(\"Executing the following order:\");\r\n console.log(order);\r\n switch (order.type) {\r\n case OrderTypes.LimitBuy:\r\n case OrderTypes.StopBuy:\r\n if (order.pos === PositionTypes.Long) {\r\n res = buyStock(order.stock, order.shares) && res;\r\n } else if (order.pos === PositionTypes.Short) {\r\n res = shortStock(order.stock, order.shares) && res;\r\n }\r\n break;\r\n case OrderTypes.LimitSell:\r\n case OrderTypes.StopSell:\r\n if (order.pos === PositionTypes.Long) {\r\n res = sellStock(order.stock, order.shares) && res;\r\n } else if (order.pos === PositionTypes.Short) {\r\n res = sellShort(order.stock, order.shares) && res;\r\n }\r\n break;\r\n }\r\n if (res) {\r\n //Remove order from order book\r\n for (var i = 0; i < stockOrders.length; ++i) {\r\n if (order == stockOrders[i]) {\r\n stockOrders.splice(i, 1);\r\n updateStockOrderList(order.stock);\r\n return;\r\n }\r\n }\r\n console.log(\"ERROR: Could not find the following Order in Order Book: \");\r\n console.log(order);\r\n } else {\r\n console.log(\"Order failed to execute\");\r\n }\r\n}\r\n\r\nfunction Order(stock, shares, price, type, position) {\r\n this.stock = stock;\r\n this.shares = shares;\r\n this.price = price;\r\n this.type = type;\r\n this.pos = position;\r\n}\r\n\r\nOrder.prototype.toJSON = function() {\r\n\treturn Generic_toJSON(\"Order\", this);\r\n}\r\n\r\nOrder.fromJSON = function(value) {\r\n\treturn Generic_fromJSON(Order, value.data);\r\n}\r\n\r\nReviver.constructors.Order = Order;\r\n\r\nlet StockMarket = {} //Full name to stock object\r\nlet StockSymbols = {} //Full name to symbol\r\nlet SymbolToStockMap = {}; //Symbol to Stock object\r\n\r\nfunction loadStockMarket(saveString) {\r\n if (saveString === \"\") {\r\n StockMarket = {};\r\n } else {\r\n StockMarket = JSON.parse(saveString, Reviver);\r\n }\r\n}\r\n\r\nfunction initStockSymbols() {\r\n //Stocks for companies at which you can work\r\n StockSymbols[Locations.AevumECorp] = \"ECP\";\r\n StockSymbols[Locations.Sector12MegaCorp] = \"MGCP\";\r\n StockSymbols[Locations.Sector12BladeIndustries] = \"BLD\";\r\n StockSymbols[Locations.AevumClarkeIncorporated] = \"CLRK\";\r\n StockSymbols[Locations.VolhavenOmniTekIncorporated] = \"OMTK\";\r\n StockSymbols[Locations.Sector12FourSigma] = \"FSIG\";\r\n StockSymbols[Locations.ChongqingKuaiGongInternational] = \"KGI\";\r\n StockSymbols[Locations.AevumFulcrumTechnologies] = \"FLCM\";\r\n StockSymbols[Locations.IshimaStormTechnologies] = \"STM\";\r\n StockSymbols[Locations.NewTokyoDefComm] = \"DCOMM\";\r\n StockSymbols[Locations.VolhavenHeliosLabs] = \"HLS\";\r\n StockSymbols[Locations.NewTokyoVitaLife] = \"VITA\";\r\n StockSymbols[Locations.Sector12IcarusMicrosystems] = \"ICRS\";\r\n StockSymbols[Locations.Sector12UniversalEnergy] = \"UNV\";\r\n StockSymbols[Locations.AevumAeroCorp] = \"AERO\";\r\n StockSymbols[Locations.VolhavenOmniaCybersystems] = \"OMN\";\r\n StockSymbols[Locations.ChongqingSolarisSpaceSystems] = \"SLRS\";\r\n StockSymbols[Locations.NewTokyoGlobalPharmaceuticals] = \"GPH\";\r\n StockSymbols[Locations.IshimaNovaMedical] = \"NVMD\";\r\n StockSymbols[Locations.AevumWatchdogSecurity] = \"WDS\";\r\n StockSymbols[Locations.VolhavenLexoCorp] = \"LXO\";\r\n StockSymbols[Locations.AevumRhoConstruction] = \"RHOC\";\r\n StockSymbols[Locations.Sector12AlphaEnterprises] = \"APHE\";\r\n StockSymbols[Locations.VolhavenSysCoreSecurities] = \"SYSC\";\r\n StockSymbols[Locations.VolhavenCompuTek] = \"CTK\";\r\n StockSymbols[Locations.AevumNetLinkTechnologies] = \"NTLK\";\r\n StockSymbols[Locations.IshimaOmegaSoftware] = \"OMGA\";\r\n StockSymbols[Locations.Sector12FoodNStuff] = \"FNS\";\r\n\r\n //Stocks for other companies\r\n StockSymbols[\"Sigma Cosmetics\"] = \"SGC\";\r\n StockSymbols[\"Joes Guns\"] = \"JGN\";\r\n StockSymbols[\"Catalyst Ventures\"] = \"CTYS\";\r\n StockSymbols[\"Microdyne Technologies\"] = \"MDYN\";\r\n StockSymbols[\"Titan Laboratories\"] = \"TITN\";\r\n}\r\n\r\nfunction initStockMarket() {\r\n for (var stk in StockMarket) {\r\n if (StockMarket.hasOwnProperty(stk)) {\r\n delete StockMarket[stk];\r\n }\r\n }\r\n\r\n var ecorp = Locations.AevumECorp;\r\n var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, getRandomInt(20000, 25000));\r\n StockMarket[ecorp] = ecorpStk;\r\n\r\n var megacorp = Locations.Sector12MegaCorp;\r\n var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, getRandomInt(25000, 33000));\r\n StockMarket[megacorp] = megacorpStk;\r\n\r\n var blade = Locations.Sector12BladeIndustries;\r\n var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, getRandomInt(15000, 22000));\r\n StockMarket[blade] = bladeStk;\r\n\r\n var clarke = Locations.AevumClarkeIncorporated;\r\n var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, getRandomInt(15000, 20000));\r\n StockMarket[clarke] = clarkeStk;\r\n\r\n var omnitek = Locations.VolhavenOmniTekIncorporated;\r\n var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, getRandomInt(35000, 40000));\r\n StockMarket[omnitek] = omnitekStk;\r\n\r\n var foursigma = Locations.Sector12FourSigma;\r\n var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, getRandomInt(60000, 70000));\r\n StockMarket[foursigma] = foursigmaStk;\r\n\r\n var kuaigong = Locations.ChongqingKuaiGongInternational;\r\n var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, getRandomInt(20000, 24000));\r\n StockMarket[kuaigong] = kuaigongStk;\r\n\r\n var fulcrum = Locations.AevumFulcrumTechnologies;\r\n var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, getRandomInt(30000, 35000));\r\n StockMarket[fulcrum] = fulcrumStk;\r\n\r\n var storm = Locations.IshimaStormTechnologies;\r\n var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, getRandomInt(21000, 24000));\r\n StockMarket[storm] = stormStk;\r\n\r\n var defcomm = Locations.NewTokyoDefComm;\r\n var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, getRandomInt(10000, 15000));\r\n StockMarket[defcomm] = defcommStk;\r\n\r\n var helios = Locations.VolhavenHeliosLabs;\r\n var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, getRandomInt(12000, 16000));\r\n StockMarket[helios] = heliosStk;\r\n\r\n var vitalife = Locations.NewTokyoVitaLife;\r\n var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, getRandomInt(10000, 12000));\r\n StockMarket[vitalife] = vitalifeStk;\r\n\r\n var icarus = Locations.Sector12IcarusMicrosystems;\r\n var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, getRandomInt(16000, 20000));\r\n StockMarket[icarus] = icarusStk;\r\n\r\n var universalenergy = Locations.Sector12UniversalEnergy;\r\n var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, getRandomInt(20000, 25000));\r\n StockMarket[universalenergy] = universalenergyStk;\r\n\r\n var aerocorp = Locations.AevumAeroCorp;\r\n var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, getRandomInt(10000, 15000));\r\n StockMarket[aerocorp] = aerocorpStk;\r\n\r\n var omnia = Locations.VolhavenOmniaCybersystems;\r\n var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, getRandomInt(9000, 12000));\r\n StockMarket[omnia] = omniaStk;\r\n\r\n var solaris = Locations.ChongqingSolarisSpaceSystems;\r\n var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, getRandomInt(18000, 24000));\r\n StockMarket[solaris] = solarisStk;\r\n\r\n var globalpharm = Locations.NewTokyoGlobalPharmaceuticals;\r\n var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, getRandomInt(18000, 24000));\r\n StockMarket[globalpharm] = globalpharmStk;\r\n\r\n var nova = Locations.IshimaNovaMedical;\r\n var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, getRandomInt(18000, 24000));\r\n StockMarket[nova] = novaStk;\r\n\r\n var watchdog = Locations.AevumWatchdogSecurity;\r\n var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, getRandomInt(5000, 7500));\r\n StockMarket[watchdog] = watchdogStk;\r\n\r\n var lexocorp = Locations.VolhavenLexoCorp;\r\n var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, getRandomInt(5000, 7500));\r\n StockMarket[lexocorp] = lexocorpStk;\r\n\r\n var rho = Locations.AevumRhoConstruction;\r\n var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, getRandomInt(3000, 6000));\r\n StockMarket[rho] = rhoStk;\r\n\r\n var alpha = Locations.Sector12AlphaEnterprises;\r\n var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, getRandomInt(5000, 7500));\r\n StockMarket[alpha] = alphaStk;\r\n\r\n var syscore = Locations.VolhavenSysCoreSecurities;\r\n var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, getRandomInt(4000, 7000))\r\n StockMarket[syscore] = syscoreStk;\r\n\r\n var computek = Locations.VolhavenCompuTek;\r\n var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, getRandomInt(2000, 5000));\r\n StockMarket[computek] = computekStk;\r\n\r\n var netlink = Locations.AevumNetLinkTechnologies;\r\n var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, getRandomInt(2000, 4000));\r\n StockMarket[netlink] = netlinkStk;\r\n\r\n var omega = Locations.IshimaOmegaSoftware;\r\n var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, getRandomInt(3000, 6000));\r\n StockMarket[omega] = omegaStk;\r\n\r\n var fns = Locations.Sector12FoodNStuff;\r\n var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, getRandomInt(1000, 4000));\r\n StockMarket[fns] = fnsStk;\r\n\r\n var sigmacosm = \"Sigma Cosmetics\";\r\n var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, getRandomInt(2000, 3000));\r\n StockMarket[sigmacosm] = sigmacosmStk;\r\n\r\n var joesguns = \"Joes Guns\";\r\n var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, getRandomInt(500, 1000));\r\n StockMarket[joesguns] = joesgunsStk;\r\n\r\n var catalyst = \"Catalyst Ventures\";\r\n var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, getRandomInt(500, 1000));\r\n StockMarket[catalyst] = catalystStk;\r\n\r\n var microdyne = \"Microdyne Technologies\";\r\n var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, getRandomInt(20000, 25000));\r\n StockMarket[microdyne] = microdyneStk;\r\n\r\n var titanlabs = \"Titan Laboratories\";\r\n var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, getRandomInt(15000, 20000));\r\n StockMarket[titanlabs] = titanlabsStk;\r\n\r\n var orders = {};\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;}\r\n orders[stock.symbol] = [];\r\n }\r\n }\r\n StockMarket[\"Orders\"] = orders;\r\n}\r\n\r\nfunction initSymbolToStockMap() {\r\n for (var name in StockSymbols) {\r\n if (StockSymbols.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (stock == null) {\r\n console.log(\"ERROR finding stock\");\r\n continue;\r\n }\r\n var symbol = StockSymbols[name];\r\n SymbolToStockMap[symbol] = stock;\r\n }\r\n }\r\n}\r\n\r\nfunction stockMarketCycle() {\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n var thresh = 0.6;\r\n if (stock.b) {thresh = 0.4;}\r\n if (Math.random() < thresh) {\r\n stock.b = !stock.b;\r\n }\r\n }\r\n }\r\n}\r\n\r\n//Returns true if successful, false otherwise\r\nfunction buyStock(stock, shares) {\r\n if (stock == null || shares < 0 || isNaN(shares)) {\r\n dialogBoxCreate(\"Failed to buy stock. This may be a bug, contact developer\");\r\n return false;\r\n }\r\n shares = Math.round(shares);\r\n if (shares == 0) {return false;}\r\n\r\n var totalPrice = stock.price * shares;\r\n if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) {\r\n dialogBoxCreate(\"You do not have enough money to purchase this. You need $\" +\r\n formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString() + \".\");\r\n return false;\r\n }\r\n\r\n var origTotal = stock.playerShares * stock.playerAvgPx;\r\n Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission);\r\n var newTotal = origTotal + totalPrice;\r\n stock.playerShares += shares;\r\n stock.playerAvgPx = newTotal / stock.playerShares;\r\n updateStockPlayerPosition(stock);\r\n dialogBoxCreate(\"Bought \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share. You also paid $\" +\r\n formatNumber(CONSTANTS.StockMarketCommission, 2) + \" in commission fees.\");\r\n return true;\r\n}\r\n\r\n//Returns true if successful and false otherwise\r\nfunction sellStock(stock, shares) {\r\n if (shares == 0) {return false;}\r\n if (stock == null || shares < 0 || isNaN(shares)) {\r\n dialogBoxCreate(\"Failed to sell stock. This may be a bug, contact developer\");\r\n return false;\r\n }\r\n shares = Math.round(shares);\r\n if (shares > stock.playerShares) {shares = stock.playerShares;}\r\n if (shares === 0) {return false;}\r\n var gains = stock.price * shares - CONSTANTS.StockMarketCommission;\r\n Player.gainMoney(gains);\r\n stock.playerShares -= shares;\r\n if (stock.playerShares == 0) {\r\n stock.playerAvgPx = 0;\r\n }\r\n updateStockPlayerPosition(stock);\r\n dialogBoxCreate(\"Sold \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share. After commissions, you gained \" +\r\n \"a total of $\" + formatNumber(gains, 2));\r\n return true;\r\n}\r\n\r\n//Returns true if successful and false otherwise\r\nfunction shortStock(stock, shares, workerScript=null) {\r\n var tixApi = (workerScript instanceof WorkerScript);\r\n if (stock == null || isNaN(shares) || shares < 0) {\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"ERROR: shortStock() failed because of invalid arguments.\");\r\n } else {\r\n dialogBoxCreate(\"Failed to initiate a short position in a stock. This is probably \" +\r\n \"due to an invalid quantity. Otherwise, this may be a bug, so contact developer\");\r\n }\r\n return false;\r\n }\r\n shares = Math.round(shares);\r\n if (shares === 0) {return false;}\r\n\r\n var totalPrice = stock.price * shares;\r\n if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) {\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"ERROR: shortStock() failed because you do not have \" +\r\n \"money to purchase this short position. You need \" +\r\n numeral(totalPrice + CONSTANTS.StockMarketCommission).format('($0.000a)'));\r\n } else {\r\n dialogBoxCreate(\"You do not have enough money to purchase this short position. You need $\" +\r\n formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2) + \".\");\r\n }\r\n\r\n return false;\r\n }\r\n\r\n var origTotal = stock.playerShortShares * stock.playerAvgShortPx;\r\n Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission);\r\n var newTotal = origTotal + totalPrice;\r\n stock.playerShortShares += shares;\r\n stock.playerAvgShortPx = newTotal / stock.playerShortShares;\r\n updateStockPlayerPosition(stock);\r\n if (tixApi) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {\r\n workerScript.scriptRef.log(\"Bought a short position of \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at \" +\r\n numeral(stock.price).format('($0.000a)') + \" per share. Paid \" +\r\n numeral(CONSTANTS.StockMarketCommission).format('($0.000a)') + \" in commission fees.\");\r\n }\r\n } else {\r\n dialogBoxCreate(\"Bought a short position of \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share. You also paid $\" +\r\n formatNumber(CONSTANTS.StockMarketCommission, 2) + \" in commission fees.\");\r\n }\r\n return true;\r\n}\r\n\r\n//Returns true if successful and false otherwise\r\nfunction sellShort(stock, shares, workerScript=null) {\r\n var tixApi = (workerScript instanceof WorkerScript);\r\n if (stock == null || isNaN(shares) || shares < 0) {\r\n if (tixApi) {\r\n workerScript.scriptRef.log(\"ERROR: sellShort() failed because of invalid arguments.\");\r\n } else {\r\n dialogBoxCreate(\"Failed to sell a short position in a stock. This is probably \" +\r\n \"due to an invalid quantity. Otherwise, this may be a bug, so contact developer\");\r\n }\r\n return false;\r\n }\r\n shares = Math.round(shares);\r\n if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}\r\n if (shares === 0) {return false;}\r\n\r\n var origCost = shares * stock.playerAvgShortPx;\r\n var profit = ((stock.playerAvgShortPx - stock.price) * shares) - CONSTANTS.StockMarketCommission;\r\n if (isNaN(profit)) {profit = 0;}\r\n Player.gainMoney(origCost + profit);\r\n if (tixApi) {\r\n workerScript.scriptRef.onlineMoneyMade += profit;\r\n Player.scriptProdSinceLastAug += profit;\r\n }\r\n\r\n stock.playerShortShares -= shares;\r\n if (stock.playerShortShares === 0) {\r\n stock.playerAvgShortPx = 0;\r\n }\r\n updateStockPlayerPosition(stock);\r\n if (tixApi) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {\r\n workerScript.scriptRef.log(\"Sold your short position of \" + shares + \" shares of \" + stock.symbol + \" at \" +\r\n numeral(stock.price).format('($0.000a)') + \" per share. After commissions, you gained \" +\r\n \"a total of \" + numeral(origCost + profit).format('($0.000a)'));\r\n }\r\n } else {\r\n dialogBoxCreate(\"Sold your short position of \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share. After commissions, you gained \" +\r\n \"a total of $\" + formatNumber(origCost + profit, 2));\r\n }\r\n\r\n return true;\r\n}\r\n\r\nfunction updateStockPrices() {\r\n var v = Math.random();\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;}\r\n var av = (v * stock.mv) / 100;\r\n if (isNaN(av)) {av = .02;}\r\n\r\n var chc = 50;\r\n if (stock.b) {\r\n chc = (chc + stock.otlkMag)/100;\r\n if (isNaN(chc)) {chc = 0.5;}\r\n } else {\r\n chc = (chc - stock.otlkMag)/100;\r\n if (isNaN(chc)) {chc = 0.5;}\r\n }\r\n if (stock.price >= StockPriceCap) {\r\n chc = -1; //Limit on stock price\r\n stock.b = false;\r\n }\r\n\r\n var c = Math.random();\r\n if (c < chc) {\r\n stock.price *= (1 + av);\r\n processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);\r\n processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);\r\n processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);\r\n processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);\r\n if (Engine.currentPage == Engine.Page.StockMarket) {\r\n updateStockTicker(stock, true);\r\n }\r\n } else {\r\n stock.price /= (1 + av);\r\n processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);\r\n processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);\r\n processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);\r\n processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);\r\n if (Engine.currentPage == Engine.Page.StockMarket) {\r\n updateStockTicker(stock, false);\r\n }\r\n }\r\n\r\n var otlkMagChange = stock.otlkMag * av;\r\n if (stock.otlkMag <= 0.1) {\r\n otlkMagChange = 1;\r\n }\r\n if (c < 0.5) {\r\n stock.otlkMag += otlkMagChange;\r\n } else {\r\n stock.otlkMag -= otlkMagChange;\r\n }\r\n if (stock.otlkMag < 0) {\r\n stock.otlkMag *= -1;\r\n stock.b = !stock.b;\r\n }\r\n\r\n }\r\n }\r\n}\r\n\r\n//Checks and triggers any orders for the specified stock\r\nfunction processOrders(stock, orderType, posType) {\r\n var orderBook = StockMarket[\"Orders\"];\r\n if (orderBook == null) {\r\n var orders = {};\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;}\r\n orders[stock.symbol] = [];\r\n }\r\n }\r\n StockMarket[\"Orders\"] = orders;\r\n return; //Newly created, so no orders to process\r\n }\r\n var stockOrders = orderBook[stock.symbol];\r\n if (stockOrders == null || !(stockOrders.constructor === Array)) {\r\n console.log(\"ERROR: Invalid Order book for \" + stock.symbol + \" in processOrders()\");\r\n stockOrders = [];\r\n return;\r\n }\r\n for (var i = 0; i < stockOrders.length; ++i) {\r\n var order = stockOrders[i];\r\n if (order.type === orderType && order.pos === posType) {\r\n switch(order.type) {\r\n case OrderTypes.LimitBuy:\r\n if (order.pos === PositionTypes.Long && stock.price <= order.price) {\r\n executeOrder/*66*/(order);\r\n } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {\r\n executeOrder/*66*/(order);\r\n }\r\n break;\r\n case OrderTypes.LimitSell:\r\n if (order.pos === PositionTypes.Long && stock.price >= order.price) {\r\n executeOrder/*66*/(order);\r\n } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {\r\n executeOrder/*66*/(order);\r\n }\r\n break;\r\n case OrderTypes.StopBuy:\r\n if (order.pos === PositionTypes.Long && stock.price >= order.price) {\r\n executeOrder/*66*/(order);\r\n } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {\r\n executeOrder/*66*/(order);\r\n }\r\n break;\r\n case OrderTypes.StopSell:\r\n if (order.pos === PositionTypes.Long && stock.price <= order.price) {\r\n executeOrder/*66*/(order);\r\n } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {\r\n executeOrder/*66*/(order);\r\n }\r\n break;\r\n default:\r\n console.log(\"Invalid order type: \" + order.type);\r\n return;\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction setStockMarketContentCreated(b) {\r\n stockMarketContentCreated = b;\r\n}\r\n\r\nvar stockMarketContentCreated = false;\r\nvar stockMarketPortfolioMode = false;\r\nvar COMM = CONSTANTS.StockMarketCommission;\r\nfunction displayStockMarketContent() {\r\n if (Player.hasWseAccount == null) {Player.hasWseAccount = false;}\r\n if (Player.hasTixApiAccess == null) {Player.hasTixApiAccess = false;}\r\n\r\n //Purchase WSE Account button\r\n var wseAccountButton = clearEventListeners(\"stock-market-buy-account\");\r\n wseAccountButton.innerText = \"Buy WSE Account - $\" + formatNumber(CONSTANTS.WSEAccountCost, 2).toString();\r\n if (!Player.hasWseAccount && Player.money.gte(CONSTANTS.WSEAccountCost)) {\r\n wseAccountButton.setAttribute(\"class\", \"a-link-button\");\r\n } else if (Player.hasWseAccount){\r\n wseAccountButton.innerText = \"WSE Account - Purchased\";\r\n wseAccountButton.setAttribute(\"class\", \"a-link-button-bought\");\r\n } else {\r\n wseAccountButton.setAttribute(\"class\", \"a-link-button-inactive\");\r\n }\r\n wseAccountButton.addEventListener(\"click\", function() {\r\n Player.hasWseAccount = true;\r\n initStockMarket();\r\n initSymbolToStockMap();\r\n Player.loseMoney(CONSTANTS.WSEAccountCost);\r\n displayStockMarketContent();\r\n return false;\r\n });\r\n\r\n //Purchase TIX API Access account\r\n var tixApiAccessButton = clearEventListeners(\"stock-market-buy-tix-api\");\r\n tixApiAccessButton.innerText = \"Buy Trade Information eXchange (TIX) API Access - $\" +\r\n formatNumber(CONSTANTS.TIXAPICost, 2).toString();\r\n if (!Player.hasTixApiAccess && Player.money.gte(CONSTANTS.TIXAPICost)) {\r\n tixApiAccessButton.setAttribute(\"class\", \"a-link-button\");\r\n } else if(Player.hasTixApiAccess) {\r\n tixApiAccessButton.innerText = \"Trade Information eXchange (TIX) API Access - Purchased\"\r\n tixApiAccessButton.setAttribute(\"class\", \"a-link-button-bought\");\r\n } else {\r\n tixApiAccessButton.setAttribute(\"class\", \"a-link-button-inactive\");\r\n }\r\n tixApiAccessButton.addEventListener(\"click\", function() {\r\n Player.hasTixApiAccess = true;\r\n Player.loseMoney(CONSTANTS.TIXAPICost);\r\n displayStockMarketContent();\r\n return false;\r\n });\r\n\r\n var stockList = document.getElementById(\"stock-market-list\");\r\n if (stockList == null) {return;}\r\n\r\n if (!Player.hasWseAccount) {\r\n stockMarketContentCreated = false;\r\n while (stockList.firstChild) {\r\n stockList.removeChild(stockList.firstChild);\r\n }\r\n return;\r\n }\r\n\r\n //Create stock market content if you have an account\r\n if (!stockMarketContentCreated && Player.hasWseAccount) {\r\n console.log(\"Creating Stock Market UI\");\r\n document.getElementById(\"stock-market-commission\").innerHTML =\r\n \"Commission Fees: Every transaction you make has a $\" +\r\n formatNumber(CONSTANTS.StockMarketCommission, 2) + \" commission fee.
\" +\r\n \"WARNING: When you reset after installing Augmentations, the Stock Market is reset. \" +\r\n \"This means all your positions are lost, so make sure to sell your stocks before installing \" +\r\n \"Augmentations!\";\r\n\r\n var investopediaButton = clearEventListeners(\"stock-market-investopedia\");\r\n investopediaButton.addEventListener(\"click\", function() {\r\n var txt = \"When making a transaction on the stock market, there are two \" +\r\n \"types of positions: Long and Short. A Long position is the typical \" +\r\n \"scenario where you buy a stock and earn a profit if the price of that \" +\r\n \"stock increases. Meanwhile, a Short position is the exact opposite. \" +\r\n \"In a Short position you purchase shares of a stock and earn a profit \" +\r\n \"if the price of that stock decreases. This is also called 'shorting' a stock.
\" +\r\n \"NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.
\" +\r\n \"There are three different types of orders you can make to buy or sell \" +\r\n \"stocks on the exchange: Market Order, Limit Order, and Stop Order. \" +\r\n \"Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked \" +\r\n \"later on in the game.
\" +\r\n \"When you place a Market Order to buy or sell a stock, the order executes \" +\r\n \"immediately at whatever the current price of the stock is. For example \" +\r\n \"if you choose to short a stock with 5000 shares using a Market Order, \" +\r\n \"you immediately purchase those 5000 shares in a Short position at whatever \" +\r\n \"the current market price is for that stock.
\" +\r\n \"A Limit Order is an order that only executes under certain conditions. \" +\r\n \"A Limit Order is used to buy or sell a stock at a specified price or better. \" +\r\n \"For example, lets say you purchased a Long position of 100 shares of some stock \" +\r\n \"at a price of $10 per share. You can place a Limit Order to sell those 100 shares \" +\r\n \"at $50 or better. The Limit Order will execute when the price of the stock reaches a \" +\r\n \"value of $50 or higher.
\" +\r\n \"A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock \" +\r\n \"at a specified price (before the price gets 'worse'). For example, lets say you purchased \" +\r\n \"a Short position of 100 shares of some stock at a price of $100 per share. \" +\r\n \"The current price of the stock is $80 (a profit of $20 per share). You can place a \" +\r\n \"Stop Order to sell the Short position if the stock's price reaches $90 or higher. \" +\r\n \"This can be used to lock in your profits and limit any losses.
\" +\r\n \"Here is a summary of how each order works and when they execute:
\" +\r\n \"In a LONG Position:
\" +\r\n \"A Limit Order to buy will execute if the stock's price <= order's price
\" +\r\n \"A Limit Order to sell will execute if the stock's price >= order's price
\" +\r\n \"A Stop Order to buy will execute if the stock's price >= order's price
\" +\r\n \"A Stop Order to sell will execute if the stock's price <= order's price
\" +\r\n \"In a SHORT Position:
\" +\r\n \"A Limit Order to buy will execute if the stock's price >= order's price
\" +\r\n \"A Limit Order to sell will execute if the stock's price <= order's price
\" +\r\n \"A Stop Order to buy will execute if the stock's price <= order's price
\" +\r\n \"A Stop Order to sell will execute if the stock's price >= order's price.\";\r\n dialogBoxCreate(txt);\r\n return false;\r\n });\r\n\r\n //Switch to Portfolio Mode Button\r\n var modeBtn = clearEventListeners(\"stock-market-mode\");\r\n if (modeBtn) {\r\n modeBtn.innerHTML = \"Switch to 'Portfolio' Mode\" +\r\n \"Displays only the stocks for which you have shares or orders\";\r\n modeBtn.addEventListener(\"click\", switchToPortfolioMode);\r\n }\r\n\r\n //Expand/Collapse tickers buttons\r\n var expandBtn = clearEventListeners(\"stock-market-expand-tickers\"),\r\n collapseBtn = clearEventListeners(\"stock-market-collapse-tickers\"),\r\n stockList = document.getElementById(\"stock-market-list\");\r\n if (expandBtn) {\r\n expandBtn.addEventListener(\"click\", ()=>{\r\n var tickerHdrs = stockList.getElementsByClassName(\"accordion-header\");\r\n for (var i = 0; i < tickerHdrs.length; ++i) {\r\n if (!tickerHdrs[i].classList.contains(\"active\")) {\r\n tickerHdrs[i].click();\r\n }\r\n }\r\n });\r\n }\r\n if (collapseBtn) {\r\n collapseBtn.addEventListener(\"click\",()=>{\r\n var tickerHdrs = stockList.getElementsByClassName(\"accordion-header\");\r\n for (var i = 0; i < tickerHdrs.length; ++i) {\r\n if (tickerHdrs[i].classList.contains(\"active\")) {\r\n tickerHdrs[i].click();\r\n }\r\n }\r\n });\r\n }\r\n\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;} //orders property is an array\r\n createStockTicker(stock);\r\n }\r\n }\r\n setStockTickerClickHandlers(); //Clicking headers opens/closes panels\r\n stockMarketContentCreated = true;\r\n }\r\n\r\n if (Player.hasWseAccount) {\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n updateStockTicker(stock, null);\r\n updateStockOrderList(stock);\r\n }\r\n }\r\n }\r\n}\r\n\r\n//Displays only stocks you have position/order in\r\nfunction switchToPortfolioMode() {\r\n stockMarketPortfolioMode = true;\r\n var stockList = document.getElementById(\"stock-market-list\");\r\n if (stockList == null) {return;}\r\n var modeBtn = clearEventListeners(\"stock-market-mode\");\r\n if (modeBtn) {\r\n modeBtn.innerHTML = \"Switch to 'All stocks' Mode\" +\r\n \"Displays all stocks on the WSE\";\r\n modeBtn.addEventListener(\"click\", switchToDisplayAllMode);\r\n }\r\n while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}\r\n\r\n //Get Order book (create it if it hasn't been created)\r\n var orderBook = StockMarket[\"Orders\"];\r\n if (orderBook == null) {\r\n var orders = {};\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;}\r\n orders[stock.symbol] = [];\r\n }\r\n }\r\n StockMarket[\"Orders\"] = orders;\r\n }\r\n\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;} //orders property is an array\r\n var stockOrders = orderBook[stock.symbol];\r\n if (stock.playerShares === 0 && stock.playerShortShares === 0 &&\r\n stockOrders.length === 0) {continue;}\r\n createStockTicker(stock);\r\n }\r\n }\r\n setStockTickerClickHandlers();\r\n}\r\n\r\n//Displays all stocks\r\nfunction switchToDisplayAllMode() {\r\n stockMarketPortfolioMode = false;\r\n var stockList = document.getElementById(\"stock-market-list\");\r\n if (stockList == null) {return;}\r\n var modeBtn = clearEventListeners(\"stock-market-mode\");\r\n if (modeBtn) {\r\n modeBtn.innerHTML = \"Switch to 'Portfolio' Mode\" +\r\n \"Displays only the stocks for which you have shares or orders\";\r\n modeBtn.addEventListener(\"click\", switchToPortfolioMode);\r\n }\r\n while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}\r\n for (var name in StockMarket) {\r\n if (StockMarket.hasOwnProperty(name)) {\r\n var stock = StockMarket[name];\r\n if (!(stock instanceof Stock)) {continue;} //orders property is an array\r\n createStockTicker(stock);\r\n }\r\n }\r\n setStockTickerClickHandlers();\r\n}\r\n\r\nfunction createStockTicker(stock) {\r\n if (!(stock instanceof Stock)) {\r\n console.log(\"Invalid stock in createStockSticker()\");\r\n return;\r\n }\r\n var tickerId = \"stock-market-ticker-\" + stock.symbol;\r\n var li = document.createElement(\"li\"), hdr = document.createElement(\"button\");\r\n hdr.classList.add(\"accordion-header\");\r\n hdr.setAttribute(\"id\", tickerId + \"-hdr\");\r\n hdr.innerHTML = stock.name + \" - \" + stock.symbol + \" - $\" + stock.price;\r\n\r\n //Div for entire panel\r\n var stockDiv = document.createElement(\"div\");\r\n stockDiv.classList.add(\"accordion-panel\");\r\n stockDiv.setAttribute(\"id\", tickerId + \"-panel\");\r\n\r\n /* Create panel DOM */\r\n var qtyInput = document.createElement(\"input\"),\r\n longShortSelect = document.createElement(\"select\"),\r\n orderTypeSelect = document.createElement(\"select\"),\r\n buyButton = document.createElement(\"span\"),\r\n sellButton = document.createElement(\"span\"),\r\n buyMaxButton = document.createElement(\"span\"),\r\n sellAllButton = document.createElement(\"span\"),\r\n positionTxt = document.createElement(\"p\"),\r\n orderList = document.createElement(\"ul\");\r\n\r\n qtyInput.classList.add(\"stock-market-input\");\r\n qtyInput.placeholder = \"Quantity (Shares)\";\r\n qtyInput.setAttribute(\"id\", tickerId + \"-qty-input\");\r\n qtyInput.setAttribute(\"onkeydown\", \"return ( event.ctrlKey || event.altKey \" +\r\n \" || (47Long Position: \" +\r\n \"Shares in the long position will increase \" +\r\n \"in value if the price of the corresponding stock increases
\" +\r\n \"
Shares: \" + formatNumber(stock.playerShares, 0) +\r\n \"
Average Price: \" + numeral(stock.playerAvgPx).format('$0.000a') +\r\n \" (Total Cost: \" + numeral(totalCost).format('$0.000a') + \")\" +\r\n \"
Profit: \" + numeral(gains).format('$0.000a') +\r\n \" (\" + formatNumber(percentageGains*100, 2) + \"%)
\";\r\n if (Player.bitNodeN === 8 || (hasWallStreetSF && wallStreetSFLvl >= 2)) {\r\n stock.posTxtEl.innerHTML +=\r\n \"Short Position: \" +\r\n \"Shares in short position will increase \" +\r\n \"in value if the price of the corresponding stock decreases
\" +\r\n \"
Shares: \" + formatNumber(stock.playerShortShares, 0) +\r\n \"
Average Price: \" + numeral(stock.playerAvgShortPx).format('$0.000a') +\r\n \" (Total Cost: \" + numeral(shortTotalCost).format('$0.000a') + \")\" +\r\n \"
Profit: \" + numeral(shortGains).format('$0.000a') +\r\n \" (\" + formatNumber(shortPercentageGains*100, 2) + \"%)\" +\r\n \"Orders:
\";\r\n }\r\n\r\n}\r\n\r\nfunction updateStockOrderList(stock) {\r\n if (Engine.currentPage !== Engine.Page.StockMarket) {return;}\r\n var tickerId = \"stock-market-ticker-\" + stock.symbol;\r\n var orderList = document.getElementById(tickerId + \"-order-list\");\r\n if (orderList == null) {\r\n if (!stockMarketPortfolioMode) {console.log(\"ERROR: Could not find order list for \" + stock.symbol);}\r\n return;\r\n }\r\n\r\n var orderBook = StockMarket[\"Orders\"];\r\n if (orderBook == null) {\r\n console.log(\"ERROR: Could not find order book in stock market\");\r\n return;\r\n }\r\n var stockOrders = orderBook[stock.symbol];\r\n if (stockOrders == null) {\r\n console.log(\"ERROR: Could not find orders for: \" + stock.symbol);\r\n return;\r\n }\r\n\r\n if (stockMarketPortfolioMode) {\r\n if (stock.playerShares === 0 && stock.playerShortShares === 0 &&\r\n StockMarket[\"Orders\"] && StockMarket[\"Orders\"][stock.symbol] &&\r\n StockMarket[\"Orders\"][stock.symbol].length === 0) {\r\n removeElementById(tickerId + \"-hdr\");\r\n removeElementById(tickerId + \"-panel\");\r\n return;\r\n } else {\r\n //If the ticker hasn't been created, create it (handles updating)\r\n //If it has been created, continue normally\r\n if (document.getElementById(tickerId + \"-hdr\") == null) {\r\n createStockTicker(stock);\r\n setStockTickerClickHandlers();\r\n return;\r\n }\r\n }\r\n }\r\n\r\n //Remove everything from list\r\n while (orderList.firstChild) {\r\n orderList.removeChild(orderList.firstChild);\r\n }\r\n\r\n for (var i = 0; i < stockOrders.length; ++i) {\r\n (function() {\r\n var order = stockOrders[i];\r\n var li = document.createElement(\"li\");\r\n li.style.padding = \"4px\";\r\n var posText = (order.pos === PositionTypes.Long ? \"Long Position\" : \"Short Position\");\r\n li.style.color = \"white\";\r\n li.innerText = order.type + \" - \" + posText + \" - \" +\r\n order.shares + \" @ $\" + formatNumber(order.price, 2);\r\n\r\n var cancelButton = document.createElement(\"span\");\r\n cancelButton.classList.add(\"stock-market-order-cancel-btn\");\r\n cancelButton.classList.add(\"a-link-button\");\r\n cancelButton.innerHTML = \"Cancel Order\";\r\n cancelButton.addEventListener(\"click\", function() {\r\n cancelOrder({order: order}, null);\r\n return false;\r\n });\r\n li.appendChild(cancelButton);\r\n orderList.appendChild(li);\r\n }());\r\n\r\n }\r\n}\r\n\r\nexport {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols,\r\n initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock,\r\n sellStock, shortStock, sellShort, updateStockPrices, displayStockMarketContent,\r\n updateStockTicker, updateStockPlayerPosition, loadStockMarket,\r\n setStockMarketContentCreated, placeOrder, cancelOrder, Order, OrderTypes, PositionTypes};\r\n","import {Engine} from \"./engine.js\";\r\n\r\n/* Settings.js */\r\nlet Settings = {\r\n CodeInstructionRunTime: 50,\r\n MaxLogCapacity: 50,\r\n MaxPortCapacity: 50,\r\n SuppressMessages: false,\r\n SuppressFactionInvites: false,\r\n AutosaveInterval: 60,\r\n DisableHotkeys: false,\r\n ThemeHighlightColor: \"#ffffff\",\r\n ThemeFontColor: \"#66ff33\",\r\n ThemeBackgroundColor: \"#000000\",\r\n EditorTheme: \"Monokai\",\r\n EditorKeybinding: \"ace\",\r\n}\r\n\r\nfunction loadSettings(saveString) {\r\n Settings = JSON.parse(saveString);\r\n}\r\n\r\nfunction initSettings() {\r\n Settings.CodeInstructionRunTime = 50;\r\n Settings.MaxLogCapacity = 50;\r\n Settings.MaxPortCapacity = 50;\r\n Settings.SuppressMessages = false;\r\n Settings.SuppressFactionInvites = false;\r\n Settings.AutosaveInterval = 60;\r\n Settings.DisableHotkeys = false;\r\n}\r\n\r\nfunction setSettingsLabels() {\r\n var nsExecTime = document.getElementById(\"settingsNSExecTimeRangeValLabel\");\r\n var nsLogLimit = document.getElementById(\"settingsNSLogRangeValLabel\");\r\n var nsPortLimit = document.getElementById(\"settingsNSPortRangeValLabel\");\r\n var suppressMsgs = document.getElementById(\"settingsSuppressMessages\");\r\n var suppressFactionInv = document.getElementById(\"settingsSuppressFactionInvites\")\r\n var autosaveInterval = document.getElementById(\"settingsAutosaveIntervalValLabel\");\r\n var disableHotkeys = document.getElementById(\"settingsDisableHotkeys\");\r\n\r\n //Initialize values on labels\r\n nsExecTime.innerHTML = Settings.CodeInstructionRunTime + \"ms\";\r\n nsLogLimit.innerHTML = Settings.MaxLogCapacity;\r\n nsPortLimit.innerHTML = Settings.MaxPortCapacity;\r\n suppressMsgs.checked = Settings.SuppressMessages;\r\n suppressFactionInv.checked = Settings.SuppressFactionInvites;\r\n autosaveInterval.innerHTML = Settings.AutosaveInterval;\r\n disableHotkeys.checked = Settings.DisableHotkeys;\r\n\r\n //Set handlers for when input changes\r\n var nsExecTimeInput = document.getElementById(\"settingsNSExecTimeRangeVal\");\r\n var nsLogRangeInput = document.getElementById(\"settingsNSLogRangeVal\");\r\n var nsPortRangeInput = document.getElementById(\"settingsNSPortRangeVal\");\r\n var nsAutosaveIntervalInput = document.getElementById(\"settingsAutosaveIntervalVal\");\r\n nsExecTimeInput.value = Settings.CodeInstructionRunTime;\r\n nsLogRangeInput.value = Settings.MaxLogCapacity;\r\n nsPortRangeInput.value = Settings.MaxPortCapacity;\r\n nsAutosaveIntervalInput.value = Settings.AutosaveInterval;\r\n\r\n nsExecTimeInput.oninput = function() {\r\n nsExecTime.innerHTML = this.value + 'ms';\r\n Settings.CodeInstructionRunTime = this.value;\r\n };\r\n\r\n nsLogRangeInput.oninput = function() {\r\n nsLogLimit.innerHTML = this.value;\r\n Settings.MaxLogCapacity = this.value;\r\n };\r\n\r\n nsPortRangeInput.oninput = function() {\r\n nsPortLimit.innerHTML = this.value;\r\n Settings.MaxPortCapacity = this.value;\r\n };\r\n\r\n nsAutosaveIntervalInput.oninput = function() {\r\n autosaveInterval.innerHTML = this.value;\r\n Settings.AutosaveInterval = Number(this.value);\r\n if (Number(this.value) === 0) {\r\n Engine.Counters.autoSaveCounter = Infinity;\r\n } else {\r\n Engine.Counters.autoSaveCounter = Number(this.value) * 5;\r\n }\r\n };\r\n\r\n suppressMsgs.onclick = function() {\r\n Settings.SuppressMessages = this.checked;\r\n };\r\n\r\n suppressFactionInv.onclick = function() {\r\n Settings.SuppressFactionInvites = this.checked;\r\n };\r\n\r\n disableHotkeys.onclick = function() {\r\n Settings.DisableHotkeys = this.checked;\r\n }\r\n\r\n //Theme\r\n if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {\r\n console.log(\"ERROR: Cannot find Theme Settings\");\r\n return;\r\n }\r\n if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) &&\r\n /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) &&\r\n /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) {\r\n document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor);\r\n document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor);\r\n document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor);\r\n }\r\n}\r\n\r\nexport {Settings, initSettings, setSettingsLabels, loadSettings};\r\n","/*\r\n *\r\n * decimal.js v7.2.3\r\n * An arbitrary-precision Decimal type for JavaScript.\r\n * https://github.com/MikeMcl/decimal.js\r\n * Copyright (c) 2017 Michael Mclaughlin
\" +\r\n \"This tutorial will show you the basics of the game. \" +\r\n \"You may skip the tutorial at any time.\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.GoToCharacterPage:\r\n iTutorialSetText(\"Let's start by heading to the Stats page. Click the 'Stats' tab on \" +\r\n \"the main navigation menu (left-hand side of the screen)\");\r\n\r\n //No next button\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"none\";\r\n\r\n //Flash Character tab\r\n document.getElementById(\"stats-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n\r\n //Initialize everything necessary to open the \"Character\" page\r\n var charaterMainMenuButton = document.getElementById(\"stats-menu-link\");\r\n charaterMainMenuButton.addEventListener(\"click\", function() {\r\n Engine.loadCharacterContent();\r\n iTutorialNextStep(); //Opening the character page will go to the next step\r\n clearEventListeners(\"stats-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.CharacterPage:\r\n iTutorialSetText(\"The Stats page shows a lot of important information about your progress, \" +\r\n \"such as your skills, money, and bonuses/multipliers. \")\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.CharacterGoToTerminalPage:\r\n iTutorialSetText(\"Let's head to your computer's terminal by clicking the 'Terminal' tab on the \" +\r\n \"main navigation menu.\");\r\n //No next button\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"none\";\r\n\r\n document.getElementById(\"terminal-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n\r\n //Initialize everything necessary to open the 'Terminal' Page\r\n var terminalMainMenuButton = document.getElementById(\"terminal-menu-link\");\r\n terminalMainMenuButton.addEventListener(\"click\", function() {\r\n Engine.loadTerminalContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"terminal-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.TerminalIntro:\r\n iTutorialSetText(\"The Terminal is used to interface with your home computer as well as \" +\r\n \"all of the other machines around the world.\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.TerminalHelp:\r\n iTutorialSetText(\"Let's try it out. Start by entering the 'help' command into the Terminal \" +\r\n \"(Don't forget to press Enter after typing the command)\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"none\";\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalLs:\r\n iTutorialSetText(\"The 'help' command displays a list of all available Terminal commands, how to use them, \" +\r\n \"and a description of what they do.
Let's try another command. Enter the 'ls' command\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalScan:\r\n iTutorialSetText(\"'ls' is a basic command that shows all of the contents (programs/scripts) \" +\r\n \"on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. \" +\r\n \"We'll get to what this does later.
Using your home computer's terminal, you can connect \" +\r\n \"to other machines throughout the world. Let's do that now by first entering \" +\r\n \"the 'scan' command. \");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalScanAnalyze1:\r\n iTutorialSetText(\"The 'scan' command shows all available network connections. In other words, \" +\r\n \"it displays a list of all servers that can be connected to from your \" +\r\n \"current machine. A server is identified by either its IP or its hostname.
\" +\r\n \"That's great and all, but there's so many servers. Which one should you go to? \" +\r\n \"The 'scan-analyze' command gives some more detailed information about servers on the \" +\r\n \"network. Try it now\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalScanAnalyze2:\r\n iTutorialSetText(\"You just ran 'scan-analyze' with a depth of one. This command shows more detailed \" +\r\n \"information about each server that you can connect to (servers that are a distance of \" +\r\n \"one node away).
It is also possible to run 'scan-analyze' with \" +\r\n \"a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.\")\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalConnect:\r\n iTutorialSetText(\"Now you can see information about all servers that are up to two nodes away, as well \" +\r\n \"as figure out how to navigate to those servers through the network. You can only connect to \" +\r\n \"a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in \" +\r\n \"the ip or the hostname, but dont use both.
\" +\r\n \"From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is \" +\r\n \"only one node away. Let's connect so it now using: 'connect foodnstuff'\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalAnalyze:\r\n iTutorialSetText(\"You are now connected to another machine! What can you do now? You can hack it!
In the year 2077, currency has \" +\r\n \"become digital and decentralized. People and corporations store their money \" +\r\n \"on servers and computers. Using your hacking abilities, you can hack servers \" +\r\n \"to steal money and gain experience.
\" +\r\n \"Before you try to hack a server, you should run diagnostics using the 'analyze' command\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalNuke:\r\n iTutorialSetText(\"When the 'analyze' command finishes running it will show useful information \" +\r\n \"about hacking the server.
For this server, the required hacking skill is only 1, \" +\r\n \"which means you can hack it right now. However, in order to hack a server \" +\r\n \"you must first gain root access. The 'NUKE.exe' program that we saw earlier on your \" +\r\n \"home computer is a virus that will grant you root access to a machine if there are enough \" +\r\n \"open ports.
The 'analyze' results shows that there do not need to be any open ports \" +\r\n \"on this machine for the NUKE virus to work, so go ahead and run the virus using the \" +\r\n \"'run NUKE.exe' command.\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalManualHack:\r\n iTutorialSetText(\"You now have root access! You can hack the server using the 'hack' command. \" +\r\n \"Try doing that now.\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalHackingMechanics:\r\n iTutorialSetText(\"You are now attempting to hack the server. Note that performing a hack takes time and \" +\r\n \"only has a certain percentage chance \" +\r\n \"of success. This time and success chance is determined by a variety of factors, including \" +\r\n \"your hacking skill and the server's security level.
\" +\r\n \"If your attempt to hack the server is successful, you will steal a certain percentage \" +\r\n \"of the server's total money. This percentage is affected by your hacking skill and \" +\r\n \"the server's security level.
The amount of money on a server is not limitless. So, if \" +\r\n \"you constantly hack a server and deplete its money, then you will encounter \" +\r\n \"diminishing returns in your hacking.\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.TerminalCreateScript:\r\n iTutorialSetText(\"Hacking is the core mechanic of the game and is necessary for progressing. However, \" +\r\n \"you don't want to be hacking manually the entire time. You can automate your hacking \" +\r\n \"by writing scripts!
To create a new script or edit an existing one, you can use the 'nano' \" +\r\n \"command. Scripts must end with the '.script' extension. Let's make a script now by \" +\r\n \"entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c\" +\r\n \" will end a command like hack early)\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"none\";\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalTypeScript:\r\n iTutorialSetText(\"This is the script editor. You can use it to program your scripts. Scripts are \" +\r\n \"written in the Netscript language, a programming language created for \" +\r\n \"this game. There are details about the Netscript language in the documentation, which \" +\r\n \"can be accessed in the 'Tutorial' tab on the main navigation menu. I highly suggest you check \" +\r\n \"it out after this tutorial. For now, just copy \" +\r\n \"and paste the following code into the script editor:
\" +\r\n \"while(true) {
\" +\r\n \" hack('foodnstuff');
\" +\r\n \"}
\" +\r\n \"For anyone with basic programming experience, this code should be straightforward. \" +\r\n \"This script will continuously hack the 'foodnstuff' server.
\" +\r\n \"To save and close the script editor, press the button in the bottom left, or press ctrl + b.\");\r\n //next step triggered in saveAndCloseScriptEditor() (Script.js)\r\n break;\r\n case iTutorialSteps.TerminalFree:\r\n iTutorialSetText(\"Now we'll run the script. Scripts require a certain amount of RAM to run, and can be \" +\r\n \"run on any machine which you have root access to. Different servers have different \" +\r\n \"amounts of RAM. You can also purchase more RAM for your home server.
To check how much \" +\r\n \"RAM is available on this machine, enter the 'free' command.\");\r\n //next step triggered by terminal commmand\r\n break;\r\n case iTutorialSteps.TerminalRunScript:\r\n iTutorialSetText(\"We have 16GB of free RAM on this machine, which is enough to run our \" +\r\n \"script. Let's run our script using 'run foodnstuff.script'.\");\r\n //next step triggered by terminal commmand\r\n break;\r\n case iTutorialSteps.TerminalGoToActiveScriptsPage:\r\n iTutorialSetText(\"Your script is now running! The script might take a few seconds to 'fully start up'. \" +\r\n \"Your scripts will continuously run in the background and will automatically stop if \" +\r\n \"the code ever completes (the 'foodnstuff.script' will never complete because it \" +\r\n \"runs an infinite loop).
These scripts can passively earn you income and hacking experience. \" +\r\n \"Your scripts will also earn money and experience while you are offline, although at a \" +\r\n \"much slower rate.
\" +\r\n \"Let's check out some statistics for our running scripts by clicking the \" +\r\n \"'Active Scripts' link in the main navigation menu.\");\r\n document.getElementById(\"active-scripts-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n var activeScriptsMainMenuButton = document.getElementById(\"active-scripts-menu-link\");\r\n activeScriptsMainMenuButton.addEventListener(\"click\", function() {\r\n Engine.loadActiveScriptsContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"active-scripts-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.ActiveScriptsPage:\r\n iTutorialSetText(\"This page displays stats/information about all of your scripts that are \" +\r\n \"running across every existing server. You can use this to gauge how well \" +\r\n \"your scripts are doing. Let's go back to the Terminal now using the 'Terminal'\" +\r\n \"link.\");\r\n document.getElementById(\"terminal-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n //Initialize everything necessary to open the 'Terminal' Page\r\n var terminalMainMenuButton = clearEventListeners(\"terminal-menu-link\");\r\n terminalMainMenuButton.addEventListener(\"click\", function() {\r\n Engine.loadTerminalContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"terminal-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.ActiveScriptsToTerminal:\r\n iTutorialSetText(\"One last thing about scripts, each active script contains logs that detail \" +\r\n \"what it's doing. We can check these logs using the 'tail' command. Do that \" +\r\n \"now for the script we just ran by typing 'tail foodnstuff.script'\");\r\n //next step triggered by terminal command\r\n break;\r\n case iTutorialSteps.TerminalTailScript:\r\n iTutorialSetText(\"The log for this script won't show much right now (it might show nothing at all) because it \" +\r\n \"just started running...but check back again in a few minutes!
\" +\r\n \"This pretty much covers the basics of hacking. To learn more about writing \" +\r\n \"scripts using the Netscript language, select the 'Tutorial' link in the \" +\r\n \"main navigation menu to look at the documentation. For now, let's move on \" +\r\n \"to something else!\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.GoToHacknetNodesPage:\r\n iTutorialSetText(\"Hacking is not the only way to earn money. One other way to passively \" +\r\n \"earn money is by purchasing and upgrading Hacknet Nodes. Let's go to \" +\r\n \"the 'Hacknet Nodes' page through the main navigation menu now.\");\r\n document.getElementById(\"hacknet-nodes-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n var hacknetNodesButton = clearEventListeners(\"hacknet-nodes-menu-link\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"none\";\r\n hacknetNodesButton.addEventListener(\"click\", function() {\r\n Engine.loadHacknetNodesContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"hacknet-nodes-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.HacknetNodesIntroduction:\r\n iTutorialSetText(\"From this page you can purchase new Hacknet Nodes and upgrade your \" +\r\n \"existing ones. Let's purchase a new one now.\");\r\n //Next step triggered by purchaseHacknet() (HacknetNode.js)\r\n break;\r\n case iTutorialSteps.HacknetNodesGoToWorldPage:\r\n iTutorialSetText(\"You just purchased a Hacknet Node! This Hacknet Node will passively \" +\r\n \"earn you money over time, both online and offline. When you get enough \" +\r\n \" money, you can upgrade \" +\r\n \"your newly-purchased Hacknet Node below.
\" +\r\n \"Let's go to the 'City' page through the main navigation menu.\");\r\n document.getElementById(\"city-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n var worldButton = clearEventListeners(\"city-menu-link\");\r\n worldButton.addEventListener(\"click\", function() {\r\n Engine.loadWorldContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"city-menu-link\");\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.WorldDescription:\r\n iTutorialSetText(\"This page lists all of the different locations you can currently \" +\r\n \"travel to. Each location has something that you can do. \" +\r\n \"There's a lot of content out in the world, make sure \" +\r\n \"you explore and discover!
\" +\r\n \"Lastly, click on the 'Tutorial' link in the main navigation menu.\");\r\n document.getElementById(\"tutorial-menu-link\").setAttribute(\"class\", \"flashing-button\");\r\n var tutorialButton = clearEventListeners(\"tutorial-menu-link\");\r\n tutorialButton.addEventListener(\"click\", function() {\r\n Engine.loadTutorialContent();\r\n iTutorialNextStep();\r\n clearEventListeners(\"tutorial-menu-link\");\r\n return false;\r\n });\r\n break;\r\n\r\n case iTutorialSteps.TutorialPageInfo:\r\n iTutorialSetText(\"This page contains a lot of different documentation about the game's \" +\r\n \"content and mechanics. I know it's a lot, but I highly suggest you read \" +\r\n \"(or at least skim) through this before you start playing. That's the end of the tutorial. \" +\r\n \"Hope you enjoy the game!\");\r\n var next = clearEventListeners(\"interactive-tutorial-next\");\r\n next.style.display = \"inline-block\";\r\n next.innerHTML = \"Finish Tutorial\";\r\n\r\n var backButton = clearEventListeners(\"interactive-tutorial-back\");\r\n backButton.style.display = \"none\";\r\n\r\n next.addEventListener(\"click\", function() {\r\n iTutorialNextStep();\r\n return false;\r\n });\r\n break;\r\n case iTutorialSteps.End:\r\n iTutorialEnd();\r\n break;\r\n default:\r\n throw new Error(\"Invalid tutorial step\");\r\n }\r\n}\r\n\r\n//Go to the next step and evaluate it\r\nfunction iTutorialNextStep() {\r\n switch(currITutorialStep) {\r\n case iTutorialSteps.Start:\r\n currITutorialStep = iTutorialSteps.GoToCharacterPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.GoToCharacterPage:\r\n document.getElementById(\"stats-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.CharacterPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.CharacterPage:\r\n currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.CharacterGoToTerminalPage:\r\n document.getElementById(\"terminal-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.TerminalIntro;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalIntro:\r\n currITutorialStep = iTutorialSteps.TerminalHelp;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalHelp:\r\n currITutorialStep = iTutorialSteps.TerminalLs;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalLs:\r\n currITutorialStep = iTutorialSteps.TerminalScan;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalScan:\r\n currITutorialStep = iTutorialSteps.TerminalScanAnalyze1;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalScanAnalyze1:\r\n currITutorialStep = iTutorialSteps.TerminalScanAnalyze2;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalScanAnalyze2:\r\n currITutorialStep = iTutorialSteps.TerminalConnect;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalConnect:\r\n currITutorialStep = iTutorialSteps.TerminalAnalyze;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalAnalyze:\r\n currITutorialStep = iTutorialSteps.TerminalNuke;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalNuke:\r\n currITutorialStep = iTutorialSteps.TerminalManualHack;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalManualHack:\r\n currITutorialStep = iTutorialSteps.TerminalHackingMechanics;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalHackingMechanics:\r\n currITutorialStep = iTutorialSteps.TerminalCreateScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalCreateScript:\r\n currITutorialStep = iTutorialSteps.TerminalTypeScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalTypeScript:\r\n currITutorialStep = iTutorialSteps.TerminalFree;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalFree:\r\n currITutorialStep = iTutorialSteps.TerminalRunScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalRunScript:\r\n currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalGoToActiveScriptsPage:\r\n document.getElementById(\"active-scripts-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.ActiveScriptsPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.ActiveScriptsPage:\r\n document.getElementById(\"terminal-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.ActiveScriptsToTerminal:\r\n currITutorialStep = iTutorialSteps.TerminalTailScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalTailScript:\r\n currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.GoToHacknetNodesPage:\r\n document.getElementById(\"hacknet-nodes-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.HacknetNodesIntroduction:\r\n currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.HacknetNodesGoToWorldPage:\r\n document.getElementById(\"city-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.WorldDescription;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.WorldDescription:\r\n document.getElementById(\"tutorial-menu-link\").removeAttribute(\"class\");\r\n currITutorialStep = iTutorialSteps.TutorialPageInfo;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TutorialPageInfo:\r\n currITutorialStep = iTutorialSteps.End;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.End:\r\n break;\r\n default:\r\n throw new Error(\"Invalid tutorial step\");\r\n }\r\n}\r\n\r\n//Go to previous step and evaluate\r\nfunction iTutorialPrevStep() {\r\n switch(currITutorialStep) {\r\n case iTutorialSteps.Start:\r\n currITutorialStep = iTutorialSteps.Start;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.GoToCharacterPage:\r\n currITutorialStep = iTutorialSteps.Start;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.CharacterPage:\r\n currITutorialStep = iTutorialSteps.GoToCharacterPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.CharacterGoToTerminalPage:\r\n currITutorialStep = iTutorialSteps.CharacterPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalIntro:\r\n currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalHelp:\r\n currITutorialStep = iTutorialSteps.TerminalIntro;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalLs:\r\n currITutorialStep = iTutorialSteps.TerminalHelp;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalScan:\r\n currITutorialStep = iTutorialSteps.TerminalLs;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalConnect:\r\n currITutorialStep = iTutorialSteps.TerminalScan;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalAnalyze:\r\n currITutorialStep = iTutorialSteps.TerminalConnect;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalNuke:\r\n currITutorialStep = iTutorialSteps.TerminalAnalyze;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalManualHack:\r\n currITutorialStep = iTutorialSteps.TerminalNuke;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalHackingMechanics:\r\n currITutorialStep = iTutorialSteps.TerminalManualHack;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalCreateScript:\r\n currITutorialStep = iTutorialSteps.TerminalManualHack;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalTypeScript:\r\n currITutorialStep = iTutorialSteps.TerminalCreateScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalFree:\r\n currITutorialStep = iTutorialSteps.TerminalTypeScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalRunScript:\r\n currITutorialStep = iTutorialSteps.TerminalFree;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalGoToActiveScriptsPage:\r\n currITutorialStep = iTutorialSteps.TerminalRunScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.ActiveScriptsPage:\r\n currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.ActiveScriptsToTerminal:\r\n currITutorialStep = iTutorialSteps.ActiveScriptsPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TerminalTailScript:\r\n currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.GoToHacknetNodesPage:\r\n currITutorialStep = iTutorialSteps.TerminalTailScript;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.HacknetNodesIntroduction:\r\n currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.HacknetNodesGoToWorldPage:\r\n currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.WorldDescription:\r\n currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.TutorialPageInfo:\r\n currITutorialStep = iTutorialSteps.WorldDescription;\r\n iTutorialEvaluateStep();\r\n break;\r\n case iTutorialSteps.End:\r\n break;\r\n default:\r\n throw new Error(\"Invalid tutorial step\");\r\n }\r\n}\r\n\r\nfunction iTutorialEnd() {\r\n //Re-enable auto save\r\n Engine.Counters.autoSaveCounter = 300;\r\n console.log(\"Ending interactive tutorial\");\r\n Engine.init();\r\n currITutorialStep = iTutorialSteps.End;\r\n iTutorialIsRunning = false;\r\n document.getElementById(\"interactive-tutorial-container\").style.display = \"none\";\r\n dialogBoxCreate(\"If you are new to the game, the following links may be useful for you!
\" +\r\n \"Getting Started Guide\" +\r\n \"Wiki
\" +\r\n \"The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. \" +\r\n \"To read it, go to Terminal and enter
cat hackers-starting-handbook.lit\");\r\n Player.getHomeComputer().messages.push(\"hackers-starting-handbook.lit\");\r\n}\r\n\r\nfunction iTutorialSetText(txt) {\r\n var textBox = document.getElementById(\"interactive-tutorial-text\");\r\n if (textBox == null) {throw new Error(\"Could not find text box\"); return;}\r\n textBox.innerHTML = txt;\r\n textBox.parentElement.scrollTop = 0; // this resets scroll position\r\n}\r\n\r\nexport {iTutorialSteps, iTutorialEnd, iTutorialStart, iTutorialNextStep, currITutorialStep,\r\n iTutorialIsRunning};\r\n","var ace = require('brace');\r\nrequire('brace/mode/javascript');\r\nrequire('../netscript');\r\nrequire('brace/theme/chaos');\r\nrequire('brace/theme/chrome');\r\nrequire('brace/theme/monokai');\r\nrequire('brace/theme/solarized_dark');\r\nrequire('brace/theme/solarized_light');\r\nrequire('brace/theme/terminal');\r\nrequire('brace/theme/twilight');\r\nrequire('brace/theme/xcode');\r\nrequire(\"brace/keybinding/vim\");\r\nrequire(\"brace/keybinding/emacs\");\r\nrequire(\"brace/ext/language_tools\");\r\n\r\n// Importing this doesn't work for some reason.\r\nconst walk = require(\"acorn/dist/walk\");\r\n\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {FconfSettings, parseFconfSettings} from \"./Fconf.js\";\r\nimport {iTutorialSteps, iTutorialNextStep,\r\n iTutorialIsRunning, currITutorialStep} from \"./InteractiveTutorial.js\";\r\nimport {evaluateImport} from \"./NetscriptEvaluator.js\";\r\nimport {NetscriptFunctions} from \"./NetscriptFunctions.js\";\r\nimport {addWorkerScript, killWorkerScript,\r\n WorkerScript} from \"./NetscriptWorker.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {AllServers, processSingleServerGrowth} from \"./Server.js\";\r\nimport {Settings} from \"./Settings.js\";\r\nimport {post, Terminal} from \"./Terminal.js\";\r\nimport {TextFile} from \"./TextFile.js\";\r\n\r\nimport {parse, Node} from \"../utils/acorn.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\nimport {compareArrays, createElement} from \"../utils/HelperFunctions.js\";\r\nimport {formatNumber, numOccurrences,\r\n numNetscriptOperators} from \"../utils/StringHelperFunctions.js\";\r\n\r\nvar keybindings = {\r\n ace: null,\r\n vim: \"ace/keyboard/vim\",\r\n emacs: \"ace/keyboard/emacs\",\r\n};\r\n\r\nfunction isScriptFilename(f) {\r\n return f.endsWith(\".js\") || f.endsWith(\".script\") || f.endsWith(\".ns\");\r\n}\r\n\r\nvar scriptEditorRamCheck = null, scriptEditorRamText = null;\r\nfunction scriptEditorInit() {\r\n //Create buttons at the bottom of script editor\r\n var wrapper = document.getElementById(\"script-editor-buttons-wrapper\");\r\n if (wrapper == null) {\r\n console.log(\"Error finding 'script-editor-buttons-wrapper'\");\r\n return;\r\n }\r\n var closeButton = createElement(\"a\", {\r\n class:\"a-link-button\", display:\"inline-block\",\r\n innerText:\"Save & Close (Ctrl/Cmd + b)\",\r\n clickListener:()=>{\r\n saveAndCloseScriptEditor();\r\n return false;\r\n }\r\n });\r\n\r\n scriptEditorRamText = createElement(\"p\", {\r\n display:\"inline-block\", margin:\"10px\", id:\"script-editor-status-text\"\r\n });\r\n\r\n var checkboxLabel = createElement(\"label\", {\r\n for:\"script-editor-ram-check\", margin:\"4px\", marginTop: \"8px\",\r\n innerText:\"Dynamic RAM Usage Checker\", color:\"white\",\r\n tooltip:\"Enable/Disable the dynamic RAM Usage display. You may \" +\r\n \"want to disable it for very long scripts because there may be \" +\r\n \"performance issues\"\r\n });\r\n\r\n scriptEditorRamCheck = createElement(\"input\", {\r\n type:\"checkbox\", name:\"script-editor-ram-check\", id:\"script-editor-ram-check\",\r\n margin:\"4px\", marginTop: \"8px\",\r\n });\r\n scriptEditorRamCheck.checked = true;\r\n\r\n var documentationButton = createElement(\"a\", {\r\n display:\"inline-block\", class:\"a-link-button\", innerText:\"Netscript Documentation\",\r\n href:\"https://bitburner.readthedocs.io/en/latest/index.html\",\r\n target:\"_blank\"\r\n });\r\n\r\n wrapper.appendChild(closeButton);\r\n wrapper.appendChild(scriptEditorRamText);\r\n wrapper.appendChild(scriptEditorRamCheck);\r\n wrapper.appendChild(checkboxLabel);\r\n wrapper.appendChild(documentationButton);\r\n\r\n //Initialize ACE Script editor\r\n var editor = ace.edit('javascript-editor');\r\n editor.getSession().setMode('ace/mode/netscript');\r\n editor.setTheme('ace/theme/monokai');\r\n document.getElementById('javascript-editor').style.fontSize='16px';\r\n editor.setOption(\"showPrintMargin\", false);\r\n\r\n /* Script editor options */\r\n //Theme\r\n var themeDropdown = document.getElementById(\"script-editor-option-theme\");\r\n if (Settings.EditorTheme) {\r\n var initialIndex = 2;\r\n for (var i = 0; i < themeDropdown.options.length; ++i) {\r\n if (themeDropdown.options[i].value === Settings.EditorTheme) {\r\n initialIndex = i;\r\n break;\r\n }\r\n }\r\n themeDropdown.selectedIndex = initialIndex;\r\n } else {\r\n themeDropdown.selectedIndex = 2;\r\n }\r\n\r\n themeDropdown.onchange = function() {\r\n var val = themeDropdown.value;\r\n Settings.EditorTheme = val;\r\n var themePath = \"ace/theme/\" + val.toLowerCase();\r\n editor.setTheme(themePath);\r\n };\r\n themeDropdown.onchange();\r\n\r\n //Keybinding\r\n var keybindingDropdown = document.getElementById(\"script-editor-option-keybinding\");\r\n if (Settings.EditorKeybinding) {\r\n var initialIndex = 0;\r\n for (var i = 0; i < keybindingDropdown.options.length; ++i) {\r\n if (keybindingDropdown.options[i].value === Settings.EditorKeybinding) {\r\n initialIndex = i;\r\n break;\r\n }\r\n }\r\n keybindingDropdown.selectedIndex = initialIndex;\r\n } else {\r\n keybindingDropdown.selectedIndex = 0;\r\n }\r\n keybindingDropdown.onchange = function() {\r\n var val = keybindingDropdown.value;\r\n Settings.EditorKeybinding = val;\r\n editor.setKeyboardHandler(keybindings[val.toLowerCase()]);\r\n };\r\n keybindingDropdown.onchange();\r\n\r\n //Highlight Active line\r\n var highlightActiveChkBox = document.getElementById(\"script-editor-option-highlightactiveline\");\r\n highlightActiveChkBox.onchange = function() {\r\n editor.setHighlightActiveLine(highlightActiveChkBox.checked);\r\n };\r\n\r\n //Show Invisibles\r\n var showInvisiblesChkBox = document.getElementById(\"script-editor-option-showinvisibles\");\r\n showInvisiblesChkBox.onchange = function() {\r\n editor.setShowInvisibles(showInvisiblesChkBox.checked);\r\n };\r\n\r\n //Use Soft Tab\r\n var softTabChkBox = document.getElementById(\"script-editor-option-usesofttab\");\r\n softTabChkBox.onchange = function() {\r\n editor.getSession().setUseSoftTabs(softTabChkBox.checked);\r\n };\r\n\r\n //Jshint Maxerr\r\n var maxerr = document.getElementById(\"script-editor-option-maxerr\");\r\n var maxerrLabel = document.getElementById(\"script-editor-option-maxerror-value-label\");\r\n maxerrLabel.innerHTML = maxerr.value;\r\n maxerr.onchange = function() {\r\n editor.getSession().$worker.send(\"changeOptions\", [{maxerr:maxerr.value}]);\r\n maxerrLabel.innerHTML = maxerr.value;\r\n }\r\n\r\n //Configure some of the VIM keybindings\r\n ace.config.loadModule('ace/keyboard/vim', function(module) {\r\n var VimApi = module.CodeMirror.Vim;\r\n VimApi.defineEx('write', 'w', function(cm, input) {\r\n saveAndCloseScriptEditor();\r\n });\r\n VimApi.defineEx('quit', 'q', function(cm, input) {\r\n Engine.loadTerminalContent();\r\n });\r\n VimApi.defineEx('xwritequit', 'x', function(cm, input) {\r\n saveAndCloseScriptEditor();\r\n });\r\n VimApi.defineEx('wqwritequit', 'wq', function(cm, input) {\r\n saveAndCloseScriptEditor();\r\n });\r\n });\r\n\r\n //Function autocompleter\r\n editor.setOption(\"enableBasicAutocompletion\", true);\r\n var autocompleter = {\r\n getCompletions: function(editor, session, pos, prefix, callback) {\r\n if (prefix.length === 0) {callback(null, []); return;}\r\n var words = [];\r\n var fns = NetscriptFunctions(null);\r\n for (var name in fns) {\r\n if (fns.hasOwnProperty(name)) {\r\n words.push({\r\n name: name,\r\n value: name,\r\n });\r\n }\r\n }\r\n callback(null, words);\r\n },\r\n }\r\n editor.completers = [autocompleter];\r\n}\r\n\r\n//Updates RAM usage in script\r\nfunction updateScriptEditorContent() {\r\n var filename = document.getElementById(\"script-editor-filename\").value;\r\n if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !isScriptFilename(filename)) {\r\n scriptEditorRamText.innerText = \"N/A\";\r\n return;\r\n }\r\n var editor = ace.edit('javascript-editor');\r\n var code = editor.getValue();\r\n var codeCopy = code.repeat(1);\r\n var ramUsage = calculateRamUsage(codeCopy);\r\n if (ramUsage !== -1) {\r\n scriptEditorRamText.innerText = \"RAM: \" + formatNumber(ramUsage, 2).toString() + \"GB\";\r\n } else {\r\n scriptEditorRamText.innerText = \"RAM: Syntax Error\";\r\n }\r\n}\r\n\r\n//Define key commands in script editor (ctrl o to save + close, etc.)\r\n$(document).keydown(function(e) {\r\n if (Settings.DisableHotkeys === true) {return;}\r\n\tif (Engine.currentPage == Engine.Page.ScriptEditor) {\r\n\t\t//Ctrl + b\r\n if (e.keyCode == 66 && (e.ctrlKey || e.metaKey)) {\r\n e.preventDefault();\r\n\t\t\tsaveAndCloseScriptEditor();\r\n }\r\n\t}\r\n});\r\n\r\nfunction saveAndCloseScriptEditor() {\r\n var filename = document.getElementById(\"script-editor-filename\").value;\r\n var editor = ace.edit('javascript-editor');\r\n var code = editor.getValue();\r\n if (iTutorialIsRunning && currITutorialStep == iTutorialSteps.TerminalTypeScript) {\r\n if (filename != \"foodnstuff.script\") {\r\n dialogBoxCreate(\"Leave the script name as 'foodnstuff'!\");\r\n return;\r\n }\r\n code = code.replace(/\\s/g, \"\");\r\n if (code.indexOf(\"while(true){hack('foodnstuff');}\") == -1) {\r\n dialogBoxCreate(\"Please copy and paste the code from the tutorial!\");\r\n return;\r\n }\r\n iTutorialNextStep();\r\n }\r\n\r\n if (filename == \"\") {\r\n dialogBoxCreate(\"You must specify a filename!\");\r\n return;\r\n }\r\n\r\n if (checkValidFilename(filename) == false) {\r\n dialogBoxCreate(\"Script filename can contain only alphanumerics, hyphens, and underscores\");\r\n return;\r\n }\r\n\r\n var s = Player.getCurrentServer();\r\n if (filename === \".fconf\") {\r\n try {\r\n parseFconfSettings(code);\r\n } catch(e) {\r\n dialogBoxCreate(\"Invalid .fconf file\");\r\n return;\r\n }\r\n } else if (isScriptFilename(filename)) {\r\n //If the current script already exists on the server, overwrite it\r\n for (var i = 0; i < s.scripts.length; i++) {\r\n if (filename == s.scripts[i].filename) {\r\n s.scripts[i].saveScript();\r\n Engine.loadTerminalContent();\r\n return;\r\n }\r\n }\r\n\r\n //If the current script does NOT exist, create a new one\r\n var script = new Script();\r\n script.saveScript();\r\n s.scripts.push(script);\r\n } else if (filename.endsWith(\".txt\")) {\r\n for (var i = 0; i < s.textFiles.length; ++i) {\r\n if (s.textFiles[i].fn === filename) {\r\n s.textFiles[i].write(code);\r\n Engine.loadTerminalContent();\r\n return;\r\n }\r\n }\r\n var textFile = new TextFile(filename, code);\r\n s.textFiles.push(textFile);\r\n } else {\r\n dialogBoxCreate(\"Invalid filename. Must be either a script (.script) or \" +\r\n \" or text file (.txt)\")\r\n return;\r\n }\r\n Engine.loadTerminalContent();\r\n}\r\n\r\n//Checks that the string contains only valid characters for a filename, which are alphanumeric,\r\n// underscores, hyphens, and dots\r\nfunction checkValidFilename(filename) {\r\n\tvar regex = /^[.a-zA-Z0-9_-]+$/;\r\n\r\n\tif (filename.match(regex)) {\r\n\t\treturn true;\r\n\t}\r\n\treturn false;\r\n}\r\n\r\nfunction Script() {\r\n\tthis.filename \t= \"\";\r\n this.code = \"\";\r\n this.ramUsage = 0;\r\n\tthis.server \t= \"\";\t//IP of server this script is on\r\n this.module = \"\";\r\n};\r\n\r\n//Get the script data from the Script Editor and save it to the object\r\nScript.prototype.saveScript = function() {\r\n\tif (Engine.currentPage == Engine.Page.ScriptEditor) {\r\n\t\t//Update code and filename\r\n var editor = ace.edit('javascript-editor');\r\n var code = editor.getValue();\r\n\t\tthis.code = code.replace(/^\\s+|\\s+$/g, '');\r\n\r\n\t\tvar filename = document.getElementById(\"script-editor-filename\").value;\r\n\t\tthis.filename = filename;\r\n\r\n\t\t//Server\r\n\t\tthis.server = Player.currentServer;\r\n\r\n\t\t//Calculate/update ram usage, execution time, etc.\r\n\t\tthis.updateRamUsage();\r\n\r\n this.module = \"\";\r\n\t}\r\n}\r\n\r\n//Updates how much RAM the script uses when it is running.\r\nScript.prototype.updateRamUsage = function() {\r\n var codeCopy = this.code.repeat(1);\r\n var res = calculateRamUsage(codeCopy);\r\n if (res !== -1) {\r\n this.ramUsage = res;\r\n }\r\n}\r\n\r\n// These special strings are used to reference the presence of a given logical\r\n// construct within a user script.\r\nconst specialReferenceIF = \"__SPECIAL_referenceIf\";\r\nconst specialReferenceFOR = \"__SPECIAL_referenceFor\";\r\nconst specialReferenceWHILE = \"__SPECIAL_referenceWhile\";\r\n\r\n// The global scope of a script is registered under this key during parsing.\r\nconst memCheckGlobalKey = \".__GLOBAL__\";\r\n\r\n// Calcluates the amount of RAM a script uses. Uses parsing and AST walking only,\r\n// rather than NetscriptEvaluator. This is useful because NetscriptJS code does\r\n// not work under NetscriptEvaluator.\r\nfunction parseOnlyRamCalculate(server, code, workerScript) {\r\n try {\r\n // Maps dependent identifiers to their dependencies.\r\n //\r\n // The initial identifier is __SPECIAL_INITIAL_MODULE__.__GLOBAL__.\r\n // It depends on all the functions declared in the module, all the global scopes\r\n // of its imports, and any identifiers referenced in this global scope. Each\r\n // function depends on all the identifiers referenced internally.\r\n // We walk the dependency graph to calculate RAM usage, given that some identifiers\r\n // reference Netscript functions which have a RAM cost.\r\n let dependencyMap = {};\r\n\r\n // Scripts we've parsed.\r\n const completedParses = new Set();\r\n\r\n // Scripts we've discovered that need to be parsed.\r\n const parseQueue = [];\r\n\r\n // Parses a chunk of code with a given module name, and updates parseQueue and dependencyMap.\r\n function parseCode(code, moduleName) {\r\n const result = parseOnlyCalculateDeps(code, moduleName);\r\n completedParses.add(moduleName);\r\n\r\n // Add any additional modules to the parse queue;\r\n for (let i = 0; i < result.additionalModules.length; ++i) {\r\n if (!completedParses.has(result.additionalModules[i])) {\r\n parseQueue.push(result.additionalModules[i]);\r\n }\r\n }\r\n\r\n // Splice all the references in.\r\n dependencyMap = {...dependencyMap, ...result.dependencyMap};\r\n }\r\n\r\n const initialModule = \"__SPECIAL_INITIAL_MODULE__\";\r\n parseCode(code, initialModule);\r\n\r\n while (parseQueue.length > 0) {\r\n // Get the code from the server.\r\n const nextModule = parseQueue.shift();\r\n\r\n const script = server.getScript(nextModule);\r\n if (!script) return -1; // No such script on the server.\r\n\r\n // Not sure why we always take copies, but let's do that here too.\r\n parseCode(script.code.repeat(1), nextModule);\r\n }\r\n\r\n // Finally, walk the reference map and generate a ram cost. The initial set of keys to scan\r\n // are those that start with __SPECIAL_INITIAL_MODULE__.\r\n let ram = CONSTANTS.ScriptBaseRamCost;\r\n const unresolvedRefs = Object.keys(dependencyMap).filter(s => s.startsWith(initialModule));\r\n const resolvedRefs = new Set();\r\n while (unresolvedRefs.length > 0) {\r\n const ref = unresolvedRefs.shift();\r\n resolvedRefs.add(ref);\r\n\r\n if (ref.endsWith(\".*\")) {\r\n // A prefix reference. We need to find all matching identifiers.\r\n const prefix = ref.slice(0, ref.length - 2);\r\n for (let ident of Object.keys(dependencyMap).filter(k => k.startsWith(prefix))) {\r\n for (let dep of dependencyMap[ident] || []) {\r\n if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep);\r\n }\r\n }\r\n } else {\r\n // An exact reference. Add all dependencies of this ref.\r\n for (let dep of dependencyMap[ref] || []) {\r\n if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep);\r\n }\r\n }\r\n\r\n // Check if this is one of the special keys, and add the appropriate ram cost if so.\r\n if (ref == specialReferenceIF) ram += CONSTANTS.ScriptIfRamCost;\r\n if (ref == specialReferenceFOR) ram += CONSTANTS.ScriptForRamCost;\r\n if (ref == specialReferenceWHILE) ram += CONSTANTS.ScriptWhileRamCost;\r\n if (ref == \"hacknetnodes\") ram += CONSTANTS.ScriptHacknetNodesRamCost;\r\n\r\n // Check if this ident is a function in the workerscript env. If it is, then we need to\r\n // get its RAM cost. We do this by calling it, which works because the running script\r\n // is in checkingRam mode.\r\n //\r\n // TODO it would be simpler to just reference a dictionary.\r\n try {\r\n var func = workerScript.env.get(ref);\r\n if (typeof func === \"function\") {\r\n try {\r\n var res = func.apply(null, []);\r\n if (typeof res === \"number\") {\r\n ram += res;\r\n }\r\n } catch(e) {\r\n console.log(\"ERROR applying function: \" + e);\r\n }\r\n }\r\n } catch (error) { continue; }\r\n\r\n }\r\n return ram;\r\n\r\n } catch (error) {\r\n console.info(\"parse or eval error: \", error);\r\n // This is not unexpected. The user may be editing a script, and it may be in\r\n // a transitory invalid state.\r\n return -1;\r\n }\r\n}\r\n\r\n// Parses one script and calculates its ram usage, for the global scope and each function.\r\n// Returns a cost map and a dependencyMap for the module. Returns a reference map to be joined\r\n// onto the main reference map, and a list of modules that need to be parsed.\r\nfunction parseOnlyCalculateDeps(code, currentModule) {\r\n const ast = parse(code, {sourceType:\"module\", ecmaVersion: 8});\r\n\r\n // Everything from the global scope goes in \".\". Everything else goes in \".function\", where only\r\n // the outermost layer of functions counts.\r\n const globalKey = currentModule + memCheckGlobalKey;\r\n const dependencyMap = {};\r\n dependencyMap[globalKey] = new Set();\r\n\r\n // If we reference this internal name, we're really referencing that external name.\r\n // Filled when we import names from other modules.\r\n let internalToExternal = {};\r\n\r\n var additionalModules = [];\r\n\r\n // References get added pessimistically. They are added for thisModule.name, name, and for\r\n // any aliases.\r\n function addRef(key, name) {\r\n const s = dependencyMap[key] || (dependencyMap[key] = new Set());\r\n if (name in internalToExternal) {\r\n s.add(internalToExternal[name]);\r\n }\r\n s.add(currentModule + \".\" + name);\r\n s.add(name); // For builtins like hack.\r\n }\r\n\r\n // If we discover a dependency identifier, state.key is the dependent identifier.\r\n // walkDeeper is for doing recursive walks of expressions in composites that we handle.\r\n function commonVisitors() {\r\n return {\r\n Identifier: (node, st, walkDeeper) => {\r\n addRef(st.key, node.name);\r\n },\r\n WhileStatement: (node, st, walkDeeper) => {\r\n addRef(st.key, specialReferenceWHILE);\r\n node.test && walkDeeper(node.test, st);\r\n node.body && walkDeeper(node.body, st);\r\n },\r\n DoWhileStatement: (node, st, walkDeeper) => {\r\n addRef(st.key, specialReferenceWHILE);\r\n node.test && walkDeeper(node.test, st);\r\n node.body && walkDeeper(node.body, st);\r\n },\r\n ForStatement: (node, st, walkDeeper) => {\r\n addRef(st.key, specialReferenceFOR);\r\n node.init && walkDeeper(node.init, st);\r\n node.test && walkDeeper(node.test, st);\r\n node.update && walkDeeper(node.update, st);\r\n node.body && walkDeeper(node.body, st);\r\n },\r\n IfStatement: (node, st, walkDeeper) => {\r\n addRef(st.key, specialReferenceIF);\r\n node.test && walkDeeper(node.test, st);\r\n node.consequent && walkDeeper(node.consequent, st);\r\n node.alternate && walkDeeper(node.alternate, st);\r\n },\r\n MemberExpression: (node, st, walkDeeper) => {\r\n node.object && walkDeeper(node.object, st);\r\n node.property && walkDeeper(node.property, st);\r\n },\r\n }\r\n }\r\n\r\n walk.recursive(ast, {key: globalKey}, {\r\n ImportDeclaration: (node, st, walkDeeper) => {\r\n const importModuleName = node.source.value;\r\n additionalModules.push(importModuleName);\r\n\r\n // This module's global scope refers to that module's global scope, no matter how we\r\n // import it.\r\n dependencyMap[st.key].add(importModuleName + memCheckGlobalKey);\r\n\r\n for (let i = 0; i < node.specifiers.length; ++i) {\r\n const spec = node.specifiers[i];\r\n if (spec.imported !== undefined && spec.local !== undefined) {\r\n // We depend on specific things.\r\n internalToExternal[spec.local.name] = importModuleName + \".\" + spec.imported.name;\r\n } else {\r\n // We depend on everything.\r\n dependencyMap[st.key].add(importModuleName + \".*\");\r\n }\r\n }\r\n },\r\n FunctionDeclaration: (node, st, walkDeeper) => {\r\n // Don't use walkDeeper, because we are changing the visitor set.\r\n const key = currentModule + \".\" + node.id.name;\r\n walk.recursive(node, {key: key}, commonVisitors());\r\n },\r\n ...commonVisitors()\r\n });\r\n\r\n return {dependencyMap: dependencyMap, additionalModules: additionalModules};\r\n}\r\n\r\nfunction calculateRamUsage(codeCopy) {\r\n //Create a temporary/mock WorkerScript and an AST from the code\r\n var currServ = Player.getCurrentServer();\r\n var workerScript = new WorkerScript({\r\n filename:\"foo\",\r\n scriptRef: {code:\"\"},\r\n args:[]\r\n });\r\n workerScript.checkingRam = true; //Netscript functions will return RAM usage\r\n workerScript.serverIp = currServ.ip;\r\n\r\n try {\r\n return parseOnlyRamCalculate(currServ, codeCopy, workerScript);\r\n\t} catch (e) {\r\n console.log(\"Failed to parse ram using new method. Falling back.\", e);\r\n\t}\r\n\r\n // Try the old way.\r\n\r\n try {\r\n var ast = parse(codeCopy, {sourceType:\"module\"});\r\n } catch(e) {\r\n return -1;\r\n }\r\n\r\n //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes\r\n var queue = [], ramUsage = CONSTANTS.ScriptBaseRamCost;\r\n var whileUsed = false, forUsed = false, ifUsed = false;\r\n queue.push(ast);\r\n while (queue.length != 0) {\r\n var exp = queue.shift();\r\n switch (exp.type) {\r\n case \"ImportDeclaration\":\r\n //Gets an array of all imported functions as AST expressions\r\n //and pushes them on the queue.\r\n var res = evaluateImport(exp, workerScript, true);\r\n for (var i = 0; i < res.length; ++i) {\r\n queue.push(res[i]);\r\n }\r\n break;\r\n case \"BlockStatement\":\r\n case \"Program\":\r\n for (var i = 0; i < exp.body.length; ++i) {\r\n if (exp.body[i] instanceof Node) {\r\n queue.push(exp.body[i]);\r\n }\r\n }\r\n break;\r\n case \"WhileStatement\":\r\n if (!whileUsed) {\r\n ramUsage += CONSTANTS.ScriptWhileRamCost;\r\n whileUsed = true;\r\n }\r\n break;\r\n case \"ForStatement\":\r\n if (!forUsed) {\r\n ramUsage += CONSTANTS.ScriptForRamCost;\r\n forUsed = true;\r\n }\r\n break;\r\n case \"IfStatement\":\r\n if (!ifUsed) {\r\n ramUsage += CONSTANTS.ScriptIfRamCost;\r\n ifUsed = true;\r\n }\r\n break;\r\n case \"Identifier\":\r\n if (exp.name in workerScript.env.vars) {\r\n var func = workerScript.env.get(exp.name);\r\n if (typeof func === \"function\") {\r\n try {\r\n var res = func.apply(null, []);\r\n if (typeof res === \"number\") {\r\n ramUsage += res;\r\n }\r\n } catch(e) {\r\n console.log(\"ERROR applying function: \" + e);\r\n }\r\n }\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n for (var prop in exp) {\r\n if (exp.hasOwnProperty(prop)) {\r\n if (exp[prop] instanceof Node) {\r\n queue.push(exp[prop]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n //Special case: hacknetnodes array\r\n if (codeCopy.includes(\"hacknetnodes\")) {\r\n ramUsage += CONSTANTS.ScriptHacknetNodesRamCost;\r\n }\r\n return ramUsage;\r\n}\r\n\r\nScript.prototype.download = function() {\r\n var filename = this.filename + \".js\";\r\n var file = new Blob([this.code], {type: 'text/plain'});\r\n if (window.navigator.msSaveOrOpenBlob) {// IE10+\r\n window.navigator.msSaveOrOpenBlob(file, filename);\r\n } else { // Others\r\n var a = document.createElement(\"a\"),\r\n url = URL.createObjectURL(file);\r\n a.href = url;\r\n a.download = filename;\r\n document.body.appendChild(a);\r\n a.click();\r\n setTimeout(function() {\r\n document.body.removeChild(a);\r\n window.URL.revokeObjectURL(url);\r\n }, 0);\r\n }\r\n}\r\n\r\nScript.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Script\", this);\r\n}\r\n\r\n\r\nScript.fromJSON = function(value) {\r\n return Generic_fromJSON(Script, value.data);\r\n}\r\n\r\nReviver.constructors.Script = Script;\r\n\r\n//Called when the game is loaded. Loads all running scripts (from all servers)\r\n//into worker scripts so that they will start running\r\nfunction loadAllRunningScripts() {\r\n\tvar count = 0;\r\n var total = 0;\r\n let skipScriptLoad = (window.location.href.toLowerCase().indexOf(\"?noscripts\") !== -1);\r\n if (skipScriptLoad) {console.log(\"Skipping the load of any scripts during startup\");}\r\n\tfor (var property in AllServers) {\r\n\t\tif (AllServers.hasOwnProperty(property)) {\r\n\t\t\tvar server = AllServers[property];\r\n\r\n\t\t\t//Reset each server's RAM usage to 0\r\n\t\t\tserver.ramUsed = 0;\r\n\r\n //Reset modules on all scripts\r\n for (var i = 0; i < server.scripts.length; ++i) {\r\n server.scripts[i].module = \"\";\r\n }\r\n\r\n if (skipScriptLoad) {\r\n //Start game with no scripts\r\n server.runningScripts.length = 0;\r\n } else {\r\n for (var j = 0; j < server.runningScripts.length; ++j) {\r\n \t\t\t\tcount++;\r\n server.runningScripts[j].scriptRef.module = \"\";\r\n \t\t\t\taddWorkerScript(server.runningScripts[j], server);\r\n\r\n \t\t\t\t//Offline production\r\n \t\t\t\ttotal += scriptCalculateOfflineProduction(server.runningScripts[j]);\r\n \t\t\t}\r\n }\r\n\t\t}\r\n\t}\r\n return total;\r\n\tconsole.log(\"Loaded \" + count.toString() + \" running scripts\");\r\n}\r\n\r\nfunction scriptCalculateOfflineProduction(runningScriptObj) {\r\n\t//The Player object stores the last update time from when we were online\r\n\tvar thisUpdate = new Date().getTime();\r\n\tvar lastUpdate = Player.lastUpdate;\r\n\tvar timePassed = (thisUpdate - lastUpdate) / 1000;\t//Seconds\r\n\tconsole.log(\"Offline for \" + timePassed + \" seconds\");\r\n\r\n\t//Calculate the \"confidence\" rating of the script's true production. This is based\r\n\t//entirely off of time. We will arbitrarily say that if a script has been running for\r\n\t//4 hours (14400 sec) then we are completely confident in its ability\r\n\tvar confidence = (runningScriptObj.onlineRunningTime) / 14400;\r\n\tif (confidence >= 1) {confidence = 1;}\r\n\r\n //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]\r\n\r\n //Grow\r\n for (var ip in runningScriptObj.dataMap) {\r\n if (runningScriptObj.dataMap.hasOwnProperty(ip)) {\r\n if (runningScriptObj.dataMap[ip][2] == 0 || runningScriptObj.dataMap[ip][2] == null) {continue;}\r\n var serv = AllServers[ip];\r\n if (serv == null) {continue;}\r\n var timesGrown = Math.round(0.5 * runningScriptObj.dataMap[ip][2] / runningScriptObj.onlineRunningTime * timePassed);\r\n console.log(runningScriptObj.filename + \" called grow() on \" + serv.hostname + \" \" + timesGrown + \" times while offline\");\r\n runningScriptObj.log(\"Called grow() on \" + serv.hostname + \" \" + timesGrown + \" times while offline\");\r\n var growth = processSingleServerGrowth(serv, timesGrown * 450);\r\n runningScriptObj.log(serv.hostname + \" grown by \" + formatNumber(growth * 100 - 100, 6) + \"% from grow() calls made while offline\");\r\n }\r\n }\r\n\r\n var totalOfflineProduction = 0;\r\n for (var ip in runningScriptObj.dataMap) {\r\n if (runningScriptObj.dataMap.hasOwnProperty(ip)) {\r\n if (runningScriptObj.dataMap[ip][0] == 0 || runningScriptObj.dataMap[ip][0] == null) {continue;}\r\n var serv = AllServers[ip];\r\n if (serv == null) {continue;}\r\n var production = 0.5 * runningScriptObj.dataMap[ip][0] / runningScriptObj.onlineRunningTime * timePassed;\r\n production *= confidence;\r\n if (production > serv.moneyAvailable) {\r\n production = serv.moneyAvailable;\r\n }\r\n totalOfflineProduction += production;\r\n Player.gainMoney(production);\r\n console.log(runningScriptObj.filename + \" generated $\" + production + \" while offline by hacking \" + serv.hostname);\r\n runningScriptObj.log(runningScriptObj.filename + \" generated $\" + production + \" while offline by hacking \" + serv.hostname);\r\n serv.moneyAvailable -= production;\r\n if (serv.moneyAvailable < 0) {serv.moneyAvailable = 0;}\r\n if (isNaN(serv.moneyAvailable)) {serv.moneyAvailable = 0;}\r\n }\r\n }\r\n\r\n //Offline EXP gain\r\n\t//A script's offline production will always be at most half of its online production.\r\n\tvar expGain = 0.5 * (runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime) * timePassed;\r\n\texpGain *= confidence;\r\n\r\n\tPlayer.gainHackingExp(expGain);\r\n\r\n\t//Update script stats\r\n\trunningScriptObj.offlineMoneyMade += totalOfflineProduction;\r\n\trunningScriptObj.offlineRunningTime += timePassed;\r\n\trunningScriptObj.offlineExpGained += expGain;\r\n\r\n //Fortify a server's security based on how many times it was hacked\r\n for (var ip in runningScriptObj.dataMap) {\r\n if (runningScriptObj.dataMap.hasOwnProperty(ip)) {\r\n if (runningScriptObj.dataMap[ip][1] == 0 || runningScriptObj.dataMap[ip][1] == null) {continue;}\r\n var serv = AllServers[ip];\r\n if (serv == null) {continue;}\r\n var timesHacked = Math.round(0.5 * runningScriptObj.dataMap[ip][1] / runningScriptObj.onlineRunningTime * timePassed);\r\n console.log(runningScriptObj.filename + \" hacked \" + serv.hostname + \" \" + timesHacked + \" times while offline\");\r\n runningScriptObj.log(\"Hacked \" + serv.hostname + \" \" + timesHacked + \" times while offline\");\r\n serv.fortify(CONSTANTS.ServerFortifyAmount * timesHacked);\r\n }\r\n }\r\n\r\n //Weaken\r\n for (var ip in runningScriptObj.dataMap) {\r\n if (runningScriptObj.dataMap.hasOwnProperty(ip)) {\r\n if (runningScriptObj.dataMap[ip][3] == 0 || runningScriptObj.dataMap[ip][3] == null) {continue;}\r\n var serv = AllServers[ip];\r\n if (serv == null) {continue;}\r\n var timesWeakened = Math.round(0.5 * runningScriptObj.dataMap[ip][3] / runningScriptObj.onlineRunningTime * timePassed);\r\n console.log(runningScriptObj.filename + \" called weaken() on \" + serv.hostname + \" \" + timesWeakened + \" times while offline\");\r\n runningScriptObj.log(\"Called weaken() on \" + serv.hostname + \" \" + timesWeakened + \" times while offline\");\r\n serv.weaken(CONSTANTS.ServerWeakenAmount * timesWeakened);\r\n }\r\n }\r\n\r\n return totalOfflineProduction;\r\n}\r\n\r\n//Returns a RunningScript object matching the filename and arguments on the\r\n//designated server, and false otherwise\r\nfunction findRunningScript(filename, args, server) {\r\n for (var i = 0; i < server.runningScripts.length; ++i) {\r\n if (server.runningScripts[i].filename == filename &&\r\n compareArrays(server.runningScripts[i].args, args)) {\r\n return server.runningScripts[i];\r\n }\r\n }\r\n return null;\r\n}\r\n\r\nfunction RunningScript(script, args) {\r\n if (script == null || script == undefined) {return;}\r\n this.filename = script.filename;\r\n this.args = args;\r\n this.scriptRef = script;\r\n this.server = script.server; //IP Address only\r\n\r\n this.logs = []; //Script logging. Array of strings, with each element being a log entry\r\n this.logUpd = false;\r\n\r\n\t//Stats to display on the Scripts menu, and used to determine offline progress\r\n\tthis.offlineRunningTime \t= 0.01;\t//Seconds\r\n\tthis.offlineMoneyMade \t\t= 0;\r\n\tthis.offlineExpGained \t\t= 0;\r\n\tthis.onlineRunningTime \t\t= 0.01;\t//Seconds\r\n\tthis.onlineMoneyMade \t\t= 0;\r\n\tthis.onlineExpGained \t\t= 0;\r\n\r\n this.threads = 1;\r\n\r\n //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]\r\n this.dataMap = new AllServersMap([0, 0, 0, 0], true);\r\n}\r\n\r\nRunningScript.prototype.log = function(txt) {\r\n if (this.logs.length > Settings.MaxLogCapacity) {\r\n //Delete first element and add new log entry to the end.\r\n //TODO Eventually it might be better to replace this with circular array\r\n //to improve performance\r\n this.logs.shift();\r\n }\r\n let logEntry = txt;\r\n if (FconfSettings.ENABLE_TIMESTAMPS) {\r\n logEntry = \"[\" + Terminal.getTimestamp() + \"] \" + logEntry;\r\n }\r\n this.logs.push(logEntry);\r\n this.logUpd = true;\r\n}\r\n\r\nRunningScript.prototype.displayLog = function() {\r\n for (var i = 0; i < this.logs.length; ++i) {\r\n post(this.logs[i]);\r\n }\r\n}\r\n\r\nRunningScript.prototype.clearLog = function() {\r\n this.logs.length = 0;\r\n}\r\n\r\n//Update the moneyStolen and numTimesHack maps when hacking\r\nRunningScript.prototype.recordHack = function(serverIp, moneyGained, n=1) {\r\n if (this.dataMap == null) {\r\n //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]\r\n this.dataMap = new AllServersMap([0, 0, 0, 0], true);\r\n }\r\n this.dataMap[serverIp][0] += moneyGained;\r\n this.dataMap[serverIp][1] += n;\r\n}\r\n\r\n//Update the grow map when calling grow()\r\nRunningScript.prototype.recordGrow = function(serverIp, n=1) {\r\n if (this.dataMap == null) {\r\n //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]\r\n this.dataMap = new AllServersMap([0, 0, 0, 0], true);\r\n }\r\n this.dataMap[serverIp][2] += n;\r\n}\r\n\r\n//Update the weaken map when calling weaken() {\r\nRunningScript.prototype.recordWeaken = function(serverIp, n=1) {\r\n if (this.dataMap == null) {\r\n //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]\r\n this.dataMap = new AllServersMap([0, 0, 0, 0], true);\r\n }\r\n this.dataMap[serverIp][3] += n;\r\n}\r\n\r\nRunningScript.prototype.toJSON = function() {\r\n return Generic_toJSON(\"RunningScript\", this);\r\n}\r\n\r\n\r\nRunningScript.fromJSON = function(value) {\r\n return Generic_fromJSON(RunningScript, value.data);\r\n}\r\n\r\nReviver.constructors.RunningScript = RunningScript;\r\n\r\n//Creates an object that creates a map/dictionary with the IP of each existing server as\r\n//a key. Initializes every key with a specified value that can either by a number or an array\r\nfunction AllServersMap(arr=false, filterOwned=false) {\r\n for (var ip in AllServers) {\r\n if (AllServers.hasOwnProperty(ip)) {\r\n if (filterOwned && (AllServers[ip].purchasedByPlayer || AllServers[ip].hostname === \"home\")) {\r\n continue;\r\n }\r\n if (arr) {\r\n this[ip] = [0, 0, 0, 0];\r\n } else {\r\n this[ip] = 0;\r\n }\r\n }\r\n }\r\n}\r\n\r\nAllServersMap.prototype.toJSON = function() {\r\n return Generic_toJSON(\"AllServersMap\", this);\r\n}\r\n\r\n\r\nAllServersMap.fromJSON = function(value) {\r\n return Generic_fromJSON(AllServersMap, value.data);\r\n}\r\n\r\nReviver.constructors.AllServersMap = AllServersMap;\r\n\r\nexport {updateScriptEditorContent, loadAllRunningScripts, findRunningScript,\r\n RunningScript, Script, AllServersMap, scriptEditorInit, isScriptFilename};\r\n","import {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Faction, Factions, factionExists,\r\n joinFaction, displayFactionContent} from \"./Faction.js\";\r\nimport {Locations} from \"./Location.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {hackWorldDaemon} from \"./RedPill.js\";\r\nimport {KEY} from \"./Terminal.js\";\r\n\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {getRandomInt, addOffset, clearObject,\r\n createElement, removeChildrenFromElement,\r\n exceptionAlert, createPopup, appendLineBreaks,\r\n removeElementById, removeElement,\r\n createProgressBarText} from \"../utils/HelperFunctions.js\";\r\nimport {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\nimport numeral from \"numeral/min/numeral.min\";\r\nimport {formatNumber} from \"../utils/StringHelperFunctions.js\";\r\n\r\n\r\nvar CityNames = [\"Aevum\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Ishima\", \"Volhaven\"];\r\n\r\nvar CyclesPerSecond = 5; //Game cycle is 200 ms\r\n\r\nvar StaminaGainPerSecond = 0.0085;\r\nvar BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty\r\nvar MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain\r\n\r\nvar DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time\r\n\r\n//The difficulty multiplier affects stamina loss and hp loss of an action. Its formula is:\r\n//difficulty ^ exponentialFactor + difficulty / linearFactor\r\nvar DiffMultExponentialFactor = 0.28;\r\nvar DiffMultLinearFactor = 670;\r\n\r\nvar BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action\r\n\r\nvar PopulationThreshold = 1e9; //Population at which success rates start being affected\r\nvar ChaosThreshold = 50; //City chaos level after which it starts making tasks harder\r\n\r\nvar BaseStatGain = 1; //Base stat gain per second\r\nvar BaseIntGain = 0.001; //Base intelligence stat gain\r\n\r\nvar ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value\r\n\r\nvar RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank\r\nvar RankNeededForFaction = 25;\r\n\r\nvar ContractSuccessesPerLevel = 3; //How many successes you need to level up a contract\r\nvar OperationSuccessesPerLevel = 2.5; //How many successes you need to level up an op\r\n\r\nvar RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point\r\n\r\nvar ContractBaseMoneyGain = 10e3; //Base Money Gained per contract\r\n\r\n//DOM related variables\r\nvar ActiveActionCssClass = \"bladeburner-active-action\";\r\n\r\n//Console related stuff\r\nvar consoleHistory = []; //Console command history\r\nvar consoleHistoryIndex = 0;\r\nvar consoleHelpText = {\r\n helpList:\"Use 'help [command]' to get more information about a particular Bladeburner console command.
\" +\r\n \"automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks
\" +\r\n \"clear/cls Clear the console
\" +\r\n \"help [cmd] Display this help text, or help text for a specific command
\" +\r\n \"log [en/dis] [type] Enable or disable logging for events and actions
\" +\r\n \"skill [action] [name] Level or display info about your Bladeburner skills
\" +\r\n \"start [type] [name] Start a Bladeburner action/task
\" +\r\n \"stop Stops your current Bladeburner action/task
\",\r\n automate:\"automate [var] [val] [hi/low]
\" +\r\n \"A simple way to automate your Bladeburner actions. This console command can be used \" +\r\n \"to automatically start an action when your stamina rises above a certain threshold, and \" +\r\n \"automatically switch to another action when your stamina drops below another threshold.
\" +\r\n \"automate status - Check the current status of your automation and get a brief description of what it'll do
\" +\r\n \"automate en - Enable the automation feature
\" +\r\n \"automate dis - Disable the automation feature
\" +\r\n \"There are four properties that must be set for this automation to work properly. Here is how to set them:
\" +\r\n \"automate stamina 100 high
\" +\r\n \"automate contract Tracking high
\" +\r\n \"automate stamina 50 low
\" +\r\n 'automate general \"Field Analysis\" low
' +\r\n \"Using the four console commands above will set the automation to perform Tracking contracts \" +\r\n \"if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below \" +\r\n \"50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must \" +\r\n \"exactly match whatever the name is in the UI.\",\r\n clear:\"clear
Clears the console\",\r\n cls:\"cls
Clears the console\",\r\n help:\"help [command]
\" +\r\n \"Running 'help' with no arguments displays the general help text, which lists all console commands \" +\r\n \"and a brief description of what they do. A command can be specified to get more specific help text \" +\r\n \"about that particular command. For example:
\" +\r\n \"help automate
\" +\r\n \"will display specific information about using the automate console command\",\r\n log:\"log [en/dis] [type]
\" +\r\n \"Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged \" +\r\n \"in the console. There are also random events that are logged in the console as well. The five categories of \" +\r\n \"things that get logged are:
\" +\r\n \"[general, contracts, ops, blackops, events]
\" +\r\n \"The logging for these categories can be enabled or disabled like so:
\" +\r\n \"log dis contracts - Disables logging that occurs when contracts are completed
\" +\r\n \"log en contracts - Enables logging that occurs when contracts are completed
\" +\r\n \"log dis events - Disables logging for Bladeburner random events
\" +\r\n \"Logging can be universally enabled/disabled using the 'all' keyword:
\" +\r\n \"log dis all
\" +\r\n \"log en all\",\r\n skill:\"skill [action] [name]
\" +\r\n \"Level or display information about your skills.
\" +\r\n \"To display information about all of your skills and your multipliers, use:
\" +\r\n \"skill list
\" +\r\n \"To display information about a specific skill, specify the name of the skill afterwards. \" +\r\n \"Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If \" +\r\n \"the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
\" +\r\n \"skill list Reaper
\" +\r\n 'skill list \"Digital Observer\"
' +\r\n \"This console command can also be used to level up skills:
\" +\r\n \"skill level [skill name]\",\r\n start:\"start [type] [name]
\" +\r\n \"Start an action. An action is specified by its type and its name. The \" +\r\n \"name is case-sensitive. It must appear exactly as it does in the UI. If \" +\r\n \"the name of the action has whitespace, enclose it in double quotation marks. \" +\r\n \"Valid action types include:
\" +\r\n \"[general, contract, op, blackop]
\" +\r\n \"Examples:
\" +\r\n 'start contract Tracking
' +\r\n 'start op \"Undercover Operation\"
',\r\n stop:\"stop
\" +\r\n \"Stop your current action and go idle\",\r\n}\r\n\r\n//Keypresses for Console\r\n$(document).keydown(function(event) {\r\n if (Engine.currentPage === Engine.Page.Bladeburner) {\r\n //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {\r\n // DomElems.consoleInput.focus();\r\n //}\r\n\r\n if (!(Player.bladeburner instanceof Bladeburner)) {return;}\r\n\r\n //NOTE: Keycodes imported from Terminal.js\r\n if (event.keyCode === KEY.ENTER) {\r\n event.preventDefault();\r\n var command = DomElems.consoleInput.value;\r\n if (command.length > 0) {\r\n Player.bladeburner.postToConsole(\"> \" + command);\r\n Player.bladeburner.resetConsoleInput();\r\n Player.bladeburner.executeConsoleCommands(command);\r\n }\r\n }\r\n\r\n if (event.keyCode === KEY.UPARROW) {\r\n if (DomElems.consoleInput == null) {return;}\r\n var i = consoleHistoryIndex;\r\n var len = consoleHistory.length;\r\n\r\n if (len === 0) {return;}\r\n if (i < 0 || i > len) {\r\n consoleHistoryIndex = len;\r\n }\r\n\r\n if (i !== 0) {\r\n --consoleHistoryIndex;\r\n }\r\n\r\n var prevCommand = consoleHistory[consoleHistoryIndex];\r\n DomElems.consoleInput.value = prevCommand;\r\n setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);\r\n }\r\n\r\n if (event.keyCode === KEY.DOWNARROW) {\r\n if (DomElems.consoleInput == null) {return;}\r\n var i = consoleHistoryIndex;\r\n var len = consoleHistory.length;\r\n\r\n if (len == 0) {return;}\r\n if (i < 0 || i > len) {\r\n consoleHistoryIndex = len;\r\n }\r\n\r\n //Latest command, put nothing\r\n if (i == len || i == len-1) {\r\n consoleHistoryIndex = len;\r\n DomElems.consoleInput.value = \"\";\r\n } else {\r\n ++consoleHistoryIndex;\r\n var prevCommand = consoleHistory[consoleHistoryIndex];\r\n DomElems.consoleInput.value = prevCommand;\r\n }\r\n }\r\n }\r\n});\r\n\r\nfunction City(params={}) {\r\n this.name = params.name ? params.name : Locations.Sector12;\r\n\r\n //Synthoid population and estimate\r\n this.pop = params.pop ? params.pop : getRandomInt(800e6, 1.2*PopulationThreshold);\r\n this.popEst = this.pop * (Math.random() + 0.5);\r\n\r\n //Number of Synthoid communities population and estimate\r\n this.comms = params.comms ? params.comms : getRandomInt(1, 40);\r\n this.commsEst = this.comms + getRandomInt(-2, 2);\r\n if (this.commsEst < 0) {this.commsEst = 0;}\r\n this.chaos = 0;\r\n}\r\n\r\nCity.prototype.improvePopulationEstimateByCount = function(n) {\r\n if (isNaN(n)) {throw new Error(\"NaN passeed into City.improvePopulationEstimateByCount()\");}\r\n if (this.popEst < this.pop) {\r\n this.popEst += n;\r\n if (this.popEst > this.pop) {this.popEst = this.pop;}\r\n } else if (this.popEst > this.pop) {\r\n this.popEst -= n;\r\n if (this.popEst < this.pop) {this.popEst = this.pop;}\r\n }\r\n}\r\n\r\n//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%\r\nCity.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {\r\n p = p*skillMult;\r\n if (isNaN(p)) {throw new Error(\"NaN passed into City.improvePopulationEstimateByPercentage()\");}\r\n if (this.popEst < this.pop) {\r\n ++this.popEst; //In case estimate is 0\r\n this.popEst *= (1 + (p/100));\r\n if (this.popEst > this.pop) {this.popEst = this.pop;}\r\n } else if (this.popEst > this.pop) {\r\n this.popEst *= (1 - (p/100));\r\n if (this.popEst < this.pop) {this.popEst = this.pop;}\r\n }\r\n}\r\n\r\nCity.prototype.improveCommunityEstimate = function(n=1) {\r\n if (isNaN(n)) {throw new Error(\"NaN passed into City.improveCommunityEstimate()\");}\r\n if (this.commsEst < this.comms) {\r\n this.commsEst += n;\r\n if (this.commsEst > this.comms) {this.commsEst = this.comms;}\r\n } else if (this.commsEst > this.comms) {\r\n this.commsEst -= n;\r\n if (this.commsEst < this.comms) {this.commsEst = this.comms;}\r\n }\r\n}\r\n\r\n//@params options:\r\n// estChange(int): How much the estimate should change by\r\n// estOffset(int): Add offset to estimate (offset by percentage)\r\nCity.prototype.changePopulationByCount = function(n, params={}) {\r\n if (isNaN(n)) {throw new Error(\"NaN passed into City.changePopulationByCount()\");}\r\n this.pop += n;\r\n if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}\r\n if (params.estOffset) {\r\n this.popEst = addOffset(this.popEst, params.estOffset);\r\n }\r\n this.popEst = Math.max(this.popEst, 0);\r\n}\r\n\r\n//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%\r\n//@params options:\r\n// changeEstEqually(bool) - Change the population estimate by an equal amount\r\n// nonZero (bool) - Set to true to ensure that population always changes by at least 1\r\nCity.prototype.changePopulationByPercentage = function(p, params={}) {\r\n if (isNaN(p)) {throw new Error(\"NaN passed into City.changePopulationByPercentage()\");}\r\n if (p === 0) {return;}\r\n var change = Math.round(this.pop * (p/100));\r\n\r\n //Population always changes by at least 1\r\n if (params.nonZero && change === 0) {\r\n p > 0 ? change = 1 : change = -1;\r\n }\r\n\r\n this.pop += change;\r\n if (params.changeEstEqually) {\r\n this.popEst += change;\r\n if (this.popEst < 0) {this.popEst = 0;}\r\n }\r\n return change;\r\n}\r\n\r\nCity.prototype.changeChaosByCount = function(n) {\r\n if (isNaN(n)) {throw new Error(\"NaN passed into City.changeChaosByCount()\");}\r\n if (n === 0) {return;}\r\n this.chaos += n;\r\n if (this.chaos < 0) {this.chaos = 0;}\r\n}\r\n\r\n//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)\r\nCity.prototype.changeChaosByPercentage = function(p) {\r\n if (isNaN(p)) {throw new Error(\"NaN passed into City.chaosChaosByPercentage()\");}\r\n if (p === 0) {return;}\r\n var change = this.chaos * (p/100);\r\n this.chaos += change;\r\n if (this.chaos < 0) {this.chaos = 0;}\r\n}\r\n\r\nCity.prototype.toJSON = function() {\r\n return Generic_toJSON(\"City\", this);\r\n}\r\nCity.fromJSON = function(value) {\r\n return Generic_fromJSON(City, value.data);\r\n}\r\nReviver.constructors.City = City;\r\n\r\nfunction Skill(params={name:\"foo\", desc:\"foo\"}) {\r\n if (params.name) {\r\n this.name = params.name;\r\n } else {\r\n throw new Error(\"Failed to initialize Bladeburner Skill. No name was specified in ctor\");\r\n }\r\n if (params.desc) {\r\n this.desc = params.desc;\r\n } else {\r\n throw new Error(\"Failed to initialize Bladeburner Skills. No desc was specified in ctor\");\r\n }\r\n this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points\r\n this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level\r\n\r\n if (params.maxLvl) {this.maxLvl = params.maxLvl;}\r\n\r\n //These benefits are additive. So total multiplier will be level (handled externally) times the\r\n //effects below\r\n if (params.successChanceAll) {this.successChanceAll = params.successChanceAll;}\r\n if (params.successChanceStealth) {this.successChanceStealth = params.successChanceStealth;}\r\n if (params.successChanceKill) {this.successChanceKill = params.successChanceKill;}\r\n if (params.successChanceContract) {this.successChanceContract = params.successChanceContract;}\r\n if (params.successChanceOperation) {this.successChanceOperation = params.successChanceOperation;}\r\n\r\n //This multiplier affects everything that increases synthoid population/community estimate\r\n //e.g. Field analysis, Investigation Op, Undercover Op\r\n if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}\r\n\r\n if (params.actionTime) {this.actionTime = params.actionTime;}\r\n if (params.effHack) {this.effHack = params.effHack;}\r\n if (params.effStr) {this.effStr = params.effStr;}\r\n if (params.effDef) {this.effDef = params.effDef;}\r\n if (params.effDex) {this.effDex = params.effDex;}\r\n if (params.effAgi) {this.effAgi = params.effAgi;}\r\n if (params.effCha) {this.effCha = params.effCha;}\r\n\r\n if (params.stamina) {this.stamina = params.stamina;}\r\n\r\n //Equipment\r\n if (params.weaponAbility) {this.weaponAbility = params.weaponAbility;}\r\n if (params.gunAbility) {this.gunAbility = params.gunAbility;}\r\n}\r\nvar Skills = {};\r\nvar SkillNames = {\r\n BladesIntuition: \"Blade's Intuition\",\r\n Reaper: \"Reaper\",\r\n Cloak: \"Cloak\",\r\n Marksman: \"Marksman\",\r\n WeaponProficiency: \"Weapon Proficiency\",\r\n Overclock: \"Overclock\",\r\n EvasiveSystem: \"Evasive System\",\r\n ShortCircuit: \"Short-Circuit\",\r\n DigitalObserver: \"Digital Observer\",\r\n Datamancer: \"Datamancer\",\r\n Tracer: \"Tracer\",\r\n CybersEdge: \"Cyber's Edge\"\r\n}\r\n\r\n//Base Class for Contracts, Operations, and BlackOps\r\nfunction Action(params={}) {\r\n this.name = params.name ? params.name : \"\";\r\n this.desc = params.desc ? params.desc : \"\";\r\n\r\n //Difficulty scales with level\r\n //Exact formula is not set in stone\r\n //Initial design: baseDifficulty * (difficultyFac ^ level)?\r\n //difficulty Fac is slightly greater than 1\r\n this.level = 1;\r\n this.maxLevel = 1;\r\n this.autoLevel = true;\r\n this.baseDifficulty = params.baseDifficulty ? addOffset(params.baseDifficulty, 10) : 100;\r\n this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;\r\n\r\n //Rank increase/decrease is affected by this exponent\r\n this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;\r\n\r\n this.successes = 0;\r\n this.failures = 0;\r\n\r\n //All of these scale with level/difficulty\r\n this.rankGain = params.rankGain ? params.rankGain : 0;\r\n if (params.rankLoss) {this.rankLoss = params.rankLoss;}\r\n if (params.hpLoss) {\r\n this.hpLoss = params.hpLoss;\r\n this.hpLost = 0;\r\n }\r\n\r\n //Action Category. Current categories are stealth and kill\r\n this.isStealth = params.isStealth ? true : false;\r\n this.isKill = params.isKill ? true : false;\r\n\r\n //Number of this contract remaining, and its growth rate\r\n //Growth rate is an integer and the count will increase by that integer every \"cycle\"\r\n this.count = params.count ? params.count : getRandomInt(1e3, 25e3);\r\n this.countGrowth = params.countGrowth ? params.countGrowth : getRandomInt(1, 5);\r\n\r\n //Weighting of each stat in determining action success rate\r\n var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};\r\n this.weights = params.weights ? params.weights : defaultWeights;\r\n\r\n //Check to make sure weights are summed properly\r\n var sum = 0;\r\n for (var weight in this.weights) {\r\n if (this.weights.hasOwnProperty(weight)) {\r\n sum += this.weights[weight];\r\n }\r\n }\r\n if (sum - 1 >= 10 * Number.EPSILON) {\r\n throw new Error(\"Invalid weights when constructing Action \" + this.name +\r\n \". The weights should sum up to 1. They sum up to :\" + 1);\r\n }\r\n\r\n //Diminishing returns of stats (stat ^ decay where 0 <= decay <= 1)\r\n var defaultDecays = {hack:0.9,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.9,int:0.9};\r\n this.decays = params.decays ? params.decays : defaultDecays;\r\n for (var decay in this.decays) {\r\n if (this.decays.hasOwnProperty(decay)) {\r\n if (this.decays[decay] > 1) {\r\n throw new Error(\"Invalid decays when constructing \" +\r\n \"Action \" + this.name + \". \" +\r\n \"Decay value cannot be greater than 1\");\r\n }\r\n }\r\n }\r\n}\r\n\r\nAction.prototype.getDifficulty = function() {\r\n var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);\r\n if (isNaN(difficulty)) {throw new Error(\"Calculated NaN in Action.getDifficulty()\");}\r\n return difficulty;\r\n}\r\n\r\n//@inst - Bladeburner Object\r\n//@params - options:\r\n// est (bool): Get success chance estimate instead of real success chance\r\nAction.prototype.getSuccessChance = function(inst, params={}) {\r\n if (inst == null) {throw new Error(\"Invalid Bladeburner instance passed into Action.getSuccessChance\");}\r\n var difficulty = this.getDifficulty();\r\n var competence = 0;\r\n for (var stat in this.weights) {\r\n if (this.weights.hasOwnProperty(stat)) {\r\n var playerStatLvl = Player.queryStatFromString(stat);\r\n var key = \"eff\" + stat.charAt(0).toUpperCase() + stat.slice(1);\r\n var effMultiplier = inst.skillMultipliers[key];\r\n if (effMultiplier == null) {\r\n console.log(\"ERROR: Failed to find Bladeburner Skill multiplier for: \" + stat);\r\n effMultiplier = 1;\r\n }\r\n competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));\r\n }\r\n }\r\n competence *= inst.calculateStaminaPenalty();\r\n\r\n //For Operations, factor in team members\r\n if (this instanceof Operation || this instanceof BlackOperation) {\r\n if (this.teamCount && this.teamCount > 0) {\r\n this.teamCount = Math.min(this.teamCount, inst.teamSize);\r\n var teamMultiplier = Math.pow(this.teamCount, 0.05);\r\n competence *= teamMultiplier;\r\n }\r\n }\r\n\r\n //Lower city population results in lower chances\r\n if (!(this instanceof BlackOperation)) {\r\n var city = inst.getCurrentCity();\r\n if (params.est) {\r\n competence *= (city.popEst / PopulationThreshold);\r\n } else {\r\n competence *= (city.pop / PopulationThreshold);\r\n }\r\n\r\n //Too high of a chaos results in lower chances\r\n if (city.chaos > ChaosThreshold) {\r\n var diff = 1 + (city.chaos - ChaosThreshold);\r\n var mult = Math.pow(diff, 0.1);\r\n difficulty *= mult;\r\n }\r\n\r\n //For Raid Operations, no communities = fail\r\n if (this instanceof Operation && this.name === \"Raid\") {\r\n if (city.comms <= 0) {return 0;}\r\n }\r\n }\r\n\r\n //Factor skill multipliers into success chance\r\n competence *= inst.skillMultipliers.successChanceAll;\r\n if (this instanceof Operation || this instanceof BlackOperation) {\r\n competence *= inst.skillMultipliers.successChanceOperation;\r\n }\r\n if (this instanceof Contract) {\r\n competence *= inst.skillMultipliers.successChanceContract;\r\n }\r\n if (this.isStealth) {\r\n competence *= inst.skillMultipliers.successChanceStealth;\r\n }\r\n if (this.isKill) {\r\n competence *= inst.skillMultipliers.successChanceKill;\r\n }\r\n\r\n //Augmentation multiplier\r\n competence *= Player.bladeburner_success_chance_mult;\r\n\r\n if (isNaN(competence)) {throw new Error(\"Competence calculated as NaN in Action.getSuccessChance()\");}\r\n return Math.min(1, competence / difficulty);\r\n}\r\n\r\n//Tests for success. Should be called when an action has completed\r\n// @inst - Bladeburner Object\r\nAction.prototype.attempt = function(inst) {\r\n return (Math.random() < this.getSuccessChance(inst));\r\n}\r\n\r\nAction.prototype.getActionTime = function(inst) {\r\n var difficulty = this.getDifficulty();\r\n var baseTime = difficulty / DifficultyToTimeFactor;\r\n var skillFac = inst.skillMultipliers.actionTime; //Always < 1\r\n\r\n var effAgility = Player.agility * inst.skillMultipliers.effAgi;\r\n var effDexterity = Player.dexterity * inst.skillMultipliers.effDex;\r\n var statFac = 0.5 * (Math.pow(effAgility, 0.03) + Math.pow(effDexterity, 0.03)); //Always > 1\r\n\r\n baseTime = Math.max(1, baseTime * skillFac / statFac);\r\n\r\n if (this instanceof Contract) {\r\n return Math.ceil(baseTime);\r\n } else if (this instanceof Operation) {\r\n return Math.ceil(baseTime);\r\n } else if (this instanceof BlackOperation) {\r\n return Math.ceil(baseTime * 1.5);\r\n } else {\r\n throw new Error(\"Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation\");\r\n }\r\n}\r\n\r\nAction.prototype.getSuccessesNeededForNextLevel = function(baseSuccessesPerLevel) {\r\n return (0.5) * (this.maxLevel) * (2 * baseSuccessesPerLevel + (this.maxLevel-1));\r\n}\r\n\r\nAction.prototype.setMaxLevel = function(baseSuccessesPerLevel) {\r\n if (this.successes > this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel)) {\r\n ++this.maxLevel;\r\n }\r\n}\r\n\r\nAction.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Action\", this);\r\n}\r\nAction.fromJSON = function(value) {\r\n return Generic_fromJSON(Action, value.data);\r\n}\r\nReviver.constructors.Action = Action;\r\nvar GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.\r\n\r\n//Action Identifier\r\nvar ActionTypes = Object.freeze({\r\n \"Idle\": 1,\r\n \"Contract\": 2,\r\n \"Operation\": 3,\r\n \"BlackOp\": 4,\r\n \"BlackOperation\": 4,\r\n \"Training\": 5,\r\n \"Recruitment\": 6,\r\n \"FieldAnalysis\": 7,\r\n \"Field Analysis\": 7\r\n});\r\nfunction ActionIdentifier(params={}) {\r\n if (params.name) {this.name = params.name;}\r\n if (params.type) {this.type = params.type;}\r\n}\r\nActionIdentifier.prototype.toJSON = function() {\r\n return Generic_toJSON(\"ActionIdentifier\", this);\r\n}\r\nActionIdentifier.fromJSON = function(value) {\r\n return Generic_fromJSON(ActionIdentifier, value.data);\r\n}\r\nReviver.constructors.ActionIdentifier = ActionIdentifier;\r\n\r\n//Contracts\r\nfunction Contract(params={}) {\r\n Action.call(this, params);\r\n}\r\nContract.prototype = Object.create(Action.prototype);\r\nContract.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Contract\", this);\r\n}\r\nContract.fromJSON = function(value) {\r\n return Generic_fromJSON(Contract, value.data);\r\n}\r\nReviver.constructors.Contract = Contract;\r\n\r\n//Operations\r\nfunction Operation(params={}) {\r\n Action.call(this, params);\r\n this.reqdRank = params.reqdRank ? params.reqdRank : 100;\r\n this.teamCount = params.teamCount ? params.teamCount : 0; //# of team members to use\r\n}\r\nOperation.prototype = Object.create(Action.prototype);\r\nOperation.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Operation\", this);\r\n}\r\nOperation.fromJSON = function(value) {\r\n return Generic_fromJSON(Operation, value.data);\r\n}\r\nReviver.constructors.Operation = Operation;\r\n\r\n//Black Operations\r\nfunction BlackOperation(params={}) {\r\n Operation.call(this, params);\r\n\r\n //Black ops are one time missions\r\n this.count = 1;\r\n this.countGrowth = 0;\r\n}\r\nBlackOperation.prototype = Object.create(Action.prototype);\r\nBlackOperation.prototype.toJSON = function() {\r\n return Generic_toJSON(\"BlackOperation\", this);\r\n}\r\nBlackOperation.fromJSON = function(value) {\r\n return Generic_fromJSON(BlackOperation, value.data);\r\n}\r\nReviver.constructors.BlackOperation = BlackOperation;\r\nvar BlackOperations = {};\r\n\r\nfunction Bladeburner(params={}) {\r\n this.numHosp = 0; //Number of hospitalizations\r\n this.moneyLost = 0; //Money lost due to hospitalizations\r\n this.rank = 0;\r\n this.maxRank = 0; //Used to determine skill points\r\n\r\n this.skillPoints = 0;\r\n this.totalSkillPoints = 0;\r\n\r\n this.teamSize = 0; //Number of team members\r\n this.teamLost = 0; //Number of team members lost\r\n\r\n this.storedCycles = 0;\r\n\r\n this.randomEventCounter = getRandomInt(300, 600); //5-10 minutes\r\n\r\n //These times are in seconds\r\n this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)\r\n this.actionTimeCurrent = 0;\r\n\r\n //ActionIdentifier Object\r\n var idleActionType = ActionTypes[\"Idle\"];\r\n this.action = new ActionIdentifier({type:idleActionType});\r\n\r\n this.cities = {};\r\n for (var i = 0; i < CityNames.length; ++i) {\r\n this.cities[CityNames[i]] = new City({name:CityNames[i]});\r\n }\r\n this.city = Locations.Sector12;\r\n\r\n //Map of SkillNames -> level\r\n this.skills = {};\r\n this.skillMultipliers = {};\r\n this.updateSkillMultipliers(); //Calls resetSkillMultipliers()\r\n\r\n //Max Stamina is based on stats and Bladeburner-specific bonuses\r\n this.staminaBonus = 0; //Gained from training\r\n this.maxStamina = 0;\r\n this.calculateMaxStamina();\r\n this.stamina = this.maxStamina;\r\n\r\n //Contracts and Operations objects. These objects have unique\r\n //properties because they are randomized in each instance and have stats like\r\n //successes/failures, so they need to be saved/loaded by the game.\r\n this.contracts = {};\r\n this.operations = {};\r\n\r\n //Object that contains name of all Black Operations that have been completed\r\n this.blackops = {};\r\n\r\n //Flags for whether these actions should be logged to console\r\n this.logging = {\r\n general:true,\r\n contracts:true,\r\n ops:true,\r\n blackops:true,\r\n events:true,\r\n }\r\n\r\n //Simple automation values\r\n this.automateEnabled = false;\r\n this.automateActionHigh = 0;\r\n this.automateThreshHigh = 0; //Stamina Threshold\r\n this.automateActionLow = 0;\r\n this.automateThreshLow = 0; //Stamina Threshold\r\n\r\n //Initialization\r\n initBladeburner();\r\n this.initializeDomElementRefs();\r\n if (params.new) {this.create();}\r\n}\r\n\r\nBladeburner.prototype.create = function() {\r\n this.contracts[\"Tracking\"] = new Contract({\r\n name:\"Tracking\",\r\n desc:\"Identify and locate Synthoids. This contract involves reconnaissance \" +\r\n \"and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
\" +\r\n \"Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for \" +\r\n \"whatever city you are currently in.\",\r\n baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,\r\n rankGain:0.3, hpLoss:0.5,\r\n count:getRandomInt(300, 800), countGrowth:getRandomInt(1, 5),\r\n weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},\r\n decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},\r\n isStealth:true\r\n });\r\n this.contracts[\"Bounty Hunter\"] = new Contract({\r\n name:\"Bounty Hunter\",\r\n desc:\"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
\" +\r\n \"Successfully completing a Bounty Hunter contract will lower the population in your \" +\r\n \"current city, and will also increase its chaos level.\",\r\n baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,\r\n rankGain:0.9, hpLoss:1,\r\n count:getRandomInt(200, 750), countGrowth:getRandomInt(1, 3),\r\n weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},\r\n decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},\r\n isKill:true\r\n });\r\n this.contracts[\"Retirement\"] = new Contract({\r\n name:\"Retirement\",\r\n desc:\"Hunt down and retire (kill) rogue Synthoids.
\" +\r\n \"Successfully copmleting a Retirement contract will lower the population in your current \" +\r\n \"city, and will also increase its chaos level.\",\r\n baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,\r\n rankGain:0.6, hpLoss:1,\r\n count:getRandomInt(300, 900), countGrowth:getRandomInt(1,4),\r\n weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},\r\n decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},\r\n isKill:true\r\n });\r\n\r\n this.operations[\"Investigation\"] = new Operation({\r\n name:\"Investigation\",\r\n desc:\"As a field agent, investigate and identify Synthoid \" +\r\n \"populations, movements, and operations.
Successful \" +\r\n \"Investigation ops will increase the accuracy of your \" +\r\n \"synthoid data.
\" +\r\n \"You will NOT lose HP from failed Investigation ops.\",\r\n baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,\r\n rankGain:2, rankLoss:0.2,\r\n count:getRandomInt(50, 400), countGrowth:1,\r\n weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},\r\n decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},\r\n isStealth:true\r\n });\r\n this.operations[\"Undercover Operation\"] = new Operation({\r\n name:\"Undercover Operation\",\r\n desc:\"Conduct undercover operations to identify hidden \" +\r\n \"and underground Synthoid communities and organizations.
\" +\r\n \"Successful Undercover ops will increase the accuracy of your synthoid \" +\r\n \"data.\",\r\n baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,\r\n rankGain:4, rankLoss:0.4, hpLoss:2,\r\n count:getRandomInt(50, 300), countGrowth:1,\r\n weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},\r\n decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},\r\n isStealth:true\r\n });\r\n this.operations[\"Sting Operation\"] = new Operation({\r\n name:\"Sting Operation\",\r\n desc:\"Conduct a sting operation to bait and capture particularly \" +\r\n \"notorious Synthoid criminals.\",\r\n baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,\r\n rankGain:5, rankLoss:0.5, hpLoss:2.5,\r\n count:getRandomInt(25,400), countGrowth:0.75,\r\n weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},\r\n decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},\r\n isStealth:true\r\n });\r\n this.operations[\"Raid\"] = new Operation({\r\n name:\"Raid\",\r\n desc:\"Lead an assault on a known Synthoid community. Note that \" +\r\n \"there must be an existing Synthoid community in your current city \" +\r\n \"in order for this Operation to be successful\",\r\n baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,\r\n rankGain:50,rankLoss:2.5,hpLoss:50,\r\n count:getRandomInt(25, 150), countGrowth:0.2,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},\r\n isKill:true\r\n });\r\n this.operations[\"Stealth Retirement Operation\"] = new Operation({\r\n name:\"Stealth Retirement Operation\",\r\n desc:\"Lead a covert operation to retire Synthoids. The \" +\r\n \"objective is to complete the task without \" +\r\n \"drawing any attention. Stealth and discretion are key.\",\r\n baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,\r\n rankGain:20, rankLoss:2, hpLoss:10,\r\n count:getRandomInt(25, 250), countGrowth:0.1,\r\n weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},\r\n decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},\r\n isStealth:true, isKill:true\r\n });\r\n this.operations[\"Assassination\"] = new Operation({\r\n name:\"Assassination\",\r\n desc:\"Assassinate Synthoids that have been identified as \" +\r\n \"important, high-profile social and political leaders \" +\r\n \"in the Synthoid communities.\",\r\n baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,\r\n rankGain:40, rankLoss:4, hpLoss:5,\r\n count:getRandomInt(25, 200), countGrowth:0.1,\r\n weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},\r\n isStealth:true, isKill:true\r\n });\r\n}\r\n\r\nBladeburner.prototype.storeCycles = function(numCycles=1) {\r\n this.storedCycles += numCycles;\r\n}\r\n\r\nBladeburner.prototype.process = function() {\r\n //If the Player starts doing some other actions, set action to idle and alert\r\n if (Player.isWorking) {\r\n if (this.action.type !== ActionTypes[\"Idle\"]) {\r\n dialogBoxCreate(\"Your Bladeburner action was cancelled because you started \" +\r\n \"doing something else\");\r\n }\r\n this.resetAction();\r\n }\r\n\r\n //A 'tick' for this mechanic is one second (= 5 game cycles)\r\n if (this.storedCycles >= CyclesPerSecond) {\r\n var seconds = Math.floor(this.storedCycles / CyclesPerSecond);\r\n seconds = Math.min(seconds, 5); //Max of 5 'ticks'\r\n this.storedCycles -= seconds * CyclesPerSecond;\r\n\r\n //Stamina\r\n this.calculateMaxStamina();\r\n this.stamina += (this.calculateStaminaGainPerSecond() * seconds);\r\n this.stamina = Math.min(this.maxStamina, this.stamina);\r\n\r\n //Count increase for contracts/operations\r\n for (var contractName in this.contracts) {\r\n if (this.contracts.hasOwnProperty(contractName)) {\r\n var contract = this.contracts[contractName];\r\n contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);\r\n }\r\n }\r\n for (var operationName in this.operations) {\r\n if (this.operations.hasOwnProperty(operationName)) {\r\n var op = this.operations[operationName];\r\n op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);\r\n }\r\n }\r\n\r\n //Chaos goes down very slowly\r\n for (var i = 0; i < CityNames.length; ++i) {\r\n var city = this.cities[CityNames[i]];\r\n if (!(city instanceof City)) {throw new Error(\"Invalid City object when processing passive chaos reduction in Bladeburner.process\");}\r\n city.chaos -= (0.0001 * seconds);\r\n city.chaos = Math.max(0, city.chaos);\r\n }\r\n\r\n //Random Events\r\n this.randomEventCounter -= seconds;\r\n if (this.randomEventCounter <= 0) {\r\n this.randomEvent();\r\n this.randomEventCounter = getRandomInt(300, 600);\r\n }\r\n\r\n this.processAction(seconds);\r\n\r\n //Automation\r\n if (this.automateEnabled) {\r\n if (this.stamina <= this.automateThreshLow) {\r\n if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {\r\n this.action = this.automateActionLow;\r\n this.startAction(this.action);\r\n }\r\n } else if (this.stamina >= this.automateThreshHigh) {\r\n if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {\r\n this.action = this.automateActionHigh;\r\n this.startAction(this.action);\r\n }\r\n }\r\n }\r\n\r\n if (Engine.currentPage === Engine.Page.Bladeburner) {\r\n this.updateContent();\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.calculateMaxStamina = function() {\r\n var effAgility = Player.agility * this.skillMultipliers.effAgi;\r\n var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);\r\n maxStamina *= this.skillMultipliers.stamina;\r\n maxStamina *= Player.bladeburner_max_stamina_mult;\r\n if (isNaN(maxStamina)) {throw new Error(\"Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()\");}\r\n this.maxStamina = maxStamina;\r\n}\r\n\r\nBladeburner.prototype.calculateStaminaGainPerSecond = function() {\r\n var effAgility = Player.agility * this.skillMultipliers.effAgi;\r\n var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;\r\n var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);\r\n return gain * (this.skillMultipliers.stamina * Player.bladeburner_stamina_gain_mult);\r\n}\r\n\r\nBladeburner.prototype.calculateStaminaPenalty = function() {\r\n return Math.min(1, this.stamina / (0.5 * this.maxStamina));\r\n}\r\n\r\nBladeburner.prototype.changeRank = function(change) {\r\n if (isNaN(change)) {throw new Error(\"NaN passed into Bladeburner.changeRank()\");}\r\n this.rank += change;\r\n if (this.rank < 0) {this.rank = 0;}\r\n this.maxRank = Math.max(this.rank, this.maxRank);\r\n\r\n var bladeburnersFactionName = \"Bladeburners\";\r\n if (factionExists(bladeburnersFactionName)) {\r\n var bladeburnerFac = Factions[bladeburnersFactionName];\r\n if (!(bladeburnerFac instanceof Faction)) {\r\n throw new Error(\"Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button\");\r\n }\r\n if (bladeburnerFac.isMember) {\r\n bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * Player.faction_rep_mult);\r\n }\r\n }\r\n\r\n //Gain skill points. You get 1 every 4 ranks\r\n var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;\r\n if (this.maxRank >= rankNeededForSp) {\r\n //Calculate how many skill points to gain\r\n var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);\r\n this.skillPoints += gainedSkillPoints;\r\n this.totalSkillPoints += gainedSkillPoints;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getCurrentCity = function() {\r\n var city = this.cities[this.city];\r\n if (!(city instanceof City)) {\r\n throw new Error(\"Bladeburner.getCurrentCity() did not properly return a City object\");\r\n }\r\n return city;\r\n}\r\n\r\nBladeburner.prototype.resetSkillMultipliers = function() {\r\n this.skillMultipliers = {\r\n successChanceAll:1,\r\n successChanceStealth:1,\r\n successChanceKill:1,\r\n successChanceContract:1,\r\n successChanceOperation:1,\r\n successChanceEstimate:1,\r\n actionTime:1,\r\n effHack:1,\r\n effStr:1,\r\n effDef:1,\r\n effDex:1,\r\n effAgi:1,\r\n effCha:1,\r\n effInt:1,\r\n stamina:1,\r\n weaponAbility:1,\r\n gunAbility:1,\r\n };\r\n}\r\n\r\nBladeburner.prototype.updateSkillMultipliers = function() {\r\n this.resetSkillMultipliers();\r\n for (var skillName in this.skills) {\r\n if (this.skills.hasOwnProperty(skillName)) {\r\n var skill = Skills[skillName];\r\n if (skill == null) {\r\n throw new Error(\"Could not find Skill Object for: \" + skillName);\r\n }\r\n var level = this.skills[skillName];\r\n if (level == null || level <= 0) {continue;} //Not upgraded\r\n\r\n var multiplierNames = Object.keys(this.skillMultipliers);\r\n for (var i = 0; i < multiplierNames.length; ++i) {\r\n var multiplierName = multiplierNames[i];\r\n if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {\r\n var value = skill[multiplierName] * level;\r\n var multiplierValue = 1 + (value / 100);\r\n if (multiplierName === \"actionTime\") {\r\n multiplierValue = 1 - (value / 100);\r\n }\r\n this.skillMultipliers[multiplierName] *= multiplierValue;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.upgradeSkill = function(skill) {\r\n //This does NOT handle deduction of skill points\r\n var skillName = skill.name;\r\n if (this.skills[skillName]) {\r\n ++this.skills[skillName];\r\n } else {\r\n this.skills[skillName] = 1;\r\n }\r\n if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {\r\n throw new Error(\"Level of Skill \" + skillName + \" is invalid: \" + this.skills[skillName]);\r\n }\r\n this.updateSkillMultipliers();\r\n}\r\n\r\nBladeburner.prototype.getActionObject = function(actionId) {\r\n //Given an ActionIdentifier object, returns the corresponding\r\n //Contract, Operation, or BlackOperation object\r\n switch (actionId.type) {\r\n case ActionTypes[\"Contract\"]:\r\n return this.contracts[actionId.name];\r\n break;\r\n case ActionTypes[\"Operation\"]:\r\n return this.operations[actionId.name];\r\n break;\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n return BlackOperations[actionId.name];\r\n break;\r\n default:\r\n return null;\r\n console.log(\"WARNING: Bladeburner.getActionObject() called with an unexpected \" +\r\n \"ActionIdentifier type: \" + actionId.type);\r\n }\r\n}\r\n\r\n//Sets the player to the \"IDLE\" action\r\nBladeburner.prototype.resetAction = function() {\r\n this.action = new ActionIdentifier({type:ActionTypes.Idle});\r\n}\r\n\r\nBladeburner.prototype.startAction = function(actionId) {\r\n if (actionId == null) {return;}\r\n this.action = actionId;\r\n this.actionTimeCurrent = 0;\r\n switch (actionId.type) {\r\n case ActionTypes[\"Idle\"]:\r\n this.actionTimeToComplete = 0;\r\n break;\r\n case ActionTypes[\"Contract\"]:\r\n try {\r\n var action = this.getActionObject(actionId);\r\n if (action == null) {\r\n throw new Error(\"Failed to get Contract Object for: \" + actionId.name);\r\n }\r\n if (action.count < 1) {return this.resetAction();}\r\n this.actionTimeToComplete = action.getActionTime(this);\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n break;\r\n case ActionTypes[\"Operation\"]:\r\n try {\r\n var action = this.getActionObject(actionId);\r\n if (action == null) {\r\n throw new Error (\"Failed to get Operation Object for: \" + actionId.name);\r\n }\r\n if (action.count < 1) {return this.resetAction();}\r\n this.actionTimeToComplete = action.getActionTime(this);\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n break;\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n try {\r\n var action = this.getActionObject(actionId);\r\n if (action == null) {\r\n throw new Error(\"Failed to get BlackOperation object for: \" + actionId.name);\r\n }\r\n this.actionTimeToComplete = action.getActionTime(this);\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n break;\r\n case ActionTypes[\"Training\"]:\r\n this.actionTimeToComplete = 30;\r\n break;\r\n case ActionTypes[\"Recruitment\"]:\r\n this.actionTimeToComplete = this.getRecruitmentTime();\r\n break;\r\n case ActionTypes[\"FieldAnalysis\"]:\r\n case ActionTypes[\"Field Analysis\"]:\r\n this.actionTimeToComplete = 30;\r\n break;\r\n default:\r\n throw new Error(\"Invalid Action Type in Bladeburner.startAction(): \" + actionId.type);\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.processAction = function(seconds) {\r\n if (this.action.type === ActionTypes[\"Idle\"]) {return;}\r\n if (this.actionTimeToComplete <= 0) {\r\n console.log(\"action.type: \" + this.action.type);\r\n throw new Error(\"Invalid actionTimeToComplete value: \" + this.actionTimeToComplete);\r\n }\r\n if (!(this.action instanceof ActionIdentifier)) {\r\n throw new Error(\"Bladeburner.action is not an ActionIdentifier Object\");\r\n }\r\n\r\n this.actionTimeCurrent += seconds;\r\n if (this.actionTimeCurrent >= this.actionTimeToComplete) {\r\n return this.completeAction();\r\n }\r\n}\r\n\r\nBladeburner.prototype.completeAction = function() {\r\n switch (this.action.type) {\r\n case ActionTypes[\"Contract\"]:\r\n case ActionTypes[\"Operation\"]:\r\n try {\r\n var isOperation = (this.action.type === ActionTypes[\"Operation\"]);\r\n var action = this.getActionObject(this.action);\r\n if (action == null) {\r\n throw new Error(\"Failed to get Contract/Operation Object for: \" + this.action.name);\r\n }\r\n var difficulty = action.getDifficulty();\r\n var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;\r\n var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);\r\n\r\n //Stamina loss is based on difficulty\r\n this.stamina -= (BaseStaminaLoss * difficultyMultiplier);\r\n if (this.stamina < 0) {this.stamina = 0;}\r\n\r\n //Process Contract/Operation success/failure\r\n if (action.attempt(this)) {\r\n this.gainActionStats(action, true);\r\n ++action.successes;\r\n --action.count;\r\n\r\n //Earn money for contracts\r\n var moneyGain = 0;\r\n if (!isOperation) {\r\n moneyGain = ContractBaseMoneyGain * rewardMultiplier;\r\n Player.gainMoney(moneyGain);\r\n }\r\n\r\n if (isOperation) {\r\n this.setMaxLevel(OperationSuccessesPerLevel);\r\n } else {\r\n this.setMaxLevel(ContractSuccessesPerLevel);\r\n }\r\n if (action.rankGain) {\r\n var gain = addOffset(action.rankGain * rewardMultiplier, 10);\r\n this.changeRank(gain);\r\n if (isOperation && this.logging.ops) {\r\n this.log(action.name + \" successfully completed! Gained \" + formatNumber(gain, 3) + \" rank\");\r\n } else if (!isOperation && this.logging.contracts) {\r\n this.log(action.name + \" contract successfully completed! Gained \" + formatNumber(gain, 3) + \" rank and \" + numeral(moneyGain).format(\"$0.000a\"));\r\n }\r\n }\r\n isOperation ? this.completeOperation(true) : this.completeContract(true);\r\n } else {\r\n this.gainActionStats(action, false);\r\n ++action.failures;\r\n var loss = 0, damage = 0;\r\n if (action.rankLoss) {\r\n loss = addOffset(action.rankLoss * rewardMultiplier, 10);\r\n this.changeRank(-1 * loss);\r\n }\r\n if (action.hpLoss) {\r\n damage = action.hpLoss * difficultyMultiplier;\r\n damage = Math.ceil(addOffset(damage, 10));\r\n this.hpLost += damage;\r\n if (Player.takeDamage(damage)) {\r\n ++this.numHosp;\r\n this.moneyLost += (CONSTANTS.HospitalCostPerHp * Player.max_hp);\r\n }\r\n }\r\n var logLossText = \"\";\r\n if (loss > 0) {logLossText += \"Lost \" + formatNumber(loss, 3) + \" rank.\";}\r\n if (damage > 0) {logLossText += \"Took \" + formatNumber(damage, 0) + \" damage.\";}\r\n if (isOperation && this.logging.ops) {\r\n this.log(action.name + \" failed! \" + logLossText);\r\n } else if (!isOperation && this.logging.contracts) {\r\n this.log(action.name + \" contract failed! \" + logLossText);\r\n }\r\n isOperation ? this.completeOperation(false) : this.completeContract(false);\r\n }\r\n if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel\r\n this.startAction(this.action); //Repeat action\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n break;\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n try {\r\n var action = this.getActionObject(this.action);\r\n if (action == null || !(action instanceof BlackOperation)) {\r\n throw new Error(\"Failed to get BlackOperation Object for: \" + this.action.name);\r\n }\r\n var difficulty = action.getDifficulty();\r\n var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;\r\n\r\n //Stamina loss is based on difficulty\r\n this.stamina -= (BaseStaminaLoss * difficultyMultiplier);\r\n if (this.stamina < 0) {this.stamina = 0;}\r\n\r\n //Team loss variables\r\n var teamCount = action.teamCount, teamLossMax;\r\n\r\n if (action.attempt(this)) {\r\n this.gainActionStats(action, true);\r\n action.count = 0;\r\n this.blackops[action.name] = true;\r\n var rankGain = 0;\r\n if (action.rankGain) {\r\n rankGain = addOffset(action.rankGain, 10);\r\n this.changeRank(rankGain);\r\n }\r\n teamLossMax = Math.ceil(teamCount/2);\r\n\r\n //Operation Daedalus\r\n if (action.name === \"Operation Daedalus\") {\r\n this.resetAction();\r\n return hackWorldDaemon(Player.bitNodeN);\r\n }\r\n\r\n if (Engine.currentPage === Engine.Page.Bladeburner) {\r\n this.createActionAndSkillsContent();\r\n }\r\n\r\n if (this.logging.blackops) {\r\n this.log(action.name + \" successful! Gained \" + formatNumber(rankGain, 1) + \" rank\");\r\n }\r\n } else {\r\n this.gainActionStats(action, false);\r\n var rankLoss = 0, damage = 0;\r\n if (action.rankLoss) {\r\n rankLoss = addOffset(action.rankLoss, 10);\r\n this.changeRank(-1 * rankLoss);\r\n }\r\n if (action.hpLoss) {\r\n damage = action.hpLoss * difficultyMultiplier;\r\n damage = Math.ceil(addOffset(damage, 10));\r\n if (Player.takeDamage(damage)) {\r\n ++this.numHosp;\r\n this.moneyLost += (CONSTANTS.HospitalCostPerHp * Player.max_hp);\r\n }\r\n }\r\n teamLossMax = Math.floor(teamCount);\r\n\r\n if (this.logging.blackops) {\r\n this.log(action.name + \" failed! Lost \" + formatNumber(rankLoss, 1) + \" rank and took\" + formatNumber(damage, 0) + \" damage\");\r\n }\r\n }\r\n\r\n this.resetAction(); //Stop regardless of success or fail\r\n\r\n //Calculate team lossses\r\n if (teamCount >= 1) {\r\n var losses = getRandomInt(1, teamLossMax);\r\n this.teamSize -= losses;\r\n this.teamLost += losses;\r\n if (this.logging.blackops) {\r\n this.log(\"You lost \" + formatNumber(losses, 0) + \" team members during \" + action.name);\r\n }\r\n }\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n break;\r\n case ActionTypes[\"Training\"]:\r\n this.stamina -= (0.5 * BaseStaminaLoss);\r\n var strExpGain = 30 * Player.strength_exp_mult,\r\n defExpGain = 30 * Player.defense_exp_mult,\r\n dexExpGain = 30 * Player.dexterity_exp_mult,\r\n agiExpGain = 30 * Player.agility_exp_mult,\r\n staminaGain = 0.04 * this.skillMultipliers.stamina;\r\n Player.gainStrengthExp(strExpGain);\r\n Player.gainDefenseExp(defExpGain);\r\n Player.gainDexterityExp(dexExpGain);\r\n Player.gainAgilityExp(agiExpGain);\r\n this.staminaBonus += (staminaGain);\r\n if (this.logging.general) {\r\n this.log(\"Training completed. Gained: \" +\r\n formatNumber(strExpGain, 1) + \" str exp, \" +\r\n formatNumber(defExpGain, 1) + \" def exp, \" +\r\n formatNumber(dexExpGain, 1) + \" dex exp, \" +\r\n formatNumber(agiExpGain, 1) + \" agi exp, \" +\r\n formatNumber(staminaGain, 3) + \" max stamina\");\r\n }\r\n this.startAction(this.action); //Repeat action\r\n break;\r\n case ActionTypes[\"FieldAnalysis\"]:\r\n case ActionTypes[\"Field Analysis\"]:\r\n //Does not use stamina. Effectiveness depends on hacking, int, and cha\r\n var eff = 0.04 * Math.pow(Player.hacking_skill, 0.3) +\r\n 0.04 * Math.pow(Player.intelligence, 0.9) +\r\n 0.02 * Math.pow(Player.charisma, 0.3);\r\n eff *= Player.bladeburner_analysis_mult;\r\n if (isNaN(eff) || eff < 0) {\r\n throw new Error(\"Field Analysis Effectiveness calculated to be NaN or negative\");\r\n }\r\n var hackingExpGain = 20 * Player.hacking_exp_mult,\r\n charismaExpGain = 20 * Player.charisma_exp_mult;\r\n Player.gainHackingExp(hackingExpGain);\r\n Player.gainIntelligenceExp(BaseIntGain);\r\n Player.gainCharismaExp(charismaExpGain);\r\n this.changeRank(0.1);\r\n console.log(\"DEBUG: Field Analysis effectiveness is \" + (eff * this.skillMultipliers.successChanceEstimate));\r\n this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);\r\n if (this.logging.general) {\r\n this.log(\"Field analysis completed. Gained 0.1 rank, \" + formatNumber(hackingExpGain, 1) + \" hacking exp, and \" + formatNumber(charismaExpGain, 1) + \" charisma exp\");\r\n }\r\n this.startAction(this.action); //Repeat action\r\n break;\r\n case ActionTypes[\"Recruitment\"]:\r\n var successChance = this.getRecruitmentSuccessChance();\r\n console.log(\"Bladeburner recruitment success chance: \" + successChance);\r\n if (Math.random() < successChance) {\r\n var expGain = 2 * BaseStatGain * this.actionTimeToComplete;\r\n Player.gainCharismaExp(expGain);\r\n ++this.teamSize;\r\n if (this.logging.general) {\r\n this.log(\"Successfully recruited a team member! Gained \" + formatNumber(expGain, 1) + \" charisma exp\");\r\n }\r\n } else {\r\n var expGain = BaseStatGain * this.actionTimeToComplete;\r\n Player.gainCharismaExp(expGain);\r\n if (this.logging.general) {\r\n this.log(\"Failed to recruit a team member. Gained \" + formatNumber(expGain, 1) + \" charisma exp\");\r\n }\r\n }\r\n this.startAction(this.action); //Repeat action\r\n break;\r\n default:\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.completeContract = function(success) {\r\n if (this.action.type !== ActionTypes.Contract) {\r\n throw new Error(\"completeContract() called even though current action is not a Contract\");\r\n }\r\n var city = this.getCurrentCity();\r\n if (success) {\r\n switch (this.action.name) {\r\n case \"Tracking\":\r\n //Increase estimate accuracy by a relatively small amount\r\n city.improvePopulationEstimateByCount(getRandomInt(100, 1e3));\r\n break;\r\n case \"Bounty Hunter\":\r\n city.changePopulationByCount(-1, {estChange:-1});\r\n city.changeChaosByCount(0.02);\r\n break;\r\n case \"Retirement\":\r\n city.changePopulationByCount(-1, {estChange:-1});\r\n city.changeChaosByCount(0.04);\r\n break;\r\n default:\r\n throw new Error(\"Invalid Action name in completeContract: \" + this.action.name);\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.completeOperation = function(success) {\r\n if (this.action.type !== ActionTypes.Operation) {\r\n throw new Error(\"completeOperation() called even though current action is not an Operation\");\r\n }\r\n var action = this.getActionObject(this.action);\r\n if (action == null) {\r\n throw new Error(\"Failed to get Contract/Operation Object for: \" + this.action.name);\r\n }\r\n\r\n //Calculate team losses\r\n var teamCount = action.teamCount, max;\r\n if (teamCount >= 1) {\r\n if (success) {\r\n max = Math.ceil(teamCount/2);\r\n } else {\r\n max = Math.floor(teamCount)\r\n }\r\n var losses = getRandomInt(0, max);\r\n this.teamSize -= losses;\r\n this.teamLost += losses;\r\n if (this.logging.ops && losses > 0) {\r\n this.log(\"Lost \" + formatNumber(losses, 0) + \" team members during this \" + action.name);\r\n }\r\n }\r\n\r\n var city = this.getCurrentCity();\r\n if (this.logging.ops) {\r\n if (success) {\r\n this.log(action.name + \" completed successfully! \")\r\n } else {\r\n\r\n }\r\n }\r\n switch (action.name) {\r\n case \"Investigation\":\r\n if (success) {\r\n city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);\r\n if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {\r\n city.improveCommunityEstimate(1);\r\n }\r\n } else {\r\n this.triggerPotentialMigration(this.city, 0.1);\r\n }\r\n break;\r\n case \"Undercover Operation\":\r\n if (success) {\r\n city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);\r\n if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {\r\n city.improveCommunityEstimate(1);\r\n }\r\n } else {\r\n this.triggerPotentialMigration(this.city, 0.15);\r\n }\r\n break;\r\n case \"Sting Operation\":\r\n if (success) {\r\n city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});\r\n }\r\n city.changeChaosByCount(0.1);\r\n break;\r\n case \"Raid\":\r\n if (success) {\r\n city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});\r\n --city.comms;\r\n --city.commsEst;\r\n } else {\r\n var change = getRandomInt(-3, -1);\r\n city.changePopulationByPercentage(change, {nonZero:true});\r\n }\r\n city.changeChaosByPercentage(getRandomInt(1, 5));\r\n break;\r\n case \"Stealth Retirement Operation\":\r\n if (success) {\r\n city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});\r\n }\r\n city.changeChaosByPercentage(getRandomInt(-3, -1));\r\n break;\r\n case \"Assassination\":\r\n if (success) {\r\n city.changePopulationByCount(-1, {estChange:-1});\r\n }\r\n city.changeChaosByPercentage(getRandomInt(-5, 5));\r\n break;\r\n default:\r\n throw new Error(\"Invalid Action name in completeOperation: \" + this.action.name);\r\n }\r\n}\r\n\r\nBladeburner.prototype.getRecruitmentTime = function() {\r\n var effCharisma = Player.charisma * this.skillMultipliers.effCha;\r\n var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;\r\n return Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));\r\n}\r\n\r\nBladeburner.prototype.getRecruitmentSuccessChance = function() {\r\n return Math.pow(Player.charisma, 0.45) / (this.teamSize + 1);\r\n}\r\n\r\n//Process stat gains from Contracts, Operations, and Black Operations\r\n//@action(Action obj) - Derived action class\r\n//@success(bool) - Whether action was successful\r\nBladeburner.prototype.gainActionStats = function(action, success) {\r\n var difficulty = action.getDifficulty();\r\n\r\n //Gain multiplier based on difficulty. If this changes then the\r\n //same variable calculated in completeAction() needs to change too\r\n var difficultyMult = Math.pow(difficulty, 0.21);\r\n\r\n var time = this.actionTimeToComplete;\r\n var successMult = success ? 1 : 0.5;\r\n\r\n var unweightedGain = time * BaseStatGain * successMult * difficultyMult;\r\n var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;\r\n Player.gainHackingExp(unweightedGain * action.weights.hack * Player.hacking_exp_mult);\r\n Player.gainStrengthExp(unweightedGain * action.weights.str * Player.strength_exp_mult);\r\n Player.gainDefenseExp(unweightedGain * action.weights.def * Player.defense_exp_mult);\r\n Player.gainDexterityExp(unweightedGain * action.weights.dex * Player.dexterity_exp_mult);\r\n Player.gainAgilityExp(unweightedGain * action.weights.agi * Player.agility_exp_mult);\r\n Player.gainCharismaExp(unweightedGain * action.weights.cha * Player.charisma_exp_mult);\r\n Player.gainIntelligenceExp(unweightedIntGain * action.weights.int);\r\n}\r\n\r\nBladeburner.prototype.randomEvent = function() {\r\n var chance = Math.random();\r\n\r\n //Choose random source/destination city for events\r\n var sourceCityName = CityNames[getRandomInt(0, 5)];\r\n var sourceCity = this.cities[sourceCityName];\r\n if (!(sourceCity instanceof City)) {\r\n throw new Error(\"sourceCity was not a City object in Bladeburner.randomEvent()\");\r\n }\r\n\r\n var destCityName = CityNames[getRandomInt(0, 5)];\r\n while (destCityName === sourceCityName) {\r\n destCityName = CityNames[getRandomInt(0, 5)];\r\n }\r\n var destCity = this.cities[destCityName];\r\n\r\n if (!(sourceCity instanceof City) || !(destCity instanceof City)) {\r\n throw new Error(\"sourceCity was not a City object in Bladeburner.randomEvent()\");\r\n }\r\n\r\n if (chance <= 0.05) {\r\n //New Synthoid Community, 5%\r\n ++sourceCity.comms;\r\n var percentage = getRandomInt(10, 20) / 100;\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop += count;\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that a new Synthoid community was formed in a city\");\r\n }\r\n } else if (chance <= 0.1) {\r\n //Synthoid Community Migration, 5%\r\n if (sourceCity.comms <= 0) {\r\n //If no comms in source city, then instead trigger a new Synthoid community event\r\n ++sourceCity.comms;\r\n var percentage = getRandomInt(10, 20) / 100;\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop += count;\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that a new Synthoid community was formed in a city\");\r\n }\r\n } else {\r\n --sourceCity.comms;\r\n ++destCity.comms;\r\n\r\n //Change pop\r\n var percentage = getRandomInt(10, 20) / 100;\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop -= count;\r\n destCity.pop += count;\r\n\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that a Synthoid community migrated from \" + sourceCityName + \" to some other city\");\r\n }\r\n }\r\n } else if (chance <= 0.3) {\r\n //New Synthoids (non community), 20%\r\n var percentage = getRandomInt(8, 24) / 100;\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop += count;\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that the Synthoid population of \" + sourceCityName + \" just changed significantly\");\r\n }\r\n } else if (chance <= 0.5) {\r\n //Synthoid migration (non community) 20%\r\n this.triggerMigration(sourceCityName);\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that a large number of Synthoids migrated from \" + sourceCityName + \" to some other city\");\r\n }\r\n } else if (chance <= 0.7) {\r\n //Synthoid Riots (+chaos), 20%\r\n sourceCity.chaos += 1;\r\n sourceCity.chaos *= (1 + getRandomInt(5, 10) / 100);\r\n if (this.logging.events) {\r\n this.log(\"Tensions between Synthoids and humans lead to riots in \" + sourceCityName + \"! Chaos increased\");\r\n }\r\n } else if (chance <= 0.9) {\r\n //Less Synthoids, 20%\r\n var percentage = getRandomInt(5, 20) / 100;\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop -= count;\r\n if (this.logging.events) {\r\n this.log(\"Intelligence indicates that the Synthoid population of \" + sourceCityName + \" just changed significantly\");\r\n }\r\n }\r\n //20% chance of nothing happening\r\n}\r\n\r\nBladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {\r\n if (chance == null || isNaN(chance)) {\r\n console.log(\"ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()\");\r\n }\r\n if (chance > 1) {chance /= 100;}\r\n if (Math.random() < chance) {this.triggerMigration(sourceCityName);}\r\n}\r\n\r\nBladeburner.prototype.triggerMigration = function(sourceCityName) {\r\n var destCityName = CityNames[getRandomInt(0, 5)];\r\n while (destCityName === sourceCityName) {\r\n destCityName = CityNames[getRandomInt(0, 5)];\r\n }\r\n var destCity = this.cities[destCityName];\r\n var sourceCity = this.cities[sourceCityName];\r\n if (destCity == null || sourceCity == null) {\r\n throw new Error(\"Failed to find City with name: \" + destCityName);\r\n }\r\n var rand = Math.random(), percentage = getRandomInt(3, 15) / 100;\r\n\r\n if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration\r\n percentage *= getRandomInt(2, 4); //Migration increases population change\r\n --sourceCity.comms;\r\n ++destCity.comms;\r\n }\r\n var count = Math.round(sourceCity.pop * percentage);\r\n sourceCity.pop -= count;\r\n destCity.pop += count;\r\n}\r\n\r\nvar DomElems = {};\r\n\r\nBladeburner.prototype.initializeDomElementRefs = function() {\r\n DomElems = {\r\n bladeburnerDiv: null,\r\n\r\n //Main Divs\r\n overviewConsoleParentDiv: null,\r\n\r\n overviewDiv: null, //Overview of stats that stays fixed on left\r\n actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)\r\n currentTab: null, //Contracts, Operations, Black Ops, Skills\r\n\r\n consoleDiv: null,\r\n consoleTable: null,\r\n consoleInputRow: null, //tr\r\n consoleInputCell: null, //td\r\n consoleInputHeader: null, //\"> \"\r\n consoleInput: null, //Actual input element\r\n\r\n //Overview Content\r\n overviewRank: null,\r\n overviewStamina: null,\r\n overviewStaminaHelpTip: null,\r\n overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city\r\n overviewEstPop: null,\r\n overviewEstPopHelpTip: null,\r\n overviewEstComms: null,\r\n overviewChaos: null,\r\n overviewSkillPoints: null,\r\n overviewAugSuccessMult: null,\r\n overviewAugMaxStaminaMult: null,\r\n overviewAugStaminaGainMult: null,\r\n overviewAugAnalysisMult: null,\r\n\r\n //Actions and Skills Content\r\n actionsAndSkillsDesc: null,\r\n actionsAndSkillsList: null, //ul element of all UI elements in this panel\r\n generalActions: {},\r\n contracts: {},\r\n operations: {},\r\n blackops: {},\r\n skills: {},\r\n };\r\n}\r\n\r\nBladeburner.prototype.createContent = function() {\r\n DomElems.bladeburnerDiv = createElement(\"div\", {\r\n id:\"bladeburner-container\", position:\"fixed\", class:\"generic-menupage-container\",\r\n });\r\n\r\n //Parent Div for Overview and Console\r\n DomElems.overviewConsoleParentDiv = createElement(\"div\", {\r\n height:\"60%\", display:\"block\", position:\"relative\",\r\n });\r\n\r\n //Overview and Action/Skill pane\r\n DomElems.overviewDiv = createElement(\"div\", {\r\n width:\"30%\", display:\"inline-block\", border:\"1px solid white\",\r\n });\r\n\r\n DomElems.actionAndSkillsDiv = createElement(\"div\", {\r\n height:\"60%\", width:\"70%\", display:\"block\",\r\n border:\"1px solid white\", margin:\"6px\", padding:\"6px\",\r\n });\r\n\r\n DomElems.currentTab = \"general\";\r\n\r\n this.createOverviewContent();\r\n this.createActionAndSkillsContent();\r\n\r\n //Console\r\n DomElems.consoleDiv = createElement(\"div\", {\r\n class:\"bladeburner-console-div\",\r\n clickListener:()=>{\r\n if (DomElems.consoleInput instanceof Element) {\r\n DomElems.consoleInput.focus();\r\n }\r\n return false;\r\n }\r\n });\r\n DomElems.consoleTable = createElement(\"table\", {class:\"bladeburner-console-table\"});\r\n DomElems.consoleInputRow = createElement(\"tr\", {class:\"bladeburner-console-input-row\", id:\"bladeubrner-console-input-row\"});\r\n DomElems.consoleInputCell = createElement(\"td\", {class:\"bladeburner-console-input-cell\"});\r\n DomElems.consoleInputHeader = createElement(\"pre\", {innerText:\"> \"});\r\n DomElems.consoleInput = createElement(\"input\", {\r\n type:\"text\", class:\"bladeburner-console-input\", tabIndex:1,\r\n onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}\r\n });\r\n\r\n DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);\r\n DomElems.consoleInputCell.appendChild(DomElems.consoleInput);\r\n DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);\r\n DomElems.consoleTable.appendChild(DomElems.consoleInputRow);\r\n DomElems.consoleDiv.appendChild(DomElems.consoleTable);\r\n\r\n DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);\r\n DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);\r\n DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);\r\n DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);\r\n\r\n document.getElementById(\"entire-game-container\").appendChild(DomElems.bladeburnerDiv);\r\n\r\n this.postToConsole(\"Bladeburner Console BETA\");\r\n this.postToConsole(\"Type 'help' to see console commands\");\r\n DomElems.consoleInput.focus();\r\n}\r\n\r\nBladeburner.prototype.clearContent = function() {\r\n if (DomElems.bladeburnerDiv instanceof Element) {\r\n removeChildrenFromElement(DomElems.bladeburnerDiv);\r\n removeElement(DomElems.bladeburnerDiv);\r\n }\r\n clearObject(DomElems);\r\n this.initializeDomElementRefs();\r\n}\r\n\r\nBladeburner.prototype.createOverviewContent = function() {\r\n if (DomElems.overviewDiv == null) {\r\n throw new Error(\"Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null\");\r\n }\r\n\r\n DomElems.overviewRank = createElement(\"p\", {\r\n innerText:\"Rank: \",\r\n display:\"inline-block\",\r\n tooltip:\"Your rank within the Bladeburner division\",\r\n });\r\n\r\n DomElems.overviewStamina = createElement(\"p\", {\r\n display:\"inline-block\",\r\n });\r\n\r\n DomElems.overviewStaminaHelpTip = createElement(\"div\", {\r\n innerText:\"?\", class:\"help-tip\",\r\n clickListener:()=>{\r\n dialogBoxCreate(\"Performing actions will use up your stamina.
\" +\r\n \"Your max stamina is determined primarily by your agility stat.
\" +\r\n \"Your stamina gain rate is determined by both your agility and your \" +\r\n \"max stamina. Higher max stamina leads to a higher gain rate.
\" +\r\n \"Once your \" +\r\n \"stamina falls below 50% of its max value, it begins to negatively \" +\r\n \"affect the success rate of your contracts/operations. This penalty \" +\r\n \"is shown in the overview panel. If the penalty is 15%, then this means \" +\r\n \"your success rate would be multipled by 85% (100 - 15).
\" +\r\n \"Your max stamina and stamina gain rate can also be increased by \" +\r\n \"training, or through skills and Augmentation upgrades.\");\r\n }\r\n });\r\n\r\n DomElems.overviewGen1 = createElement(\"p\", {\r\n display:\"block\",\r\n });\r\n\r\n DomElems.overviewEstPop = createElement(\"p\", {\r\n innerText:\"Est. Synthoid Population: \",\r\n display:\"inline-block\",\r\n tooltip:\"This is your Bladeburner division's estimate of how many Synthoids exist \" +\r\n \"in your current city.\"\r\n });\r\n\r\n DomElems.overviewEstPopHelpTip = createElement(\"div\", {\r\n innerText:\"?\", class:\"help-tip\",\r\n clickListener:()=>{\r\n dialogBoxCreate(\"The success rate of your contracts/operations depends on \" +\r\n \"the population of Synthoids in your current city. \" +\r\n \"The success rate that is shown to you is only an estimate, \" +\r\n \"and it is based on your Synthoid population estimate.
\" +\r\n \"Therefore, it is important that this Synthoid population estimate \" +\r\n \"is accurate so that you have a better idea of your \" +\r\n \"success rate for contracts/operations. Certain \" +\r\n \"actions will increase the accuracy of your population \" +\r\n \"estimate.
\" +\r\n \"The Synthoid populations of cities can change due to your \" +\r\n \"actions or random events. If random events occur, they will \" +\r\n \"be logged in the Bladeburner Console.\");\r\n }\r\n });\r\n\r\n DomElems.overviewEstComms = createElement(\"p\", {\r\n innerText:\"Est. Synthoid Communities: \",\r\n display:\"inline-block\",\r\n tooltip:\"This is your Bladeburner divison's estimate of how many Synthoid \" +\r\n \"communities exist in your current city.\",\r\n });\r\n\r\n DomElems.overviewChaos = createElement(\"p\", {\r\n innerText:\"City Chaos: \",\r\n display:\"inline-block\",\r\n tooltip:\"The city's chaos level due to tensions and conflicts between humans and Synthoids. \" +\r\n \"Having too high of a chaos level can make contracts and operations harder.\"\r\n });\r\n\r\n DomElems.overviewSkillPoints = createElement(\"p\", {display:\"block\"});\r\n\r\n DomElems.overviewAugSuccessMult = createElement(\"p\", {display:\"block\"});\r\n DomElems.overviewAugMaxStaminaMult = createElement(\"p\", {display:\"block\"});\r\n DomElems.overviewAugStaminaGainMult = createElement(\"p\", {display:\"block\"});\r\n DomElems.overviewAugAnalysisMult = createElement(\"p\", {display:\"block\"});\r\n\r\n\r\n DomElems.overviewDiv.appendChild(DomElems.overviewRank);\r\n appendLineBreaks(DomElems.overviewDiv, 1);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewStamina);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewGen1);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);\r\n appendLineBreaks(DomElems.overviewDiv, 1);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);\r\n appendLineBreaks(DomElems.overviewDiv, 1);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewChaos);\r\n appendLineBreaks(DomElems.overviewDiv, 2);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);\r\n appendLineBreaks(DomElems.overviewDiv, 1);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);\r\n DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);\r\n\r\n //Travel to new city button\r\n appendLineBreaks(DomElems.overviewDiv, 1);\r\n DomElems.overviewDiv.appendChild(createElement(\"a\", {\r\n innerHTML:\"Travel\", class:\"a-link-button\", display:\"inline-block\",\r\n clickListener:()=>{\r\n var popupId = \"bladeburner-travel-popup-cancel-btn\";\r\n var popupArguments = [];\r\n popupArguments.push(createElement(\"a\", { //Cancel Button\r\n innerText:\"Cancel\", class:\"a-link-button\",\r\n clickListener:()=>{\r\n removeElementById(popupId); return false;\r\n }\r\n }))\r\n popupArguments.push(createElement(\"p\", { //Info Text\r\n innerText:\"Travel to a different city for your Bladeburner \" +\r\n \"activities. This does not cost any money. The city you are \" +\r\n \"in for your Bladeburner duties does not affect \" +\r\n \"your location in the game otherwise\",\r\n }));\r\n for (var i = 0; i < CityNames.length; ++i) {\r\n (function(inst, i) {\r\n popupArguments.push(createElement(\"div\", {\r\n //Reusing this css class...it adds a border and makes it\r\n //so that background color changes when you hover\r\n class:\"cmpy-mgmt-find-employee-option\",\r\n innerText:CityNames[i],\r\n clickListener:()=>{\r\n inst.city = CityNames[i];\r\n removeElementById(popupId);\r\n inst.updateOverviewContent();\r\n return false;\r\n }\r\n }));\r\n })(this, i);\r\n }\r\n createPopup(popupId, popupArguments);\r\n }\r\n }));\r\n\r\n //Faction button\r\n var bladeburnersFactionName = \"Bladeburners\";\r\n if (factionExists(bladeburnersFactionName)) {\r\n var bladeburnerFac = Factions[bladeburnersFactionName];\r\n if (!(bladeburnerFac instanceof Faction)) {\r\n throw new Error(\"Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button\");\r\n }\r\n DomElems.overviewDiv.appendChild(createElement(\"a\", {\r\n innerText:\"Faction\", class:\"a-link-button\", display:\"inline-block\",\r\n tooltip:\"Apply to the Bladeburner Faction, or go to the faction page if you are already a member\",\r\n clickListener:()=>{\r\n if (bladeburnerFac.isMember) {\r\n Engine.loadFactionContent();\r\n displayFactionContent(bladeburnersFactionName);\r\n } else {\r\n if (this.rank >= RankNeededForFaction) {\r\n joinFaction(bladeburnerFac);\r\n dialogBoxCreate(\"Congratulations! You were accepted into the Bladeburners faction\");\r\n removeChildrenFromElement(DomElems.overviewDiv);\r\n this.createOverviewContent();\r\n } else {\r\n dialogBoxCreate(\"You need a rank of 25 to join the Bladeburners Faction!\")\r\n }\r\n }\r\n return false;\r\n }\r\n }));\r\n }\r\n\r\n DomElems.overviewDiv.appendChild(createElement(\"br\"));\r\n DomElems.overviewDiv.appendChild(createElement(\"br\"));\r\n\r\n this.updateOverviewContent();\r\n}\r\n\r\nBladeburner.prototype.createActionAndSkillsContent = function() {\r\n if (DomElems.currentTab == null) {DomElems.currentTab = \"general\";}\r\n\r\n removeChildrenFromElement(DomElems.actionAndSkillsDiv);\r\n clearObject(DomElems.generalActions);\r\n clearObject(DomElems.contracts);\r\n clearObject(DomElems.operations);\r\n clearObject(DomElems.blackops);\r\n clearObject(DomElems.skills);\r\n\r\n //Navigation buttons\r\n var currTab = DomElems.currentTab.toLowerCase();\r\n var buttons = [\"General\", \"Contracts\", \"Operations\", \"BlackOps\", \"Skills\"];\r\n for (var i = 0; i < buttons.length; ++i) {\r\n (function(buttons, i, inst, currTab) {\r\n\r\n DomElems.actionAndSkillsDiv.appendChild(createElement(\"a\", {\r\n innerText:buttons[i],\r\n class:currTab === buttons[i].toLowerCase() ? \"bladeburner-nav-button-inactive\" : \"bladeburner-nav-button\",\r\n clickListener:()=>{\r\n DomElems.currentTab = buttons[i].toLowerCase();\r\n inst.createActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n }) (buttons, i, this, currTab);\r\n }\r\n\r\n //General info/description for each action\r\n DomElems.actionsAndSkillsDesc = createElement(\"p\", {\r\n display:\"block\", margin:\"4px\", padding:\"4px\"\r\n });\r\n\r\n //List for actions/skills\r\n removeChildrenFromElement(DomElems.actionsAndSkillsList);\r\n DomElems.actionsAndSkillsList = createElement(\"ul\");\r\n\r\n switch(currTab) {\r\n case \"general\":\r\n this.createGeneralActionsContent();\r\n break;\r\n case \"contracts\":\r\n this.createContractsContent();\r\n break;\r\n case \"operations\":\r\n this.createOperationsContent();\r\n break;\r\n case \"blackops\":\r\n this.createBlackOpsContent();\r\n break;\r\n case \"skills\":\r\n this.createSkillsContent();\r\n break;\r\n default:\r\n throw new Error(\"Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent\");\r\n }\r\n this.updateContent();\r\n\r\n DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);\r\n DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);\r\n}\r\n\r\nBladeburner.prototype.createGeneralActionsContent = function() {\r\n if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {\r\n throw new Error(\"Bladeburner.createGeneralActionsContent called with either \" +\r\n \"DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null\");\r\n }\r\n\r\n DomElems.actionsAndSkillsDesc.innerText =\r\n \"These are generic actions that will assist you in your Bladeburner \" +\r\n \"duties. They will not affect your Bladeburner rank in any way.\"\r\n\r\n for (var actionName in GeneralActions) {\r\n if (GeneralActions.hasOwnProperty(actionName)) {\r\n DomElems.generalActions[actionName] = createElement(\"div\", {\r\n class:\"bladeburner-action\", name:actionName\r\n });\r\n DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.createContractsContent = function() {\r\n if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {\r\n throw new Error(\"Bladeburner.createContractsContent called with either \" +\r\n \"DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null\");\r\n }\r\n\r\n DomElems.actionsAndSkillsDesc.innerHTML =\r\n \"Complete contracts in order to increase your Bitburner rank and earn money. \" +\r\n \"Failing a contract will cause you to lose HP, which can lead to hospitalization.
\" +\r\n \"You can unlock higher-level contracts by successfully completing them. \" +\r\n \"Higher-level contracts are more difficult, but grant more rank, experience, and money.\";\r\n\r\n for (var contractName in this.contracts) {\r\n if (this.contracts.hasOwnProperty(contractName)) {\r\n DomElems.contracts[contractName] = createElement(\"div\", {\r\n class:\"bladeburner-action\", name:contractName\r\n });\r\n DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.createOperationsContent = function() {\r\n if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {\r\n throw new Error(\"Bladeburner.createOperationsContent called with either \" +\r\n \"DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null\");\r\n }\r\n\r\n DomElems.actionsAndSkillsDesc.innerHTML =\r\n \"Carry out operations for the Bladeburner division. \" +\r\n \"Failing an operation will reduce your Bladeburner rank. It will also \" +\r\n \"cause you to lose HP, which can lead to hospitalization. In general, \" +\r\n \"operations are harder and more punishing than contracts, \" +\r\n \"but are also more rewarding.
\" +\r\n \"Operations can affect the chaos level and Synthoid population of your \" +\r\n \"current city. The exact effects vary between different Operations.
\" +\r\n \"For operations, you can use a team. You must first recruit team members. \" +\r\n \"Having a larger team will improves your chances of success.
\" +\r\n \"You can unlock higher-level operations by successfully completing them. \" +\r\n \"Higher-level operations are more difficult, but grant more rank and experience.\";\r\n\r\n for (var operationName in this.operations) {\r\n if (this.operations.hasOwnProperty(operationName)) {\r\n DomElems.operations[operationName] = createElement(\"div\", {\r\n class:\"bladeburner-action\", name:operationName\r\n });\r\n DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.createBlackOpsContent = function() {\r\n if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {\r\n throw new Error(\"Bladeburner.createBlackOpsContent called with either \" +\r\n \"DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null\");\r\n }\r\n\r\n DomElems.actionsAndSkillsDesc.innerHTML =\r\n \"Black Operations (Black Ops) are special, one-time covert operations. \" +\r\n \"Each Black Op must be unlocked successively by completing \" +\r\n \"the one before it.
\" +\r\n \"Like normal operations, you may use a team for Black Ops. Failing \" +\r\n \"a black op will incur heavy HP and rank losses.\";\r\n\r\n //Put Black Operations in sequence of required rank\r\n var blackops = [];\r\n for (var blackopName in BlackOperations) {\r\n if (BlackOperations.hasOwnProperty(blackopName)) {\r\n blackops.push(BlackOperations[blackopName]);\r\n }\r\n }\r\n blackops.sort(function(a, b) {\r\n return (a.reqdRank - b.reqdRank);\r\n });\r\n\r\n for (var i = 0; i < blackops.length; ++i) {\r\n DomElems.blackops[blackops[i].name] = createElement(\"div\", {\r\n class:\"bladeburner-action\", name:blackops[i].name\r\n });\r\n DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);\r\n if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops\r\n }\r\n}\r\n\r\nBladeburner.prototype.createSkillsContent = function() {\r\n if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {\r\n throw new Error(\"Bladeburner.createSkillsContent called with either \" +\r\n \"DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null\");\r\n }\r\n\r\n //Display Current multipliers\r\n DomElems.actionsAndSkillsDesc.innerHTML =\r\n \"You will gain one skill point every \" + RanksPerSkillPoint + \" ranks.
\" +\r\n \"Note that when upgrading a skill, the benefit for that skill is additive. \" +\r\n \"However, the effects of different skills with each other is multiplicative.
\"\r\n var multKeys = Object.keys(this.skillMultipliers);\r\n for (var i = 0; i < multKeys.length; ++i) {\r\n var mult = this.skillMultipliers[multKeys[i]];\r\n if (mult && mult !== 1) {\r\n mult = formatNumber(mult, 3);\r\n switch(multKeys[i]) {\r\n case \"successChanceAll\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Total Success Chance: x\" + mult + \"
\";\r\n break;\r\n case \"successChanceStealth\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Stealth Success Chance: x\" + mult + \"
\";\r\n break;\r\n case \"successChanceKill\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Retirement Success Chance: x\" + mult + \"
\";\r\n break;\r\n case \"successChanceContract\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Contract Success Chance: x\" + mult + \"
\";\r\n break;\r\n case \"successChanceOperation\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Operation Success Chance: x\" + mult + \"
\";\r\n break;\r\n case \"successChanceEstimate\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Synthoid Data Estimate: x\" + mult + \"
\";\r\n break;\r\n case \"actionTime\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Action Time: x\" + mult + \"
\";\r\n break;\r\n case \"effHack\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Hacking Skill: x\" + mult + \"
\";\r\n break;\r\n case \"effStr\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Strength: x\" + mult + \"
\";\r\n break;\r\n case \"effDef\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Defense: x\" + mult + \"
\";\r\n break;\r\n case \"effDex\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Dexterity: x\" + mult + \"
\";\r\n break;\r\n case \"effAgi\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Agility: x\" + mult + \"
\";\r\n break;\r\n case \"effCha\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Charisma: x\" + mult + \"
\";\r\n break;\r\n case \"effInt\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Intelligence: x\" + mult + \"
\";\r\n break;\r\n case \"stamina\":\r\n DomElems.actionsAndSkillsDesc.innerHTML += \"Stamina: x\" + mult + \"
\";\r\n break;\r\n case \"weaponAbility\":\r\n //DomElems.actionsAndSkillsDesc.innerHTML +=\r\n break;\r\n case \"gunAbility\":\r\n //DomElems.actionsAndSkillsDesc.innerHTML\r\n break;\r\n default:\r\n console.log(\"Warning: Unrecognized SkillMult Key: \" + multKeys[i]);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //Skill Points\r\n DomElems.actionAndSkillsDiv.appendChild(createElement(\"p\", {\r\n innerHTML:\"
Skill Points: \" + formatNumber(this.skillPoints, 0) + \"\"\r\n }));\r\n\r\n //UI Element for each skill\r\n for (var skillName in Skills) {\r\n if (Skills.hasOwnProperty(skillName)) {\r\n DomElems.skills[skillName] = createElement(\"div\", {\r\n class:\"bladeburner-action\", name:skillName\r\n });\r\n DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.updateContent = function() {\r\n this.updateOverviewContent();\r\n this.updateActionAndSkillsContent();\r\n}\r\n\r\nBladeburner.prototype.updateOverviewContent = function() {\r\n if (Engine.currentPage !== Engine.Page.Bladeburner) {return;}\r\n DomElems.overviewRank.childNodes[0].nodeValue = \"Rank: \" + formatNumber(this.rank, 2);\r\n DomElems.overviewStamina.innerText = \"Stamina: \" + formatNumber(this.stamina, 3) + \" / \" + formatNumber(this.maxStamina, 3);\r\n DomElems.overviewGen1.innerHTML =\r\n \"Stamina Penalty: \" + formatNumber((1-this.calculateStaminaPenalty())*100, 1) + \"%
\" +\r\n \"Team Size: \" + formatNumber(this.teamSize, 0) + \"
\" +\r\n \"Team Members Lost: \" + formatNumber(this.teamLost, 0) + \"
\" +\r\n \"Num Times Hospitalized: \" + this.numHosp + \"
\" +\r\n \"Money Lost From Hospitalizations: \" + numeral(this.moneyLost).format(\"$0.000a\") + \"
\" +\r\n \"Current City: \" + this.city + \"
\";\r\n\r\n DomElems.overviewEstPop.childNodes[0].nodeValue = \"Est. Synthoid Population: \" + numeral(this.getCurrentCity().popEst).format(\"0.000a\");\r\n DomElems.overviewEstComms.childNodes[0].nodeValue = \"Est. Synthoid Communities: \" + formatNumber(this.getCurrentCity().comms, 0);\r\n DomElems.overviewChaos.childNodes[0].nodeValue = \"City Chaos: \" + formatNumber(this.getCurrentCity().chaos);\r\n DomElems.overviewSkillPoints.innerText = \"Skill Points: \" + formatNumber(this.skillPoints, 0);\r\n DomElems.overviewAugSuccessMult.innerText = \"Aug. Success Chance Mult: \" + formatNumber(Player.bladeburner_success_chance_mult*100, 1) + \"%\";\r\n DomElems.overviewAugMaxStaminaMult.innerText = \"Aug. Max Stamina Mult: \" + formatNumber(Player.bladeburner_max_stamina_mult*100, 1) + \"%\";\r\n DomElems.overviewAugStaminaGainMult.innerText = \"Aug. Stamina Gain Mult: \" + formatNumber(Player.bladeburner_stamina_gain_mult*100, 1) + \"%\";\r\n DomElems.overviewAugAnalysisMult.innerText = \"Aug. Field Analysis Mult: \" + formatNumber(Player.bladeburner_analysis_mult*100, 1) + \"%\";\r\n}\r\n\r\nBladeburner.prototype.updateActionAndSkillsContent = function() {\r\n if (DomElems.currentTab == null) {DomElems.currentTab = \"general\";}\r\n switch(DomElems.currentTab.toLowerCase()) {\r\n case \"general\":\r\n var actionElems = Object.keys(DomElems.generalActions);\r\n for (var i = 0; i < actionElems.length; ++i) {\r\n var actionElem = DomElems.generalActions[actionElems[i]];\r\n var name = actionElem.name;\r\n var actionObj = GeneralActions[name];\r\n if (actionObj == null) {\r\n throw new Error(\"Could not find Object \" + name + \" in Bladeburner.updateActionAndSkillsContent()\");\r\n }\r\n if (this.action.type === ActionTypes[name]) {\r\n actionElem.classList.add(ActiveActionCssClass);\r\n } else {\r\n actionElem.classList.remove(ActiveActionCssClass);\r\n }\r\n this.updateGeneralActionsUIElement(actionElem, actionObj);\r\n }\r\n break;\r\n case \"contracts\":\r\n var contractElems = Object.keys(DomElems.contracts);\r\n for (var i = 0; i < contractElems.length; ++i) {\r\n var contractElem = DomElems.contracts[contractElems[i]];\r\n var name = contractElem.name;\r\n if (this.action.type === ActionTypes[\"Contract\"] && name === this.action.name) {\r\n contractElem.classList.add(ActiveActionCssClass);\r\n } else {\r\n contractElem.classList.remove(ActiveActionCssClass);\r\n }\r\n var contract = this.contracts[name];\r\n if (contract == null) {\r\n throw new Error(\"Could not find Contract \" + name + \" in Bladeburner.updateActionAndSkillsContent()\");\r\n }\r\n this.updateContractsUIElement(contractElem, contract);\r\n }\r\n break;\r\n case \"operations\":\r\n var operationElems = Object.keys(DomElems.operations);\r\n for (var i = 0; i < operationElems.length; ++i) {\r\n var operationElem = DomElems.operations[operationElems[i]];\r\n var name = operationElem.name;\r\n if (this.action.type === ActionTypes[\"Operation\"] && name === this.action.name) {\r\n operationElem.classList.add(ActiveActionCssClass);\r\n } else {\r\n operationElem.classList.remove(ActiveActionCssClass);\r\n }\r\n var operation = this.operations[name];\r\n if (operation == null) {\r\n throw new Error(\"Could not find Operation \" + name + \" in Bladeburner.updateActionAndSkillsContent()\");\r\n }\r\n this.updateOperationsUIElement(operationElem, operation);\r\n }\r\n break;\r\n case \"blackops\":\r\n var blackopsElems = Object.keys(DomElems.blackops);\r\n for (var i = 0; i < blackopsElems.length; ++i) {\r\n var blackopElem = DomElems.blackops[blackopsElems[i]];\r\n var name = blackopElem.name;\r\n if (this.action.type === ActionTypes[\"BlackOperation\"] && name === this.action.name) {\r\n blackopElem.classList.add(ActiveActionCssClass);\r\n } else {\r\n blackopElem.classList.remove(ActiveActionCssClass);\r\n }\r\n var blackop = BlackOperations[name];\r\n if (blackop == null) {\r\n throw new Error(\"Could not find BlackOperation \" + name + \" in Bladeburner.updateActionAndSkillsContent()\");\r\n }\r\n this.updateBlackOpsUIElement(blackopElem, blackop);\r\n }\r\n break;\r\n case \"skills\":\r\n var skillElems = Object.keys(DomElems.skills);\r\n for (var i = 0; i < skillElems.length; ++i) {\r\n var skillElem = DomElems.skills[skillElems[i]];\r\n var name = skillElem.name;\r\n var skill = Skills[name];\r\n if (skill == null) {\r\n throw new Error(\"Could not find Skill \" + name + \" in Bladeburner.updateActionAndSkillsContent()\");\r\n }\r\n this.updateSkillsUIElement(skillElem, skill);\r\n }\r\n break;\r\n default:\r\n throw new Error(\"Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent\");\r\n }\r\n}\r\n\r\nBladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {\r\n removeChildrenFromElement(el);\r\n var isActive = el.classList.contains(ActiveActionCssClass);\r\n\r\n el.appendChild(createElement(\"h2\", { //Header\r\n innerText:isActive ? action.name + \" (IN PROGRESS - \" +\r\n formatNumber(this.actionTimeCurrent, 0) + \" / \" +\r\n formatNumber(this.actionTimeToComplete, 0) + \")\"\r\n : action.name,\r\n display:\"inline-block\",\r\n }));\r\n\r\n if (isActive) { //Progress bar if its active\r\n var progress = this.actionTimeCurrent / this.actionTimeToComplete;\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\",\r\n innerText:createProgressBarText({progress:progress})\r\n }));\r\n } else {\r\n //Start button\r\n el.appendChild(createElement(\"a\", {\r\n innerText:\"Start\", class: \"a-link-button\",\r\n margin:\"3px\", padding:\"3px\",\r\n clickListener:()=>{\r\n this.action.type = ActionTypes[action.name];\r\n this.action.name = action.name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n }\r\n\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"pre\", { //Info\r\n innerHTML:action.desc, display:\"inline-block\"\r\n }));\r\n\r\n\r\n}\r\n\r\nBladeburner.prototype.updateContractsUIElement = function(el, action) {\r\n removeChildrenFromElement(el);\r\n var isActive = el.classList.contains(ActiveActionCssClass);\r\n var estimatedSuccessChance = action.getSuccessChance(this, {est:true});\r\n\r\n el.appendChild(createElement(\"h2\", { //Header\r\n innerText:isActive ? action.name + \" (IN PROGRESS - \" +\r\n formatNumber(this.actionTimeCurrent, 0) + \" / \" +\r\n formatNumber(this.actionTimeToComplete, 0) + \")\"\r\n : action.name,\r\n display:\"inline-block\"\r\n }));\r\n\r\n if (isActive) { //Progress bar if its active\r\n var progress = this.actionTimeCurrent / this.actionTimeToComplete;\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\",\r\n innerText:createProgressBarText({progress:progress})\r\n }));\r\n } else { //Start button\r\n el.appendChild(createElement(\"a\", {\r\n innerText:\"Start\", class: \"a-link-button\",\r\n padding:\"3px\", margin:\"3px\",\r\n clickListener:()=>{\r\n this.action.type = ActionTypes.Contract;\r\n this.action.name = action.name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n }\r\n\r\n //Level and buttons to change level\r\n var maxLevel = (action.level >= action.maxLevel);\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"pre\", {\r\n display:\"inline-block\",\r\n innerText:\"Level: \" + action.level + \" / \" + action.maxLevel,\r\n tooltip:action.getSuccessesNeededForNextLevel(ContractSuccessesPerLevel) + \" successes \" +\r\n \"needed for next level\"\r\n }));\r\n el.appendChild(createElement(\"a\", {\r\n class: maxLevel ? \"a-link-button-inactive\" : \"a-link-button\", innerHTML:\"↑\",\r\n padding:\"2px\", margin:\"2px\",\r\n tooltip: isActive ? \"WARNING: changing the level will restart the contract\" : \"\",\r\n display:\"inline\",\r\n clickListener:()=>{\r\n ++action.level;\r\n if (isActive) {this.startAction(this.action);} //Restart Action\r\n this.updateContractsUIElement(el, action);\r\n return false;\r\n }\r\n }));\r\n el.appendChild(createElement(\"a\", {\r\n class: (action.level <= 1) ? \"a-link-button-inactive\" : \"a-link-button\", innerHTML:\"↓\",\r\n padding:\"2px\", margin:\"2px\",\r\n tooltip: isActive ? \"WARNING: changing the level will restart the contract\" : \"\",\r\n display:\"inline\",\r\n clickListener:()=>{\r\n --action.level;\r\n if (isActive) {this.startAction(this.action);} //Restart Action\r\n this.updateContractsUIElement(el, action);\r\n return false;\r\n }\r\n }));\r\n\r\n var actionTime = action.getActionTime(this);\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"pre\", { //Info\r\n display:\"inline-block\",\r\n innerHTML:action.desc + \"\\n\\n\" +\r\n \"Estimated success chance: \" + formatNumber(estimatedSuccessChance*100, 1) + \"%\\n\" +\r\n \"Time Required (s): \" + formatNumber(actionTime, 0) + \"\\n\" +\r\n \"Contracts remaining: \" + Math.floor(action.count) + \"\\n\" +\r\n \"Successes: \" + action.successes + \"\\n\" +\r\n \"Failures: \" + action.failures,\r\n }));\r\n\r\n //Autolevel Checkbox\r\n el.appendChild(createElement(\"br\"));\r\n var autolevelCheckboxId = \"bladeburner-\" + action.name + \"-autolevel-checkbox\";\r\n el.appendChild(createElement(\"label\", {\r\n for:autolevelCheckboxId, innerText:\"Autolevel\",color:\"white\",\r\n tooltip:\"Automatically increase contract level when possible\"\r\n }));\r\n var autolevelCheckbox = createElement(\"input\", {\r\n type:\"checkbox\", id:autolevelCheckboxId, margin:\"4px\",\r\n checked:action.autoLevel,\r\n changeListener:()=>{\r\n action.autoLevel = autolevelCheckbox.checked;\r\n }\r\n });\r\n el.appendChild(autolevelCheckbox);\r\n}\r\n\r\nBladeburner.prototype.updateOperationsUIElement = function(el, action) {\r\n removeChildrenFromElement(el);\r\n var isActive = el.classList.contains(ActiveActionCssClass);\r\n var estimatedSuccessChance = action.getSuccessChance(this, {est:true});\r\n el.appendChild(createElement(\"h2\", { //Header\r\n innerText:isActive ? action.name + \" (IN PROGRESS - \" +\r\n formatNumber(this.actionTimeCurrent, 0) + \" / \" +\r\n formatNumber(this.actionTimeToComplete, 0) + \")\"\r\n : action.name,\r\n display:\"inline-block\"\r\n }));\r\n\r\n if (isActive) { //Progress bar if its active\r\n var progress = this.actionTimeCurrent / this.actionTimeToComplete;\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\",\r\n innerText:createProgressBarText({progress:progress})\r\n }));\r\n } else { //Start button and set Team Size button\r\n el.appendChild(createElement(\"a\", {\r\n innerText:\"Start\", class: \"a-link-button\",\r\n margin:\"3px\", padding:\"3px\",\r\n clickListener:()=>{\r\n this.action.type = ActionTypes.Operation;\r\n this.action.name = action.name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n el.appendChild(createElement(\"a\", {\r\n innerText:\"Set Team Size (Curr Size: \" + formatNumber(action.teamCount, 0) + \")\", class:\"a-link-button\",\r\n margin:\"3px\", padding:\"3px\",\r\n clickListener:()=>{\r\n var popupId = \"bladeburner-operation-set-team-size-popup\";\r\n var txt = createElement(\"p\", {\r\n innerText:\"Enter the amount of team members you would like to take on these \" +\r\n \"operations. If you do not have the specified number of team members, \" +\r\n \"then as many as possible will be used. Note that team members may \" +\r\n \"be lost during operations.\"\r\n\r\n });\r\n var input = createElement(\"input\", {\r\n type:\"number\", placeholder: \"Team Members\"\r\n });\r\n var setBtn = createElement(\"a\", {\r\n innerText:\"Confirm\", class:\"a-link-button\",\r\n clickListener:()=>{\r\n var num = Math.round(parseFloat(input.value));\r\n if (isNaN(num)) {\r\n dialogBoxCreate(\"Invalid value entered for number of Team Members (must be numeric)\")\r\n } else {\r\n action.teamCount = num;\r\n this.updateOperationsUIElement(el, action);\r\n }\r\n removeElementById(popupId);\r\n return false;\r\n }\r\n });\r\n var cancelBtn = createElement(\"a\", {\r\n innerText:\"Cancel\", class:\"a-link-button\",\r\n clickListener:()=>{\r\n removeElementById(popupId);\r\n return false;\r\n }\r\n });\r\n createPopup(popupId, [txt, input, setBtn, cancelBtn]);\r\n }\r\n }));\r\n }\r\n\r\n //Level and buttons to change level\r\n var maxLevel = (action.level >= action.maxLevel);\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"pre\", {\r\n display:\"inline-block\",\r\n innerText:\"Level: \" + action.level + \" / \" + action.maxLevel,\r\n tooltip:action.getSuccessesNeededForNextLevel(OperationSuccessesPerLevel) + \" successes \" +\r\n \"needed for next level\"\r\n }));\r\n el.appendChild(createElement(\"a\", {\r\n class: maxLevel ? \"a-link-button-inactive\" : \"a-link-button\", innerHTML:\"↑\",\r\n padding:\"2px\", margin:\"2px\",\r\n tooltip: isActive ? \"WARNING: changing the level will restart the Operation\" : \"\",\r\n display:\"inline\",\r\n clickListener:()=>{\r\n ++action.level;\r\n if (isActive) {this.startAction(this.action);} //Restart Action\r\n this.updateOperationsUIElement(el, action);\r\n return false;\r\n }\r\n }));\r\n el.appendChild(createElement(\"a\", {\r\n class: (action.level <= 1) ? \"a-link-button-inactive\" : \"a-link-button\", innerHTML:\"↓\",\r\n padding:\"2px\", margin:\"2px\",\r\n tooltip: isActive ? \"WARNING: changing the level will restart the Operation\" : \"\",\r\n display:\"inline\",\r\n clickListener:()=>{\r\n --action.level;\r\n if (isActive) {this.startAction(this.action);} //Restart Action\r\n this.updateOperationsUIElement(el, action);\r\n return false;\r\n }\r\n }));\r\n\r\n //General Info\r\n var difficulty = action.getDifficulty();\r\n var actionTime = action.getActionTime(this);\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"pre\", {\r\n display:\"inline-block\",\r\n innerHTML:action.desc + \"\\n\\n\" +\r\n \"Estimated success chance: \" + formatNumber(estimatedSuccessChance*100, 1) + \"%\\n\" +\r\n \"Time Required(s): \" + formatNumber(actionTime, 1) + \"\\n\" +\r\n \"Operations remaining: \" + Math.floor(action.count) + \"\\n\" +\r\n \"Successes: \" + action.successes + \"\\n\" +\r\n \"Failures: \" + action.failures,\r\n }));\r\n\r\n //Autolevel Checkbox\r\n el.appendChild(createElement(\"br\"));\r\n var autolevelCheckboxId = \"bladeburner-\" + action.name + \"-autolevel-checkbox\";\r\n el.appendChild(createElement(\"label\", {\r\n for:autolevelCheckboxId, innerText:\"Autolevel\",color:\"white\",\r\n tooltip:\"Automatically increase operation level when possible\"\r\n }));\r\n var autolevelCheckbox = createElement(\"input\", {\r\n type:\"checkbox\", id:autolevelCheckboxId, margin:\"4px\",\r\n checked:action.autoLevel,\r\n changeListener:()=>{\r\n action.autoLevel = autolevelCheckbox.checked;\r\n }\r\n });\r\n el.appendChild(autolevelCheckbox);\r\n}\r\n\r\nBladeburner.prototype.updateBlackOpsUIElement = function(el, action) {\r\n removeChildrenFromElement(el);\r\n var isActive = el.classList.contains(ActiveActionCssClass);\r\n var isCompleted = (this.blackops[action.name] != null);\r\n var estimatedSuccessChance = action.getSuccessChance(this, {est:true});\r\n var difficulty = action.getDifficulty();\r\n var actionTime = action.getActionTime(this);\r\n var hasReqdRank = this.rank >= action.reqdRank;\r\n\r\n //UI for Completed Black Op\r\n if (isCompleted) {\r\n el.appendChild(createElement(\"h2\", {\r\n innerText:action.name + \" (COMPLETED)\", display:\"block\",\r\n }));\r\n return;\r\n }\r\n\r\n el.appendChild(createElement(\"h2\", { //Header\r\n innerText:isActive ? action.name + \" (IN PROGRESS - \" +\r\n formatNumber(this.actionTimeCurrent, 0) + \" / \" +\r\n formatNumber(this.actionTimeToComplete, 0) + \")\"\r\n : action.name,\r\n display:\"inline-block\",\r\n }));\r\n\r\n if (isActive) { //Progress bar if its active\r\n var progress = this.actionTimeCurrent / this.actionTimeToComplete;\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\",\r\n innerText:createProgressBarText({progress:progress})\r\n }));\r\n } else {\r\n el.appendChild(createElement(\"a\", { //Start button\r\n innerText:\"Start\", margin:\"3px\", padding:\"3px\",\r\n class:hasReqdRank ? \"a-link-button\" : \"a-link-button-inactive\",\r\n clickListener:()=>{\r\n this.action.type = ActionTypes.BlackOperation;\r\n this.action.name = action.name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n el.appendChild(createElement(\"a\", { //Set Team Size Button\r\n innerText:\"Set Team Size (Curr Size: \" + formatNumber(action.teamCount, 0) + \")\", class:\"a-link-button\",\r\n margin:\"3px\", padding:\"3px\",\r\n clickListener:()=>{\r\n var popupId = \"bladeburner-operation-set-team-size-popup\";\r\n var txt = createElement(\"p\", {\r\n innerText:\"Enter the amount of team members you would like to take on this \" +\r\n \"BlackOp. If you do not have the specified number of team members, \" +\r\n \"then as many as possible will be used. Note that team members may \" +\r\n \"be lost during operations.\"\r\n\r\n });\r\n var input = createElement(\"input\", {\r\n type:\"number\", placeholder: \"Team Members\"\r\n });\r\n var setBtn = createElement(\"a\", {\r\n innerText:\"Confirm\", class:\"a-link-button\",\r\n clickListener:()=>{\r\n var num = Math.round(parseFloat(input.value));\r\n if (isNaN(num)) {\r\n dialogBoxCreate(\"Invalid value entered for number of Team Members (must be numeric)\")\r\n } else {\r\n action.teamCount = num;\r\n this.updateBlackOpsUIElement(el, action);\r\n }\r\n removeElementById(popupId);\r\n return false;\r\n }\r\n });\r\n var cancelBtn = createElement(\"a\", {\r\n innerText:\"Cancel\", class:\"a-link-button\",\r\n clickListener:()=>{\r\n removeElementById(popupId);\r\n return false;\r\n }\r\n });\r\n createPopup(popupId, [txt, input, setBtn, cancelBtn]);\r\n }\r\n }));\r\n }\r\n\r\n //Info\r\n appendLineBreaks(el, 2);\r\n el.appendChild(createElement(\"p\", {\r\n display:\"inline-block\",\r\n innerHTML:\"
\" + action.desc + \"
\",\r\n }));\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\", color:hasReqdRank ? \"white\" : \"red\",\r\n innerHTML:\"Required Rank: \" + formatNumber(action.reqdRank, 0) + \"
\"\r\n }));\r\n el.appendChild(createElement(\"p\", {\r\n display:\"inline-block\",\r\n innerHTML:\"Estimated Success Chance: \" + formatNumber(estimatedSuccessChance*100, 1) + \"%\\n\" +\r\n \"Time Required(s): \" + formatNumber(actionTime, 1),\r\n }))\r\n}\r\n\r\nBladeburner.prototype.updateSkillsUIElement = function(el, skill) {\r\n removeChildrenFromElement(el);\r\n var skillName = skill.name;\r\n var currentLevel = 0;\r\n if (this.skills[skillName] && !isNaN(this.skills[skillName])) {\r\n currentLevel = this.skills[skillName];\r\n }\r\n var pointCost = skill.baseCost + (currentLevel * skill.costInc);\r\n\r\n el.appendChild(createElement(\"h2\", { //Header\r\n innerText:skill.name + \" (Lvl \" + currentLevel + \")\", display:\"inline-block\"\r\n }));\r\n\r\n var canLevel = this.skillPoints >= pointCost;\r\n var maxLvl = skill.maxLvl ? currentLevel >= skill.maxLvl : false;\r\n el.appendChild(createElement(\"a\", { //Level up button\r\n innerText:\"Level\", display:\"inline-block\",\r\n class: canLevel && !maxLvl ? \"a-link-button\" : \"a-link-button-inactive\",\r\n margin:\"3px\", padding:\"3px\",\r\n clickListener:()=>{\r\n if (this.skillPoints < pointCost) {return;}\r\n this.skillPoints -= pointCost;\r\n this.upgradeSkill(skill);\r\n this.createActionAndSkillsContent();\r\n return false;\r\n }\r\n }));\r\n appendLineBreaks(el, 2);\r\n if (maxLvl) {\r\n el.appendChild(createElement(\"p\", {\r\n color:\"red\", display:\"block\",\r\n innerText:\"MAX LEVEL\"\r\n }));\r\n } else {\r\n el.appendChild(createElement(\"p\", {\r\n display:\"block\",\r\n innerText:\"Skill Points required: \" + formatNumber(pointCost, 0),\r\n }));\r\n }\r\n el.appendChild(createElement(\"p\", { //Info/Description\r\n innerHTML:skill.desc, display:\"inline-block\",\r\n }));\r\n}\r\n\r\n//Bladeburner Console Window\r\nBladeburner.prototype.postToConsole = function(input) {\r\n if (input == null || DomElems.consoleDiv == null) {return;}\r\n $(\"#bladeubrner-console-input-row\").before(' ');\r\n if (DomElems.consoleTable.childNodes.length > 200) {\r\n DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);\r\n }\r\n\tthis.updateConsoleScroll();\r\n}\r\n\r\nBladeburner.prototype.updateConsoleScroll = function() {\r\n DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;\r\n}\r\n\r\nBladeburner.prototype.resetConsoleInput = function() {\r\n DomElems.consoleInput.value = \"\";\r\n}\r\n\r\nBladeburner.prototype.clearConsole = function() {\r\n while (DomElems.consoleTable.childNodes.length > 1) {\r\n DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);\r\n }\r\n}\r\n\r\nBladeburner.prototype.log = function(input) {\r\n //Adds a timestamp and then just calls postToConsole\r\n var d = new Date();\r\n var timestamp = d.getMonth() + \"/\" + d.getDay() + \" \" + d.getHours() + \":\" + d.getMinutes();\r\n this.postToConsole(\"[\" + timestamp + \"] \" + input);\r\n}\r\n\r\n//Handles a potential series of commands (comm1; comm2; comm3;)\r\nBladeburner.prototype.executeConsoleCommands = function(commands) {\r\n try {\r\n //Console History\r\n if (consoleHistory[consoleHistory.length-1] != commands) {\r\n consoleHistory.push(commands);\r\n if (consoleHistory.length > 50) {\r\n consoleHistory.splice(0, 1);\r\n }\r\n }\r\n consoleHistoryIndex = consoleHistory.length;\r\n\r\n var arrayOfCommands = commands.split(\";\");\r\n for (var i = 0; i < arrayOfCommands.length; ++i) {\r\n this.executeConsoleCommand(arrayOfCommands[i]);\r\n }\r\n } catch(e) {\r\n exceptionAlert(e);\r\n }\r\n}\r\n\r\n//A single command\r\nBladeburner.prototype.executeConsoleCommand = function(command) {\r\n command = command.trim();\r\n command = command.replace(/\\s\\s+/g, ' '); //Replace all whitespace w/ a single space\r\n\r\n var args = this.parseCommandArguments(command);\r\n if (args.length <= 0) {return;} //Log an error?\r\n\r\n switch(args[0].toLowerCase()) {\r\n case \"automate\":\r\n this.executeAutomateConsoleCommand(args);\r\n break;\r\n case \"clear\":\r\n case \"cls\":\r\n this.clearConsole();\r\n break;\r\n case \"help\":\r\n this.executeHelpConsoleCommand(args);\r\n break;\r\n case \"log\":\r\n this.executeLogConsoleCommand(args);\r\n break;\r\n case \"skill\":\r\n this.executeSkillConsoleCommand(args);\r\n break;\r\n case \"start\":\r\n this.executeStartConsoleCommand(args);\r\n break;\r\n case \"stop\":\r\n this.resetAction();\r\n break;\r\n default:\r\n this.postToConsole(\"Invalid console command\");\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.parseCommandArguments = function(command) {\r\n //Returns an array with command and its arguments in each index.\r\n //e.g. skill \"blade's intuition\" foo returns [skill, blade's intuition, foo]\r\n //The input to this fn will be trimmed and will have all whitespace replaced w/ a single space\r\n var args = [];\r\n var start = 0, i = 0;\r\n while (i < command.length) {\r\n var c = command.charAt(i);\r\n if (c === '\"') {\r\n var endQuote = command.indexOf('\"', i+1);\r\n if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === \" \")) {\r\n args.push(command.substr(i+1, (endQuote - i - 1)));\r\n if (endQuote === command.length-1) {\r\n start = i = endQuote+1;\r\n } else {\r\n start = i = endQuote+2; //Skip the space\r\n }\r\n continue;\r\n }\r\n } else if (c === \" \") {\r\n args.push(command.substr(start, i-start));\r\n start = i+1;\r\n }\r\n ++i;\r\n }\r\n if (start !== i) {args.push(command.substr(start, i-start));}\r\n console.log(\"Bladeburner.parseCommandArguments returned: \" + args);\r\n return args;\r\n}\r\n\r\nBladeburner.prototype.executeAutomateConsoleCommand = function(args) {\r\n if (args.length !== 2 && args.length !== 4) {\r\n this.postToConsole(\"Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info\");\r\n return;\r\n }\r\n\r\n //Enable/Disable\r\n if (args.length === 2) {\r\n var flag = args[1];\r\n if (flag.toLowerCase() === \"status\") {\r\n this.postToConsole(\"Automation: \" + (this.automateEnabled ? \"enabled\" : \"disabled\"));\r\n if (this.automateEnabled) {\r\n this.postToConsole(\"When your stamina drops to \" + formatNumber(this.automateThreshLow, 0) +\r\n \", you will automatically switch to \" + this.automateActionLow.name +\r\n \". When your stamina recovers to \" +\r\n formatNumber(this.automateThreshHigh, 0) + \", you will automatically \" +\r\n \"switch to \" + this.automateActionHigh.name + \".\");\r\n }\r\n\r\n } else if (flag.toLowerCase().includes(\"en\")) {\r\n if (!(this.automateActionLow instanceof ActionIdentifier) ||\r\n !(this.automateActionHigh instanceof ActionIdentifier)) {\r\n return this.log(\"Failed to enable automation. Actions were not set\");\r\n }\r\n this.automateEnabled = true;\r\n this.log(\"Bladeburner automation enabled\");\r\n } else if (flag.toLowerCase().includes(\"d\")) {\r\n this.automateEnabled = false;\r\n this.log(\"Bladeburner automation disabled\");\r\n } else {\r\n this.log(\"Invalid argument for 'automate' console command: \" + args[1]);\r\n }\r\n return;\r\n }\r\n\r\n //Set variables\r\n if (args.length === 4) {\r\n var variable = args[1], val = args[2];\r\n\r\n var highLow = false; //True for high, false for low\r\n if (args[3].toLowerCase().includes(\"hi\")) {highLow = true;}\r\n\r\n switch (variable) {\r\n case \"general\":\r\n case \"gen\":\r\n if (GeneralActions[val] != null) {\r\n var action = new ActionIdentifier({\r\n type:ActionTypes[val], name:val\r\n });\r\n if (highLow) {\r\n this.automateActionHigh = action;\r\n } else {\r\n this.automateActionLow = action;\r\n }\r\n this.log(\"Automate (\" + (highLow ? \"HIGH\" : \"LOW\") + \") action set to \" + val);\r\n } else {\r\n this.postToConsole(\"Invalid action name specified: \" + val);\r\n }\r\n break;\r\n case \"contract\":\r\n case \"contracts\":\r\n if (this.contracts[val] != null) {\r\n var action = new ActionIdentifier({\r\n type:ActionTypes.Contract, name:val\r\n });\r\n if (highLow) {\r\n this.automateActionHigh = action;\r\n } else {\r\n this.automateActionLow = action;\r\n }\r\n this.log(\"Automate (\" + (highLow ? \"HIGH\" : \"LOW\") + \") action set to \" + val);\r\n } else {\r\n this.postToConsole(\"Invalid contract name specified: \" + val);\r\n }\r\n break;\r\n case \"ops\":\r\n case \"op\":\r\n case \"operations\":\r\n case \"operation\":\r\n if (this.operations[val] != null) {\r\n var action = new ActionIdentifier({\r\n type:ActionTypes.Operation, name:val\r\n });\r\n if (highLow) {\r\n this.automateActionHigh = action;\r\n } else {\r\n this.automateActionLow = action;\r\n }\r\n this.log(\"Automate (\" + (highLow ? \"HIGH\" : \"LOW\") + \") action set to \" + val);\r\n } else {\r\n this.postToConsole(\"Invalid Operation name specified: \" + val);\r\n }\r\n break;\r\n case \"stamina\":\r\n if (isNaN(val)) {\r\n this.postToConsole(\"Invalid value specified for stamina threshold (must be numeric): \" + val);\r\n } else {\r\n if (highLow) {\r\n this.automateThreshHigh = Number(val);\r\n } else {\r\n this.automateThreshLow = Number(val);\r\n }\r\n this.log(\"Automate (\" + (highLow ? \"HIGH\" : \"LOW\") + \") stamina threshold set to \" + val);\r\n }\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n return;\r\n }\r\n}\r\n\r\nBladeburner.prototype.executeHelpConsoleCommand = function(args) {\r\n if (args.length === 1) {\r\n this.postToConsole(consoleHelpText.helpList);\r\n } else {\r\n for (var i = 1; i < args.length; ++i) {\r\n var commandText = consoleHelpText[args[i]];\r\n if (commandText != null) {\r\n this.postToConsole(commandText);\r\n this.postToConsole(\"' + input + '
\");\r\n }\r\n }\r\n }\r\n}\r\n\r\nBladeburner.prototype.executeLogConsoleCommand = function(args) {\r\n if (args.length < 3) {\r\n this.postToConsole(\"Invalid usage of log command: log [enable/disable] [action/event]\");\r\n this.postToConsole(\"Use 'help log' for more details and examples\");\r\n return;\r\n }\r\n\r\n var flag = true;\r\n if (args[1].toLowerCase().includes(\"d\")) {flag = false;} //d for disable\r\n\r\n switch (args[2].toLowerCase()) {\r\n case \"general\":\r\n case \"gen\":\r\n this.logging.general = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for general actions\");\r\n break;\r\n case \"contract\":\r\n case \"contracts\":\r\n this.logging.contracts = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for Contracts\");\r\n break;\r\n case \"ops\":\r\n case \"op\":\r\n case \"operations\":\r\n case \"operation\":\r\n this.logging.ops = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for Operations\");\r\n break;\r\n case \"blackops\":\r\n case \"blackop\":\r\n case \"black operations\":\r\n case \"black operation\":\r\n this.logging.blackops = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for BlackOps\");\r\n break;\r\n case \"event\":\r\n case \"events\":\r\n this.logging.events = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for events\");\r\n break;\r\n case \"all\":\r\n this.logging.general = flag;\r\n this.logging.contracts = flag;\r\n this.logging.ops = flag;\r\n this.logging.blackops = flag;\r\n this.logging.events = flag;\r\n this.log(\"Logging \" + (flag ? \"enabled\" : \"disabled\") + \" for everything\");\r\n break;\r\n default:\r\n this.postToConsole(\"Invalid action/event type specified: \" + args[2]);\r\n this.postToConsole(\"Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]\");\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.executeSkillConsoleCommand = function(args) {\r\n switch (args.length) {\r\n case 1:\r\n //Display Skill Help Command\r\n this.postToConsole(\"Invalid usage of 'skill' console command: skill [action] [name]\");\r\n this.postToConsole(\"Use 'help skill' for more info\");\r\n break;\r\n case 2:\r\n if (args[1].toLowerCase() === \"list\") {\r\n //List all skills and their level\r\n this.postToConsole(\"Skills: \");\r\n var skillNames = Object.keys(Skills);\r\n for(var i = 0; i < skillNames.length; ++i) {\r\n var skill = Skills[skillNames[i]];\r\n var level = 0;\r\n if (this.skills[skill.name] != null) {level = this.skills[skill.name];}\r\n this.postToConsole(skill.name + \": Level \" + formatNumber(level, 0));\r\n }\r\n this.postToConsole(\" \");\r\n this.postToConsole(\"Effects: \");\r\n var multKeys = Object.keys(this.skillMultipliers);\r\n for (var i = 0; i < multKeys.length; ++i) {\r\n var mult = this.skillMultipliers[multKeys[i]];\r\n if (mult && mult !== 1) {\r\n mult = formatNumber(mult, 3);\r\n switch(multKeys[i]) {\r\n case \"successChanceAll\":\r\n this.postToConsole(\"Total Success Chance: x\" + mult);\r\n break;\r\n case \"successChanceStealth\":\r\n this.postToConsole(\"Stealth Success Chance: x\" + mult);\r\n break;\r\n case \"successChanceKill\":\r\n this.postToConsole(\"Retirement Success Chance: x\" + mult);\r\n break;\r\n case \"successChanceContract\":\r\n this.postToConsole(\"Contract Success Chance: x\" + mult);\r\n break;\r\n case \"successChanceOperation\":\r\n this.postToConsole(\"Operation Success Chance: x\" + mult);\r\n break;\r\n case \"successChanceEstimate\":\r\n this.postToConsole(\"Synthoid Data Estimate: x\" + mult);\r\n break;\r\n case \"actionTime\":\r\n this.postToConsole(\"Action Time: x\" + mult);\r\n break;\r\n case \"effHack\":\r\n this.postToConsole(\"Hacking Skill: x\" + mult);\r\n break;\r\n case \"effStr\":\r\n this.postToConsole(\"Strength: x\" + mult);\r\n break;\r\n case \"effDef\":\r\n this.postToConsole(\"Defense: x\" + mult);\r\n break;\r\n case \"effDex\":\r\n this.postToConsole(\"Dexterity: x\" + mult);\r\n break;\r\n case \"effAgi\":\r\n this.postToConsole(\"Agility: x\" + mult);\r\n break;\r\n case \"effCha\":\r\n this.postToConsole(\"Charisma: x\" + mult);\r\n break;\r\n case \"effInt\":\r\n this.postToConsole(\"Intelligence: x\" + mult);\r\n break;\r\n case \"stamina\":\r\n this.postToConsole(\"Stamina: x\" + mult);\r\n break;\r\n case \"weaponAbility\":\r\n //DomElems.actionsAndSkillsDesc.innerHTML +=\r\n break;\r\n case \"gunAbility\":\r\n //DomElems.actionsAndSkillsDesc.innerHTML\r\n break;\r\n default:\r\n console.log(\"Warning: Unrecognized SkillMult Key: \" + multKeys[i]);\r\n break;\r\n }\r\n }\r\n }\r\n } else {\r\n this.postToConsole(\"Invalid usage of 'skill' console command: skill [action] [name]\");\r\n this.postToConsole(\"Use 'help skill' for more info\");\r\n }\r\n break;\r\n case 3:\r\n var skillName = args[2];\r\n var skill = Skills[skillName];\r\n if (skill == null || !(skill instanceof Skill)) {\r\n return this.postToConsole(\"Invalid skill name (Note that this is case-sensitive): \" + skillName);\r\n }\r\n if (args[1].toLowerCase() === \"list\") {\r\n this.postToConsole(skill.name + \": Level \" + formatNumber(this.skills[skill.name]), 0);\r\n } else if (args[1].toLowerCase() === \"level\") {\r\n var currentLevel = 0;\r\n if (this.skills[skillName] && !isNaN(this.skills[skillName])) {\r\n currentLevel = this.skills[skillName];\r\n }\r\n var pointCost = skill.baseCost + (currentLevel * skill.costInc);\r\n if (this.skillPoints >= pointCost) {\r\n this.skillPoints -= pointCost;\r\n this.upgradeSkill(skill);\r\n this.log(skill.name + \" upgraded to Level \" + this.skills[skillName]);\r\n this.createActionAndSkillsContent();\r\n } else {\r\n this.postToConsole(\"You do not have enough Skill Points to upgrade this. You need \" + formatNumber(pointCost, 0));\r\n }\r\n\r\n } else {\r\n this.postToConsole(\"Invalid usage of 'skill' console command: skill [action] [name]\");\r\n this.postToConsole(\"Use 'help skill' for more info\");\r\n }\r\n break;\r\n default:\r\n this.postToConsole(\"Invalid usage of 'skill' console command: skill [action] [name]\");\r\n this.postToConsole(\"Use 'help skill' for more info\");\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.executeStartConsoleCommand = function(args) {\r\n if (args.length !== 3) {\r\n this.postToConsole(\"Invalid usage of 'start' console command: start [type] [name]\");\r\n this.postToConsole(\"Use 'help start' for more info\");\r\n return;\r\n }\r\n var name = args[2];\r\n switch (args[1].toLowerCase()) {\r\n case \"general\":\r\n case \"gen\":\r\n if (GeneralActions[name] != null) {\r\n this.action.type = ActionTypes[name];\r\n this.action.name = name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n } else {\r\n this.postToConsole(\"Invalid action name specified: \" + args[2]);\r\n }\r\n break;\r\n case \"contract\":\r\n case \"contracts\":\r\n if (this.contracts[name] != null) {\r\n this.action.type = ActionTypes.Contract;\r\n this.action.name = name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n } else {\r\n this.postToConsole(\"Invalid contract name specified: \" + args[2]);\r\n }\r\n break;\r\n case \"ops\":\r\n case \"op\":\r\n case \"operations\":\r\n case \"operation\":\r\n if (this.operations[name] != null) {\r\n this.action.type = ActionTypes.Operation;\r\n this.action.name = name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n } else {\r\n this.postToConsole(\"Invalid Operation name specified: \" + args[2]);\r\n }\r\n break;\r\n case \"blackops\":\r\n case \"blackop\":\r\n case \"black operations\":\r\n case \"black operation\":\r\n if (BlackOperations[name] != null) {\r\n this.action.type = ActionTypes.BlackOperation;\r\n this.action.name = name;\r\n this.startAction(this.action);\r\n this.updateActionAndSkillsContent();\r\n } else {\r\n this.postToConsole(\"Invalid BlackOp name specified: \" + args[2]);\r\n }\r\n break;\r\n default:\r\n this.postToConsole(\"Invalid action/event type specified: \" + args[1]);\r\n this.postToConsole(\"Examples of valid action/event identifiers are: [general, contract, op, blackop]\");\r\n break;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getActionIdFromTypeAndName = function(type=\"\", name=\"\") {\r\n if (type === \"\" || name === \"\") {return null;}\r\n var action = new ActionIdentifier();\r\n var convertedType = type.toLowerCase().trim();\r\n var convertedName = name.toLowerCase().trim();\r\n switch (convertedType) {\r\n case \"contract\":\r\n case \"contracts\":\r\n action.type = ActionTypes[\"Contract\"];\r\n if (this.contracts.hasOwnProperty(name)) {\r\n action.name = name;\r\n return action;\r\n } else {\r\n return null;\r\n }\r\n case \"operation\":\r\n case \"operations\":\r\n case \"op\":\r\n case \"ops\":\r\n action.type = ActionTypes[\"Operation\"];\r\n if (this.operations.hasOwnProperty(name)) {\r\n action.name = name;\r\n return action;\r\n } else {\r\n return null;\r\n }\r\n case \"blackoperation\":\r\n case \"black operation\":\r\n case \"black operations\":\r\n case \"black op\":\r\n case \"black ops\":\r\n case \"blackop\":\r\n case \"blackops\":\r\n action.type = ActionTypes[\"BlackOp\"];\r\n if (BlackOperations.hasOwnProperty(name)) {\r\n action.name = name;\r\n return action;\r\n } else {\r\n return null;\r\n }\r\n case \"general\":\r\n case \"general action\":\r\n case \"gen\":\r\n break;\r\n default:\r\n return null;\r\n }\r\n\r\n if (convertedType.startsWith(\"gen\")) {\r\n switch (convertedName) {\r\n case \"training\":\r\n action.type = ActionTypes[\"Training\"];\r\n break;\r\n case \"recruitment\":\r\n case \"recruit\":\r\n action.type = ActionTypes[\"Recruitment\"];\r\n break;\r\n case \"field analysis\":\r\n case \"fieldanalysis\":\r\n action.type = ActionTypes[\"Field Analysis\"];\r\n break;\r\n default:\r\n return null;\r\n }\r\n return action;\r\n }\r\n}\r\n\r\nBladeburner.prototype.isContractNameNetscriptFn = function(name) {\r\n return this.contracts.hasOwnProperty(name);\r\n}\r\n\r\nBladeburner.prototype.isOperationNameNetscriptFn = function(name) {\r\n return this.operations.hasOwnProperty(name);\r\n}\r\n\r\nBladeburner.prototype.isBlackOpNameNetscriptFn = function(name) {\r\n return BlackOperations.hasOwnProperty(name);\r\n}\r\n\r\nBladeburner.prototype.isGeneralActionNameNetscriptFn = function(name) {\r\n return GeneralActions.hasOwnProperty(name);\r\n}\r\n\r\nBladeburner.prototype.isSkillNameNetscriptFn = function(name) {\r\n return Skills.hasOwnProperty(name);\r\n}\r\n\r\nBladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.startAction() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return false;\r\n }\r\n\r\n try {\r\n this.startAction(actionId);\r\n if (workerScript.shouldLog(\"startAction\")) {\r\n workerScript.scriptRef.log(\"Starting Bladeburner action with type \" + type + \" and name \" + name);\r\n }\r\n return true;\r\n } catch(e) {\r\n this.resetAction();\r\n workerScript.scriptRef.log(\"ERROR: Bladeburner.startAction() failed to start action of type \" + type + \" due to invalid name: \" + name +\r\n \"Note that this name is case-sensitive and whitespace-sensitive\");\r\n return false;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.getActionTime() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n var actionObj = this.getActionObject(actionId);\r\n if (actionObj == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n switch (actionId.type) {\r\n case ActionTypes[\"Contract\"]:\r\n case ActionTypes[\"Operation\"]:\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n return actionObj.getActionTime(this);\r\n case ActionTypes[\"Training\"]:\r\n case ActionTypes[\"Field Analysis\"]:\r\n case ActionTypes[\"FieldAnalysis\"]:\r\n return 30;\r\n case ActionTypes[\"Recruitment\"]:\r\n return this.getRecruitmentTime();\r\n default:\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.getActionEstimatedSuccessChance() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n var actionObj = this.getActionObject(actionId);\r\n if (actionObj == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n switch (actionId.type) {\r\n case ActionTypes[\"Contract\"]:\r\n case ActionTypes[\"Operation\"]:\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n return actionObj.getSuccessChance(this);\r\n case ActionTypes[\"Training\"]:\r\n case ActionTypes[\"Field Analysis\"]:\r\n case ActionTypes[\"FieldAnalysis\"]:\r\n return 1;\r\n case ActionTypes[\"Recruitment\"]:\r\n return this.getRecruitmentSuccessChance();\r\n default:\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.getActionCountRemaining() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n var actionObj = this.getActionObject(actionId);\r\n if (actionObj == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n switch (actionId.type) {\r\n case ActionTypes[\"Contract\"]:\r\n case ActionTypes[\"Operation\"]:\r\n case ActionTypes[\"BlackOp\"]:\r\n case ActionTypes[\"BlackOperation\"]:\r\n return actionObj.count;\r\n case ActionTypes[\"Training\"]:\r\n case ActionTypes[\"Field Analysis\"]:\r\n case ActionTypes[\"FieldAnalysis\"]:\r\n return Infinity;\r\n default:\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n}\r\n\r\nBladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.getSkillLevel() failed due to an invalid skill specified: \" +\r\n skillName + \". Note that the name of the skill is case-sensitive\";\r\n\r\n if (skillName === \"\") {\r\n //If skill name isn't specified, return an object with all of the player's skill levels\r\n let copy = Object.assign({}, this.Skills);\r\n return copy;\r\n }\r\n\r\n if (!Skills.hasOwnProperty(skillName)) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n return Skills[skillName];\r\n}\r\n\r\nBladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.upgradeSkill() failed due to an invalid skill specified: \" +\r\n skillName + \". Note that the name of the skill is case-sensitive\";\r\n if (!Skills.hasOwnProperty(skillName)) {\r\n workerScript.log(errorLogText);\r\n return false;\r\n }\r\n\r\n var skill = Skills[skillName];\r\n var currentLevel = 0;\r\n if (this.skills[skillName] && !isNaN(this.skills[skillName])) {\r\n currentLevel = this.skills[skillName];\r\n }\r\n var cost = skill.baseCost + (currentLevel * skill.costInc);\r\n\r\n if (this.skillPoints < cost) {\r\n if (workerScript.shouldLog(\"upgradeSkill\")) {\r\n workerScript.log(\"Bladeburner.upgradeSkill() failed because you do not have enough \" +\r\n \"skill points to upgrade \" + skillName + \" (You have \" +\r\n this.skillPoints + \", you need \" + cost + \")\");\r\n }\r\n return false;\r\n }\r\n\r\n this.skillPoints -= cost;\r\n this.upgradeSkill(skill);\r\n if (Engine.currentPage === Engine.Page.Bladeburner && DomElems.currentTab.toLowerCase() === \"skills\") {\r\n this.createActionAndSkillsContent();\r\n }\r\n if (workerScript.shouldLog(\"upgradeSkill\")) {\r\n workerScript.log(skillName + \" successfully upgraded to level \" + this.skills[skillName]);\r\n }\r\n return true;\r\n}\r\n\r\nBladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript) {\r\n if (type === \"\" && name === \"\") {\r\n return this.teamSize;\r\n }\r\n\r\n var errorLogText = \"ERROR: Bladeburner.getTeamSize() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n var actionObj = this.getActionObject(actionId);\r\n if (actionObj == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n if (actionId.type === ActionTypes[\"Operation\"] ||\r\n actionId.type === ActionTypes[\"BlackOp\"] ||\r\n actionId.type === ActionTypes[\"BlackOperation\"]) {\r\n return actionObj.teamCount;\r\n } else {\r\n return 0;\r\n }\r\n}\r\n\r\nBladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) {\r\n var errorLogText = \"ERROR: Bladeburner.setTeamSize() failed due to an invalid action specified. \" +\r\n \"Type: \" + type + \", Name: \" + name + \". Note that for contracts and operations, the \" +\r\n \"name of the operation is case-sensitive.\";\r\n var actionId = this.getActionIdFromTypeAndName(type, name);\r\n if (actionId == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n if (actionId.type !== ActionTypes[\"Operation\"] ||\r\n actionId.type !== ActionTypes[\"BlackOp\"] ||\r\n actionId.type !== ActionTypes[\"BlackOperation\"]) {\r\n workerScript.log(\"ERROR: Bladeburner.setTeamSize() failed. This function \" +\r\n \"only works for Operations and BlackOps\");\r\n return -1;\r\n }\r\n\r\n var actionObj = this.getActionObject(actionId);\r\n if (actionObj == null) {\r\n workerScript.log(errorLogText);\r\n return -1;\r\n }\r\n\r\n var sanitizedSize = Math.round(size);\r\n if (isNaN(sanitizedSize)) {\r\n workerScript.log(\"ERROR: Bladeburner.setTeamSize() failed due to an invalid 'size' argument: \" + size);\r\n return -1;\r\n }\r\n if (this.teamSize < sanitizedSize) {sanitizedSize = this.teamSize;}\r\n actionObj.teamCount = sanitizedSize;\r\n if (workerScript.shouldLog(\"setTeamSize\")) {\r\n workerScript.log(\"Team size for \" + name + \" set to \" + sanitizedSize);\r\n }\r\n return sanitizedSize;\r\n}\r\n\r\nBladeburner.prototype.getCityEstimatedPopulationNetscriptFn = function(cityName, workerScript) {\r\n if (!this.cities.hasOwnProperty(cityName)) {\r\n workerScript.log(\"ERROR: Bladeburner.getCityEstimatedPopulation() failed because the specified \" +\r\n \"city was invalid: \" + cityName + \". Note that this city argument is case-sensitive\");\r\n return -1;\r\n }\r\n return this.cities[cityName].popEst;\r\n}\r\n\r\nBladeburner.prototype.getCityEstimatedCommunitiesNetscriptFn = function(cityName, workerScript) {\r\n if (!this.cities.hasOwnProperty(cityName)) {\r\n workerScript.log(\"ERROR: Bladeburner.getCityEstimatedCommunities() failed because the specified \" +\r\n \"city was invalid: \" + cityName + \". Note that this city argument is case-sensitive\");\r\n return -1;\r\n }\r\n return this.cities[cityName].commsEst;\r\n}\r\n\r\nBladeburner.prototype.getCityChaosNetscriptFn = function(cityName, workerScript) {\r\n if (!this.cities.hasOwnProperty(cityName)) {\r\n workerScript.log(\"ERROR: Bladeburner.getCityChaos() failed because the specified \" +\r\n \"city was invalid: \" + cityName + \". Note that this city argument is case-sensitive\");\r\n return -1;\r\n }\r\n return this.cities[cityName].chaos;\r\n}\r\n\r\nBladeburner.prototype.switchCityNetscriptFn = function(cityName, workerScript) {\r\n if (!this.cities.hasOwnProperty(cityName)) {\r\n workerScript.log(\"ERROR: Bladeburner.switchCity() failed because the specified \" +\r\n \"city was invalid: \" + cityName + \". Note that this city argument is case-sensitive\");\r\n return false;\r\n }\r\n this.city = cityName;\r\n return true;\r\n}\r\n\r\nBladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) {\r\n var bladeburnerFac = Factions[bladeburnersFactionName];\r\n if (bladeburnerFac.isMember) {\r\n return true;\r\n } else if (this.rank >= RankNeededForFaction) {\r\n joinFaction(bladeburnerFac);\r\n if (workerScript.shouldLog(\"joinBladeburnerFaction\")) {\r\n workerScript.log(\"Joined Bladeburners Faction\");\r\n }\r\n if (Engine.currentPage === Engine.Page.Bladeburner) {\r\n removeChildrenFromElement(DomElems.overviewDiv);\r\n this.createOverviewContent();\r\n }\r\n return true;\r\n } else {\r\n if (workerScript.shouldLog(\"joinBladeburnerFaction\")) {\r\n workerScript.log(\"Failed to join Bladeburners Faction because \" +\r\n \"you do not have the required \" + RankNeededForFaction + \" rank\");\r\n }\r\n return false;\r\n }\r\n}\r\n\r\nBladeburner.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Bladeburner\", this);\r\n}\r\nBladeburner.fromJSON = function(value) {\r\n return Generic_fromJSON(Bladeburner, value.data);\r\n}\r\nReviver.constructors.Bladeburner = Bladeburner;\r\n\r\n//This initialized Bladeburner-related data that is NOT saved/loaded\r\n// eg: Skill Objects, BLack Operations\r\n//Any data that is saved/loaded should go in Bladeburner object\r\n// eg: contracts, operations\r\nfunction initBladeburner() {\r\n //Skills\r\n Skills[SkillNames.BladesIntuition] = new Skill({\r\n name:SkillNames.BladesIntuition,\r\n desc:\"Each level of this skill increases your success chance \" +\r\n \"for all contracts and operations by 3%\",\r\n baseCost:5, costInc:2,\r\n successChanceAll:3\r\n });\r\n Skills[SkillNames.Reaper] = new Skill({\r\n name:SkillNames.Reaper,\r\n desc:\"Each level of this skill increases your \" +\r\n \"effective combat stats for Bladeburner actions by 3%\",\r\n baseCost:3, costInc:2,\r\n effStr:3, effDef:3, effDex:3, effAgi:3\r\n });\r\n Skills[SkillNames.Cloak] = new Skill({\r\n name:SkillNames.Cloak,\r\n desc:\"Each level of this skill increases your \" +\r\n \"success chance in stealth-related contracts and operations by 5.5%\",\r\n baseCost:3, costInc:1,\r\n successChanceStealth:5.5\r\n });\r\n\r\n //TODO Marksman\r\n //TODO Weapon Proficiency\r\n\r\n Skills[SkillNames.Overclock] = new Skill({\r\n name:SkillNames.Overclock,\r\n desc:\"Each level of this skill decreases the time it takes \" +\r\n \"to attempt a contract or operation by 1% (Max Level: 95)\",\r\n baseCost:5, costInc:1, maxLvl:95,\r\n actionTime:1\r\n });\r\n Skills[SkillNames.EvasiveSystem] = new Skill({\r\n name:SkillNames.EvasiveSystem,\r\n desc:\"Each level of this skill increases your effective \" +\r\n \"dexterity and agility for Bladeburner actions by 5%\",\r\n baseCost:2, costInc: 1,\r\n effDex:5, effAgi:5\r\n });\r\n Skills[SkillNames.ShortCircuit] = new Skill({\r\n name:SkillNames.ShortCircuit,\r\n desc:\"Each level of this skill increases your success chance \" +\r\n \"in contracts and operations that involve retirement by 5.5%\",\r\n baseCost:3, costInc:2,\r\n successChanceKill:5.5\r\n });\r\n Skills[SkillNames.DigitalObserver] = new Skill({\r\n name:SkillNames.DigitalObserver,\r\n desc:\"Each level of this skill increases your success chance in \" +\r\n \"all operations by 4%\",\r\n baseCost:5, costInc:2,\r\n successChanceOperation:4\r\n });\r\n Skills[SkillNames.Datamancer] = new Skill({\r\n name:SkillNames.Datamancer,\r\n desc:\"Each level of this skill increases your effectiveness in \" +\r\n \"synthoid population analysis and investigation by 5%. \" +\r\n \"This affects all actions that can potentially increase \" +\r\n \"the accuracy of your synthoid population/community estimates.\",\r\n baseCost:3,costInc:1,\r\n successChanceEstimate:5\r\n });\r\n Skills[SkillNames.Tracer] = new Skill({\r\n name:SkillNames.Tracer,\r\n desc:\"Each level of this skill increases your success chance in \" +\r\n \"all contracts by 4%\",\r\n baseCost:3, costInc:2,\r\n successChanceContract:4\r\n });\r\n Skills[SkillNames.CybersEdge] = new Skill({\r\n name:SkillNames.CybersEdge,\r\n desc:\"Each level of this skill increases your max \" +\r\n \"stamina by 2%\",\r\n baseCost:1, costInc:3,\r\n stamina:2\r\n });\r\n\r\n //General Actions\r\n var actionName = \"Training\";\r\n GeneralActions[actionName] = new Action({\r\n name:actionName,\r\n desc:\"Improve your abilities at the Bladeburner unit's specialized training \" +\r\n \"center. Doing this gives experience for all combat stats and also \" +\r\n \"increases your max stamina.\"\r\n });\r\n\r\n var actionName = \"Field Analysis\";\r\n GeneralActions[actionName] = new Action({\r\n name:actionName,\r\n desc:\"Mine and analyze Synthoid-related data. This improve the \" +\r\n \"Bladeburner's unit intelligence on Synthoid locations and \" +\r\n \"activities. Completing this action will improve the accuracy \" +\r\n \"of your Synthoid population estimated in the current city.
\" +\r\n \"Does NOT require stamina.\"\r\n });\r\n\r\n var actionName = \"Recruitment\";\r\n GeneralActions[actionName] = new Action({\r\n name:actionName,\r\n desc:\"Attempt to recruit members for your Bladeburner team. These members \" +\r\n \"can help you conduct operations.
\" +\r\n \"Does NOT require stamina.\"\r\n });\r\n\r\n //Black Operations\r\n BlackOperations[\"Operation Typhoon\"] = new BlackOperation({\r\n name:\"Operation Typhoon\",\r\n desc:\"Obadiah Zenyatta is the leader of a RedWater PMC. It has long \" +\r\n \"been known among the intelligence community that Zenyatta, along \" +\r\n \"with the rest of the PMC, is a Synthoid.
\" +\r\n \"The goal of Operation Typhoon is to find and eliminate \" +\r\n \"Zenyatta and RedWater by any means necessary. After the task \" +\r\n \"is completed, the actions must be covered up from the general public.\",\r\n baseDifficulty:2000, reqdRank:2.5e3,\r\n rankGain:50, rankLoss:10, hpLoss:100,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Zero\"] = new BlackOperation({\r\n name:\"Operation Zero\",\r\n desc:\"AeroCorp is one of the world's largest defense contractors. \" +\r\n \"It's leader, Steve Watataki, is thought to be a supporter of \" +\r\n \"Synthoid rights. He must be removed.
\" +\r\n \"The goal of Operation Zero is to covertly infiltrate AeroCorp and \" +\r\n \"uncover any incriminating evidence or \" +\r\n \"information against Watataki that will cause him to be removed \" +\r\n \"from his position at AeroCorp. Incriminating evidence can be \" +\r\n \"fabricated as a last resort. Be warned that AeroCorp has some of \" +\r\n \"the most advanced security measures in the world.\",\r\n baseDifficulty:2500, reqdRank:5e3,\r\n rankGain:60, rankLoss:15, hpLoss:50,\r\n weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isStealth:true\r\n });\r\n BlackOperations[\"Operation X\"] = new BlackOperation({\r\n name:\"Operation X\",\r\n desc:\"We have recently discovered an underground publication \" +\r\n \"group called Samizdat. Even though most of their publications \" +\r\n \"are nonsensical conspiracy theories, the average human is \" +\r\n \"gullible enough to believe them. Many of their works discuss \" +\r\n \"Synthoids and pose a threat to society. The publications are spreading \" +\r\n \"rapidly in China and other Eastern countries.
\" +\r\n \"Samizdat has done a good job of keeping hidden and anonymous. \" +\r\n \"However, we've just received intelligence that their base of \" +\r\n \"operations is in Ishima's underground sewer systems. Your task is to \" +\r\n \"investigate the sewer systems, and eliminate Samizdat. They must \" +\r\n \"never publish anything again.\",\r\n baseDifficulty:3000, reqdRank:7.5e3,\r\n rankGain:75, rankLoss:15, hpLoss:100,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Titan\"] = new BlackOperation({\r\n name:\"Operation Titan\",\r\n desc:\"Several months ago Titan Laboratories' Bioengineering department \" +\r\n \"was infiltrated by Synthoids. As far as we know, Titan Laboratories' \" +\r\n \"management has no knowledge about this. We don't know what the \" +\r\n \"Synthoids are up to, but the research that they could \" +\r\n \"be conducting using Titan Laboraties' vast resources is potentially \" +\r\n \"very dangerous.
\" +\r\n \"Your goal is to enter and destroy the Bioengineering department's \" +\r\n \"facility in Aevum. The task is not just to retire the Synthoids there, but \" +\r\n \"also to destroy any information or research at the facility that \" +\r\n \"is relevant to the Synthoids and their goals.\",\r\n baseDifficulty:4000, reqdRank:10e3,\r\n rankGain:100, rankLoss:20, hpLoss:100,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Ares\"] = new BlackOperation({\r\n name:\"Operation Ares\",\r\n desc:\"One of our undercover agents, Agent Carter, has informed us of a \" +\r\n \"massive weapons deal going down in Dubai between rogue Russian \" +\r\n \"militants and a radical Synthoid community. These weapons are next-gen \" +\r\n \"plasma and energy weapons. It is critical for the safety of humanity \" +\r\n \"that this deal does not happen.
\" +\r\n \"Your task is to intercept the deal. Leave no survivors.\",\r\n baseDifficulty:5000, reqdRank:12.5e3,\r\n rankGain:125, rankLoss:20, hpLoss:200,\r\n weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},\r\n decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Archangel\"] = new BlackOperation({\r\n name:\"Operation Archangel\",\r\n desc:\"Our analysts have discovered that the popular Red Rabbit brothel in \" +\r\n \"Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence \" +\r\n \"suggests that the profit from this brothel is used to fund a large \" +\r\n \"black market arms trafficking operation.
\" +\r\n \"The goal of this operation is to take out the leaders that are running \" +\r\n \"the Red Rabbit brothel. Try to limit the number of other casualties, \" +\r\n \"but do what you must to complete the mission.\",\r\n baseDifficulty:7500, reqdRank:15e3,\r\n rankGain:200, rankLoss:20, hpLoss:25,\r\n weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},\r\n decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true,\r\n });\r\n BlackOperations[\"Operation Juggernaut\"] = new BlackOperation({\r\n name:\"Operation Juggernaut\",\r\n desc:\"The CIA has just encountered a new security threat. A new \" +\r\n \"criminal group, lead by a shadowy operative who calls himself \" +\r\n \"Juggernaut, has been smuggling drugs and weapons (including \" +\r\n \"suspected bioweapons) into Sector-12. We also have reason \" +\r\n \"to believe the tried to break into one of Universal Energy's \" +\r\n \"facilities in order to cause a city-wide blackout. The CIA \" +\r\n \"suspects that Juggernaut is a heavily-augmented Synthoid, and \" +\r\n \"have thus enlisted our help.
\" +\r\n \"Your mission is to eradicate Juggernaut and his followers.\",\r\n baseDifficulty:10e3, reqdRank:20e3,\r\n rankGain:300, rankLoss:40, hpLoss:300,\r\n weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},\r\n decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true,\r\n });\r\n BlackOperations[\"Operation Red Dragon\"] = new BlackOperation({\r\n name:\"Operation Red Dragon\",\r\n desc:\"The Tetrads criminal organization is suspected of \" +\r\n \"reverse-engineering the MK-VI Synthoid design. We believe \" +\r\n \"they altered and possibly improved the design and began \" +\r\n \"manufacturing their own Synthoid models in order to bolster \" +\r\n \"their criminal activities.
\" +\r\n \"Your task is to infiltrate and destroy the Tetrads' base of operations \" +\r\n \"in Los Angeles. Intelligence tells us that their base houses \" +\r\n \"one of their Synthoid manufacturing units.\",\r\n baseDifficulty:12.5e3, reqdRank:25e3,\r\n rankGain:500, rankLoss:50, hpLoss:500,\r\n weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true,\r\n });\r\n BlackOperations[\"Operation K\"] = new BlackOperation({\r\n name:\"Operation K\",\r\n desc:\"CODE RED SITUATION. Our intelligence tells us that VitaLife \" +\r\n \"has discovered a new android cloning technology. This technology \" +\r\n \"is supposedly capable of cloning Synthoid, not only physically \" +\r\n \"but also their advanced AI modules. We do not believe that \" +\r\n \"VitaLife is trying to use this technology illegally or \" +\r\n \"maliciously, but if any Synthoids were able to infiltrate the \" +\r\n \"corporation and take advantage of this technology then the \" +\r\n \"results would be catastrophic.
\" +\r\n \"We do not have the power or jurisdiction to shutdown this down \" +\r\n \"through legal or political means, so we must resort to a covert \" +\r\n \"operation. Your goal is to destroy this technology and eliminate\" +\r\n \"anyone who was involved in its creation.\",\r\n baseDifficulty:15e3, reqdRank:30e3,\r\n rankGain:750, rankLoss:60, hpLoss:1000,\r\n weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Deckard\"] = new BlackOperation({\r\n name:\"Operation Deckard\",\r\n desc:\"Despite your success in eliminating VitaLife's new android-replicating \" +\r\n \"technology in Operation K, we've discovered that a small group of \" +\r\n \"MK-VI Synthoids were able to make off with the schematics and design \" +\r\n \"of the technology before the Operation. It is almost a certainty that \" +\r\n \"these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising.\" +\r\n \"The goal of Operation Deckard is to hunt down these Synthoids and retire \" +\r\n \"them. I don't need to tell you how critical this mission is.\",\r\n baseDifficulty:20e3, reqdRank:40e3,\r\n rankGain:1e3, rankLoss:75, hpLoss:200,\r\n weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},\r\n decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true,\r\n });\r\n BlackOperations[\"Operation Tyrell\"] = new BlackOperation({\r\n name:\"Operation Tyrell\",\r\n desc:\"A week ago Blade Industries reported a small break-in at one \" +\r\n \"of their Aevum Augmentation storage facitilities. We figured out \" +\r\n \"that The Dark Army was behind the heist, and didn't think any more \" +\r\n \"of it. However, we've just discovered that several known MK-VI Synthoids \" +\r\n \"were part of that break-in group.
\" +\r\n \"We cannot have Synthoids upgrading their already-enhanced abilities \" +\r\n \"with Augmentations. Your task is to hunt down the associated Dark Army \" +\r\n \"members and eliminate them.\",\r\n baseDifficulty:25e3, reqdRank:50e3,\r\n rankGain:1.5e3, rankLoss:100, hpLoss:500,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true,\r\n });\r\n BlackOperations[\"Operation Wallace\"] = new BlackOperation({\r\n name:\"Operation Wallace\",\r\n desc:\"Based on information gathered from Operation Tyrell, we've discovered \" +\r\n \"that The Dark Army was well aware that there were Synthoids amongst \" +\r\n \"their ranks. Even worse, we believe that The Dark Army is working \" +\r\n \"together with other criminal organizations such as The Syndicate and \" +\r\n \"that they are planning some sort of large-scale takeover of multiple major \" +\r\n \"cities, most notably Aevum. We suspect that Synthoids have infiltrated \" +\r\n \"the ranks of these criminal factions and are trying to stage another \" +\r\n \"Synthoid uprising.
\" +\r\n \"The best way to deal with this is to prevent it before it even happens. \" +\r\n \"The goal of Operation Wallace is to destroy the Dark Army and \" +\r\n \"Syndicate factions in Aevum immediately. Leave no survivors.\",\r\n baseDifficulty:30e3, reqdRank:75e3,\r\n rankGain:2e3, rankLoss:150, hpLoss:1500,\r\n weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Shoulder of Orion\"] = new BlackOperation({\r\n name:\"Operation Shoulder of Orion\",\r\n desc:\"China's Solaris Space Systems is secretly launching the first \" +\r\n \"manned spacecraft in over a decade using Synthoids. We believe \" +\r\n \"China is trying to establish the first off-world colonies.
\" +\r\n \"The mission is to prevent this launch without instigating an \" +\r\n \"international conflict. When you accept this mission you will be \" +\r\n \"officially disavowed by the NSA and the national government until after you \" +\r\n \"successfully return. In the event of failure, all of the operation's \" +\r\n \"team members must not let themselves be captured alive.\",\r\n baseDifficulty:35e3, reqdRank:100e3,\r\n rankGain:2.5e3, rankLoss:500, hpLoss:1500,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isStealth:true\r\n });\r\n BlackOperations[\"Operation Hyron\"] = new BlackOperation({\r\n name:\"Operation Hyron\",\r\n desc:\"Our intelligence tells us that Fulcrum Technologies is developing \" +\r\n \"a quantum supercomputer using human brains as core \" +\r\n \"processors. This supercomputer \" +\r\n \"is rumored to be able to store vast amounts of data and \" +\r\n \"perform computations unmatched by any other supercomputer on the \" +\r\n \"planet. But more importantly, the use of organic human brains \" +\r\n \"means that the supercomputer may be able to reason abstractly \" +\r\n \"and become self-aware.
\" +\r\n \"I do not need to remind you why sentient-level AIs pose a serious \" +\r\n \"thread to all of mankind.
\" +\r\n \"The research for this project is being conducted at one of Fulcrum \" +\r\n \"Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. \" +\r\n \"Infiltrate the compound, delete and destroy the work, and then find and kill the \" +\r\n \"project lead.\",\r\n baseDifficulty:40e3, reqdRank:125e3,\r\n rankGain:3e3, rankLoss:1e3, hpLoss:500,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Morpheus\"] = new BlackOperation({\r\n name:\"Operation Morpheus\",\r\n desc:\"DreamSense Technologies is an advertising company that uses \" +\r\n \"special technology to transmit their ads into the peoples \" +\r\n \"dreams and subconcious. They do this using broadcast transmitter \" +\r\n \"towers. Based on information from our agents and informants in \" +\r\n \"Chonqging, we have reason to believe that one of the broadcast \" +\r\n \"towers there has been compromised by Synthoids and is being used \" +\r\n \"to spread pro-Synthoid propaganda.
\" +\r\n \"The mission is to destroy this broadcast tower. Speed and \" +\r\n \"stealth are of the upmost important for this.\",\r\n baseDifficulty:45e3, reqdRank:150e3,\r\n rankGain:4e3, rankLoss:1e3, hpLoss:100,\r\n weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isStealth:true\r\n });\r\n BlackOperations[\"Operation Ion Storm\"] = new BlackOperation({\r\n name:\"Operation Ion Storm\",\r\n desc:\"Our analysts have uncovered a gathering of MK-VI Synthoids \" +\r\n \"that have taken up residence in the Sector-12 Slums. We \" +\r\n \"don't know if they are rogue Synthoids from the Uprising, \" +\r\n \"but we do know that they have been stockpiling \" +\r\n \"weapons, money, and other resources. This makes them dangerous.
\" +\r\n \"This is a full-scale assault operation to find and retire all of these \" +\r\n \"Synthoids in the Sector-12 Slums.\",\r\n baseDifficulty:50e3, reqdRank:175e3,\r\n rankGain:5e3, rankLoss:1e3, hpLoss:5000,\r\n weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Annihilus\"] = new BlackOperation({\r\n name:\"Operation Annihilus\",\r\n desc:\"Our superiors have ordered us to eradicate everything and everyone \" +\r\n \"in an underground facility located in Aevum. They tell us \" +\r\n \"that the facility houses many dangerous Synthoids and \" +\r\n \"belongs to a terrorist organization called \" +\r\n \"'The Covenant'. We have no prior intelligence about this \" +\r\n \"organization, so you are going in blind.\",\r\n baseDifficulty:55e3, reqdRank:200e3,\r\n rankGain:7.5e3, rankLoss:1e3, hpLoss:10e3,\r\n weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Ultron\"] = new BlackOperation({\r\n name:\"Operation Ultron\",\r\n desc:\"OmniTek Incorporated, the original designer and manufacturer of Synthoids, \" +\r\n \"has notified us of a malfunction in their AI design. This malfunction, \" +\r\n \"when triggered, causes MK-VI Synthoids to become radicalized and seek out \" +\r\n \"the destruction of humanity. They say that this bug affects all MK-VI Synthoids, \" +\r\n \"not just the rogue ones from the Uprising.
\" +\r\n \"OmniTek has also told us they they believe someone has triggered this \" +\r\n \"malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids \" +\r\n \"are now amassing in Volhaven to form a terrorist group called Ultron.
\" +\r\n \"Intelligence suggests Ultron is heavily armed and that their members are \" +\r\n \"augmented. We believe Ultron is making moves to take control of \" +\r\n \"and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
\" +\r\n \"Your task is to find and destroy Ultron.\",\r\n baseDifficulty:60e3, reqdRank:250e3,\r\n rankGain:10e3, rankLoss:2e3, hpLoss:10e3,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n isKill:true\r\n });\r\n BlackOperations[\"Operation Centurion\"] = new BlackOperation({\r\n name:\"Operation Centurion\",\r\n desc:\"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
\" +\r\n \"Throughout all of humanity's history, we have relied on \" +\r\n \"technology to survive, conquer, and progress. Its advancement became our primary goal. \" +\r\n \"And at the peak of human civilization technology turned into \" +\r\n \"power. Global, absolute power.
\" +\r\n \"It seems that the universe is not without a sense of irony.
\" +\r\n \"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)\",\r\n baseDifficulty:70e3, reqdRank:300e3,\r\n rankGain:15e3, rankLoss:5e3, hpLoss:10e3,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n });\r\n BlackOperations[\"Operation Vindictus\"] = new BlackOperation({\r\n name:\"Operation Vindictus\",\r\n desc:\"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
\" +\r\n \"The bits are all around us. The daemons that hold the Node \" +\r\n \"together can manifest themselves in many different ways.
\" +\r\n \"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)\",\r\n baseDifficulty:75e3, reqdRank:350e3,\r\n rankGain:20e3, rankLoss:20e3, hpLoss:20e3,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n });\r\n BlackOperations[\"Operation Daedalus\"] = new BlackOperation({\r\n name:\"Operation Daedalus\",\r\n desc:\"Yesterday we obeyed kings and bent our neck to emperors. \" +\r\n \"Today we kneel only to truth.\",\r\n baseDifficulty:80e3, reqdRank:400e3,\r\n rankGain:40e3, rankLoss:10e3, hpLoss:100e3,\r\n weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},\r\n decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},\r\n });\r\n}\r\n\r\nexport {Bladeburner};\r\n","import {CONSTANTS} from \"./Constants.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\n\r\n\r\nfunction Crime(name, type, time, money, difficulty, karma, params) {\r\n this.name = name;\r\n this.type = type;\r\n this.time = time;\r\n this.money = money;\r\n this.difficulty = difficulty;\r\n this.karma = karma;\r\n\r\n this.hacking_success_weight = params.hacking_success_weight ? params.hacking_success_weight : 0;\r\n this.strength_success_weight = params.strength_success_weight ? params.strength_success_weight : 0;\r\n this.defense_success_weight = params.defense_success_weight ? params.defense_success_weight : 0;\r\n this.dexterity_success_weight = params.dexterity_success_weight ? params.dexterity_success_weight : 0;\r\n this.agility_success_weight = params.agility_success_weight ? params.agility_success_weight : 0;\r\n this.charisma_success_weight = params.charisma_success_weight ? params.charisma_success_weight : 0;\r\n\r\n this.hacking_exp = params.hacking_exp ? params.hacking_exp : 0;\r\n this.strength_exp = params.strength_exp ? params.strength_exp : 0;\r\n this.defense_exp = params.defense_exp ? params.defense_exp : 0;\r\n this.dexterity_exp = params.dexterity_exp ? params.dexterity_exp : 0;\r\n this.agility_exp = params.agility_exp ? params.agility_exp : 0;\r\n this.charisma_exp = params.charisma_exp ? params.charisma_exp : 0;\r\n this.intelligence_exp = params.intelligence_exp ? params.intelligence_exp : 0;\r\n\r\n this.kills = params.kills ? params.kills : 0;\r\n}\r\n\r\nCrime.prototype.commit = function(div=1, singParams=null) {\r\n if (div <= 0) {div = 1;}\r\n Player.crimeType = this.type;\r\n Player.startCrime(\r\n this.hacking_exp/div,\r\n this.strength_exp/div,\r\n this.defense_exp/div,\r\n this.dexterity_exp/div,\r\n this.agility_exp/div,\r\n this.charisma_exp/div,\r\n this.money/div, this.time, singParams);\r\n return this.time;\r\n}\r\n\r\nCrime.prototype.successRate = function() {\r\n var chance = (this.hacking_success_weight * Player.hacking_skill +\r\n this.strength_success_weight * Player.strength +\r\n this.defense_success_weight * Player.defense +\r\n this.dexterity_success_weight * Player.dexterity +\r\n this.agility_success_weight * Player.agility +\r\n this.charisma_success_weight * Player.charisma +\r\n CONSTANTS.IntelligenceCrimeWeight * Player.intelligence);\r\n chance /= CONSTANTS.MaxSkillLevel;\r\n chance /= this.difficulty;\r\n chance *= Player.crime_success_mult;\r\n return Math.min(chance, 1);\r\n}\r\n\r\nconst Crimes = {\r\n Shoplift: new Crime(\"Shoplift\", CONSTANTS.CrimeShoplift, 2e3, 15e3, 1/20, 0.1, {\r\n dexterity_success_weight: 1,\r\n agility_success_weight: 1,\r\n\r\n dexterity_exp: 2,\r\n agility_exp: 2,\r\n }),\r\n\r\n RobStore: new Crime(\"Rob Store\", CONSTANTS.CrimeRobStore, 60e3, 400e3, 1/5, 0.5, {\r\n hacking_exp: 30,\r\n dexterity_exp: 45,\r\n agility_exp: 45,\r\n\r\n hacking_success_weight: 0.5 ,\r\n dexterity_success_weight: 2,\r\n agility_success_weight: 1,\r\n\r\n intelligence_exp: 0.25 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n\r\n Mug: new Crime(\"Mug\", CONSTANTS.CrimeMug, 4e3, 36e3, 1/5, 0.25, {\r\n strength_exp: 3,\r\n defense_exp: 3,\r\n dexterity_exp: 3,\r\n agility_exp: 3,\r\n\r\n strength_success_weight: 1.5,\r\n defense_success_weight: 0.5,\r\n dexterity_success_weight: 1.5,\r\n agility_success_weight: 0.5,\r\n }),\r\n\r\n Larceny: new Crime(\"Larceny\", CONSTANTS.CrimeLarceny, 90e3, 800e3, 1/3, 1.5, {\r\n hacking_exp: 45,\r\n dexterity_exp: 60,\r\n agility_exp: 60,\r\n\r\n hacking_skill_success_weight: 0.5,\r\n dexterity_success_weight: 1,\r\n agility_success_weight: 1,\r\n\r\n intelligence_exp: 0.5 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n\r\n DealDrugs: new Crime(\"Deal Drugs\", CONSTANTS.CrimeDrugs, 10e3, 120e3, 1, 0.5, {\r\n dexterity_exp: 5,\r\n agility_exp: 5,\r\n charisma_exp: 10,\r\n\r\n charisma_success_weight: 3,\r\n dexterity_success_weight: 2,\r\n agility_success_weight: 1,\r\n }),\r\n\r\n BondForgery: new Crime(\"Bond Forgery\", CONSTANTS.CrimeBondForgery, 300e3, 4.5e6, 1/2, 0.1, {\r\n hacking_exp: 100,\r\n dexterity_exp: 150,\r\n charisma_exp: 15,\r\n\r\n hacking_skill_success_weight: 0.05,\r\n dexterity_success_weight: 1.25,\r\n\r\n intelligence_exp: 2 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n\r\n TraffickArms: new Crime(\"Traffick Arms\", CONSTANTS.CrimeTraffickArms, 40e3, 600e3, 2, 1, {\r\n strength_exp: 20,\r\n defense_exp: 20,\r\n dexterity_exp: 20,\r\n agility_exp: 20,\r\n charisma_exp: 40,\r\n\r\n charisma_success_weight: 1,\r\n strength_success_weight: 1,\r\n defense_success_weight: 1,\r\n dexterity_success_weight: 1,\r\n agility_success_weight: 1,\r\n }),\r\n\r\n Homicide: new Crime(\"Homicide\", CONSTANTS.CrimeHomicide, 3e3, 45e3, 1, 3, {\r\n strength_exp: 2,\r\n defense_exp: 2,\r\n dexterity_exp: 2,\r\n agility_exp: 2,\r\n\r\n strength_success_weight: 2,\r\n defense_success_weight: 2,\r\n dexterity_success_weight: 0.5,\r\n agility_success_weight: 0.5,\r\n\r\n kills: 1,\r\n }),\r\n\r\n GrandTheftAuto: new Crime(\"Grand Theft Auto\", CONSTANTS.CrimeGrandTheftAuto, 80e3, 1.6e6, 8, 5, {\r\n strength_exp: 20,\r\n defense_exp: 20,\r\n dexterity_exp: 20,\r\n agility_exp: 80,\r\n charisma_exp: 40,\r\n\r\n hacking_skill_success_weight: 1,\r\n strength_success_weight: 1,\r\n dexterity_success_weight: 4,\r\n agility_success_weight: 2,\r\n charisma_success_weight: 2,\r\n\r\n intelligence_exp: CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n\r\n Kidnap: new Crime(\"Kidnap\", CONSTANTS.CrimeKidnap, 120e3, 3.6e6, 5, 6, {\r\n strength_exp: 80,\r\n defense_exp: 80,\r\n dexterity_exp: 80,\r\n agility_exp: 80,\r\n charisma_exp: 80,\r\n\r\n charisma_success_weight: 1,\r\n strength_success_weight: 1,\r\n dexterity_success_weight: 1,\r\n agility_success_weight: 1,\r\n\r\n intelligence_exp: 2 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n\r\n Assassination: new Crime(\"Assassination\", CONSTANTS.CrimeAssassination, 300e3, 12e6, 8, 10, {\r\n strength_exp: 300,\r\n defense_exp: 300,\r\n dexterity_exp: 300,\r\n agility_exp: 300,\r\n\r\n strength_success_weight: 1,\r\n dexterity_success_weight: 2,\r\n agility_success_weight: 1,\r\n\r\n intelligence_exp: 5 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n\r\n kills: 1,\r\n }),\r\n\r\n Heist: new Crime(\"Heist\", CONSTANTS.CrimeHeist, 600e3, 120e6, 18, 15, {\r\n hacking_exp: 450,\r\n strength_exp: 450,\r\n defense_exp: 450,\r\n dexterity_exp: 450,\r\n agility_exp: 450,\r\n charisma_exp: 450,\r\n\r\n hacking_skill_success_weight: 1,\r\n strength_success_weight: 1,\r\n defense_success_weight: 1,\r\n dexterity_success_weight: 1,\r\n agility_success_weight: 1,\r\n charisma_success_weight: 1,\r\n\r\n intelligence_exp: 10 * CONSTANTS.IntelligenceCrimeBaseExpGain,\r\n }),\r\n};\r\n\r\nfunction determineCrimeSuccess(type, moneyGained) {\r\n var chance = 0;\r\n var found = false;\r\n for(const i in Crimes) {\r\n const crime = Crimes[i];\r\n if(crime.type == type) {\r\n chance = crime.successRate();\r\n found = true;\r\n break;\r\n }\r\n }\r\n if(!found) {\r\n console.log(crime);\r\n dialogBoxCreate(\"ERR: Unrecognized crime type. This is probably a bug please contact the developer\");\r\n return;\r\n }\r\n\r\n if (Math.random() <= chance) {\r\n //Success\r\n Player.gainMoney(moneyGained);\r\n return true;\r\n } else {\r\n //Failure\r\n return false;\r\n }\r\n}\r\n\r\nfunction findCrime(roughName) {\r\n if (roughName.includes(\"shoplift\")) {\r\n return Crimes.Shoplift;\r\n } else if (roughName.includes(\"rob\") && roughName.includes(\"store\")) {\r\n return Crimes.RobStore;\r\n } else if (roughName.includes(\"mug\")) {\r\n return Crimes.Mug;\r\n } else if (roughName.includes(\"larceny\")) {\r\n return Crimes.Larceny;\r\n } else if (roughName.includes(\"drugs\")) {\r\n return Crimes.DealDrugs;\r\n } else if (roughName.includes(\"bond\") && roughName.includes(\"forge\")) {\r\n return Crimes.BondForgery;\r\n } else if (roughName.includes(\"traffick\") && roughName.includes(\"arms\")) {\r\n return Crimes.TraffickArms;\r\n } else if (roughName.includes(\"homicide\")) {\r\n return Crimes.Homicide;\r\n } else if (roughName.includes(\"grand\") && roughName.includes(\"auto\")) {\r\n return Crimes.GrandTheftAuto;\r\n } else if (roughName.includes(\"kidnap\")) {\r\n return Crimes.Kidnap;\r\n } else if (roughName.includes(\"assassinate\")) {\r\n return Crimes.Assassination;\r\n } else if (roughName.includes(\"heist\")) {\r\n return Crimes.Heist;\r\n }\r\n return null;\r\n}\r\n\r\nexport {determineCrimeSuccess,findCrime,Crimes};\r\n","import {Augmentations, Augmentation,\r\n AugmentationNames} from \"./Augmentations.js\";\r\nimport {Programs} from \"./CreateProgram.js\";\r\nimport {inMission} from \"./Missions.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {redPillFlag} from \"./RedPill.js\";\r\nimport {GetServerByHostname} from \"./Server.js\";\r\nimport {Settings} from \"./Settings.js\";\r\nimport {dialogBoxCreate, dialogBoxOpened} from \"../utils/DialogBox.js\";\r\nimport {Reviver, Generic_toJSON,\r\n Generic_fromJSON} from \"../utils/JSONReviver.js\";\r\n\r\n/* Message.js */\r\nfunction Message(filename=\"\", msg=\"\") {\r\n this.filename = filename;\r\n this.msg = msg;\r\n this.recvd = false;\r\n}\r\n\r\nMessage.prototype.toJSON = function() {\r\n return Generic_toJSON(\"Message\", this);\r\n}\r\n\r\n\r\nMessage.fromJSON = function(value) {\r\n return Generic_fromJSON(Message, value.data);\r\n}\r\n\r\nReviver.constructors.Message = Message;\r\n\r\n//Sends message to player, including a pop up\r\nfunction sendMessage(msg, forced=false) {\r\n console.log(\"sending message: \" + msg.filename);\r\n msg.recvd = true;\r\n if (forced || !Settings.SuppressMessages) {\r\n showMessage(msg);\r\n }\r\n addMessageToServer(msg, \"home\");\r\n}\r\n\r\nfunction showMessage(msg) {\r\n var txt = \"Message received from unknown sender:
\" +\r\n \"\" + msg.msg + \"
\" +\r\n \"This message was saved as \" + msg.filename + \" onto your home computer.\";\r\n dialogBoxCreate(txt);\r\n}\r\n\r\n//Adds a message to a server\r\nfunction addMessageToServer(msg, serverHostname) {\r\n var server = GetServerByHostname(serverHostname);\r\n if (server == null) {\r\n console.log(\"WARNING: Did not locate \" + serverHostname);\r\n return;\r\n }\r\n for (var i = 0; i < server.messages.length; ++i) {\r\n if (server.messages[i].filename === msg.filename) {\r\n return; //Already exists\r\n }\r\n }\r\n server.messages.push(msg);\r\n}\r\n\r\n//Checks if any of the 'timed' messages should be sent\r\nfunction checkForMessagesToSend() {\r\n var jumper0 = Messages[MessageFilenames.Jumper0];\r\n var jumper1 = Messages[MessageFilenames.Jumper1];\r\n var jumper2 = Messages[MessageFilenames.Jumper2];\r\n var jumper3 = Messages[MessageFilenames.Jumper3];\r\n var jumper4 = Messages[MessageFilenames.Jumper4];\r\n var cybersecTest = Messages[MessageFilenames.CyberSecTest];\r\n var nitesecTest = Messages[MessageFilenames.NiteSecTest];\r\n var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];\r\n var redpill = Messages[MessageFilenames.RedPill];\r\n\r\n var redpillOwned = false;\r\n if (Augmentations[AugmentationNames.TheRedPill].owned) {\r\n redpillOwned = true;\r\n }\r\n\r\n if (redpill && redpillOwned && Player.sourceFiles.length === 0 && !redPillFlag && !inMission) {\r\n if (!dialogBoxOpened) {\r\n sendMessage(redpill, true);\r\n }\r\n } else if (redpill && redpillOwned) {\r\n //If player has already destroyed a BitNode, message is not forced\r\n if (!redPillFlag && !inMission && !dialogBoxOpened) {\r\n sendMessage(redpill);\r\n }\r\n } else if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) {\r\n sendMessage(jumper0);\r\n Player.getHomeComputer().programs.push(Programs.Flight);\r\n } else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) {\r\n sendMessage(jumper1);\r\n } else if (cybersecTest && !cybersecTest.recvd && Player.hacking_skill >= 50) {\r\n sendMessage(cybersecTest);\r\n } else if (jumper2 && !jumper2.recvd && Player.hacking_skill >= 175) {\r\n sendMessage(jumper2);\r\n } else if (nitesecTest && !nitesecTest.recvd && Player.hacking_skill >= 200) {\r\n sendMessage(nitesecTest);\r\n } else if (jumper3 && !jumper3.recvd && Player.hacking_skill >= 350) {\r\n sendMessage(jumper3);\r\n } else if (jumper4 && !jumper4.recvd && Player.hacking_skill >= 490) {\r\n sendMessage(jumper4);\r\n } else if (bitrunnersTest && !bitrunnersTest.recvd && Player.hacking_skill >= 500) {\r\n sendMessage(bitrunnersTest);\r\n }\r\n}\r\n\r\nfunction AddToAllMessages(msg) {\r\n Messages[msg.filename] = msg;\r\n}\r\n\r\nlet Messages = {}\r\n\r\nfunction loadMessages(saveString) {\r\n Messages = JSON.parse(saveString, Reviver);\r\n}\r\n\r\nlet MessageFilenames = {\r\n Jumper0: \"j0.msg\",\r\n Jumper1: \"j1.msg\",\r\n Jumper2: \"j2.msg\",\r\n Jumper3: \"j3.msg\",\r\n Jumper4: \"j4.msg\",\r\n CyberSecTest: \"csec-test.msg\",\r\n NiteSecTest: \"nitesec-test.msg\",\r\n BitRunnersTest: \"19dfj3l1nd.msg\",\r\n RedPill: \"icarus.msg\",\r\n}\r\n\r\nfunction initMessages() {\r\n //Reset\r\n Messages = {};\r\n\r\n //jump3R Messages\r\n AddToAllMessages(new Message(MessageFilenames.Jumper0,\r\n \"I know you can sense it. I know you're searching for it. \" +\r\n \"It's why you spend night after \" +\r\n \"night at your computer.
It's real, I've seen it. And I can \" +\r\n \"help you find it. But not right now. You're not ready yet.
\" +\r\n \"Use this program to track your progress
\" +\r\n \"The fl1ght.exe program was added to your home computer
\" +\r\n \"-jump3R\"));\r\n AddToAllMessages(new Message(MessageFilenames.Jumper1,\r\n \"Soon you will be contacted by a hacking group known as CyberSec. \" +\r\n \"They can help you with your search.
\" +\r\n \"You should join them, garner their favor, and \" +\r\n \"exploit them for their Augmentations. But do not trust them. \" +\r\n \"They are not what they seem. No one is.
\" +\r\n \"-jump3R\"));\r\n AddToAllMessages(new Message(MessageFilenames.Jumper2,\r\n \"Do not try to save the world. There is no world to save. If \" +\r\n \"you want to find the truth, worry only about yourself. Ethics and \" +\r\n \"morals will get you killed.
Watch out for a hacking group known as NiteSec.\" +\r\n \"
-jump3R\"));\r\n AddToAllMessages(new Message(MessageFilenames.Jumper3,\r\n \"You must learn to walk before you can run. And you must \" +\r\n \"run before you can fly. Look for the black hand.
\" +\r\n \"I.I.I.I
-jump3R\"));\r\n AddToAllMessages(new Message(MessageFilenames.Jumper4,\r\n \"To find what you are searching for, you must understand the bits. \" +\r\n \"The bits are all around us. The runners will help you.
\" +\r\n \"-jump3R\"));\r\n\r\n //Messages from hacking factions\r\n AddToAllMessages(new Message(MessageFilenames.CyberSecTest,\r\n \"We've been watching you. Your skills are very impressive. But you're wasting \" +\r\n \"your talents. If you join us, you can put your skills to good use and change \" +\r\n \"the world for the better. If you join us, we can unlock your full potential.
\" +\r\n \"But first, you must pass our test. Find and hack our server using the Terminal.
\" +\r\n \"-CyberSec\"));\r\n AddToAllMessages(new Message(MessageFilenames.NiteSecTest,\r\n \"People say that the corrupted governments and corporations rule the world. \" +\r\n \"Yes, maybe they do. But do you know who everyone really fears? People \" +\r\n \"like us. Because they can't hide from us. Because they can't fight shadows \" +\r\n \"and ideas with bullets.
\" +\r\n \"Join us, and people will fear you, too.
\" +\r\n \"Find and hack our hidden server using the Terminal. Then, we will contact you again.\" +\r\n \"
-NiteSec\"));\r\n AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,\r\n \"We know what you are doing. We know what drives you. We know \" +\r\n \"what you are looking for.
\" +\r\n \"We can help you find the answers.
\" +\r\n \"run4theh111z\"));\r\n\r\n AddToAllMessages(new Message(MessageFilenames.RedPill,\r\n \"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%
\" +\r\n \")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)
\" +\r\n \"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB
\" +\r\n \"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)\"));\r\n}\r\n\r\nexport {Messages, checkForMessagesToSend, sendMessage, showMessage, loadMessages,\r\n initMessages, Message};\r\n","import {post} from \"./Terminal.js\";\r\n\r\nlet Aliases = {};\r\nlet GlobalAliases = {};\r\n\r\nfunction loadAliases(saveString) {\r\n if (saveString === \"\") {\r\n Aliases = {};\r\n } else {\r\n Aliases = JSON.parse(saveString);\r\n }\r\n}\r\n\r\nfunction loadGlobalAliases(saveString) {\r\n if (saveString === \"\") {\r\n GlobalAliases = {};\r\n } else {\r\n GlobalAliases = JSON.parse(saveString);\r\n }\r\n}\r\n\r\n//Print all aliases to terminal\r\nfunction printAliases() {\r\n for (var name in Aliases) {\r\n if (Aliases.hasOwnProperty(name)) {\r\n post(\"alias \" + name + \"=\" + Aliases[name]);\r\n }\r\n }\r\n for (var name in GlobalAliases) {\r\n if (GlobalAliases.hasOwnProperty(name)) {\r\n post(\"global alias \" + name + \"=\" + GlobalAliases[name]);\r\n }\r\n }\r\n}\r\n\r\n//True if successful, false otherwise\r\nfunction parseAliasDeclaration(dec,global=false) {\r\n var re = /^([_|\\w|!|%|,|@]+)=\"(.+)\"$/;\r\n var matches = dec.match(re);\r\n if (matches == null || matches.length != 3) {return false;}\r\n if (global){\r\n addGlobalAlias(matches[1],matches[2]);\r\n } else {\r\n addAlias(matches[1], matches[2]);\r\n }\r\n return true;\r\n}\r\n\r\nfunction addAlias(name, value) {\r\n if (name in GlobalAliases){\r\n delete GlobalAliases[name];\r\n }\r\n Aliases[name] = value;\r\n}\r\n\r\nfunction addGlobalAlias(name, value) {\r\n if (name in Aliases){\r\n delete Aliases[name];\r\n }\r\n GlobalAliases[name] = value;\r\n}\r\n\r\nfunction getAlias(name) {\r\n if (Aliases.hasOwnProperty(name)) {\r\n return Aliases[name];\r\n }\r\n return null;\r\n}\r\n\r\nfunction getGlobalAlias(name) {\r\n if (GlobalAliases.hasOwnProperty(name)) {\r\n return GlobalAliases[name];\r\n }\r\n return null;\r\n}\r\n\r\nfunction removeAlias(name) {\r\n if (Aliases.hasOwnProperty(name)) {\r\n delete Aliases[name];\r\n return true;\r\n }\r\n if (GlobalAliases.hasOwnProperty(name)) {\r\n delete GlobalAliases[name];\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n//Returns the original string with any aliases substituted in\r\n//Aliases only applied to \"whole words\", one level deep\r\nfunction substituteAliases(origCommand) {\r\n var commandArray = origCommand.split(\" \");\r\n if (commandArray.length>0){\r\n var alias = getAlias(commandArray[0]);\r\n if (alias != null) {\r\n commandArray[0] = alias;\r\n } else {\r\n var alias = getGlobalAlias(commandArray[0]);\r\n if (alias != null) {\r\n commandArray[0] = alias;\r\n }\r\n }\r\n for (var i = 0; i < commandArray.length; ++i) {\r\n var alias = getGlobalAlias(commandArray[i]);\r\n if (alias != null) {\r\n commandArray[i] = alias;\r\n }\r\n }\r\n }\r\n return commandArray.join(\" \");\r\n}\r\n\r\nexport {Aliases, GlobalAliases, printAliases, parseAliasDeclaration,\r\n removeAlias, substituteAliases, loadAliases, loadGlobalAliases};\r\n","var sprintf = require('sprintf-js').sprintf,\r\n vsprintf = require('sprintf-js').vsprintf\r\n\r\nimport {updateActiveScriptsItems} from \"./ActiveScriptsUI.js\";\r\nimport {Augmentations, Augmentation,\r\n augmentationExists, installAugmentations,\r\n AugmentationNames} from \"./Augmentations.js\";\r\nimport {BitNodeMultipliers} from \"./BitNode.js\";\r\nimport {determineCrimeSuccess, findCrime} from \"./Crimes.js\";\r\nimport {Bladeburner} from \"./Bladeburner.js\";\r\nimport {Companies, Company, CompanyPosition,\r\n CompanyPositions, companyExists} from \"./Company.js\";\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Programs} from \"./CreateProgram.js\";\r\nimport {parseDarkwebItemPrice, DarkWebItems} from \"./DarkWeb.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Factions, Faction, joinFaction,\r\n factionExists, purchaseAugmentation} from \"./Faction.js\";\r\nimport {getCostOfNextHacknetNode, purchaseHacknet} from \"./HacknetNode.js\";\r\nimport {Locations} from \"./Location.js\";\r\nimport {Message, Messages} from \"./Message.js\";\r\nimport {inMission} from \"./Missions.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {Script, findRunningScript, RunningScript,\r\n isScriptFilename} from \"./Script.js\";\r\nimport {Server, getServer, AddToAllServers,\r\n AllServers, processSingleServerGrowth,\r\n GetServerByHostname} from \"./Server.js\";\r\nimport {Settings} from \"./Settings.js\";\r\nimport {SpecialServerIps} from \"./SpecialServerIps.js\";\r\nimport {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols,\r\n initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock,\r\n sellStock, updateStockPrices, displayStockMarketContent,\r\n updateStockTicker, updateStockPlayerPosition,\r\n Stock, shortStock, sellShort, OrderTypes,\r\n PositionTypes, placeOrder, cancelOrder} from \"./StockMarket.js\";\r\nimport {post} from \"./Terminal.js\";\r\nimport {TextFile, getTextFile, createTextFile} from \"./TextFile.js\";\r\n\r\nimport {WorkerScript, workerScripts,\r\n killWorkerScript, NetscriptPorts} from \"./NetscriptWorker.js\";\r\nimport {makeRuntimeRejectMsg, netscriptDelay, runScriptFromScript,\r\n scriptCalculateHackingChance, scriptCalculateHackingTime,\r\n scriptCalculateExpGain, scriptCalculatePercentMoneyHacked,\r\n scriptCalculateGrowTime, scriptCalculateWeakenTime} from \"./NetscriptEvaluator.js\";\r\nimport {Environment} from \"./NetscriptEnvironment.js\";\r\nimport {NetscriptPort} from \"./NetscriptPort.js\";\r\n\r\nimport Decimal from \"decimal.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {printArray, powerOfTwo} from \"../utils/HelperFunctions.js\";\r\nimport {createRandomIp} from \"../utils/IPAddress.js\";\r\nimport {formatNumber, isString, isHTML} from \"../utils/StringHelperFunctions.js\";\r\nimport {yesNoBoxClose, yesNoBoxGetYesButton,\r\n yesNoBoxGetNoButton, yesNoBoxCreate,\r\n yesNoBoxOpen} from \"../utils/YesNoBox.js\";\r\n\r\nvar hasCorporationSF = false, //Source-File 3\r\n hasSingularitySF = false, //Source-File 4\r\n hasAISF = false, //Source-File 5\r\n hasBladeburnerSF = false, //Source-File 6\r\n hasBladeburner2079SF = false, //Source-File 7\r\n hasWallStreetSF = false, //Source-File 8\r\n hasBn11SF = false; //Source-File 11\r\n\r\nvar singularitySFLvl=1, wallStreetSFLvl=1;\r\n\r\nvar possibleLogs = {\r\n ALL: true,\r\n scan: true,\r\n hack: true,\r\n sleep: true,\r\n disableLog: true,\r\n enableLog: true,\r\n grow: true,\r\n weaken: true,\r\n nuke: true,\r\n brutessh: true,\r\n ftpcrack: true,\r\n relaysmtp: true,\r\n httpworm: true,\r\n sqlinject: true,\r\n spawn: true,\r\n kill: true,\r\n killall: true,\r\n scp: true,\r\n getHackingLevel: true,\r\n getServerMoneyAvailable: true,\r\n getServerSecurityLevel: true,\r\n getServerBaseSecurityLevel: true,\r\n getServerMinSecurityLevel: true,\r\n getServerRequiredHackingLevel: true,\r\n getServerMaxMoney: true,\r\n getServerGrowth: true,\r\n getServerNumPortsRequired: true,\r\n getServerRam: true,\r\n buyStock: true,\r\n sellStock: true,\r\n purchaseServer: true,\r\n deleteServer: true,\r\n universityCourse: true,\r\n gymWorkout: true,\r\n travelToCity: true,\r\n purchaseTor: true,\r\n purchaseProgram: true,\r\n stopAction: true,\r\n upgradeHomeRam: true,\r\n workForCompany: true,\r\n applyToCompany: true,\r\n joinFaction: true,\r\n workForFaction: true,\r\n createProgram: true,\r\n commitCrime: true,\r\n shortStock: true,\r\n sellShort: true,\r\n startAction: true,\r\n upgradeSkill: true,\r\n setTeamSize: true,\r\n joinBladeburnerFaction: true,\r\n}\r\n\r\n//Used to check and set flags for every Source File, despite the name of the function\r\nfunction initSingularitySFFlags() {\r\n for (var i = 0; i < Player.sourceFiles.length; ++i) {\r\n if (Player.sourceFiles[i].n === 3) {hasCorporationSF = true;}\r\n if (Player.sourceFiles[i].n === 4) {\r\n hasSingularitySF = true;\r\n singularitySFLvl = Player.sourceFiles[i].lvl;\r\n }\r\n if (Player.sourceFiles[i].n === 5) {hasAISF = true;}\r\n if (Player.sourceFiles[i].n === 6) {hasBladeburnerSF = true;}\r\n if (Player.sourceFiles[i].n === 7) {hasBladeburner2079SF = true;}\r\n if (Player.sourceFiles[i].n === 8) {\r\n hasWallStreetSF = true;\r\n wallStreetSFLvl = Player.sourceFiles[i].lvl;\r\n }\r\n if (Player.sourceFiles[i].n === 11) {hasBn11SF = true;}\r\n }\r\n}\r\n\r\nfunction NetscriptFunctions(workerScript) {\r\n var updateDynamicRam = function(fnName, ramCost) {\r\n if (workerScript.dynamicLoadedFns[fnName]) {return;}\r\n workerScript.dynamicLoadedFns[fnName] = true;\r\n workerScript.dynamicRamUsage += ramCost;\r\n if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {\r\n throw makeRuntimeRejectMsg(workerScript,\r\n \"Dynamic RAM usage calculated to be greater than initial RAM usage. \" +\r\n \"This is probably because you somehow circumvented the static RAM \" +\r\n \"calculation.
Please don't do that :(\");\r\n }\r\n };\r\n\r\n var updateStaticRam = function(fnName, ramCost) {\r\n if (workerScript.loadedFns[fnName]) {\r\n return 0;\r\n } else {\r\n workerScript.loadedFns[fnName] = true;\r\n return ramCost;\r\n }\r\n };\r\n\r\n return {\r\n Math : Math,\r\n Date : Date,\r\n Number : Number,\r\n hacknetnodes : Player.hacknetNodeWrappers,\r\n sprintf : sprintf,\r\n vsprintf: vsprintf,\r\n scan : function(ip=workerScript.serverIp, hostnames=true){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"scan\", CONSTANTS.ScriptScanRamCost);\r\n }\r\n updateDynamicRam(\"scan\", CONSTANTS.ScriptScanRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, 'Invalid IP or hostname passed into scan() command');\r\n }\r\n var out = [];\r\n for (var i = 0; i < server.serversOnNetwork.length; i++) {\r\n var entry;\r\n if (hostnames) {\r\n entry = server.getServerOnNetwork(i).hostname;\r\n } else {\r\n entry = server.getServerOnNetwork(i).ip;\r\n }\r\n if (entry == null) {\r\n continue;\r\n }\r\n out.push(entry);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {\r\n workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);\r\n }\r\n return out;\r\n },\r\n hack : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"hack\", CONSTANTS.ScriptHackRamCost);\r\n }\r\n updateDynamicRam(\"hack\", CONSTANTS.ScriptHackRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Hack() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var threads = workerScript.scriptRef.threads;\r\n if (isNaN(threads) || threads < 1) {threads = 1;}\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"hack() error. Invalid IP or hostname passed in: \" + ip + \". Stopping...\");\r\n throw makeRuntimeRejectMsg(workerScript, \"hack() error. Invalid IP or hostname passed in: \" + ip + \". Stopping...\");\r\n }\r\n\r\n //Calculate the hacking time\r\n var hackingTime = scriptCalculateHackingTime(server); //This is in seconds\r\n\r\n //No root access or skill level too low\r\n if (server.hasAdminRights == false) {\r\n workerScript.scriptRef.log(\"Cannot hack this server (\" + server.hostname + \") because user does not have root access\");\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot hack this server (\" + server.hostname + \") because user does not have root access\");\r\n }\r\n\r\n if (server.requiredHackingSkill > Player.hacking_skill) {\r\n workerScript.scriptRef.log(\"Cannot hack this server (\" + server.hostname + \") because user's hacking skill is not high enough\");\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot hack this server (\" + server.hostname + \") because user's hacking skill is not high enough\");\r\n }\r\n\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {\r\n workerScript.scriptRef.log(\"Attempting to hack \" + ip + \" in \" + hackingTime.toFixed(3) + \" seconds (t=\" + threads + \")\");\r\n }\r\n return netscriptDelay(hackingTime* 1000, workerScript).then(function() {\r\n if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}\r\n var hackChance = scriptCalculateHackingChance(server);\r\n var rand = Math.random();\r\n var expGainedOnSuccess = scriptCalculateExpGain(server) * threads;\r\n var expGainedOnFailure = (expGainedOnSuccess / 4);\r\n if (rand < hackChance) { //Success!\r\n var moneyGained = scriptCalculatePercentMoneyHacked(server);\r\n moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;\r\n\r\n //Over-the-top safety checks\r\n if (moneyGained <= 0) {\r\n moneyGained = 0;\r\n expGainedOnSuccess = expGainedOnFailure;\r\n }\r\n if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}\r\n server.moneyAvailable -= moneyGained;\r\n if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}\r\n\r\n Player.gainMoney(moneyGained);\r\n workerScript.scriptRef.onlineMoneyMade += moneyGained;\r\n Player.scriptProdSinceLastAug += moneyGained;\r\n workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);\r\n Player.gainHackingExp(expGainedOnSuccess);\r\n workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {\r\n workerScript.scriptRef.log(\"Script SUCCESSFULLY hacked \" + server.hostname + \" for $\" + formatNumber(moneyGained, 2) + \" and \" + formatNumber(expGainedOnSuccess, 4) + \" exp (t=\" + threads + \")\");\r\n }\r\n server.fortify(CONSTANTS.ServerFortifyAmount * threads);\r\n return Promise.resolve(moneyGained);\r\n } else {\r\n //Player only gains 25% exp for failure?\r\n Player.gainHackingExp(expGainedOnFailure);\r\n workerScript.scriptRef.onlineExpGained += expGainedOnFailure;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {\r\n workerScript.scriptRef.log(\"Script FAILED to hack \" + server.hostname + \". Gained \" + formatNumber(expGainedOnFailure, 4) + \" exp (t=\" + threads + \")\");\r\n }\r\n return Promise.resolve(0);\r\n }\r\n });\r\n },\r\n sleep : function(time){\r\n if (workerScript.checkingRam) {return 0;}\r\n if (time === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"sleep() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {\r\n workerScript.scriptRef.log(\"Sleeping for \" + time + \" milliseconds\");\r\n }\r\n return netscriptDelay(time, workerScript).then(function() {\r\n return Promise.resolve(true);\r\n });\r\n },\r\n grow : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"grow\", CONSTANTS.ScriptGrowRamCost);\r\n }\r\n updateDynamicRam(\"grow\", CONSTANTS.ScriptGrowRamCost);\r\n var threads = workerScript.scriptRef.threads;\r\n if (isNaN(threads) || threads < 1) {threads = 1;}\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"grow() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot grow(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot grow(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n\r\n //No root access or skill level too low\r\n if (server.hasAdminRights == false) {\r\n workerScript.scriptRef.log(\"Cannot grow this server (\" + server.hostname + \") because user does not have root access\");\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot grow this server (\" + server.hostname + \") because user does not have root access\");\r\n }\r\n\r\n var growTime = scriptCalculateGrowTime(server);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {\r\n workerScript.scriptRef.log(\"Executing grow() on server \" + server.hostname + \" in \" + formatNumber(growTime/1000, 3) + \" seconds (t=\" + threads + \")\");\r\n }\r\n return netscriptDelay(growTime, workerScript).then(function() {\r\n if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}\r\n server.moneyAvailable += (1 * threads); //It can be grown even if it has no money\r\n var growthPercentage = processSingleServerGrowth(server, 450 * threads);\r\n workerScript.scriptRef.recordGrow(server.ip, threads);\r\n var expGain = scriptCalculateExpGain(server) * threads;\r\n if (growthPercentage == 1) {\r\n expGain = 0;\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {\r\n workerScript.scriptRef.log(\"Available money on \" + server.hostname + \" grown by \" +\r\n formatNumber(growthPercentage*100 - 100, 6) + \"%. Gained \" +\r\n formatNumber(expGain, 4) + \" hacking exp (t=\" + threads +\")\");\r\n }\r\n workerScript.scriptRef.onlineExpGained += expGain;\r\n Player.gainHackingExp(expGain);\r\n return Promise.resolve(growthPercentage);\r\n });\r\n },\r\n weaken : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"weaken\", CONSTANTS.ScriptWeakenRamCost);\r\n }\r\n updateDynamicRam(\"weaken\", CONSTANTS.ScriptWeakenRamCost);\r\n var threads = workerScript.scriptRef.threads;\r\n if (isNaN(threads) || threads < 1) {threads = 1;}\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"weaken() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot weaken(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot weaken(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n\r\n //No root access or skill level too low\r\n if (server.hasAdminRights == false) {\r\n workerScript.scriptRef.log(\"Cannot weaken this server (\" + server.hostname + \") because user does not have root access\");\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot weaken this server (\" + server.hostname + \") because user does not have root access\");\r\n }\r\n\r\n var weakenTime = scriptCalculateWeakenTime(server);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {\r\n workerScript.scriptRef.log(\"Executing weaken() on server \" + server.hostname + \" in \" +\r\n formatNumber(weakenTime/1000, 3) + \" seconds (t=\" + threads + \")\");\r\n }\r\n return netscriptDelay(weakenTime, workerScript).then(function() {\r\n if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}\r\n server.weaken(CONSTANTS.ServerWeakenAmount * threads);\r\n workerScript.scriptRef.recordWeaken(server.ip, threads);\r\n var expGain = scriptCalculateExpGain(server) * threads;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {\r\n workerScript.scriptRef.log(\"Server security level on \" + server.hostname + \" weakened to \" + server.hackDifficulty +\r\n \". Gained \" + formatNumber(expGain, 4) + \" hacking exp (t=\" + threads + \")\");\r\n }\r\n workerScript.scriptRef.onlineExpGained += expGain;\r\n Player.gainHackingExp(expGain);\r\n return Promise.resolve(CONSTANTS.ServerWeakenAmount * threads);\r\n });\r\n },\r\n print : function(args){\r\n if (workerScript.checkingRam) {return 0;}\r\n if (args === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"print() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n workerScript.scriptRef.log(args.toString());\r\n },\r\n tprint : function(args) {\r\n if (workerScript.checkingRam) {return 0;}\r\n if (args === undefined || args == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"tprint() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var x = args.toString();\r\n if (isHTML(x)) {\r\n Player.takeDamage(1);\r\n dialogBoxCreate(\"You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:
\" +\r\n \"DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!
\" +\r\n \"(You lost 1 HP)\");\r\n return;\r\n }\r\n post(workerScript.scriptRef.filename + \": \" + args.toString());\r\n },\r\n clearLog : function() {\r\n if (workerScript.checkingRam) {return 0;}\r\n workerScript.scriptRef.clearLog();\r\n },\r\n disableLog : function(fn) {\r\n if (workerScript.checkingRam) {return 0;}\r\n if(possibleLogs[fn]===undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument to disableLog: \"+fn);\r\n }\r\n workerScript.disableLogs[fn] = true;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) {\r\n workerScript.scriptRef.log(\"Disabled logging for \" + fn);\r\n }\r\n },\r\n enableLog : function(fn) {\r\n if (workerScript.checkingRam) {return 0;}\r\n if(possibleLogs[fn]===undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument to enableLog: \"+fn);\r\n }\r\n delete workerScript.disableLogs[fn];\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) {\r\n workerScript.scriptRef.log(\"Enabled logging for \" + fn);\r\n }\r\n },\r\n nuke : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"nuke\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"nuke\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call nuke(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call nuke(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.NukeProgram)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the NUKE.exe virus!\");\r\n }\r\n if (server.openPortCount < server.numOpenPortsRequired) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Not enough ports opened to use NUKE.exe virus\");\r\n }\r\n if (server.hasAdminRights) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {\r\n workerScript.scriptRef.log(\"Already have root access to \" + server.hostname);\r\n }\r\n } else {\r\n server.hasAdminRights = true;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {\r\n workerScript.scriptRef.log(\"Executed NUKE.exe virus on \" + server.hostname + \" to gain root access\");\r\n }\r\n }\r\n return true;\r\n },\r\n brutessh : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"brutessh\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"brutessh\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call brutessh(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call brutessh(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.BruteSSHProgram)) {\r\n workerScript.scriptRef.log(\"You do not have the BruteSSH.exe program!\");\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the BruteSSH.exe program!\");\r\n }\r\n if (!server.sshPortOpen) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {\r\n workerScript.scriptRef.log(\"Executed BruteSSH.exe on \" + server.hostname + \" to open SSH port (22)\");\r\n }\r\n server.sshPortOpen = true;\r\n ++server.openPortCount;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {\r\n workerScript.scriptRef.log(\"SSH Port (22) already opened on \" + server.hostname);\r\n }\r\n }\r\n return true;\r\n },\r\n ftpcrack : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"ftpcrack\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"ftpcrack\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call ftpcrack(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call ftpcrack(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.FTPCrackProgram)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the FTPCrack.exe program!\");\r\n }\r\n if (!server.ftpPortOpen) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {\r\n workerScript.scriptRef.log(\"Executed FTPCrack.exe on \" + server.hostname + \" to open FTP port (21)\");\r\n }\r\n server.ftpPortOpen = true;\r\n ++server.openPortCount;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {\r\n workerScript.scriptRef.log(\"FTP Port (21) already opened on \" + server.hostname);\r\n }\r\n }\r\n return true;\r\n },\r\n relaysmtp : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"relaysmtp\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"relaysmtp\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call relaysmtp(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call relaysmtp(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.RelaySMTPProgram)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the relaySMTP.exe program!\");\r\n }\r\n if (!server.smtpPortOpen) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {\r\n workerScript.scriptRef.log(\"Executed relaySMTP.exe on \" + server.hostname + \" to open SMTP port (25)\");\r\n }\r\n server.smtpPortOpen = true;\r\n ++server.openPortCount;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {\r\n workerScript.scriptRef.log(\"SMTP Port (25) already opened on \" + server.hostname);\r\n }\r\n }\r\n return true;\r\n },\r\n httpworm : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"httpworm\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"httpworm\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call httpworm(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call httpworm(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.HTTPWormProgram)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the HTTPWorm.exe program!\");\r\n }\r\n if (!server.httpPortOpen) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {\r\n workerScript.scriptRef.log(\"Executed HTTPWorm.exe on \" + server.hostname + \" to open HTTP port (80)\");\r\n }\r\n server.httpPortOpen = true;\r\n ++server.openPortCount;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {\r\n workerScript.scriptRef.log(\"HTTP Port (80) already opened on \" + server.hostname);\r\n }\r\n }\r\n return true;\r\n },\r\n sqlinject : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"sqlinject\", CONSTANTS.ScriptPortProgramRamCost);\r\n }\r\n updateDynamicRam(\"sqlinject\", CONSTANTS.ScriptPortProgramRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Program call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"Cannot call sqlinject(). Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot call sqlinject(). Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (!Player.hasProgram(Programs.SQLInjectProgram)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You do not have the SQLInject.exe program!\");\r\n }\r\n if (!server.sqlPortOpen) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {\r\n workerScript.scriptRef.log(\"Executed SQLInject.exe on \" + server.hostname + \" to open SQL port (1433)\");\r\n }\r\n server.sqlPortOpen = true;\r\n ++server.openPortCount;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {\r\n workerScript.scriptRef.log(\"SQL Port (1433) already opened on \" + server.hostname);\r\n }\r\n }\r\n return true;\r\n },\r\n run : function(scriptname,threads = 1){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"run\", CONSTANTS.ScriptRunRamCost);\r\n }\r\n updateDynamicRam(\"run\", CONSTANTS.ScriptRunRamCost);\r\n if (scriptname === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)\");\r\n }\r\n if (isNaN(threads) || threads < 1) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument for thread count passed into run(). Must be numeric and greater than 0\");\r\n }\r\n var argsForNewScript = [];\r\n for (var i = 2; i < arguments.length; ++i) {\r\n argsForNewScript.push(arguments[i]);\r\n }\r\n var scriptServer = getServer(workerScript.serverIp);\r\n if (scriptServer == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find server. This is a bug in the game. Report to game dev\");\r\n }\r\n\r\n return runScriptFromScript(scriptServer, scriptname, argsForNewScript, workerScript, threads);\r\n },\r\n exec : function(scriptname,ip,threads = 1) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"exec\", CONSTANTS.ScriptExecRamCost);\r\n }\r\n updateDynamicRam(\"exec\", CONSTANTS.ScriptExecRamCost);\r\n if (scriptname === undefined || ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)\");\r\n }\r\n if (isNaN(threads) || threads < 1) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument for thread count passed into exec(). Must be numeric and greater than 0\");\r\n }\r\n var argsForNewScript = [];\r\n for (var i = 3; i < arguments.length; ++i) {\r\n argsForNewScript.push(arguments[i]);\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid hostname/ip passed into exec() command: \" + ip);\r\n }\r\n return runScriptFromScript(server, scriptname, argsForNewScript, workerScript, threads);\r\n },\r\n spawn : function(scriptname, threads) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"spawn\", CONSTANTS.ScriptSpawnRamCost);\r\n }\r\n updateDynamicRam(\"spawn\", CONSTANTS.ScriptSpawnRamCost);\r\n if (scriptname == null || threads == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid scriptname or numThreads argument passed to spawn()\");\r\n }\r\n setTimeout(()=>{\r\n NetscriptFunctions(workerScript).run.apply(this, arguments);\r\n }, 20000);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {\r\n workerScript.scriptRef.log(\"spawn() will execute \" + scriptname + \" in 20 seconds\");\r\n }\r\n NetscriptFunctions(workerScript).exit();\r\n },\r\n kill : function(filename,ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"kill\", CONSTANTS.ScriptKillRamCost);\r\n }\r\n updateDynamicRam(\"kill\", CONSTANTS.ScriptKillRamCost);\r\n if (filename === undefined || ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"kill() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"kill() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n var argsForKillTarget = [];\r\n for (var i = 2; i < arguments.length; ++i) {\r\n argsForKillTarget.push(arguments[i]);\r\n }\r\n var runningScriptObj = findRunningScript(filename, argsForKillTarget, server);\r\n if (runningScriptObj == null) {\r\n workerScript.scriptRef.log(\"kill() failed. No such script \"+ filename + \" on \" + server.hostname + \" with args: \" + printArray(argsForKillTarget));\r\n return false;\r\n }\r\n var res = killWorkerScript(runningScriptObj, server.ip);\r\n if (res) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {\r\n workerScript.scriptRef.log(\"Killing \" + filename + \" on \" + server.hostname + \" with args: \" + printArray(argsForKillTarget) + \". May take up to a few minutes for the scripts to die...\");\r\n }\r\n return true;\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {\r\n workerScript.scriptRef.log(\"kill() failed. No such script \"+ filename + \" on \" + server.hostname + \" with args: \" + printArray(argsForKillTarget));\r\n }\r\n return false;\r\n }\r\n },\r\n killall : function(ip=workerScript.serverIp){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"killall\", CONSTANTS.ScriptKillRamCost);\r\n }\r\n updateDynamicRam(\"killall\", CONSTANTS.ScriptKillRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"killall() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"killall() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"killall() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n var scriptsRunning = (server.runningScripts.length > 0);\r\n for (var i = server.runningScripts.length-1; i >= 0; --i) {\r\n killWorkerScript(server.runningScripts[i], server.ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {\r\n workerScript.scriptRef.log(\"killall(): Killing all scripts on \" + server.hostname + \". May take a few minutes for the scripts to die\");\r\n }\r\n return scriptsRunning;\r\n },\r\n exit : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"exit\", CONSTANTS.ScriptKillRamCost);\r\n }\r\n updateDynamicRam(\"exit\", CONSTANTS.ScriptKillRamCost);\r\n var server = getServer(workerScript.serverIp);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Error getting Server for this script in exit(). This is a bug please contact game dev\");\r\n }\r\n if (killWorkerScript(workerScript.scriptRef, server.ip)) {\r\n workerScript.scriptRef.log(\"Exiting...\");\r\n } else {\r\n workerScript.scriptRef.log(\"Exit failed(). This is a bug please contact game developer\");\r\n }\r\n },\r\n scp : function(scriptname, ip1, ip2) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"scp\", CONSTANTS.ScriptScpRamCost);\r\n }\r\n updateDynamicRam(\"scp\", CONSTANTS.ScriptScpRamCost);\r\n if (arguments.length !== 2 && arguments.length !== 3) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments\");\r\n }\r\n if (scriptname && scriptname.constructor === Array) {\r\n //Recursively call scp on all elements of array\r\n var res = false;\r\n scriptname.forEach(function(script) {\r\n if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) {\r\n res = true;\r\n };\r\n });\r\n return res;\r\n }\r\n if (!scriptname.endsWith(\".lit\") && !isScriptFilename(scriptname) &&\r\n !scriptname.endsWith(\"txt\")) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: scp() does not work with this file type. It only works for .script, .lit, and .txt files\");\r\n }\r\n\r\n var destServer, currServ;\r\n\r\n if (arguments.length === 3) { //scriptname, source, destination\r\n if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments\");\r\n }\r\n destServer = getServer(ip2);\r\n if (destServer == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid hostname/ip passed into scp() command: \" + ip);\r\n }\r\n\r\n currServ = getServer(ip1);\r\n if (currServ == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find server ip for this script. This is a bug please contact game developer\");\r\n }\r\n } else if (arguments.length === 2) { //scriptname, destination\r\n if (scriptname === undefined || ip1 === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments\");\r\n }\r\n destServer = getServer(ip1);\r\n if (destServer == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid hostname/ip passed into scp() command: \" + ip);\r\n }\r\n\r\n currServ = getServer(workerScript.serverIp);\r\n if (currServ == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find server ip for this script. This is a bug please contact game developer\");\r\n }\r\n }\r\n\r\n //Scp for lit files\r\n if (scriptname.endsWith(\".lit\")) {\r\n var found = false;\r\n for (var i = 0; i < currServ.messages.length; ++i) {\r\n if (!(currServ.messages[i] instanceof Message) && currServ.messages[i] == scriptname) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n workerScript.scriptRef.log(scriptname + \" does not exist. scp() failed\");\r\n return false;\r\n }\r\n\r\n for (var i = 0; i < destServer.messages.length; ++i) {\r\n if (destServer.messages[i] === scriptname) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(scriptname + \" copied over to \" + destServer.hostname);\r\n }\r\n return true; //Already exists\r\n }\r\n }\r\n destServer.messages.push(scriptname);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(scriptname + \" copied over to \" + destServer.hostname);\r\n }\r\n return true;\r\n }\r\n\r\n //Scp for text files\r\n if (scriptname.endsWith(\".txt\")) {\r\n var found = false, txtFile;\r\n for (var i = 0; i < currServ.textFiles.length; ++i) {\r\n if (currServ.textFiles[i].fn === scriptname) {\r\n found = true;\r\n txtFile = currServ.textFiles[i];\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n workerScript.scriptRef.log(scriptname + \" does not exist. scp() failed\");\r\n return false;\r\n }\r\n\r\n for (var i = 0; i < destServer.textFiles.length; ++i) {\r\n if (destServer.textFiles[i].fn === scriptname) {\r\n //Overwrite\r\n destServer.textFiles[i].text = txtFile.text;\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(scriptname + \" copied over to \" + destServer.hostname);\r\n }\r\n return true;\r\n }\r\n }\r\n var newFile = new TextFile(txtFile.fn, txtFile.text);\r\n destServer.textFiles.push(newFile);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(scriptname + \" copied over to \" + destServer.hostname);\r\n }\r\n return true;\r\n }\r\n\r\n //Scp for script files\r\n var sourceScript = null;\r\n for (var i = 0; i < currServ.scripts.length; ++i) {\r\n if (scriptname == currServ.scripts[i].filename) {\r\n sourceScript = currServ.scripts[i];\r\n break;\r\n }\r\n }\r\n if (sourceScript == null) {\r\n workerScript.scriptRef.log(scriptname + \" does not exist. scp() failed\");\r\n return false;\r\n }\r\n\r\n //Overwrite script if it already exists\r\n for (var i = 0; i < destServer.scripts.length; ++i) {\r\n if (scriptname == destServer.scripts[i].filename) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(\"WARNING: \" + scriptname + \" already exists on \" + destServer.hostname + \" and it will be overwritten.\");\r\n workerScript.scriptRef.log(scriptname + \" overwritten on \" + destServer.hostname);\r\n }\r\n var oldScript = destServer.scripts[i];\r\n oldScript.code = sourceScript.code;\r\n oldScript.ramUsage = sourceScript.ramUsage;\r\n return true;\r\n }\r\n }\r\n\r\n //Create new script if it does not already exist\r\n var newScript = new Script();\r\n newScript.filename = scriptname;\r\n newScript.code = sourceScript.code;\r\n newScript.ramUsage = sourceScript.ramUsage;\r\n newScript.server = destServer.ip;\r\n destServer.scripts.push(newScript);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {\r\n workerScript.scriptRef.log(scriptname + \" copied over to \" + destServer.hostname);\r\n }\r\n return true;\r\n },\r\n ls : function(ip, grep) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"ls\", CONSTANTS.ScriptScanRamCost);\r\n }\r\n updateDynamicRam(\"ls\", CONSTANTS.ScriptScanRamCost);\r\n if (ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"ls() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"ls() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n\r\n //Get the grep filter, if one exists\r\n var filter = false;\r\n if (arguments.length >= 2) {\r\n filter = grep.toString();\r\n }\r\n\r\n var allFiles = [];\r\n for (var i = 0; i < server.programs.length; i++) {\r\n if (filter) {\r\n if (server.programs[i].includes(filter)) {\r\n allFiles.push(server.programs[i]);\r\n }\r\n } else {\r\n allFiles.push(server.programs[i]);\r\n }\r\n }\r\n for (var i = 0; i < server.scripts.length; i++) {\r\n if (filter) {\r\n if (server.scripts[i].filename.includes(filter)) {\r\n allFiles.push(server.scripts[i].filename);\r\n }\r\n } else {\r\n allFiles.push(server.scripts[i].filename);\r\n }\r\n\r\n }\r\n for (var i = 0; i < server.messages.length; i++) {\r\n if (filter) {\r\n if (server.messages[i] instanceof Message) {\r\n if (server.messages[i].filename.includes(filter)) {\r\n allFiles.push(server.messages[i].filename);\r\n }\r\n } else if (server.messages[i].includes(filter)) {\r\n allFiles.push(server.messages[i]);\r\n }\r\n } else {\r\n if (server.messages[i] instanceof Message) {\r\n allFiles.push(server.messages[i].filename);\r\n } else {\r\n allFiles.push(server.messages[i]);\r\n }\r\n }\r\n }\r\n\r\n for (var i = 0; i < server.textFiles.length; i++) {\r\n if (filter) {\r\n if (server.textFiles[i].fn.includes(filter)) {\r\n allFiles.push(server.textFiles[i].fn);\r\n }\r\n } else {\r\n allFiles.push(server.textFiles[i].fn);\r\n }\r\n }\r\n\r\n //Sort the files alphabetically then print each\r\n allFiles.sort();\r\n return allFiles;\r\n },\r\n hasRootAccess : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"hasRootAccess\", CONSTANTS.ScriptHasRootAccessRamCost);\r\n }\r\n updateDynamicRam(\"hasRootAccess\", CONSTANTS.ScriptHasRootAccessRamCost);\r\n if (ip===undefined){\r\n throw makeRuntimeRejectMsg(workerScript, \"hasRootAccess() call has incorrect number of arguments. Takes 1 argument\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null){\r\n workerScript.scriptRef.log(\"hasRootAccess() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"hasRootAccess() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n return server.hasAdminRights;\r\n },\r\n getIp : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getIp\", CONSTANTS.ScriptGetHostnameRamCost);\r\n }\r\n updateDynamicRam(\"getIp\", CONSTANTS.ScriptGetHostnameRamCost);\r\n var scriptServer = getServer(workerScript.serverIp);\r\n if (scriptServer == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find server. This is a bug in the game. Report to game dev\");\r\n }\r\n return scriptServer.ip;\r\n },\r\n getHostname : function(){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getHostname\", CONSTANTS.ScriptGetHostnameRamCost);\r\n }\r\n updateDynamicRam(\"getHostname\", CONSTANTS.ScriptGetHostnameRamCost);\r\n var scriptServer = getServer(workerScript.serverIp);\r\n if (scriptServer == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find server. This is a bug in the game. Report to game dev\");\r\n }\r\n return scriptServer.hostname;\r\n },\r\n getHackingLevel : function(){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getHackingLevel\", CONSTANTS.ScriptGetHackingLevelRamCost);\r\n }\r\n updateDynamicRam(\"getHackingLevel\", CONSTANTS.ScriptGetHackingLevelRamCost);\r\n Player.updateSkillLevels();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {\r\n workerScript.scriptRef.log(\"getHackingLevel() returned \" + Player.hacking_skill);\r\n }\r\n return Player.hacking_skill;\r\n },\r\n getHackingMultipliers : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getHackingMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n }\r\n updateDynamicRam(\"getHackingMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n return {\r\n chance: Player.hacking_chance_mult,\r\n speed: Player.hacking_speed_mult,\r\n money: Player.hacking_money_mult,\r\n growth: Player.hacking_grow_mult,\r\n };\r\n },\r\n getHacknetMultipliers : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getHacknetMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n }\r\n updateDynamicRam(\"getHacknetMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n return {\r\n production: Player.hacknet_node_money_mult,\r\n purchaseCost: Player.hacknet_node_purchase_cost_mult,\r\n ramCost: Player.hacknet_node_ram_cost_mult,\r\n coreCost: Player.hacknet_node_core_cost_mult,\r\n levelCost: Player.hacknet_node_level_cost_mult,\r\n };\r\n },\r\n getBitNodeMultipliers: function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getBitNodeMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n }\r\n updateDynamicRam(\"getBitNodeMultipliers\", CONSTANTS.ScriptGetMultipliersRamCost);\r\n if (!hasAISF) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run.\");\r\n }\r\n let copy = Object.assign({}, BitNodeMultipliers);\r\n return copy;\r\n },\r\n getServerMoneyAvailable : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerMoneyAvailable\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerMoneyAvailable\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerMoneyAvailable() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerMoneyAvailable() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (server.hostname == \"home\") {\r\n //Return player's money\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {\r\n workerScript.scriptRef.log(\"getServerMoneyAvailable('home') returned player's money: $\" + formatNumber(Player.money.toNumber(), 2));\r\n }\r\n return Player.money.toNumber();\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {\r\n workerScript.scriptRef.log(\"getServerMoneyAvailable() returned \" + formatNumber(server.moneyAvailable, 2) + \" for \" + server.hostname);\r\n }\r\n return server.moneyAvailable;\r\n },\r\n getServerSecurityLevel : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {\r\n workerScript.scriptRef.log(\"getServerSecurityLevel() returned \" + formatNumber(server.hackDifficulty, 3) + \" for \" + server.hostname);\r\n }\r\n return server.hackDifficulty;\r\n },\r\n getServerBaseSecurityLevel : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerBaseSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerBaseSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {\r\n workerScript.scriptRef.log(\"getServerBaseSecurityLevel() returned \" + formatNumber(server.baseDifficulty, 3) + \" for \" + server.hostname);\r\n }\r\n return server.baseDifficulty;\r\n },\r\n getServerMinSecurityLevel : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerMinSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerMinSecurityLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {\r\n workerScript.scriptRef.log(\"getServerMinSecurityLevel() returned \" + formatNumber(server.minDifficulty, 3) + \" for \" + server.hostname);\r\n }\r\n return server.minDifficulty;\r\n },\r\n getServerRequiredHackingLevel : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerRequiredHackingLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerRequiredHackingLevel\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {\r\n workerScript.scriptRef.log(\"getServerRequiredHackingLevel returned \" + formatNumber(server.requiredHackingSkill, 0) + \" for \" + server.hostname);\r\n }\r\n return server.requiredHackingSkill;\r\n },\r\n getServerMaxMoney : function(ip){\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerMaxMoney\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerMaxMoney\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerMaxMoney() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerMaxMoney() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {\r\n workerScript.scriptRef.log(\"getServerMaxMoney() returned \" + formatNumber(server.moneyMax, 0) + \" for \" + server.hostname);\r\n }\r\n return server.moneyMax;\r\n },\r\n getServerGrowth : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerGrowth\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerGrowth\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerGrowth() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerGrowth() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {\r\n workerScript.scriptRef.log(\"getServerGrowth() returned \" + formatNumber(server.serverGrowth, 0) + \" for \" + server.hostname);\r\n }\r\n return server.serverGrowth;\r\n },\r\n getServerNumPortsRequired : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerNumPortsRequired\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerNumPortsRequired\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerNumPortsRequired() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerNumPortsRequired() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {\r\n workerScript.scriptRef.log(\"getServerNumPortsRequired() returned \" + formatNumber(server.numOpenPortsRequired, 0) + \" for \" + server.hostname);\r\n }\r\n return server.numOpenPortsRequired;\r\n },\r\n getServerRam : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getServerRam\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"getServerRam\", CONSTANTS.ScriptGetServerRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getServerRam() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getServerRam() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {\r\n workerScript.scriptRef.log(\"getServerRam() returned [\" + formatNumber(server.maxRam, 2) + \"GB, \" + formatNumber(server.ramUsed, 2) + \"GB]\");\r\n }\r\n return [server.maxRam, server.ramUsed];\r\n },\r\n serverExists : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"serverExists\", CONSTANTS.ScriptGetServerRamCost);\r\n }\r\n updateDynamicRam(\"serverExists\", CONSTANTS.ScriptGetServerRamCost);\r\n return (getServer(ip) !== null);\r\n },\r\n fileExists : function(filename,ip=workerScript.serverIp) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"fileExists\", CONSTANTS.ScriptFileExistsRamCost);\r\n }\r\n updateDynamicRam(\"fileExists\", CONSTANTS.ScriptFileExistsRamCost);\r\n if (filename === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"fileExists() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"fileExists() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n for (var i = 0; i < server.scripts.length; ++i) {\r\n if (filename == server.scripts[i].filename) {\r\n return true;\r\n }\r\n }\r\n for (var i = 0; i < server.programs.length; ++i) {\r\n if (filename.toLowerCase() == server.programs[i].toLowerCase()) {\r\n return true;\r\n }\r\n }\r\n for (var i = 0; i < server.messages.length; ++i) {\r\n if (!(server.messages[i] instanceof Message) &&\r\n filename.toLowerCase() === server.messages[i]) {\r\n return true;\r\n }\r\n }\r\n var txtFile = getTextFile(filename, server);\r\n if (txtFile != null) {\r\n return true;\r\n }\r\n return false;\r\n },\r\n isRunning : function(filename,ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isRunning\", CONSTANTS.ScriptIsRunningRamCost);\r\n }\r\n updateDynamicRam(\"isRunning\", CONSTANTS.ScriptIsRunningRamCost);\r\n if (filename === undefined || ip === undefined) {\r\n throw makeRuntimeRejectMsg(workerScript, \"isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)\");\r\n }\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"isRunning() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"isRunning() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n var argsForTargetScript = [];\r\n for (var i = 2; i < arguments.length; ++i) {\r\n argsForTargetScript.push(arguments[i]);\r\n }\r\n return (findRunningScript(filename, argsForTargetScript, server) != null);\r\n },\r\n getNextHacknetNodeCost : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getNextHacknetNodeCost\", CONSTANTS.ScriptPurchaseHacknetRamCost);\r\n }\r\n updateDynamicRam(\"getNextHacknetNodeCost\", CONSTANTS.ScriptPurchaseHacknetRamCost);\r\n return getCostOfNextHacknetNode();\r\n },\r\n\r\n purchaseHacknetNode : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"purchaseHacknetNode\", CONSTANTS.ScriptPurchaseHacknetRamCost);\r\n }\r\n updateDynamicRam(\"purchaseHacknetNode\", CONSTANTS.ScriptPurchaseHacknetRamCost);\r\n return purchaseHacknet();\r\n },\r\n getStockPrice : function(symbol) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getStockPrice\", CONSTANTS.ScriptGetStockRamCost);\r\n }\r\n updateDynamicRam(\"getStockPrice\", CONSTANTS.ScriptGetStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use getStockPrice()\");\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid stock symbol passed into getStockPrice()\");\r\n }\r\n return parseFloat(stock.price.toFixed(3));\r\n },\r\n getStockPosition : function(symbol) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getStockPosition\", CONSTANTS.ScriptGetStockRamCost);\r\n }\r\n updateDynamicRam(\"getStockPosition\", CONSTANTS.ScriptGetStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use getStockPosition()\");\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid stock symbol passed into getStockPosition()\");\r\n }\r\n return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];\r\n },\r\n buyStock : function(symbol, shares) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"buyStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"buyStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use buyStock()\");\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid stock symbol passed into buyStock()\");\r\n }\r\n if (shares < 0 || isNaN(shares)) {\r\n workerScript.scriptRef.log(\"ERROR: Invalid 'shares' argument passed to buyStock()\");\r\n return 0;\r\n }\r\n shares = Math.round(shares);\r\n if (shares === 0) {return 0;}\r\n\r\n var totalPrice = stock.price * shares;\r\n if (Player.money.lt(totalPrice + CONSTANTS.StockMarketCommission)) {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + formatNumber(shares, 0) + \" shares of \" +\r\n symbol + \". Need $\" +\r\n formatNumber(totalPrice + CONSTANTS.StockMarketCommission, 2).toString());\r\n return 0;\r\n }\r\n\r\n var origTotal = stock.playerShares * stock.playerAvgPx;\r\n Player.loseMoney(totalPrice + CONSTANTS.StockMarketCommission);\r\n var newTotal = origTotal + totalPrice;\r\n stock.playerShares += shares;\r\n stock.playerAvgPx = newTotal / stock.playerShares;\r\n if (Engine.currentPage == Engine.Page.StockMarket) {\r\n updateStockPlayerPosition(stock);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {\r\n workerScript.scriptRef.log(\"Bought \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share\");\r\n }\r\n return stock.price;\r\n },\r\n sellStock : function(symbol, shares) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"sellStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"sellStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use sellStock()\");\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid stock symbol passed into sellStock()\");\r\n }\r\n if (shares < 0 || isNaN(shares)) {\r\n workerScript.scriptRef.log(\"ERROR: Invalid 'shares' argument passed to sellStock()\");\r\n return 0;\r\n }\r\n shares = Math.round(shares);\r\n if (shares > stock.playerShares) {shares = stock.playerShares;}\r\n if (shares === 0) {return 0;}\r\n var gains = stock.price * shares - CONSTANTS.StockMarketCommission;\r\n Player.gainMoney(gains);\r\n\r\n //Calculate net profit and add to script stats\r\n var netProfit = ((stock.price - stock.playerAvgPx) * shares) - CONSTANTS.StockMarketCommission;\r\n if (isNaN(netProfit)) {netProfit = 0;}\r\n workerScript.scriptRef.onlineMoneyMade += netProfit;\r\n Player.scriptProdSinceLastAug += netProfit;\r\n\r\n stock.playerShares -= shares;\r\n if (stock.playerShares == 0) {\r\n stock.playerAvgPx = 0;\r\n }\r\n if (Engine.currentPage == Engine.Page.StockMarket) {\r\n updateStockPlayerPosition(stock);\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {\r\n workerScript.scriptRef.log(\"Sold \" + formatNumber(shares, 0) + \" shares of \" + stock.symbol + \" at $\" +\r\n formatNumber(stock.price, 2) + \" per share. Gained \" +\r\n \"$\" + formatNumber(gains, 2));\r\n }\r\n return stock.price;\r\n },\r\n shortStock(symbol, shares) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"shortStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"shortStock\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use shortStock()\");\r\n }\r\n if (Player.bitNodeN !== 8) {\r\n if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8\");\r\n }\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid stock symbol passed into shortStock()\");\r\n }\r\n var res = shortStock(stock, shares, workerScript);\r\n return res ? stock.price : 0;\r\n },\r\n sellShort(symbol, shares) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"sellShort\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"sellShort\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use sellShort()\");\r\n }\r\n if (Player.bitNodeN !== 8) {\r\n if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8\");\r\n }\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid stock symbol passed into sellShort()\");\r\n }\r\n var res = sellShort(stock, shares, workerScript);\r\n return res ? stock.price : 0;\r\n },\r\n placeOrder(symbol, shares, price, type, pos) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"placeOrder\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"placeOrder\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use placeOrder()\");\r\n }\r\n if (Player.bitNodeN !== 8) {\r\n if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8\");\r\n }\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid stock symbol passed into placeOrder()\");\r\n }\r\n var orderType, orderPos;\r\n type = type.toLowerCase();\r\n if (type.includes(\"limit\") && type.includes(\"buy\")) {\r\n orderType = OrderTypes.LimitBuy;\r\n } else if (type.includes(\"limit\") && type.includes(\"sell\")) {\r\n orderType = OrderTypes.LimitSell;\r\n } else if (type.includes(\"stop\") && type.includes(\"buy\")) {\r\n orderType = OrderTypes.StopBuy;\r\n } else if (type.includes(\"stop\") && type.includes(\"sell\")) {\r\n orderType = OrderTypes.StopSell;\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid Order Type passed into placeOrder()\");\r\n }\r\n\r\n pos = pos.toLowerCase();\r\n if (pos.includes(\"l\")) {\r\n orderPos = PositionTypes.Long;\r\n } else if (pos.includes('s')) {\r\n orderPos = PositionTypes.Short;\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid Position Type passed into placeOrder()\");\r\n }\r\n\r\n return placeOrder(stock, shares, price, orderType, orderPos, workerScript);\r\n },\r\n cancelOrder(symbol, shares, price, type, pos) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"cancelOrder\", CONSTANTS.ScriptBuySellStockRamCost);\r\n }\r\n updateDynamicRam(\"cancelOrder\", CONSTANTS.ScriptBuySellStockRamCost);\r\n if (!Player.hasTixApiAccess) {\r\n throw makeRuntimeRejectMsg(workerScript, \"You don't have TIX API Access! Cannot use cancelOrder()\");\r\n }\r\n if (Player.bitNodeN !== 8) {\r\n if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8\");\r\n }\r\n }\r\n var stock = SymbolToStockMap[symbol];\r\n if (stock == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid stock symbol passed into cancelOrder()\");\r\n }\r\n if (isNaN(shares) || isNaN(price)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric\");\r\n }\r\n var orderType, orderPos;\r\n type = type.toLowerCase();\r\n if (type.includes(\"limit\") && type.includes(\"buy\")) {\r\n orderType = OrderTypes.LimitBuy;\r\n } else if (type.includes(\"limit\") && type.includes(\"sell\")) {\r\n orderType = OrderTypes.LimitSell;\r\n } else if (type.includes(\"stop\") && type.includes(\"buy\")) {\r\n orderType = OrderTypes.StopBuy;\r\n } else if (type.includes(\"stop\") && type.includes(\"sell\")) {\r\n orderType = OrderTypes.StopSell;\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid Order Type passed into placeOrder()\");\r\n }\r\n\r\n pos = pos.toLowerCase();\r\n if (pos.includes(\"l\")) {\r\n orderPos = PositionTypes.Long;\r\n } else if (pos.includes('s')) {\r\n orderPos = PositionTypes.Short;\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid Position Type passed into placeOrder()\");\r\n }\r\n var params = {\r\n stock: stock,\r\n shares: shares,\r\n price: price,\r\n type: orderType,\r\n pos: orderPos\r\n };\r\n return cancelOrder(params, workerScript);\r\n },\r\n purchaseServer : function(hostname, ram) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"purchaseServer\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n }\r\n updateDynamicRam(\"purchaseServer\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n var hostnameStr = String(hostname);\r\n hostnameStr = hostnameStr.replace(/\\s+/g, '');\r\n if (hostnameStr == \"\") {\r\n workerScript.scriptRef.log(\"ERROR: Passed empty string for hostname argument of purchaseServer()\");\r\n return \"\";\r\n }\r\n\r\n if (Player.purchasedServers.length >= CONSTANTS.PurchasedServerLimit) {\r\n workerScript.scriptRef.log(\"ERROR: You have reached the maximum limit of \" + CONSTANTS.PurchasedServerLimit +\r\n \" servers. You cannot purchase any more.\");\r\n return \"\";\r\n }\r\n\r\n ram = Math.round(ram);\r\n if (isNaN(ram) || !powerOfTwo(ram)) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseServer() failed due to invalid ram argument. Must be numeric and a power of 2\");\r\n return \"\";\r\n }\r\n\r\n if (ram > CONSTANTS.PurchasedServerMaxRam) {\r\n workerScript.scriptRef.log(\"ERROR: purchasedServer() failed because specified RAM was too high. Maximum RAM on a purchased server is \" + CONSTANTS.PurchasedServerMaxRam + \"GB\");\r\n return \"\";\r\n }\r\n\r\n var cost = ram * CONSTANTS.BaseCostFor1GBOfRamServer;\r\n if (Player.money.lt(cost)) {\r\n workerScript.scriptRef.log(\"ERROR: Not enough money to purchase server. Need $\" + formatNumber(cost, 2));\r\n return \"\";\r\n }\r\n var newServ = new Server({\r\n ip: createRandomIp(),\r\n hostname: hostnameStr,\r\n organizationName: \"\",\r\n isConnectedTo: false,\r\n adminRights: true,\r\n purchasedByPlayer: true,\r\n maxRam: ram,\r\n });\r\n AddToAllServers(newServ);\r\n\r\n Player.purchasedServers.push(newServ.ip);\r\n var homeComputer = Player.getHomeComputer();\r\n homeComputer.serversOnNetwork.push(newServ.ip);\r\n newServ.serversOnNetwork.push(homeComputer.ip);\r\n Player.loseMoney(cost);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {\r\n workerScript.scriptRef.log(\"Purchased new server with hostname \" + newServ.hostname + \" for $\" + formatNumber(cost, 2));\r\n }\r\n return newServ.hostname;\r\n },\r\n deleteServer : function(hostname) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"deleteServer\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n }\r\n updateDynamicRam(\"deleteServer\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n var hostnameStr = String(hostname);\r\n hostnameStr = hostnameStr.replace(/\\s\\s+/g, '');\r\n var server = GetServerByHostname(hostnameStr);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"ERROR: Could not find server with hostname \" + hostnameStr + \". deleteServer() failed\");\r\n return false;\r\n }\r\n\r\n if (!server.purchasedByPlayer || server.hostname === \"home\") {\r\n workerScript.scriptRef.log(\"ERROR: Server \" + server.hostname + \" is not a purchased server. \" +\r\n \"Cannot be deleted. deleteServer() failed\");\r\n return false;\r\n }\r\n\r\n var ip = server.ip;\r\n\r\n //Can't delete server you're currently connected to\r\n if (server.isConnectedTo) {\r\n workerScript.scriptRef.log(\"ERROR: deleteServer() failed because you are currently connected to the server you are trying to delete\");\r\n return false;\r\n }\r\n\r\n //A server cannot delete itself\r\n if (ip === workerScript.serverIp) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot call deleteServer() on self. deleteServer() failed\");\r\n return false;\r\n }\r\n\r\n //Delete all scripts running on server\r\n if (server.runningScripts.length > 0) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot delete server \" + server.hostname + \" because it still has scripts running.\");\r\n return false;\r\n }\r\n\r\n //Delete from player's purchasedServers array\r\n var found = false;\r\n for (var i = 0; i < Player.purchasedServers.length; ++i) {\r\n if (ip == Player.purchasedServers[i]) {\r\n found = true;\r\n Player.purchasedServers.splice(i, 1);\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n workerScript.scriptRef.log(\"ERROR: Could not identify server \" + server.hostname +\r\n \"as a purchased server. This is likely a bug please contact game dev\");\r\n return false;\r\n }\r\n\r\n //Delete from all servers\r\n delete AllServers[ip];\r\n\r\n //Delete from home computer\r\n found = false;\r\n var homeComputer = Player.getHomeComputer();\r\n for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {\r\n if (ip == homeComputer.serversOnNetwork[i]) {\r\n homeComputer.serversOnNetwork.splice(i, 1);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {\r\n workerScript.scriptRef.log(\"Deleted server \" + hostnameStr);\r\n }\r\n return true;\r\n }\r\n }\r\n //Wasn't found on home computer\r\n workerScript.scriptRef.log(\"ERROR: Could not find server \" + server.hostname +\r\n \"as a purchased server. This is likely a bug please contact game dev\");\r\n return false;\r\n },\r\n getPurchasedServers : function(hostname=true) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getPurchasedServers\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n }\r\n updateDynamicRam(\"getPurchasedServers\", CONSTANTS.ScriptPurchaseServerRamCost);\r\n var res = [];\r\n Player.purchasedServers.forEach(function(ip) {\r\n if (hostname) {\r\n var server = getServer(ip);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Could not find server in getPurchasedServers(). This is a bug please report to game dev\");\r\n }\r\n res.push(server.hostname);\r\n } else {\r\n res.push(ip);\r\n }\r\n });\r\n return res;\r\n },\r\n write : function(port, data=\"\", mode=\"a\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"write\", CONSTANTS.ScriptReadWriteRamCost);\r\n }\r\n updateDynamicRam(\"write\", CONSTANTS.ScriptReadWriteRamCost);\r\n if (!isNaN(port)) { //Write to port\r\n //Port 1-10\r\n port = Math.round(port);\r\n if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Trying to write to invalid port: \" + port + \". Only ports 1-\" + CONSTANTS.NumNetscriptPorts + \" are valid.\");\r\n }\r\n var port = NetscriptPorts[port-1];\r\n if (port == null || !(port instanceof NetscriptPort)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Could not find port: \" + port + \". This is a bug contact the game developer\");\r\n }\r\n return port.write(data);\r\n } else if (isString(port)) { //Write to text file\r\n var fn = port;\r\n var server = getServer(workerScript.serverIp);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Error getting Server for this script in write(). This is a bug please contact game dev\");\r\n }\r\n var txtFile = getTextFile(fn, server);\r\n if (txtFile == null) {\r\n txtFile = createTextFile(fn, data, server);\r\n return true;\r\n }\r\n if (mode === \"w\") {\r\n txtFile.write(data);\r\n } else {\r\n txtFile.append(data);\r\n }\r\n return true;\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument passed in for write: \" + port);\r\n }\r\n },\r\n read : function(port) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"read\", CONSTANTS.ScriptReadWriteRamCost);\r\n }\r\n updateDynamicRam(\"read\", CONSTANTS.ScriptReadWriteRamCost);\r\n if (!isNaN(port)) { //Read from port\r\n //Port 1-10\r\n port = Math.round(port);\r\n if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Trying to read from invalid port: \" + port + \". Only ports 1-\" + CONSTANTS.NumNetscriptPorts + \" are valid.\");\r\n }\r\n var port = NetscriptPorts[port-1];\r\n if (port == null || !(port instanceof NetscriptPort)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Could not find port: \" + port + \". This is a bug contact the game developer\");\r\n }\r\n return port.read();\r\n } else if (isString(port)) { //Read from text file\r\n var fn = port;\r\n var server = getServer(workerScript.serverIp);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Error getting Server for this script in read(). This is a bug please contact game dev\");\r\n }\r\n var txtFile = getTextFile(fn, server);\r\n if (txtFile !== null) {\r\n return txtFile.text;\r\n } else {\r\n return \"\";\r\n }\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument passed in for read(): \" + port);\r\n }\r\n },\r\n peek : function(port) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"peek\", CONSTANTS.ScriptReadWriteRamCost);\r\n }\r\n updateDynamicRam(\"peek\", CONSTANTS.ScriptReadWriteRamCost);\r\n if (isNaN(port)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: peek() called with invalid argument. Must be a port number between 1 and \" + CONSTANTS.NumNetscriptPorts);\r\n }\r\n port = Math.round(port);\r\n if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: peek() called with invalid argument. Must be a port number between 1 and \" + CONSTANTS.NumNetscriptPorts);\r\n }\r\n var port = NetscriptPorts[port-1];\r\n if (port == null || !(port instanceof NetscriptPort)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Could not find port: \" + port + \". This is a bug contact the game developer\");\r\n }\r\n return port.peek();\r\n },\r\n clear : function(port) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"clear\", CONSTANTS.ScriptReadWriteRamCost);\r\n }\r\n updateDynamicRam(\"clear\", CONSTANTS.ScriptReadWriteRamCost);\r\n if (!isNaN(port)) { //Clear port\r\n port = Math.round(port);\r\n if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Trying to clear invalid port: \" + port + \". Only ports 1-\" + CONSTANTS.NumNetscriptPorts + \" are valid\");\r\n }\r\n var port = NetscriptPorts[port-1];\r\n if (port == null || !(port instanceof NetscriptPort)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Could not find port: \" + port + \". This is a bug contact the game developer\");\r\n }\r\n return port.clear();\r\n } else if (isString(port)) { //Clear text file\r\n var fn = port;\r\n var server = getServer(workerScript.serverIp);\r\n if (server == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Error getting Server for this script in clear(). This is a bug please contact game dev\");\r\n }\r\n var txtFile = getTextFile(fn, server);\r\n if (txtFile != null) {\r\n txtFile.write(\"\");\r\n }\r\n } else {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid argument passed in for clear(): \" + port);\r\n }\r\n return 0;\r\n },\r\n getPortHandle : function(port) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getPortHandle\", CONSTANTS.ScriptReadWriteRamCost * 10);\r\n }\r\n updateDynamicRam(\"getPortHandle\", CONSTANTS.ScriptReadWriteRamCost * 10);\r\n if (isNaN(port)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Invalid argument passed into getPortHandle(). Must be an integer between 1 and \" + CONSTANTS.NumNetscriptPorts);\r\n }\r\n port = Math.round(port);\r\n if (port < 1 || port > CONSTANTS.NumNetscriptPorts) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: getPortHandle() called with invalid port number: \" + port + \". Only ports 1-\" + CONSTANTS.NumNetscriptPorts + \" are valid\");\r\n }\r\n var port = NetscriptPorts[port-1];\r\n if (port == null || !(port instanceof NetscriptPort)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: Could not find port: \" + port + \". This is a bug contact the game developer\");\r\n }\r\n return port;\r\n },\r\n rm : function(fn) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"rm\", CONSTANTS.ScriptReadWriteRamCost);\r\n }\r\n updateDynamicRam(\"rm\", CONSTANTS.ScriptReadWriteRamCost);\r\n var s = getServer(workerScript.serverIp);\r\n if (s == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Error getting Server for this script in clear(). This is a bug please contact game dev\");\r\n }\r\n\r\n if (fn.includes(\".exe\")) {\r\n for (var i = 0; i < s.programs.length; ++i) {\r\n if (s.programs[i] === fn) {\r\n s.programs.splice(i, 1);\r\n return true;\r\n }\r\n }\r\n } else if (isScriptFilename(fn)) {\r\n for (var i = 0; i < s.scripts.length; ++i) {\r\n if (s.scripts[i].filename === fn) {\r\n //Check that the script isnt currently running\r\n for (var j = 0; j < s.runningScripts.length; ++j) {\r\n if (s.runningScripts[j].filename === fn) {\r\n workerScript.scriptRef.log(\"Cannot delete a script that is currently running!\");\r\n return false;\r\n }\r\n }\r\n s.scripts.splice(i, 1);\r\n return true;\r\n }\r\n }\r\n } else if (fn.endsWith(\".lit\")) {\r\n for (var i = 0; i < s.messages.length; ++i) {\r\n var f = s.messages[i];\r\n if (!(f instanceof Message) && isString(f) && f === fn) {\r\n s.messages.splice(i, 1);\r\n return true;\r\n }\r\n }\r\n } else if (fn.endsWith(\".txt\")) {\r\n for (var i = 0; i < s.textFiles.length; ++i) {\r\n if (s.textFiles[i].fn === fn) {\r\n s.textFiles.splice(i, 1);\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n },\r\n scriptRunning : function(scriptname, ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"scriptRunning\", CONSTANTS.ScriptArbScriptRamCost);\r\n }\r\n updateDynamicRam(\"scriptRunning\", CONSTANTS.ScriptArbScriptRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"scriptRunning() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"scriptRunning() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n for (var i = 0; i < server.runningScripts.length; ++i) {\r\n if (server.runningScripts[i].filename == scriptname) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n scriptKill : function(scriptname, ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"scriptKill\", CONSTANTS.ScriptArbScriptRamCost);\r\n }\r\n updateDynamicRam(\"scriptKill\", CONSTANTS.ScriptArbScriptRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"scriptKill() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"scriptKill() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n var suc = false;\r\n for (var i = 0; i < server.runningScripts.length; ++i) {\r\n if (server.runningScripts[i].filename == scriptname) {\r\n killWorkerScript(server.runningScripts[i], server.ip);\r\n suc = true;\r\n }\r\n }\r\n return suc;\r\n },\r\n getScriptName : function() {\r\n if (workerScript.checkingRam) {return 0;}\r\n return workerScript.name;\r\n },\r\n getScriptRam : function (scriptname, ip=workerScript.serverIp) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getScriptRam\", CONSTANTS.ScriptGetScriptRamCost);\r\n }\r\n updateDynamicRam(\"getScriptRam\", CONSTANTS.ScriptGetScriptRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getScriptRam() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getScriptRam() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n for (var i = 0; i < server.scripts.length; ++i) {\r\n if (server.scripts[i].filename == scriptname) {\r\n return server.scripts[i].ramUsage;\r\n }\r\n }\r\n return 0;\r\n },\r\n getHackTime : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getHackTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n }\r\n updateDynamicRam(\"getHackTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getHackTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getHackTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n return scriptCalculateHackingTime(server); //Returns seconds\r\n },\r\n getGrowTime : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getGrowTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n }\r\n updateDynamicRam(\"getGrowTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getGrowTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getGrowTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n return scriptCalculateGrowTime(server) / 1000; //Returns seconds\r\n },\r\n getWeakenTime : function(ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getWeakenTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n }\r\n updateDynamicRam(\"getWeakenTime\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getWeakenTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getWeakenTime() failed. Invalid IP or hostname passed in: \" + ip);\r\n }\r\n return scriptCalculateWeakenTime(server) / 1000; //Returns seconds\r\n },\r\n getScriptIncome : function(scriptname, ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getScriptIncome\", CONSTANTS.ScriptGetScriptRamCost);\r\n }\r\n updateDynamicRam(\"getScriptIncome\", CONSTANTS.ScriptGetScriptRamCost);\r\n if (arguments.length === 0) {\r\n //Get total script income\r\n var res = [];\r\n res.push(updateActiveScriptsItems());\r\n res.push(Player.scriptProdSinceLastAug / (Player.playtimeSinceLastAug/1000));\r\n return res;\r\n } else {\r\n //Get income for a particular script\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getScriptIncome() failed. Invalid IP or hostnamed passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getScriptIncome() failed. Invalid IP or hostnamed passed in: \" + ip);\r\n }\r\n var argsForScript = [];\r\n for (var i = 2; i < arguments.length; ++i) {\r\n argsForScript.push(arguments[i]);\r\n }\r\n var runningScriptObj = findRunningScript(scriptname, argsForScript, server);\r\n if (runningScriptObj == null) {\r\n workerScript.scriptRef.log(\"getScriptIncome() failed. No such script \"+ scriptname + \" on \" + server.hostname + \" with args: \" + printArray(argsForScript));\r\n return -1;\r\n }\r\n return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;\r\n }\r\n },\r\n getScriptExpGain : function(scriptname, ip) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getScriptExpGain\", CONSTANTS.ScriptGetScriptRamCost);\r\n }\r\n updateDynamicRam(\"getScriptExpGain\", CONSTANTS.ScriptGetScriptRamCost);\r\n if (arguments.length === 0) {\r\n var total = 0;\r\n for (var i = 0; i < workerScripts.length; ++i) {\r\n total += (workerScripts[i].scriptRef.onlineExpGained / workerScripts[i].scriptRef.onlineRunningTime);\r\n }\r\n return total;\r\n } else {\r\n //Get income for a particular script\r\n var server = getServer(ip);\r\n if (server == null) {\r\n workerScript.scriptRef.log(\"getScriptExpGain() failed. Invalid IP or hostnamed passed in: \" + ip);\r\n throw makeRuntimeRejectMsg(workerScript, \"getScriptExpGain() failed. Invalid IP or hostnamed passed in: \" + ip);\r\n }\r\n var argsForScript = [];\r\n for (var i = 2; i < arguments.length; ++i) {\r\n argsForScript.push(arguments[i]);\r\n }\r\n var runningScriptObj = findRunningScript(scriptname, argsForScript, server);\r\n if (runningScriptObj == null) {\r\n workerScript.scriptRef.log(\"getScriptExpGain() failed. No such script \"+ scriptname + \" on \" + server.hostname + \" with args: \" + printArray(argsForScript));\r\n return -1;\r\n }\r\n return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;\r\n }\r\n },\r\n getTimeSinceLastAug : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getTimeSinceLastAug\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n }\r\n updateDynamicRam(\"getTimeSinceLastAug\", CONSTANTS.ScriptGetHackTimeRamCost);\r\n return Player.playtimeSinceLastAug;\r\n },\r\n prompt : function(txt) {\r\n if (workerScript.checkingRam) {return 0;}\r\n if (yesNoBoxOpen) {\r\n workerScript.scriptRef.log(\"ERROR: confirm() failed because a pop-up dialog box is already open\");\r\n return false;\r\n }\r\n if (!isString(txt)) {txt = String(txt);}\r\n var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();\r\n yesBtn.innerHTML = \"Yes\";\r\n noBtn.innerHTML = \"No\";\r\n return new Promise(function(resolve, reject) {\r\n yesBtn.addEventListener(\"click\", ()=>{\r\n yesNoBoxClose();\r\n resolve(true);\r\n });\r\n noBtn.addEventListener(\"click\", ()=>{\r\n yesNoBoxClose();\r\n resolve(false);\r\n });\r\n yesNoBoxCreate(txt);\r\n });\r\n },\r\n\r\n /* Singularity Functions */\r\n universityCourse : function(universityName, className) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"universityCourse\", ramCost);\r\n }\r\n updateDynamicRam(\"universityCourse\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: universityCourse() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n\r\n var costMult, expMult;\r\n switch(universityName.toLowerCase()) {\r\n case Locations.AevumSummitUniversity.toLowerCase():\r\n if (Player.city != Locations.Aevum) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.AevumSummitUniversity;\r\n costMult = 4;\r\n expMult = 3;\r\n break;\r\n case Locations.Sector12RothmanUniversity.toLowerCase():\r\n if (Player.city != Locations.Sector12) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.Sector12RothmanUniversity;\r\n costMult = 3;\r\n expMult = 2;\r\n break;\r\n case Locations.VolhavenZBInstituteOfTechnology.toLowerCase():\r\n if (Player.city != Locations.Volhaven) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.VolhavenZBInstituteOfTechnology;\r\n costMult = 5;\r\n expMult = 4;\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"Invalid university name: \" + universityName + \". universityCourse() failed\");\r\n return false;\r\n }\r\n\r\n var task;\r\n switch(className.toLowerCase()) {\r\n case \"Study Computer Science\".toLowerCase():\r\n task = CONSTANTS.ClassStudyComputerScience;\r\n break;\r\n case \"Data Structures\".toLowerCase():\r\n task = CONSTANTS.ClassDataStructures;\r\n break;\r\n case \"Networks\".toLowerCase():\r\n task = CONSTANTS.ClassNetworks;\r\n break;\r\n case \"Algorithms\".toLowerCase():\r\n task = CONSTANTS.ClassAlgorithms;\r\n break;\r\n case \"Management\".toLowerCase():\r\n task = CONSTANTS.ClassManagement;\r\n break;\r\n case \"Leadership\".toLowerCase():\r\n task = CONSTANTS.ClassLeadership;\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"Invalid class name: \" + className + \". universityCourse() failed\");\r\n return false;\r\n }\r\n Player.startClass(costMult, expMult, task);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {\r\n workerScript.scriptRef.log(\"Started \" + task + \" at \" + universityName);\r\n }\r\n return true;\r\n },\r\n\r\n gymWorkout : function(gymName, stat) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"gymWorkout\", ramCost);\r\n }\r\n updateDynamicRam(\"gymWorkout\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: gymWorkout() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n var costMult, expMult;\r\n switch(gymName.toLowerCase()) {\r\n case Locations.AevumCrushFitnessGym.toLowerCase():\r\n if (Player.city != Locations.Aevum) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.AevumCrushFitnessGym;\r\n costMult = 3;\r\n expMult = 2;\r\n break;\r\n case Locations.AevumSnapFitnessGym.toLowerCase():\r\n if (Player.city != Locations.Aevum) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.AevumSnapFitnessGym;\r\n costMult = 10;\r\n expMult = 5;\r\n break;\r\n case Locations.Sector12IronGym.toLowerCase():\r\n if (Player.city != Locations.Sector12) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.Sector12IronGym;\r\n costMult = 1;\r\n expMult = 1;\r\n break;\r\n case Locations.Sector12PowerhouseGym.toLowerCase():\r\n if (Player.city != Locations.Sector12) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.Sector12PowerhouseGym;\r\n costMult = 20;\r\n expMult = 10;\r\n break;\r\n case Locations.VolhavenMilleniumFitnessGym:\r\n if (Player.city != Locations.Volhaven) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed\");\r\n return false;\r\n }\r\n Player.location = Locations.VolhavenMilleniumFitnessGym;\r\n costMult = 7;\r\n expMult = 4;\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"Invalid gym name: \" + gymName + \". gymWorkout() failed\");\r\n return false;\r\n }\r\n\r\n switch(stat.toLowerCase()) {\r\n case \"strength\".toLowerCase():\r\n case \"str\".toLowerCase():\r\n Player.startClass(costMult, expMult, CONSTANTS.ClassGymStrength);\r\n break;\r\n case \"defense\".toLowerCase():\r\n case \"def\".toLowerCase():\r\n Player.startClass(costMult, expMult, CONSTANTS.ClassGymDefense);\r\n break;\r\n case \"dexterity\".toLowerCase():\r\n case \"dex\".toLowerCase():\r\n Player.startClass(costMult, expMult, CONSTANTS.ClassGymDexterity);\r\n break;\r\n case \"agility\".toLowerCase():\r\n case \"agi\".toLowerCase():\r\n Player.startClass(costMult, expMult, CONSTANTS.ClassGymAgility);\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"Invalid stat: \" + stat + \". gymWorkout() failed\");\r\n return false;\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {\r\n workerScript.scriptRef.log(\"Started training \" + stat + \" at \" + gymName);\r\n }\r\n return true;\r\n },\r\n\r\n travelToCity(cityname) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"travelToCity\", ramCost);\r\n }\r\n updateDynamicRam(\"travelToCity\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n switch(cityname) {\r\n case Locations.Aevum:\r\n case Locations.Chongqing:\r\n case Locations.Sector12:\r\n case Locations.NewTokyo:\r\n case Locations.Ishima:\r\n case Locations.Volhaven:\r\n if(Player.money.lt(CONSTANTS.TravelCost)) {\r\n workerScript.scriptRef.log(\"ERROR: not enough money to travel with travelToCity().\");\r\n throw makeRuntimeRejectMsg(workerScript, \"ERROR: not enough money to travel with travelToCity().\");\r\n }\r\n Player.loseMoney(CONSTANTS.TravelCost);\r\n Player.city = cityname;\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {\r\n workerScript.scriptRef.log(\"Traveled to \" + cityname);\r\n }\r\n return true;\r\n default:\r\n workerScript.scriptRef.log(\"ERROR: Invalid city name passed into travelToCity().\");\r\n return false;\r\n }\r\n },\r\n\r\n purchaseTor() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"purchaseTor\", ramCost);\r\n }\r\n updateDynamicRam(\"purchaseTor\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (SpecialServerIps[\"Darkweb Server\"] != null) {\r\n workerScript.scriptRef.log(\"You already have a TOR router! purchaseTor() failed\");\r\n return false;\r\n }\r\n\r\n if (Player.money.lt(CONSTANTS.TorRouterCost)) {\r\n workerScript.scriptRef.log(\"ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed\");\r\n return false;\r\n }\r\n Player.loseMoney(CONSTANTS.TorRouterCost);\r\n\r\n var darkweb = new Server({\r\n ip:createRandomIp(), hostname:\"darkweb\", organizationName:\"\",\r\n isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1\r\n });\r\n AddToAllServers(darkweb);\r\n SpecialServerIps.addIp(\"Darkweb Server\", darkweb.ip);\r\n\r\n document.getElementById(\"location-purchase-tor\").setAttribute(\"class\", \"a-link-button-inactive\");\r\n\r\n Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);\r\n darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {\r\n workerScript.scriptRef.log(\"You have purchased a Tor router!\");\r\n }\r\n return true;\r\n },\r\n purchaseProgram(programName) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"purchaseProgram\", ramCost);\r\n }\r\n updateDynamicRam(\"purchaseProgram\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (SpecialServerIps[\"Darkweb Server\"] == null) {\r\n workerScript.scriptRef.log(\"ERROR: You do not have TOR router. purchaseProgram() failed.\");\r\n return false;\r\n }\r\n\r\n switch(programName.toLowerCase()) {\r\n case Programs.BruteSSHProgram.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the BruteSSH.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.FTPCrackProgram.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the FTPCrack.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.RelaySMTPProgram.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the relaySMTP.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.HTTPWormProgram.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.SQLInjectProgram.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the SQLInject.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.DeepscanV1.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.DeepscanV1);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n case Programs.DeepscanV2.toLowerCase():\r\n var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.DeepscanV2);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {\r\n workerScript.scriptRef.log(\"You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.\");\r\n }\r\n } else {\r\n workerScript.scriptRef.log(\"Not enough money to purchase \" + programName);\r\n return false;\r\n }\r\n return true;\r\n default:\r\n workerScript.scriptRef.log(\"ERROR: Invalid program passed into purchaseProgram().\");\r\n return false;\r\n }\r\n return true;\r\n },\r\n getStats : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost / 4;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getStats\", ramCost);\r\n }\r\n updateDynamicRam(\"getStats\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return {};\r\n }\r\n }\r\n\r\n return {\r\n hacking: Player.hacking_skill,\r\n strength: Player.strength,\r\n defense: Player.defense,\r\n dexterity: Player.dexterity,\r\n agility: Player.agility,\r\n charisma: Player.charisma,\r\n intelligence: Player.intelligence\r\n }\r\n },\r\n getCharacterInformation : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost / 4;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCharacterInformation\", ramCost);\r\n }\r\n updateDynamicRam(\"getCharacterInformation\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getCharacterInformation(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return {};\r\n }\r\n }\r\n\r\n var companyPositionTitle = \"\";\r\n if (Player.companyPosition instanceof CompanyPosition) {\r\n companyPositionTitle = Player.companyPosition.positionName;\r\n }\r\n return {\r\n bitnode: Player.bitNodeN,\r\n company: Player.companyName,\r\n jobTitle: companyPositionTitle,\r\n city: Player.city,\r\n factions: Player.factions.slice(),\r\n tor: SpecialServerIps.hasOwnProperty(\"Darkweb Server\"),\r\n timeWorked: Player.timeWorked,\r\n workHackExpGain: Player.workHackExpGained,\r\n workStrExpGain: Player.workStrExpGained,\r\n workDefExpGain: Player.workDefExpGained,\r\n workDexExpGain: Player.workDexExpGained,\r\n workAgiExpGain: Player.workAgiExpGained,\r\n workChaExpGain: Player.workChaExpGained,\r\n workRepGain: Player.workRepGained,\r\n workMoneyGain: Player.workMoneyGained,\r\n };\r\n },\r\n isBusy : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost / 4;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isBusy\", ramCost);\r\n }\r\n updateDynamicRam(\"isBusy\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return;\r\n }\r\n }\r\n return Player.isWorking;\r\n },\r\n stopAction : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn1RamCost / 2;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"stopAction\", ramCost);\r\n }\r\n updateDynamicRam(\"stopAction\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 1)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run stopAction(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.\");\r\n return false;\r\n }\r\n }\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n return true;\r\n }\r\n return false;\r\n },\r\n upgradeHomeRam : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"upgradeHomeRam\", ramCost);\r\n }\r\n updateDynamicRam(\"upgradeHomeRam\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n const cost = Player.getUpgradeHomeRamCost();\r\n\r\n if (Player.money.lt(cost)) {\r\n workerScript.scriptRef.log(\"ERROR: upgradeHomeRam() failed because you don't have enough money\");\r\n return false;\r\n }\r\n\r\n var homeComputer = Player.getHomeComputer();\r\n homeComputer.maxRam *= 2;\r\n\r\n Player.loseMoney(cost);\r\n\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {\r\n workerScript.scriptRef.log(\"Purchased additional RAM for home computer! It now has \" + homeComputer.maxRam + \"GB of RAM.\");\r\n }\r\n return true;\r\n },\r\n getUpgradeHomeRamCost : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost / 2;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getUpgradeHomeRamCost\", ramCost);\r\n }\r\n updateDynamicRam(\"getUpgradeHomeRamCost\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n return Player.getUpgradeHomeRamCost();\r\n },\r\n workForCompany : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"workForCompany\", ramCost);\r\n }\r\n updateDynamicRam(\"workForCompany\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: workForCompany() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n\r\n if (Player.companyPosition == \"\" || !(Player.companyPosition instanceof CompanyPosition)) {\r\n workerScript.scriptRef.log(\"ERROR: workForCompany() failed because you do not have a job\");\r\n return false;\r\n }\r\n\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n\r\n if (Player.companyPosition.isPartTimeJob()) {\r\n Player.startWorkPartTime();\r\n } else {\r\n Player.startWork();\r\n }\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {\r\n workerScript.scriptRef.log(\"Began working at \" + Player.companyName + \" as a \" + Player.companyPosition.positionName);\r\n }\r\n return true;\r\n },\r\n applyToCompany : function(companyName, field) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"applyToCompany\", ramCost);\r\n }\r\n updateDynamicRam(\"applyToCompany\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (!companyExists(companyName)) {\r\n workerScript.scriptRef.log(\"ERROR: applyToCompany() failed because specified company \" + companyName + \" does not exist.\");\r\n return false;\r\n }\r\n\r\n Player.location = companyName;\r\n var res;\r\n switch (field.toLowerCase()) {\r\n case \"software\":\r\n res = Player.applyForSoftwareJob(true);\r\n break;\r\n case \"software consultant\":\r\n res = Player.applyForSoftwareConsultantJob(true);\r\n break;\r\n case \"it\":\r\n res = Player.applyForItJob(true);\r\n break;\r\n case \"security engineer\":\r\n res = Player.applyForSecurityEngineerJob(true);\r\n break;\r\n case \"network engineer\":\r\n res = Player.applyForNetworkEngineerJob(true);\r\n break;\r\n case \"business\":\r\n res = Player.applyForBusinessJob(true);\r\n break;\r\n case \"business consultant\":\r\n res = Player.applyForBusinessConsultantJob(true);\r\n break;\r\n case \"security\":\r\n res = Player.applyForSecurityJob(true);\r\n break;\r\n case \"agent\":\r\n res = Player.applyForAgentJob(true);\r\n break;\r\n case \"employee\":\r\n res = Player.applyForEmployeeJob(true);\r\n break;\r\n case \"part-time employee\":\r\n res = Player.applyForPartTimeEmployeeJob(true);\r\n break;\r\n case \"waiter\":\r\n res = Player.applyForWaiterJob(true);\r\n break;\r\n case \"part-time waiter\":\r\n res = Player.applyForPartTimeWaiterJob(true);\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"ERROR: Invalid job passed into applyToCompany: \" + field + \". applyToCompany() failed\");\r\n return false;\r\n }\r\n //The Player object's applyForJob function can return string with special error messages\r\n if (isString(res)) {\r\n workerScript.scriptRef.log(res);\r\n return false;\r\n }\r\n if (res) {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {\r\n workerScript.scriptRef.log(\"You were offered a new job at \" + companyName + \" as a \" + Player.companyPosition.positionName);\r\n }\r\n } else {\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {\r\n workerScript.scriptRef.log(\"You failed to get a new job/promotion at \" + companyName + \" in the \" + field + \" field.\");\r\n }\r\n }\r\n return res;\r\n },\r\n getCompanyRep : function(companyName) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost / 2;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCompanyRep\", ramCost);\r\n }\r\n updateDynamicRam(\"getCompanyRep\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n var company = Companies[companyName];\r\n if (company == null || !(company instanceof Company)) {\r\n workerScript.scriptRef.log(\"ERROR: Invalid companyName passed into getCompanyRep(): \" + companyName);\r\n return -1;\r\n }\r\n return company.playerReputation;\r\n },\r\n getCompanyFavor : function(companyName) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost / 4;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCompanyFavor\", ramCost);\r\n }\r\n updateDynamicRam(\"getCompanyFavor\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getCompanyFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n var company = Companies[companyName];\r\n if (company == null || !(company instanceof Company)) {\r\n workerScript.scriptRef.log(\"ERROR: Invalid companyName passed into getCompanyFavor(): \" + companyName);\r\n return -1;\r\n }\r\n return company.favor;\r\n },\r\n checkFactionInvitations : function() {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"checkFactionInvitations\", ramCost);\r\n }\r\n updateDynamicRam(\"checkFactionInvitations\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n //Make a copy of Player.factionInvitations\r\n return Player.factionInvitations.slice();\r\n },\r\n joinFaction : function(name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"joinFaction\", ramCost);\r\n }\r\n updateDynamicRam(\"joinFaction\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (!factionExists(name)) {\r\n workerScript.scriptRef.log(\"ERROR: Faction specified in joinFaction() does not exist.\");\r\n return false;\r\n }\r\n\r\n if (!Player.factionInvitations.includes(name)) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot join \" + name + \" Faction because you have not been invited. joinFaction() failed\");\r\n return false;\r\n }\r\n\r\n var index = Player.factionInvitations.indexOf(name);\r\n if (index === -1) {\r\n //Redundant and should never happen...\r\n workerScript.scriptRef.log(\"ERROR: Cannot join \" + name + \" Faction because you have not been invited. joinFaction() failed\");\r\n return false;\r\n }\r\n Player.factionInvitations.splice(index, 1);\r\n var fac = Factions[name];\r\n joinFaction(fac);\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {\r\n workerScript.scriptRef.log(\"Joined the \" + name + \" faction.\");\r\n }\r\n return true;\r\n },\r\n workForFaction : function(name, type) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"workForFaction\", ramCost);\r\n }\r\n updateDynamicRam(\"workForFaction\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: workForFaction() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n\r\n if (!factionExists(name)) {\r\n workerScript.scriptRef.log(\"ERROR: Faction specified in workForFaction() does not exist.\");\r\n return false;\r\n }\r\n\r\n if (!Player.factions.includes(name)) {\r\n workerScript.scriptRef.log(\"ERROR: workForFaction() failed because you are not a member of \" + name);\r\n return false;\r\n }\r\n\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n\r\n var fac = Factions[name];\r\n //Arrays listing factions that allow each time of work\r\n var hackAvailable = [\"Illuminati\", \"Daedalus\", \"The Covenant\", \"ECorp\", \"MegaCorp\",\r\n \"Bachman & Associates\", \"Blade Industries\", \"NWO\", \"Clarke Incorporated\",\r\n \"OmniTek Incorporated\", \"Four Sigma\", \"KuaiGong International\",\r\n \"Fulcrum Secret Technologies\", \"BitRunners\", \"The Black Hand\",\r\n \"NiteSec\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Aevum\",\r\n \"Ishima\", \"Volhaven\", \"Speakers for the Dead\", \"The Dark Army\",\r\n \"The Syndicate\", \"Silhouette\", \"Netburners\", \"Tian Di Hui\", \"CyberSec\"];\r\n var fdWkAvailable = [\"Illuminati\", \"Daedalus\", \"The Covenant\", \"ECorp\", \"MegaCorp\",\r\n \"Bachman & Associates\", \"Blade Industries\", \"NWO\", \"Clarke Incorporated\",\r\n \"OmniTek Incorporated\", \"Four Sigma\", \"KuaiGong International\",\r\n \"The Black Hand\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Aevum\",\r\n \"Ishima\", \"Volhaven\", \"Speakers for the Dead\", \"The Dark Army\",\r\n \"The Syndicate\", \"Silhouette\", \"Tetrads\", \"Slum Snakes\"];\r\n var scWkAvailable = [\"ECorp\", \"MegaCorp\",\r\n \"Bachman & Associates\", \"Blade Industries\", \"NWO\", \"Clarke Incorporated\",\r\n \"OmniTek Incorporated\", \"Four Sigma\", \"KuaiGong International\",\r\n \"Fulcrum Secret Technologies\", \"Chongqing\", \"Sector-12\", \"New Tokyo\", \"Aevum\",\r\n \"Ishima\", \"Volhaven\", \"Speakers for the Dead\",\r\n \"The Syndicate\", \"Tetrads\", \"Slum Snakes\", \"Tian Di Hui\"];\r\n\r\n switch (type.toLowerCase()) {\r\n case \"hacking\":\r\n case \"hacking contracts\":\r\n case \"hackingcontracts\":\r\n if (!hackAvailable.includes(fac.name)) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot carry out hacking contracts for \" + fac.name + \". workForFaction() failed\");\r\n return false;\r\n }\r\n Player.startFactionHackWork(fac);\r\n workerScript.scriptRef.log(\"Started carrying out hacking contracts for \" + fac.name);\r\n return true;\r\n case \"field\":\r\n case \"fieldwork\":\r\n case \"field work\":\r\n if (!fdWkAvailable.includes(fac.name)) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot carry out field missions for \" + fac.name + \". workForFaction() failed\");\r\n return false;\r\n }\r\n Player.startFactionFieldWork(fac);\r\n workerScript.scriptRef.log(\"Started carrying out field missions for \" + fac.name);\r\n return true;\r\n case \"security\":\r\n case \"securitywork\":\r\n case \"security work\":\r\n if (!scWkAvailable.includes(fac.name)) {\r\n workerScript.scriptRef.log(\"ERROR: Cannot serve as security detail for \" + fac.name + \". workForFaction() failed\");\r\n return false;\r\n }\r\n Player.startFactionSecurityWork(fac);\r\n workerScript.scriptRef.log(\"Started serving as security details for \" + fac.name);\r\n return true;\r\n default:\r\n workerScript.scriptRef.log(\"ERROR: Invalid work type passed into workForFaction(): \" + type);\r\n }\r\n return true;\r\n },\r\n getFactionRep : function(name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost / 4;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getFactionRep\", ramCost);\r\n }\r\n updateDynamicRam(\"getFactionRep\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return -1;\r\n }\r\n }\r\n\r\n if (!factionExists(name)) {\r\n workerScript.scriptRef.log(\"ERROR: Faction specified in getFactionRep() does not exist.\");\r\n return -1;\r\n }\r\n\r\n return Factions[name].playerReputation;\r\n },\r\n getFactionFavor : function(name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getFactionFavor\", ramCost);\r\n }\r\n updateDynamicRam(\"getFactionFavor\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 2)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getFactionFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.\");\r\n return -1;\r\n }\r\n }\r\n\r\n if (!factionExists(name)) {\r\n workerScript.scriptRef.log(\"ERROR: Faction specified in getFactionFavor() does not exist.\");\r\n return -1;\r\n }\r\n\r\n return Factions[name].favor;\r\n },\r\n createProgram : function(name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"createProgram\", ramCost);\r\n }\r\n updateDynamicRam(\"createProgram\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return false;\r\n }\r\n }\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n\r\n switch(name.toLowerCase()) {\r\n case Programs.NukeProgram.toLowerCase():\r\n Player.startCreateProgramWork(Programs.NukeProgram, CONSTANTS.MillisecondsPerFiveMinutes, 1);\r\n break;\r\n case Programs.BruteSSHProgram.toLowerCase():\r\n if (Player.hacking_skill < 50) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.BruteSSHProgram, CONSTANTS.MillisecondsPerFiveMinutes * 2, 50);\r\n break;\r\n case Programs.FTPCrackProgram.toLowerCase():\r\n if (Player.hacking_skill < 100) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.FTPCrackProgram, CONSTANTS.MillisecondsPerHalfHour, 100);\r\n break;\r\n case Programs.RelaySMTPProgram.toLowerCase():\r\n if (Player.hacking_skill < 250) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.RelaySMTPProgram, CONSTANTS.MillisecondsPer2Hours, 250);\r\n break;\r\n case Programs.HTTPWormProgram.toLowerCase():\r\n if (Player.hacking_skill < 500) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.HTTPWormProgram, CONSTANTS.MillisecondsPer4Hours, 500);\r\n break;\r\n case Programs.SQLInjectProgram.toLowerCase():\r\n if (Player.hacking_skill < 750) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.SQLInjectProgram, CONSTANTS.MillisecondsPer8Hours, 750);\r\n break;\r\n case Programs.DeepscanV1.toLowerCase():\r\n if (Player.hacking_skill < 75) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.DeepscanV1, CONSTANTS.MillisecondsPerQuarterHour, 75);\r\n break;\r\n case Programs.DeepscanV2.toLowerCase():\r\n if (Player.hacking_skill < 400) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.DeepscanV2, CONSTANTS.MillisecondsPer2Hours, 400);\r\n break;\r\n case Programs.ServerProfiler.toLowerCase():\r\n if (Player.hacking_skill < 75) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.ServerProfiler, CONSTANTS.MillisecondsPerHalfHour, 75);\r\n break;\r\n case Programs.AutoLink.toLowerCase():\r\n if (Player.hacking_skill < 25) {\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)\");\r\n return false;\r\n }\r\n Player.startCreateProgramWork(Programs.AutoLink, CONSTANTS.MillisecondsPerQuarterHour, 25);\r\n break;\r\n default:\r\n workerScript.scriptRef.log(\"ERROR: createProgram() failed because the specified program does not exist: \" + name);\r\n return false;\r\n }\r\n workerScript.scriptRef.log(\"Began creating program: \" + name);\r\n return true;\r\n },\r\n commitCrime : function(crimeRoughName) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"commitCrime\", ramCost);\r\n }\r\n updateDynamicRam(\"commitCrime\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return;\r\n }\r\n }\r\n if (inMission) {\r\n workerScript.scriptRef.log(\"ERROR: commitCrime() failed because you are in the middle of a mission.\");\r\n return;\r\n }\r\n if (Player.isWorking) {\r\n var txt = Player.singularityStopWork();\r\n if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {\r\n workerScript.scriptRef.log(txt);\r\n }\r\n }\r\n\r\n //Set Location to slums\r\n switch(Player.city) {\r\n case Locations.Aevum:\r\n Player.location = Locations.AevumSlums;\r\n break;\r\n case Locations.Chongqing:\r\n Player.location = Locations.ChongqingSlums;\r\n break;\r\n case Locations.Sector12:\r\n Player.location = Locations.Sector12Slums;\r\n break;\r\n case Locations.NewTokyo:\r\n Player.location = Locations.NewTokyoSlums;\r\n break;\r\n case Locations.Ishima:\r\n Player.location = Locations.IshimaSlums;\r\n break;\r\n case Locations.Volhaven:\r\n Player.location = Locations.VolhavenSlums;\r\n break;\r\n default:\r\n console.log(\"Invalid Player.city value\");\r\n }\r\n\r\n const crime = findCrime(crimeRoughName.toLowerCase());\r\n if(crime == null) { // couldn't find crime\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid crime passed into commitCrime(): \" + crime);\r\n }\r\n if(workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {\r\n workerScript.scriptRef.log(\"Attempting to commit crime: \"+crime.name+\"...\");\r\n }\r\n return crime.commit(CONSTANTS.CrimeSingFnDivider, {workerscript: workerScript});\r\n },\r\n getCrimeChance : function(crimeRoughName) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCrimeChance\", ramCost);\r\n }\r\n updateDynamicRam(\"getCrimeChance\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return;\r\n }\r\n }\r\n\r\n const crime = findCrime(crimeRoughName.toLowerCase());\r\n if(crime == null) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Invalid crime passed into getCrimeChance(): \" + crime);\r\n }\r\n\r\n return crime.successRate();\r\n },\r\n getOwnedAugmentations : function(purchased=false) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getOwnedAugmentations\", ramCost);\r\n }\r\n updateDynamicRam(\"getOwnedAugmentations\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return [];\r\n }\r\n }\r\n var res = [];\r\n for (var i = 0; i < Player.augmentations.length; ++i) {\r\n res.push(Player.augmentations[i].name);\r\n }\r\n if (purchased) {\r\n for (var i = 0; i < Player.queuedAugmentations.length; ++i) {\r\n res.push(Player.queuedAugmentations[i].name);\r\n }\r\n }\r\n return res;\r\n },\r\n getAugmentationsFromFaction : function(facname) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getAugmentationsFromFaction\", ramCost);\r\n }\r\n updateDynamicRam(\"getAugmentationsFromFaction\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return [];\r\n }\r\n }\r\n\r\n if (!factionExists(facname)) {\r\n workerScript.scriptRef.log(\"ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): \" + facname);\r\n return [];\r\n }\r\n\r\n var fac = Factions[facname];\r\n var res = [];\r\n for (var i = 0; i < fac.augmentations.length; ++i) {\r\n res.push(fac.augmentations[i]);\r\n }\r\n return res;\r\n },\r\n getAugmentationCost : function(name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getAugmentationCost\", ramCost);\r\n }\r\n updateDynamicRam(\"getAugmentationCost\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (!augmentationExists(name)) {\r\n workerScript.scriptRef.log(\"ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): \" + name);\r\n return [-1, -1];\r\n }\r\n\r\n var aug = Augmentations[name];\r\n return [aug.baseRepRequirement, aug.baseCost];\r\n },\r\n purchaseAugmentation : function(faction, name) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"purchaseAugmentation\", ramCost);\r\n }\r\n updateDynamicRam(\"purchaseAugmentation\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n var fac = Factions[faction];\r\n if (fac == null || !(fac instanceof Faction)) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because of invalid faction name: \" + faction);\r\n return false;\r\n }\r\n\r\n if (!fac.augmentations.includes(name)) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because the faction \" + faction + \" does not contain the \" + name + \" augmentation\");\r\n return false;\r\n }\r\n\r\n var aug = Augmentations[name];\r\n if (aug == null || !(aug instanceof Augmentation)) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because of invalid augmentation name: \" + name);\r\n return false;\r\n }\r\n\r\n var isNeuroflux = false;\r\n if (aug.name === AugmentationNames.NeuroFluxGovernor) {\r\n isNeuroflux = true;\r\n }\r\n\r\n if (!isNeuroflux) {\r\n for (var j = 0; j < Player.queuedAugmentations.length; ++j) {\r\n if (Player.queuedAugmentations[j].name === aug.name) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because you already have \" + name);\r\n return false;\r\n }\r\n }\r\n for (var j = 0; j < Player.augmentations.length; ++j) {\r\n if (Player.augmentations[j].name === aug.name) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because you already have \" + name);\r\n return false;\r\n }\r\n }\r\n }\r\n\r\n if (fac.playerReputation < aug.baseRepRequirement) {\r\n workerScript.scriptRef.log(\"ERROR: purchaseAugmentation() failed because you do not have enough reputation with \" + fac.name);\r\n return false;\r\n }\r\n\r\n var res = purchaseAugmentation(aug, fac, true);\r\n workerScript.scriptRef.log(res);\r\n if (isString(res) && res.startsWith(\"You purchased\")) {\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n },\r\n installAugmentations : function(cbScript) {\r\n var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;\r\n if (Player.bitNodeN !== 4) {ramCost *= 8;}\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"installAugmentations\", ramCost);\r\n }\r\n updateDynamicRam(\"installAugmentations\", ramCost);\r\n if (Player.bitNodeN != 4) {\r\n if (!(hasSingularitySF && singularitySFLvl >= 3)) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.\");\r\n return false;\r\n }\r\n }\r\n\r\n if (Player.queuedAugmentations.length === 0) {\r\n workerScript.scriptRef.log(\"ERROR: installAugmentations() failed because you do not have any Augmentations to be installed\");\r\n return false;\r\n }\r\n Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);\r\n workerScript.scriptRef.log(\"Installing Augmentations. This will cause this script to be killed\");\r\n installAugmentations(cbScript);\r\n return true;\r\n },\r\n\r\n //Bladeburner API\r\n bladeburner : {\r\n isContractName : function(name) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isContractName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n }\r\n updateDynamicRam(\"isContractName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.isContractNameNetscriptFn(name);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n isOperationName : function(name) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isOperationName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n }\r\n updateDynamicRam(\"isOperationName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.isOperationNameNetscriptFn(name);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"isOperationName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n isBlackOpName : function(name) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isBlackOpName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n }\r\n updateDynamicRam(\"isBlackOpName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.isBlackOpNameNetscriptFn(name);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"isBlackOpName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n isGeneralActionName : function(name) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isGeneralActionName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n }\r\n updateDynamicRam(\"isGeneralActionName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.isGeneralActionNameNetscriptFn(name);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"isGeneralActionName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n isSkillName : function(name) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"isSkillName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n }\r\n updateDynamicRam(\"isSkillName\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 10);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.isSkillNameNetscriptFn(name);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"isSkillName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n startAction : function(type=\"\", name=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"startAction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"startAction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.startActionNetscriptFn(type, name, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.startAction() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"startAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n stopAction : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"stopAction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);\r\n }\r\n updateDynamicRam(\"stopAction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost / 2);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.resetAction();\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"stopAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getActionTime : function(type=\"\", name=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getActionTime\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getActionTime\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getActionTimeNetscriptFn(type, name, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getActionTime() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getActionTime() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getActionEstimatedSuccessChance : function(type=\"\", name=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getActionEstimatedSuccessChance\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getActionEstimatedSuccessChance\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getActionEstimatedSuccessChanceNetscriptFn(type, name, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getActionEstimatedSuccessChance() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getActionEstimatedSuccessChance() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getActionCountRemaining : function(type=\"\", name=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getActionCountRemaining\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getActionCountRemaining\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getActionCountRemainingNetscriptFn(type, name, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getActionCountRemaining() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getActionCountRemaining() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getRank : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getRank\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getRank\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.rank;\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getRank() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getSkillPoints : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getSkillPoints\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getSkillPoints\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.skillPoints;\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getSkillPoints() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getSkillLevel : function(skillName=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getSkillLevel\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getSkillLevel\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getSkillLevelNetscriptFn(skillName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getSkillLevel() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getSkillLevel() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n upgradeSkill : function(skillName) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"upgradeSkill\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"upgradeSkill\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.upgradeSkillNetscriptFn(skillName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.upgradeSkill() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"upgradeSkill() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getTeamSize : function(type=\"\", name=\"\") {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getTeamSize\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getTeamSize\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getTeamSizeNetscriptFn(type, name, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getTeamSize() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getTeamSize() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n setTeamSize : function(type=\"\", name=\"\", size) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"setTeamSize\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"setTeamSize\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.setTeamSizeNetscriptFn(type, name, size, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.setTeamSize() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"setTeamSize() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getCityEstimatedPopulation : function(cityName) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCityEstimatedPopulation\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getCityEstimatedPopulation\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getCityEstimatedPopulationNetscriptFn(cityName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getCityEstimatedPopulation() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getCityEstimatedPopulation() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getCityEstimatedCommunities : function(cityName) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCityEstimatedCommunities\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getCityEstimatedCommunities\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getCityEstimatedCommunitiesNetscriptFn(cityName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getCityEstimatedCommunities() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getCityEstimatedCommunities() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getCityChaos : function(cityName) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getCityChaos\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getCityChaos\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.getCityChaosNetscriptFn(cityName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.getCityChaos() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getCityChaos() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n switchCity : function(cityName) {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"switchCity\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"switchCity\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n try {\r\n return Player.bladeburner.switchCityNetscriptFn(cityName, workerScript);\r\n } catch(e) {\r\n throw makeRuntimeRejectMsg(workerScript, \"Bladeburner.switchCity() failed with exception: \" + e);\r\n }\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"switchCity() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n getStamina : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"getStamina\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"getStamina\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return [Player.bladeburner.stamina, Player.bladeburner.maxStamina];\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"getStamina() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n },\r\n joinBladeburnerFaction : function() {\r\n if (workerScript.checkingRam) {\r\n return updateStaticRam(\"joinBladeburnerFaction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n }\r\n updateDynamicRam(\"joinBladeburnerFaction\", CONSTANTS.ScriptBladeburnerApiBaseRamCost);\r\n if (Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || hasBladeburner2079SF)) {\r\n return Player.bladeburner.joinBladeburnerFactionNetscriptFn(workerScript);\r\n }\r\n throw makeRuntimeRejectMsg(workerScript, \"joinBladeburnerFaction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed \" +\r\n \"at the Bladeburner division or because you do not have Source-File 7\");\r\n }\r\n }\r\n } //End return\r\n} //End NetscriptFunction()\r\n\r\nexport {NetscriptFunctions, initSingularitySFFlags, hasSingularitySF, hasBn11SF,\r\n hasWallStreetSF, wallStreetSFLvl, hasCorporationSF, hasAISF, hasBladeburnerSF};\r\n","'use strict';\n\nvar support = require('./support');\nvar base64 = require('./base64');\nvar nodejsUtils = require('./nodejsUtils');\nvar setImmediate = require('core-js/library/fn/set-immediate');\nvar external = require(\"./external\");\n\n\n/**\n * Convert a string that pass as a \"binary string\": it should represent a byte\n * array but may have > 255 char codes. Be sure to take only the first byte\n * and returns the byte array.\n * @param {String} str the string to transform.\n * @return {Array|Uint8Array} the string in a binary format.\n */\nfunction string2binary(str) {\n var result = null;\n if (support.uint8array) {\n result = new Uint8Array(str.length);\n } else {\n result = new Array(str.length);\n }\n return stringToArrayLike(str, result);\n}\n\n/**\n * Create a new blob with the given content and the given type.\n * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use\n * an Uint8Array because the stock browser of android 4 won't accept it (it\n * will be silently converted to a string, \"[object Uint8Array]\").\n *\n * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:\n * when a large amount of Array is used to create the Blob, the amount of\n * memory consumed is nearly 100 times the original data amount.\n *\n * @param {String} type the mime type of the blob.\n * @return {Blob} the created blob.\n */\nexports.newBlob = function(part, type) {\n exports.checkSupport(\"blob\");\n\n try {\n // Blob constructor\n return new Blob([part], {\n type: type\n });\n }\n catch (e) {\n\n try {\n // deprecated, browser only, old way\n var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n var builder = new Builder();\n builder.append(part);\n return builder.getBlob(type);\n }\n catch (e) {\n\n // well, fuck ?!\n throw new Error(\"Bug : can't construct the Blob.\");\n }\n }\n\n\n};\n/**\n * The identity function.\n * @param {Object} input the input.\n * @return {Object} the same input.\n */\nfunction identity(input) {\n return input;\n}\n\n/**\n * Fill in an array with a string.\n * @param {String} str the string to use.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.\n */\nfunction stringToArrayLike(str, array) {\n for (var i = 0; i < str.length; ++i) {\n array[i] = str.charCodeAt(i) & 0xFF;\n }\n return array;\n}\n\n/**\n * An helper for the function arrayLikeToString.\n * This contains static informations and functions that\n * can be optimized by the browser JIT compiler.\n */\nvar arrayToStringHelper = {\n /**\n * Transform an array of int into a string, chunk by chunk.\n * See the performances notes on arrayLikeToString.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @param {String} type the type of the array.\n * @param {Integer} chunk the chunk size.\n * @return {String} the resulting string.\n * @throws Error if the chunk is too big for the stack.\n */\n stringifyByChunk: function(array, type, chunk) {\n var result = [], k = 0, len = array.length;\n // shortcut\n if (len <= chunk) {\n return String.fromCharCode.apply(null, array);\n }\n while (k < len) {\n if (type === \"array\" || type === \"nodebuffer\") {\n result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));\n }\n else {\n result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));\n }\n k += chunk;\n }\n return result.join(\"\");\n },\n /**\n * Call String.fromCharCode on every item in the array.\n * This is the naive implementation, which generate A LOT of intermediate string.\n * This should be used when everything else fail.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\n stringifyByChar: function(array){\n var resultStr = \"\";\n for(var i = 0; i < array.length; i++) {\n resultStr += String.fromCharCode(array[i]);\n }\n return resultStr;\n },\n applyCanBeUsed : {\n /**\n * true if the browser accepts to use String.fromCharCode on Uint8Array\n */\n uint8array : (function () {\n try {\n return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;\n } catch (e) {\n return false;\n }\n })(),\n /**\n * true if the browser accepts to use String.fromCharCode on nodejs Buffer.\n */\n nodebuffer : (function () {\n try {\n return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;\n } catch (e) {\n return false;\n }\n })()\n }\n};\n\n/**\n * Transform an array-like object to a string.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\nfunction arrayLikeToString(array) {\n // Performances notes :\n // --------------------\n // String.fromCharCode.apply(null, array) is the fastest, see\n // see http://jsperf.com/converting-a-uint8array-to-a-string/2\n // but the stack is limited (and we can get huge arrays !).\n //\n // result += String.fromCharCode(array[i]); generate too many strings !\n //\n // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2\n // TODO : we now have workers that split the work. Do we still need that ?\n var chunk = 65536,\n type = exports.getTypeOf(array),\n canUseApply = true;\n if (type === \"uint8array\") {\n canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;\n } else if (type === \"nodebuffer\") {\n canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;\n }\n\n if (canUseApply) {\n while (chunk > 1) {\n try {\n return arrayToStringHelper.stringifyByChunk(array, type, chunk);\n } catch (e) {\n chunk = Math.floor(chunk / 2);\n }\n }\n }\n\n // no apply or chunk error : slow and painful algorithm\n // default browser on android 4.*\n return arrayToStringHelper.stringifyByChar(array);\n}\n\nexports.applyFromCharCode = arrayLikeToString;\n\n\n/**\n * Copy the data from an array-like to an other array-like.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.\n */\nfunction arrayLikeToArrayLike(arrayFrom, arrayTo) {\n for (var i = 0; i < arrayFrom.length; i++) {\n arrayTo[i] = arrayFrom[i];\n }\n return arrayTo;\n}\n\n// a matrix containing functions to transform everything into everything.\nvar transform = {};\n\n// string to ?\ntransform[\"string\"] = {\n \"string\": identity,\n \"array\": function(input) {\n return stringToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return transform[\"string\"][\"uint8array\"](input).buffer;\n },\n \"uint8array\": function(input) {\n return stringToArrayLike(input, new Uint8Array(input.length));\n },\n \"nodebuffer\": function(input) {\n return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));\n }\n};\n\n// array to ?\ntransform[\"array\"] = {\n \"string\": arrayLikeToString,\n \"array\": identity,\n \"arraybuffer\": function(input) {\n return (new Uint8Array(input)).buffer;\n },\n \"uint8array\": function(input) {\n return new Uint8Array(input);\n },\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(input);\n }\n};\n\n// arraybuffer to ?\ntransform[\"arraybuffer\"] = {\n \"string\": function(input) {\n return arrayLikeToString(new Uint8Array(input));\n },\n \"array\": function(input) {\n return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));\n },\n \"arraybuffer\": identity,\n \"uint8array\": function(input) {\n return new Uint8Array(input);\n },\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(new Uint8Array(input));\n }\n};\n\n// uint8array to ?\ntransform[\"uint8array\"] = {\n \"string\": arrayLikeToString,\n \"array\": function(input) {\n return arrayLikeToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return input.buffer;\n },\n \"uint8array\": identity,\n \"nodebuffer\": function(input) {\n return nodejsUtils.newBufferFrom(input);\n }\n};\n\n// nodebuffer to ?\ntransform[\"nodebuffer\"] = {\n \"string\": arrayLikeToString,\n \"array\": function(input) {\n return arrayLikeToArrayLike(input, new Array(input.length));\n },\n \"arraybuffer\": function(input) {\n return transform[\"nodebuffer\"][\"uint8array\"](input).buffer;\n },\n \"uint8array\": function(input) {\n return arrayLikeToArrayLike(input, new Uint8Array(input.length));\n },\n \"nodebuffer\": identity\n};\n\n/**\n * Transform an input into any type.\n * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.\n * If no output type is specified, the unmodified input will be returned.\n * @param {String} outputType the output type.\n * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.\n * @throws {Error} an Error if the browser doesn't support the requested output type.\n */\nexports.transformTo = function(outputType, input) {\n if (!input) {\n // undefined, null, etc\n // an empty string won't harm.\n input = \"\";\n }\n if (!outputType) {\n return input;\n }\n exports.checkSupport(outputType);\n var inputType = exports.getTypeOf(input);\n var result = transform[inputType][outputType](input);\n return result;\n};\n\n/**\n * Return the type of the input.\n * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.\n * @param {Object} input the input to identify.\n * @return {String} the (lowercase) type of the input.\n */\nexports.getTypeOf = function(input) {\n if (typeof input === \"string\") {\n return \"string\";\n }\n if (Object.prototype.toString.call(input) === \"[object Array]\") {\n return \"array\";\n }\n if (support.nodebuffer && nodejsUtils.isBuffer(input)) {\n return \"nodebuffer\";\n }\n if (support.uint8array && input instanceof Uint8Array) {\n return \"uint8array\";\n }\n if (support.arraybuffer && input instanceof ArrayBuffer) {\n return \"arraybuffer\";\n }\n};\n\n/**\n * Throw an exception if the type is not supported.\n * @param {String} type the type to check.\n * @throws {Error} an Error if the browser doesn't support the requested type.\n */\nexports.checkSupport = function(type) {\n var supported = support[type.toLowerCase()];\n if (!supported) {\n throw new Error(type + \" is not supported by this platform\");\n }\n};\n\nexports.MAX_VALUE_16BITS = 65535;\nexports.MAX_VALUE_32BITS = -1; // well, \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\" is parsed as -1\n\n/**\n * Prettify a string read as binary.\n * @param {string} str the string to prettify.\n * @return {string} a pretty string.\n */\nexports.pretty = function(str) {\n var res = '',\n code, i;\n for (i = 0; i < (str || \"\").length; i++) {\n code = str.charCodeAt(i);\n res += '\\\\x' + (code < 16 ? \"0\" : \"\") + code.toString(16).toUpperCase();\n }\n return res;\n};\n\n/**\n * Defer the call of a function.\n * @param {Function} callback the function to call asynchronously.\n * @param {Array} args the arguments to give to the callback.\n */\nexports.delay = function(callback, args, self) {\n setImmediate(function () {\n callback.apply(self || null, args || []);\n });\n};\n\n/**\n * Extends a prototype with an other, without calling a constructor with\n * side effects. Inspired by nodejs' `utils.inherits`\n * @param {Function} ctor the constructor to augment\n * @param {Function} superCtor the parent constructor to use\n */\nexports.inherits = function (ctor, superCtor) {\n var Obj = function() {};\n Obj.prototype = superCtor.prototype;\n ctor.prototype = new Obj();\n};\n\n/**\n * Merge the objects passed as parameters into a new one.\n * @private\n * @param {...Object} var_args All objects to merge.\n * @return {Object} a new object with the data of the others.\n */\nexports.extend = function() {\n var result = {}, i, attr;\n for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers\n for (attr in arguments[i]) {\n if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === \"undefined\") {\n result[attr] = arguments[i][attr];\n }\n }\n }\n return result;\n};\n\n/**\n * Transform arbitrary content into a Promise.\n * @param {String} name a name for the content being processed.\n * @param {Object} inputData the content to process.\n * @param {Boolean} isBinary true if the content is not an unicode string\n * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.\n * @param {Boolean} isBase64 true if the string content is encoded with base64.\n * @return {Promise} a promise in a format usable by JSZip.\n */\nexports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {\n\n // if inputData is already a promise, this flatten it.\n var promise = external.Promise.resolve(inputData).then(function(data) {\n \n \n var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);\n\n if (isBlob && typeof FileReader !== \"undefined\") {\n return new external.Promise(function (resolve, reject) {\n var reader = new FileReader();\n\n reader.onload = function(e) {\n resolve(e.target.result);\n };\n reader.onerror = function(e) {\n reject(e.target.error);\n };\n reader.readAsArrayBuffer(data);\n });\n } else {\n return data;\n }\n });\n\n return promise.then(function(data) {\n var dataType = exports.getTypeOf(data);\n\n if (!dataType) {\n return external.Promise.reject(\n new Error(\"Can't read the data of '\" + name + \"'. Is it \" +\n \"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?\")\n );\n }\n // special case : it's way easier to work with Uint8Array than with ArrayBuffer\n if (dataType === \"arraybuffer\") {\n data = exports.transformTo(\"uint8array\", data);\n } else if (dataType === \"string\") {\n if (isBase64) {\n data = base64.decode(data);\n }\n else if (isBinary) {\n // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask\n if (isOptimizedBinaryString !== true) {\n // this is a string, not in a base64 format.\n // Be sure that this is a correct \"binary string\"\n data = string2binary(data);\n }\n }\n }\n return data;\n });\n};\n","import {parse, Node} from \"../utils/acorn.js\";\r\n\r\nvar FconfSettings = {\r\n ENABLE_BASH_HOTKEYS: false,\r\n ENABLE_TIMESTAMPS: false,\r\n}\r\n\r\nvar FconfComments = {\r\n ENABLE_BASH_HOTKEYS: \"Improved Bash emulation mode. Setting this to 1 enables several\\n\" +\r\n \"new Terminal shortcuts and features that more closely resemble\\n\" +\r\n \"a real Bash-style shell. Note that when this mode is enabled,\\n\" +\r\n \"the default browser shortcuts are overriden by the new Bash\\n\" +\r\n \"shortcuts.\\n\\n\" +\r\n \"To see a full list of the Terminal shortcuts that this enables, see:\\n\" +\r\n \"http://bitburner.readthedocs.io/en/latest/shortcuts.html\",\r\n ENABLE_TIMESTAMPS: \"Terminal commands and log entries will be timestamped. The timestamp\\n\" +\r\n \"will have the format: M/D h:m\",\r\n}\r\n\r\n//Parse Fconf settings from the config text\r\n//Throws an exception if parsing fails\r\nfunction parseFconfSettings(config) {\r\n var ast = parse(config, {sourceType:\"module\"});\r\n var queue = [];\r\n queue.push(ast);\r\n while (queue.length != 0) {\r\n var exp = queue.shift();\r\n switch (exp.type) {\r\n case \"BlockStatement\":\r\n case \"Program\":\r\n for (var i = 0; i < exp.body.length; ++i) {\r\n if (exp.body[i] instanceof Node) {\r\n queue.push(exp.body[i]);\r\n }\r\n }\r\n break;\r\n case \"AssignmentExpression\":\r\n var setting, value;\r\n if (exp.left != null && exp.left.name != null) {\r\n setting = exp.left.name;\r\n } else {\r\n break;\r\n }\r\n if (exp.right != null && exp.right.raw != null) {\r\n value = exp.right.raw;\r\n } else {\r\n break;\r\n }\r\n parseFconfSetting(setting, value);\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n for (var prop in exp) {\r\n if (exp.hasOwnProperty(prop)) {\r\n if (exp[prop] instanceof Node) {\r\n queue.push(exp[prop]);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction parseFconfSetting(setting, value) {\r\n setting = String(setting);\r\n value = String(value);\r\n if (setting == null || value == null || FconfSettings[setting] == null) {\r\n console.log(\"WARNING: Invalid .fconf setting: \" + setting);\r\n return;\r\n }\r\n\r\n //Needed to convert entered value to boolean/strings accordingly\r\n switch(setting) {\r\n case \"ENABLE_BASH_HOTKEYS\":\r\n case \"ENABLE_TIMESTAMPS\":\r\n var value = value.toLowerCase();\r\n if (value === \"1\" || value === \"true\" || value === \"y\") {\r\n value = true;\r\n } else {\r\n value = false;\r\n }\r\n FconfSettings[setting] = value;\r\n break;\r\n default:\r\n break;\r\n }\r\n return;\r\n}\r\n\r\n//Create the .fconf file text from the settings\r\nfunction createFconf() {\r\n var res = \"\";\r\n for (var setting in FconfSettings) {\r\n if (FconfSettings.hasOwnProperty(setting)) {\r\n //Setting comments (description)\r\n var comment = FconfComments[setting];\r\n if (comment == null) {continue;}\r\n var comment = comment.split(\"\\n\");\r\n for (var i = 0; i < comment.length; ++i) {\r\n res += (\"//\" + comment[i] + \"\\n\");\r\n }\r\n\r\n var value = 0;\r\n if (FconfSettings[setting] === true) {\r\n value = \"1\";\r\n } else if (FconfSettings[setting] === false) {\r\n value = \"0\";\r\n } else {\r\n value = String(FconfSettings[setting]);\r\n }\r\n res += (setting + \"=\" + value + \"\\n\\n\");\r\n }\r\n }\r\n return res;\r\n}\r\n\r\nfunction loadFconf(saveString) {\r\n let tempFconfSettings = JSON.parse(saveString);\r\n for (var setting in tempFconfSettings) {\r\n if (tempFconfSettings.hasOwnProperty(setting)) {\r\n FconfSettings[setting] = tempFconfSettings[setting];\r\n }\r\n }\r\n}\r\n\r\nexport {FconfSettings, createFconf, parseFconfSettings, loadFconf}\r\n","import {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {displayFactionContent} from \"./Faction.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {addOffset, getRandomInt,\r\n clearEventListenersEl,\r\n clearEventListeners} from \"../utils/HelperFunctions.js\";\r\nimport {formatNumber, isString} from \"../utils/StringHelperFunctions.js\";\r\nimport jsplumb from 'jsplumb'\r\n\r\nlet inMission = false; //Flag to denote whether a mission is running\r\nlet currMission = null;\r\nfunction setInMission(bool, mission) {\r\n inMission = bool;\r\n if (bool) {\r\n currMission = mission;\r\n } else {\r\n currMission = null;\r\n }\r\n}\r\n\r\n//Keyboard shortcuts\r\n$(document).keydown(function(e) {\r\n if (inMission && currMission && currMission.selectedNode.length != 0) {\r\n switch (e.keyCode) {\r\n case 65: //a for Attack\r\n currMission.actionButtons[0].click();\r\n break;\r\n case 83: //s for Scan\r\n currMission.actionButtons[1].click();\r\n break;\r\n case 87: //w for Weaken\r\n currMission.actionButtons[2].click();\r\n break;\r\n case 70: //f for Fortify\r\n currMission.actionButtons[3].click();\r\n break;\r\n case 82: //r for Overflow\r\n currMission.actionButtons[4].click();\r\n break;\r\n case 68: //d for Detach connection\r\n currMission.actionButtons[5].click();\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n});\r\n\r\nlet NodeTypes = {\r\n Core: \"CPU Core Node\", //All actions available\r\n Firewall: \"Firewall Node\", //No actions available\r\n Database: \"Database Node\", //No actions available\r\n Spam: \"Spam Node\", //No actions Available\r\n Transfer: \"Transfer Node\", //Can Weaken, Scan, Fortify and Overflow\r\n Shield: \"Shield Node\" //Can Fortify\r\n}\r\n\r\nlet NodeActions = {\r\n Attack: \"Attacking\", //Damaged based on attack stat + hacking level + opp def\r\n Scan: \"Scanning\", //-Def for target, affected by attack and hacking level\r\n Weaken: \"Weakening\", //-Attack for target, affected by attack and hacking level\r\n Fortify: \"Fortifying\", //+Defense for Node, affected by hacking level\r\n Overflow: \"Overflowing\", //+Attack but -Defense for Node, affected by hacking level\r\n}\r\n\r\nfunction Node(type, stats) {\r\n this.type = type;\r\n this.atk = stats.atk ? stats.atk : 0;\r\n this.def = stats.def ? stats.def : 0;\r\n this.hp = stats.hp ? stats.hp : 0;\r\n this.maxhp = this.hp;\r\n this.plyrCtrl = false;\r\n this.enmyCtrl = false;\r\n this.pos = [0, 0]; //x, y\r\n this.el = null; //Holds the Node's DOM element\r\n this.action = null;\r\n this.targetedCount = 0; //Count of how many connections this node is the target of\r\n\r\n //Holds the JsPlumb Connection object for this Node,\r\n //where this Node is the Source (since each Node\r\n //can only have 1 outgoing Connection)\r\n this.conn = null;\r\n}\r\n\r\nNode.prototype.setPosition = function(x, y) {\r\n this.pos = [x, y];\r\n}\r\n\r\nNode.prototype.setControlledByPlayer = function() {\r\n this.plyrCtrl = true;\r\n this.enmyCtrl = false;\r\n if (this.el) {\r\n this.el.classList.remove(\"hack-mission-enemy-node\");\r\n this.el.classList.add(\"hack-mission-player-node\");\r\n }\r\n}\r\n\r\nNode.prototype.setControlledByEnemy = function() {\r\n this.plyrCtrl = false;\r\n this.enmyCtrl = true;\r\n if (this.el) {\r\n this.el.classList.remove(\"hack-mission-player-node\");\r\n this.el.classList.add(\"hack-mission-enemy-node\");\r\n }\r\n}\r\n\r\n//Sets this node to be the active node\r\nNode.prototype.select = function(actionButtons) {\r\n if (this.enmyCtrl) {return;}\r\n this.el.classList.add(\"hack-mission-player-node-active\");\r\n\r\n //Make all buttons inactive\r\n for (var i = 0; i < actionButtons.length; ++i) {\r\n actionButtons[i].classList.remove(\"a-link-button\");\r\n actionButtons[i].classList.add(\"a-link-button-inactive\");\r\n }\r\n\r\n switch(this.type) {\r\n case NodeTypes.Core:\r\n //All buttons active\r\n for (var i = 0; i < actionButtons.length; ++i) {\r\n actionButtons[i].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[i].classList.add(\"a-link-button\");\r\n }\r\n break;\r\n case NodeTypes.Transfer:\r\n actionButtons[1].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[1].classList.add(\"a-link-button\");\r\n actionButtons[2].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[2].classList.add(\"a-link-button\");\r\n actionButtons[3].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[3].classList.add(\"a-link-button\");\r\n actionButtons[4].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[4].classList.add(\"a-link-button\");\r\n actionButtons[5].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[5].classList.add(\"a-link-button\");\r\n break;\r\n case NodeTypes.Shield:\r\n case NodeTypes.Firewall:\r\n actionButtons[3].classList.remove(\"a-link-button-inactive\");\r\n actionButtons[3].classList.add(\"a-link-button\");\r\n break;\r\n default:\r\n break;\r\n }\r\n}\r\n\r\nNode.prototype.deselect = function(actionButtons) {\r\n this.el.classList.remove(\"hack-mission-player-node-active\");\r\n for (var i = 0; i < actionButtons.length; ++i) {\r\n actionButtons[i].classList.remove(\"a-link-button\");\r\n actionButtons[i].classList.add(\"a-link-button-inactive\");\r\n }\r\n}\r\n\r\n\r\nNode.prototype.untarget = function() {\r\n if (this.targetedCount === 0) {\r\n console.log(\"WARN: Node \" + this.el.id + \" is being 'untargeted' when it has no target count\");\r\n return;\r\n }\r\n --this.targetedCount;\r\n}\r\n\r\n//Hacking mission instance\r\n//Takes in the reputation of the Faction for which the mission is\r\n//being conducted\r\nfunction HackingMission(rep, fac) {\r\n this.faction = fac;\r\n\r\n this.started = false;\r\n this.time = 180000; //5 minutes to start, milliseconds\r\n\r\n this.playerCores = [];\r\n this.playerNodes = []; //Non-core nodes\r\n this.playerAtk = 0;\r\n this.playerDef = 0;\r\n\r\n this.enemyCores = [];\r\n this.enemyDatabases = [];\r\n this.enemyNodes = []; //Non-core nodes\r\n this.enemyAtk = 0;\r\n this.enemyDef = 0;\r\n\r\n this.miscNodes = [];\r\n\r\n this.selectedNode = []; //Which of the player's nodes are currently selected\r\n\r\n this.actionButtons = []; //DOM buttons for actions\r\n\r\n this.availablePositions = [];\r\n for (var r = 0; r < 8; ++r) {\r\n for (var c = 0; c < 8; ++c) {\r\n this.availablePositions.push([r, c]);\r\n }\r\n }\r\n\r\n this.map = [];\r\n for (var i = 0; i < 8; ++i) {\r\n this.map.push([null, null, null, null, null, null, null, null]);\r\n }\r\n\r\n this.jsplumbinstance = null;\r\n\r\n this.difficulty = rep / CONSTANTS.HackingMissionRepToDiffConversion + 1;\r\n console.log(\"difficulty: \" + this.difficulty);\r\n this.reward = 250 + (rep / CONSTANTS.HackingMissionRepToRewardConversion);\r\n}\r\n\r\nHackingMission.prototype.init = function() {\r\n //Create Header DOM\r\n this.createPageDom();\r\n\r\n //Create player starting nodes\r\n var home = Player.getHomeComputer()\r\n for (var i = 0; i < home.cpuCores; ++i) {\r\n var stats = {\r\n atk: (Player.hacking_skill / 7.5) + 30,\r\n def: (Player.hacking_skill / 20),\r\n hp: (Player.hacking_skill / 4),\r\n };\r\n this.playerCores.push(new Node(NodeTypes.Core, stats));\r\n this.playerCores[i].setControlledByPlayer();\r\n this.setNodePosition(this.playerCores[i], i, 0);\r\n this.removeAvailablePosition(i, 0);\r\n }\r\n\r\n //Randomly generate enemy nodes (CPU and Firewall) based on difficulty\r\n var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4)));\r\n var numFirewalls = Math.min(20,\r\n getRandomInt(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1));\r\n var numDatabases = Math.min(10, getRandomInt(1, Math.round(this.difficulty / 3) + 1));\r\n var totalNodes = numNodes + numFirewalls + numDatabases;\r\n var xlimit = 7 - Math.floor(totalNodes / 8);\r\n var randMult = addOffset(0.8 + (this.difficulty / 5), 10);\r\n for (var i = 0; i < numNodes; ++i) {\r\n var stats = {\r\n atk: randMult * getRandomInt(80, 86),\r\n def: randMult * getRandomInt(5, 10),\r\n hp: randMult * getRandomInt(210, 230)\r\n }\r\n this.enemyCores.push(new Node(NodeTypes.Core, stats));\r\n this.enemyCores[i].setControlledByEnemy();\r\n this.setNodeRandomPosition(this.enemyCores[i], xlimit);\r\n }\r\n for (var i = 0; i < numFirewalls; ++i) {\r\n var stats = {\r\n atk: 0,\r\n def: randMult * getRandomInt(10, 20),\r\n hp: randMult * getRandomInt(275, 300)\r\n }\r\n this.enemyNodes.push(new Node(NodeTypes.Firewall, stats));\r\n this.enemyNodes[i].setControlledByEnemy();\r\n this.setNodeRandomPosition(this.enemyNodes[i], xlimit);\r\n }\r\n for (var i = 0; i < numDatabases; ++i) {\r\n var stats = {\r\n atk: 0,\r\n def: randMult * getRandomInt(30, 55),\r\n hp: randMult * getRandomInt(210, 275)\r\n }\r\n var node = new Node(NodeTypes.Database, stats);\r\n node.setControlledByEnemy();\r\n this.setNodeRandomPosition(node, xlimit);\r\n this.enemyDatabases.push(node);\r\n }\r\n this.calculateDefenses();\r\n this.calculateAttacks();\r\n this.createMap();\r\n}\r\n\r\nHackingMission.prototype.createPageDom = function() {\r\n var container = document.getElementById(\"mission-container\");\r\n\r\n var favorMult = 1 + (this.faction.favor / 100);\r\n var gain = this.reward * Player.faction_rep_mult * favorMult;\r\n var headerText = document.createElement(\"p\");\r\n headerText.innerHTML = \"You are about to start a hacking mission! You will gain \" +\r\n formatNumber(gain, 3) + \" faction reputation with \" + this.faction.name +\r\n \" if you win. For more information \" +\r\n \"about how hacking missions work, click one of the guide links \" +\r\n \"below (one opens up an in-game guide and the other opens up \" +\r\n \"the guide from the wiki). Click the 'Start' button to begin.\";\r\n headerText.style.display = \"block\";\r\n headerText.classList.add(\"hack-mission-header-element\");\r\n headerText.style.width = \"80%\";\r\n\r\n var inGameGuideBtn = document.createElement(\"a\");\r\n inGameGuideBtn.innerText = \"How to Play\";\r\n inGameGuideBtn.classList.add(\"a-link-button\");\r\n inGameGuideBtn.style.display = \"inline-block\";\r\n inGameGuideBtn.classList.add(\"hack-mission-header-element\");\r\n inGameGuideBtn.addEventListener(\"click\", function() {\r\n dialogBoxCreate(CONSTANTS.HackingMissionHowToPlay);\r\n return false;\r\n });\r\n\r\n var wikiGuideBtn = document.createElement(\"a\");\r\n wikiGuideBtn.innerText = \"Wiki Guide\";\r\n wikiGuideBtn.classList.add(\"a-link-button\");\r\n wikiGuideBtn.style.display = \"inline-block\";\r\n wikiGuideBtn.classList.add(\"hack-mission-header-element\");\r\n wikiGuideBtn.target = \"_blank\";\r\n //TODO Add link to wiki page wikiGuideBtn.href =\r\n\r\n\r\n //Start button will get replaced with forfeit when game is started\r\n var startBtn = document.createElement(\"a\");\r\n startBtn.innerHTML = \"Start\";\r\n startBtn.setAttribute(\"id\", \"hack-mission-start-btn\");\r\n startBtn.classList.add(\"a-link-button\");\r\n startBtn.classList.add(\"hack-mission-header-element\");\r\n startBtn.style.display = \"inline-block\";\r\n startBtn.addEventListener(\"click\", ()=>{\r\n this.start();\r\n return false;\r\n });\r\n\r\n var forfeitMission = document.createElement(\"a\");\r\n forfeitMission.innerHTML = \"Forfeit Mission (Exit)\";\r\n forfeitMission.classList.add(\"a-link-button\");\r\n forfeitMission.classList.add(\"hack-mission-header-element\");\r\n forfeitMission.style.display = \"inline-block\";\r\n forfeitMission.addEventListener(\"click\", ()=> {\r\n this.finishMission(false);\r\n return false;\r\n });\r\n\r\n var timer = document.createElement(\"p\");\r\n timer.setAttribute(\"id\", \"hacking-mission-timer\");\r\n timer.style.display = \"inline-block\";\r\n timer.style.margin = \"6px\";\r\n\r\n //Create Action Buttons (Attack/Scan/Weaken/ etc...)\r\n var actionsContainer = document.createElement(\"span\");\r\n actionsContainer.style.display = \"block\";\r\n actionsContainer.classList.add(\"hack-mission-action-buttons-container\");\r\n for (var i = 0; i < 6; ++i) {\r\n this.actionButtons.push(document.createElement(\"a\"));\r\n this.actionButtons[i].style.display = \"inline-block\";\r\n this.actionButtons[i].classList.add(\"a-link-button-inactive\"); //Disabled at start\r\n this.actionButtons[i].classList.add(\"tooltip\"); //Disabled at start\r\n this.actionButtons[i].classList.add(\"hack-mission-header-element\");\r\n actionsContainer.appendChild(this.actionButtons[i]);\r\n }\r\n this.actionButtons[0].innerText = \"Attack(a)\";\r\n var atkTooltip = document.createElement(\"span\");\r\n atkTooltip.classList.add(\"tooltiptexthigh\");\r\n atkTooltip.innerText = \"Lowers the targeted node's HP. The effectiveness of this depends on \" +\r\n \"this node's Attack level, your hacking level, and the opponent's defense level.\";\r\n this.actionButtons[0].appendChild(atkTooltip);\r\n this.actionButtons[1].innerText = \"Scan(s)\";\r\n var scanTooltip = document.createElement(\"span\");\r\n scanTooltip.classList.add(\"tooltiptexthigh\");\r\n scanTooltip.innerText = \"Lowers the targeted node's defense. The effectiveness of this depends on \" +\r\n \"this node's Attack level, your hacking level, and the opponent's defense level.\";\r\n this.actionButtons[1].appendChild(scanTooltip);\r\n this.actionButtons[2].innerText = \"Weaken(w)\";\r\n var WeakenTooltip = document.createElement(\"span\");\r\n WeakenTooltip.classList.add(\"tooltiptexthigh\");\r\n WeakenTooltip.innerText = \"Lowers the targeted node's attack. The effectiveness of this depends on \" +\r\n \"this node's Attack level, your hacking level, and the opponent's defense level.\";\r\n this.actionButtons[2].appendChild(WeakenTooltip);\r\n this.actionButtons[3].innerText = \"Fortify(f)\";\r\n var fortifyTooltip = document.createElement(\"span\");\r\n fortifyTooltip.classList.add(\"tooltiptexthigh\");\r\n fortifyTooltip.innerText = \"Raises this node's Defense level. The effectiveness of this depends on \" +\r\n \"your hacking level\";\r\n this.actionButtons[3].appendChild(fortifyTooltip);\r\n this.actionButtons[4].innerText = \"Overflow(r)\";\r\n var overflowTooltip = document.createElement(\"span\");\r\n overflowTooltip.classList.add(\"tooltiptexthigh\");\r\n overflowTooltip.innerText = \"Raises this node's Attack level but lowers its Defense level. The effectiveness \" +\r\n \"of this depends on your hacking level.\";\r\n this.actionButtons[4].appendChild(overflowTooltip);\r\n this.actionButtons[5].innerText = \"Drop Connection(d)\";\r\n var dropconnTooltip = document.createElement(\"span\");\r\n dropconnTooltip.classList.add(\"tooltiptexthigh\");\r\n dropconnTooltip.innerText = \"Removes this Node's current connection to some target Node, if it has one. This can \" +\r\n \"also be done by simply clicking the white connection line.\";\r\n this.actionButtons[5].appendChild(dropconnTooltip);\r\n\r\n //Player/enemy defense displays will be in action container\r\n var playerStats = document.createElement(\"p\");\r\n var enemyStats = document.createElement(\"p\");\r\n playerStats.style.display = \"inline-block\";\r\n enemyStats.style.display = \"inline-block\";\r\n playerStats.style.color = \"#00ccff\";\r\n enemyStats.style.color = \"red\";\r\n playerStats.style.margin = \"4px\";\r\n enemyStats.style.margin = \"4px\";\r\n playerStats.setAttribute(\"id\", \"hacking-mission-player-stats\");\r\n enemyStats.setAttribute(\"id\", \"hacking-mission-enemy-stats\");\r\n actionsContainer.appendChild(playerStats);\r\n actionsContainer.appendChild(enemyStats);\r\n\r\n //Set Action Button event listeners\r\n this.actionButtons[0].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n if (this.selectedNode[0].type !== NodeTypes.Core) {return;}\r\n this.setActionButtonsActive(this.selectedNode[0].type);\r\n this.setActionButton(NodeActions.Attack, false); //Set attack button inactive\r\n this.selectedNode.forEach(function(node){\r\n node.action = NodeActions.Attack;\r\n });\r\n });\r\n\r\n this.actionButtons[1].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type\r\n if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}\r\n this.setActionButtonsActive(nodeType);\r\n this.setActionButton(NodeActions.Scan, false); //Set scan button inactive\r\n this.selectedNode.forEach(function(node){\r\n node.action = NodeActions.Scan;\r\n });\r\n });\r\n\r\n this.actionButtons[2].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type\r\n if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}\r\n this.setActionButtonsActive(nodeType);\r\n this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive\r\n this.selectedNode.forEach(function(node){\r\n node.action = NodeActions.Weaken;\r\n });\r\n });\r\n\r\n this.actionButtons[3].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n this.setActionButtonsActive(this.selectedNode[0].type);\r\n this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive\r\n this.selectedNode.forEach(function(node){\r\n node.action = NodeActions.Fortify;\r\n });\r\n });\r\n\r\n this.actionButtons[4].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n var nodeType = this.selectedNode[0].type;\r\n if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}\r\n this.setActionButtonsActive(nodeType);\r\n this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive\r\n this.selectedNode.forEach(function(node){\r\n node.action = NodeActions.Overflow;\r\n });\r\n });\r\n\r\n this.actionButtons[5].addEventListener(\"click\", ()=>{\r\n if (!(this.selectedNode.length > 0)) {\r\n console.log(\"ERR: Pressing Action button without selected node\");\r\n return;\r\n }\r\n this.selectedNode.forEach(function(node){\r\n if (node.conn) {\r\n var endpoints = node.conn.endpoints;\r\n endpoints[0].detachFrom(endpoints[1]);\r\n }\r\n node.action = NodeActions.Fortify;\r\n });\r\n // if (this.selectedNode.conn) {\r\n // var endpoints = this.selectedNode.conn.endpoints;\r\n // endpoints[0].detachFrom(endpoints[1]);\r\n // }\r\n })\r\n\r\n var timeDisplay = document.createElement(\"p\");\r\n\r\n container.appendChild(headerText);\r\n container.appendChild(inGameGuideBtn);\r\n container.appendChild(wikiGuideBtn);\r\n container.appendChild(startBtn);\r\n container.appendChild(forfeitMission);\r\n container.appendChild(timer);\r\n container.appendChild(actionsContainer);\r\n container.appendChild(timeDisplay);\r\n}\r\n\r\nHackingMission.prototype.setActionButtonsInactive = function() {\r\n for (var i = 0; i < this.actionButtons.length; ++i) {\r\n this.actionButtons[i].classList.remove(\"a-link-button\");\r\n this.actionButtons[i].classList.add(\"a-link-button-inactive\");\r\n }\r\n}\r\n\r\nHackingMission.prototype.setActionButtonsActive = function(nodeType=null) {\r\n for (var i = 0; i < this.actionButtons.length; ++i) {\r\n this.actionButtons[i].classList.add(\"a-link-button\");\r\n this.actionButtons[i].classList.remove(\"a-link-button-inactive\");\r\n }\r\n\r\n //For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled\r\n //0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn\r\n if (nodeType) {\r\n switch (nodeType) {\r\n case NodeTypes.Firewall:\r\n case NodeTypes.Shield:\r\n this.actionButtons[0].classList.remove(\"a-link-button\");\r\n this.actionButtons[0].classList.add(\"a-link-button-inactive\");\r\n this.actionButtons[1].classList.remove(\"a-link-button\");\r\n this.actionButtons[1].classList.add(\"a-link-button-inactive\");\r\n this.actionButtons[2].classList.remove(\"a-link-button\");\r\n this.actionButtons[2].classList.add(\"a-link-button-inactive\");\r\n this.actionButtons[4].classList.remove(\"a-link-button\");\r\n this.actionButtons[4].classList.add(\"a-link-button-inactive\");\r\n this.actionButtons[5].classList.remove(\"a-link-button\");\r\n this.actionButtons[5].classList.add(\"a-link-button-inactive\");\r\n break;\r\n case NodeTypes.Transfer:\r\n this.actionButtons[0].classList.remove(\"a-link-button\");\r\n this.actionButtons[0].classList.add(\"a-link-button-inactive\");\r\n break;\r\n default:\r\n break;\r\n }\r\n }\r\n}\r\n\r\n//True for active, false for inactive\r\nHackingMission.prototype.setActionButton = function(i, active=true) {\r\n if (isString(i)) {\r\n switch (i) {\r\n case NodeActions.Attack:\r\n i = 0;\r\n break;\r\n case NodeActions.Scan:\r\n i = 1;\r\n break;\r\n case NodeActions.Weaken:\r\n i = 2;\r\n break;\r\n case NodeActions.Fortify:\r\n i = 3;\r\n break;\r\n case NodeActions.Overflow:\r\n default:\r\n i = 4;\r\n break;\r\n }\r\n }\r\n if (active) {\r\n this.actionButtons[i].classList.remove(\"a-link-button-inactive\");\r\n this.actionButtons[i].classList.add(\"a-link-button\");\r\n } else {\r\n this.actionButtons[i].classList.remove(\"a-link-button\");\r\n this.actionButtons[i].classList.add(\"a-link-button-inactive\");\r\n }\r\n\r\n}\r\n\r\nHackingMission.prototype.calculateAttacks = function() {\r\n var total = 0;\r\n for (var i = 0; i < this.playerCores.length; ++i) {\r\n total += this.playerCores[i].atk;\r\n }\r\n for (var i = 0; i < this.playerNodes.length; ++i) {\r\n total += this.playerNodes[i].atk;\r\n }\r\n this.playerAtk = total;\r\n document.getElementById(\"hacking-mission-player-stats\").innerHTML =\r\n \"Player Attack: \" + formatNumber(this.playerAtk, 1) + \"
\" +\r\n \"Player Defense: \" + formatNumber(this.playerDef, 1);\r\n total = 0;\r\n for (var i = 0; i < this.enemyCores.length; ++i) {\r\n total += this.enemyCores[i].atk;\r\n }\r\n for (var i = 0; i < this.enemyDatabases.length; ++i) {\r\n total += this.enemyDatabases[i].atk;\r\n }\r\n for (var i = 0; i < this.enemyNodes.length; ++i) {\r\n total += this.enemyNodes[i].atk;\r\n }\r\n this.enemyAtk = total;\r\n document.getElementById(\"hacking-mission-enemy-stats\").innerHTML =\r\n \"Enemy Attack: \" + formatNumber(this.enemyAtk, 1) + \"
\" +\r\n \"Enemy Defense: \" + formatNumber(this.enemyDef, 1);\r\n}\r\n\r\nHackingMission.prototype.calculateDefenses = function() {\r\n var total = 0;\r\n for (var i = 0; i < this.playerCores.length; ++i) {\r\n total += this.playerCores[i].def;\r\n }\r\n for (var i = 0; i < this.playerNodes.length; ++i) {\r\n total += this.playerNodes[i].def;\r\n }\r\n this.playerDef = total;\r\n document.getElementById(\"hacking-mission-player-stats\").innerHTML =\r\n \"Player Attack: \" + formatNumber(this.playerAtk, 1) + \"
\" +\r\n \"Player Defense: \" + formatNumber(this.playerDef, 1);\r\n total = 0;\r\n for (var i = 0; i < this.enemyCores.length; ++i) {\r\n total += this.enemyCores[i].def;\r\n }\r\n for (var i = 0; i < this.enemyDatabases.length; ++i) {\r\n total += this.enemyDatabases[i].def;\r\n }\r\n for (var i = 0; i < this.enemyNodes.length; ++i) {\r\n total += this.enemyNodes[i].def;\r\n }\r\n this.enemyDef = total;\r\n document.getElementById(\"hacking-mission-enemy-stats\").innerHTML =\r\n \"Enemy Attack: \" + formatNumber(this.enemyAtk, 1) + \"
\" +\r\n \"Enemy Defense: \" + formatNumber(this.enemyDef, 1);\r\n}\r\n\r\nHackingMission.prototype.removeAvailablePosition = function(x, y) {\r\n for (var i = 0; i < this.availablePositions.length; ++i) {\r\n if (this.availablePositions[i][0] === x &&\r\n this.availablePositions[i][1] === y) {\r\n this.availablePositions.splice(i, 1);\r\n return;\r\n }\r\n }\r\n console.log(\"WARNING: removeAvailablePosition() did not remove \" + x + \", \" + y);\r\n}\r\n\r\nHackingMission.prototype.setNodePosition = function(nodeObj, x, y) {\r\n if (!(nodeObj instanceof Node)) {\r\n console.log(\"WARNING: Non-Node object passed into setNodePOsition\");\r\n return;\r\n }\r\n if (isNaN(x) || isNaN(y)) {\r\n console.log(\"ERR: Invalid values passed as x and y for setNodePosition\");\r\n console.log(x);\r\n console.log(y);\r\n return;\r\n }\r\n nodeObj.pos = [x, y];\r\n this.map[x][y] = nodeObj;\r\n}\r\n\r\nHackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {\r\n var i = getRandomInt(0, this.availablePositions.length - 1);\r\n if (this.availablePositions[i][1] < xlimit) {\r\n //Recurse if not within limit\r\n return this.setNodeRandomPosition(nodeObj, xlimit);\r\n }\r\n var pos = this.availablePositions.splice(i, 1);\r\n pos = pos[0];\r\n this.setNodePosition(nodeObj, pos[0], pos[1]);\r\n}\r\n\r\nHackingMission.prototype.createMap = function() {\r\n //Use a grid\r\n var map = document.createElement(\"div\");\r\n map.classList.add(\"hack-mission-grid\");\r\n map.setAttribute(\"id\", \"hacking-mission-map\");\r\n document.getElementById(\"mission-container\").appendChild(map);\r\n\r\n //Create random Nodes for every space in the map that\r\n //hasn't been filled yet. The stats of each Node will be based on\r\n //the player/enemy attack\r\n var averageAttack = (this.playerAtk + this.enemyAtk) / 2;\r\n for (var x = 0; x < 8; ++x) {\r\n for (var y = 0; y < 8; ++y) {\r\n if (!(this.map[x][y] instanceof Node)) {\r\n var node, type = getRandomInt(0, 2);\r\n var randMult = addOffset(0.85 + (this.difficulty / 2), 15);\r\n switch (type) {\r\n case 0: //Spam\r\n var stats = {\r\n atk: 0,\r\n def: averageAttack * 1.1 + getRandomInt(15, 45),\r\n hp: randMult * getRandomInt(200, 225)\r\n }\r\n node = new Node(NodeTypes.Spam, stats);\r\n break;\r\n case 1: //Transfer\r\n var stats = {\r\n atk: 0,\r\n def: averageAttack * 1.1 + getRandomInt(15, 45),\r\n hp: randMult * getRandomInt(250, 275)\r\n }\r\n node = new Node(NodeTypes.Transfer, stats);\r\n break;\r\n case 2: //Shield\r\n default:\r\n var stats = {\r\n atk: 0,\r\n def: averageAttack * 1.1 + getRandomInt(30, 70),\r\n hp: randMult * getRandomInt(300, 320)\r\n }\r\n node = new Node(NodeTypes.Shield, stats);\r\n break;\r\n }\r\n this.setNodePosition(node, x, y);\r\n this.removeAvailablePosition(x, y);\r\n this.miscNodes.push(node);\r\n }\r\n }\r\n }\r\n\r\n //Create DOM elements in order\r\n for (var r = 0; r < 8; ++r) {\r\n for (var c = 0; c < 8; ++c) {\r\n this.createNodeDomElement(this.map[r][c]);\r\n }\r\n }\r\n\r\n //Configure all Player CPUS\r\n for (var i = 0; i < this.playerCores.length; ++i) {\r\n console.log(\"Configuring Player Node: \" + this.playerCores[i].el.id);\r\n this.configurePlayerNodeElement(this.playerCores[i].el);\r\n }\r\n}\r\n\r\nHackingMission.prototype.createNodeDomElement = function(nodeObj) {\r\n var nodeDiv = document.createElement(\"a\"), txtEl = document.createElement('p');\r\n nodeObj.el = nodeDiv;\r\n\r\n //Set the node element's id based on its coordinates\r\n var id = \"hacking-mission-node-\" + nodeObj.pos[0] + \"-\" + nodeObj.pos[1];\r\n nodeDiv.setAttribute(\"id\", id);\r\n txtEl.setAttribute(\"id\", id + \"-txt\");\r\n\r\n //Set node classes for owner\r\n nodeDiv.classList.add(\"hack-mission-node\");\r\n if (nodeObj.plyrCtrl) {\r\n nodeDiv.classList.add(\"hack-mission-player-node\");\r\n } else if (nodeObj.enmyCtrl) {\r\n nodeDiv.classList.add(\"hack-mission-enemy-node\");\r\n }\r\n\r\n //Set node classes based on type\r\n var txt;\r\n switch (nodeObj.type) {\r\n case NodeTypes.Core:\r\n txt = \"CPU Core
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-cpu-node\");\r\n break;\r\n case NodeTypes.Firewall:\r\n txt = \"Firewall
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-firewall-node\");\r\n break;\r\n case NodeTypes.Database:\r\n txt = \"Database
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-database-node\");\r\n break;\r\n case NodeTypes.Spam:\r\n txt = \"Spam
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-spam-node\");\r\n break;\r\n case NodeTypes.Transfer:\r\n txt = \"Transfer
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-transfer-node\");\r\n break;\r\n case NodeTypes.Shield:\r\n default:\r\n txt = \"Shield
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n nodeDiv.classList.add(\"hack-mission-shield-node\");\r\n break;\r\n }\r\n\r\n txt += \"
Atk: \" + formatNumber(nodeObj.atk, 1) +\r\n \"
Def: \" + formatNumber(nodeObj.def, 1);\r\n txtEl.innerHTML = txt;\r\n\r\n nodeDiv.appendChild(txtEl);\r\n document.getElementById(\"hacking-mission-map\").appendChild(nodeDiv);\r\n}\r\n\r\nHackingMission.prototype.updateNodeDomElement = function(nodeObj) {\r\n if (nodeObj.el == null) {\r\n console.log(\"ERR: Calling updateNodeDomElement on a Node without an element\");\r\n return;\r\n }\r\n\r\n var id = \"hacking-mission-node-\" + nodeObj.pos[0] + \"-\" + nodeObj.pos[1];\r\n var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + \"-txt\");\r\n\r\n //Set node classes based on type\r\n var txt;\r\n switch (nodeObj.type) {\r\n case NodeTypes.Core:\r\n txt = \"CPU Core
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n case NodeTypes.Firewall:\r\n txt = \"Firewall
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n case NodeTypes.Database:\r\n txt = \"Database
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n case NodeTypes.Spam:\r\n txt = \"Spam
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n case NodeTypes.Transfer:\r\n txt = \"Transfer
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n case NodeTypes.Shield:\r\n default:\r\n txt = \"Shield
\" + \"HP: \" +\r\n formatNumber(nodeObj.hp, 1);\r\n break;\r\n }\r\n\r\n txt += \"
Atk: \" + formatNumber(nodeObj.atk, 1) +\r\n \"
Def: \" + formatNumber(nodeObj.def, 1);\r\n if (nodeObj.action) {\r\n txt += \"
\" + nodeObj.action;\r\n }\r\n txtEl.innerHTML = txt;\r\n}\r\n\r\n//Gets a Node DOM element's corresponding Node object using its\r\n//element id. Function accepts either the DOM element object or the ID as\r\n//an argument\r\nHackingMission.prototype.getNodeFromElement = function(el) {\r\n var id;\r\n if (isString(el)) {\r\n id = el;\r\n } else {\r\n id = el.id;\r\n }\r\n id = id.replace(\"hacking-mission-node-\", \"\");\r\n var res = id.split('-');\r\n if (res.length != 2) {\r\n console.log(\"ERROR Parsing Hacking Mission Node Id. Could not find coordinates\");\r\n return null;\r\n }\r\n var x = res[0], y = res[1];\r\n if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {\r\n console.log(\"ERROR: Unexpected values for x and y: \" + x + \", \" + y);\r\n return null;\r\n }\r\n return this.map[x][y];\r\n}\r\n\r\nfunction selectNode(hackMissionInst, el) {\r\n var nodeObj = hackMissionInst.getNodeFromElement(el);\r\n if (nodeObj == null) {console.log(\"Error getting Node object\");}\r\n if (!nodeObj.plyrCtrl) {return;}\r\n\r\n clearAllSelectedNodes(hackMissionInst);\r\n nodeObj.select(hackMissionInst.actionButtons);\r\n hackMissionInst.selectedNode.push(nodeObj);\r\n}\r\n\r\nfunction multiselectNode(hackMissionInst, el) {\r\n var nodeObj = hackMissionInst.getNodeFromElement(el);\r\n if (nodeObj == null) {console.log(\"ERROR: Getting Node Object in multiselectNode()\");}\r\n if (!nodeObj.plyrCtrl) {return;}\r\n\r\n clearAllSelectedNodes(hackMissionInst);\r\n var type = nodeObj.type;\r\n if (type === NodeTypes.Core) {\r\n hackMissionInst.playerCores.forEach(function(node) {\r\n node.select(hackMissionInst.actionButtons);\r\n hackMissionInst.selectedNode.push(node);\r\n });\r\n } else {\r\n hackMissionInst.playerNodes.forEach(function(node) {\r\n if (node.type === type) {\r\n node.select(hackMissionInst.actionButtons);\r\n hackMissionInst.selectedNode.push(node);\r\n }\r\n });\r\n }\r\n}\r\n\r\nfunction clearAllSelectedNodes(hackMissionInst) {\r\n if (hackMissionInst.selectedNode.length > 0) {\r\n hackMissionInst.selectedNode.forEach(function(node){\r\n node.deselect(hackMissionInst.actionButtons);\r\n });\r\n hackMissionInst.selectedNode.length = 0;\r\n }\r\n}\r\n\r\n//Configures a DOM element representing a player-owned node to\r\n//be selectable and actionable\r\n//Note: Does NOT change its css class. This is handled by Node.setControlledBy...\r\nHackingMission.prototype.configurePlayerNodeElement = function(el) {\r\n var nodeObj = this.getNodeFromElement(el);\r\n if (nodeObj == null) {console.log(\"Error getting Node object\");}\r\n\r\n //Add event listener\r\n var self = this;\r\n function selectNodeWrapper() {\r\n selectNode(self, el);\r\n }\r\n el.addEventListener(\"click\", selectNodeWrapper);\r\n\r\n function multiselectNodeWrapper() {\r\n multiselectNode(self, el);\r\n }\r\n el.addEventListener(\"dblclick\", multiselectNodeWrapper);\r\n\r\n\r\n if (el.firstChild) {\r\n el.firstChild.addEventListener(\"click\", selectNodeWrapper);\r\n }\r\n}\r\n\r\n//Configures a DOM element representing an enemy-node by removing\r\n//any event listeners\r\nHackingMission.prototype.configureEnemyNodeElement = function(el) {\r\n //Deselect node if it was the selected node\r\n var nodeObj = this.getNodeFromElement(el);\r\n for (var i = 0; i < this.selectedNode.length; ++i) {\r\n if (this.selectedNode[i] == nodeObj) {\r\n nodeObj.deselect(this.actionButtons);\r\n this.selectedNode.splice(i, 1);\r\n break;\r\n }\r\n }\r\n}\r\n\r\n//Returns bool indicating whether a node is reachable by player\r\n//by checking if any of the adjacent nodes are owned by the player\r\nHackingMission.prototype.nodeReachable = function(node) {\r\n var x = node.pos[0], y = node.pos[1];\r\n if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;}\r\n if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}\r\n if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}\r\n if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}\r\n return false;\r\n}\r\n\r\nHackingMission.prototype.nodeReachableByEnemy = function(node) {\r\n if (node == null) {return false;}\r\n var x = node.pos[0], y = node.pos[1];\r\n if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}\r\n if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}\r\n if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}\r\n if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}\r\n return false;\r\n}\r\n\r\nHackingMission.prototype.start = function() {\r\n this.started = true;\r\n this.initJsPlumb();\r\n var startBtn = clearEventListeners(\"hack-mission-start-btn\");\r\n startBtn.classList.remove(\"a-link-button\");\r\n startBtn.classList.add(\"a-link-button-inactive\");\r\n}\r\n\r\nHackingMission.prototype.initJsPlumb = function() {\r\n var instance = jsPlumb.getInstance({\r\n DragOptions:{cursor:\"pointer\", zIndex:2000},\r\n PaintStyle: {\r\n gradient: { stops: [\r\n [ 0, \"#FFFFFF\" ],\r\n [ 1, \"#FFFFFF\" ]\r\n ] },\r\n stroke: \"#FFFFFF\",\r\n strokeWidth: 8\r\n },\r\n });\r\n\r\n this.jsplumbinstance = instance;\r\n\r\n //All player cores are sources\r\n for (var i = 0; i < this.playerCores.length; ++i) {\r\n instance.makeSource(this.playerCores[i].el, {\r\n deleteEndpointsOnEmpty:true,\r\n maxConnections:1,\r\n anchor:\"Continuous\",\r\n connector:\"Flowchart\"\r\n });\r\n }\r\n\r\n //Everything else is a target\r\n for (var i = 0; i < this.enemyCores.length; ++i) {\r\n instance.makeTarget(this.enemyCores[i].el, {\r\n maxConnections:-1,\r\n anchor:\"Continuous\",\r\n connector:\"Flowchart\"\r\n });\r\n }\r\n for (var i = 0; i < this.enemyDatabases.length; ++i) {\r\n instance.makeTarget(this.enemyDatabases[i].el, {\r\n maxConnections:-1,\r\n anchor:\"Continuous\",\r\n connector:[\"Flowchart\"]\r\n });\r\n }\r\n for (var i = 0; i < this.enemyNodes.length; ++i) {\r\n instance.makeTarget(this.enemyNodes[i].el, {\r\n maxConnections:-1,\r\n anchor:\"Continuous\",\r\n connector:\"Flowchart\"\r\n });\r\n }\r\n for (var i = 0; i < this.miscNodes.length; ++i) {\r\n instance.makeTarget(this.miscNodes[i].el, {\r\n maxConnections:-1,\r\n anchor:\"Continuous\",\r\n connector:\"Flowchart\"\r\n });\r\n }\r\n\r\n //Clicking a connection drops it\r\n instance.bind(\"click\", function(conn, originalEvent) {\r\n var endpoints = conn.endpoints;\r\n endpoints[0].detachFrom(endpoints[1]);\r\n });\r\n\r\n //Connection events\r\n instance.bind(\"connection\", (info)=>{\r\n var targetNode = this.getNodeFromElement(info.target);\r\n\r\n //Do not detach for enemy nodes\r\n var thisNode = this.getNodeFromElement(info.source);\r\n if (thisNode.enmyCtrl) {return;}\r\n\r\n //If the node is not reachable, drop the connection\r\n if (!this.nodeReachable(targetNode)) {\r\n info.sourceEndpoint.detachFrom(info.targetEndpoint);\r\n return;\r\n }\r\n\r\n var sourceNode = this.getNodeFromElement(info.source);\r\n sourceNode.conn = info.connection;\r\n var targetNode = this.getNodeFromElement(info.target);\r\n ++targetNode.targetedCount;\r\n });\r\n\r\n //Detach Connection events\r\n instance.bind(\"connectionDetached\", (info, originalEvent)=>{\r\n var sourceNode = this.getNodeFromElement(info.source);\r\n sourceNode.conn = null;\r\n var targetNode = this.getNodeFromElement(info.target);\r\n targetNode.untarget();\r\n });\r\n\r\n}\r\n\r\n//Drops all connections where the specified node is the source\r\nHackingMission.prototype.dropAllConnectionsFromNode = function(node) {\r\n var allConns = this.jsplumbinstance.getAllConnections();\r\n for (var i = allConns.length-1; i >= 0; --i) {\r\n if (allConns[i].source == node.el) {\r\n allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);\r\n }\r\n }\r\n}\r\n\r\n//Drops all connections where the specified node is the target\r\nHackingMission.prototype.dropAllConnectionsToNode = function(node) {\r\n var allConns = this.jsplumbinstance.getAllConnections();\r\n for (var i = allConns.length-1; i >= 0; --i) {\r\n if (allConns[i].target == node.el) {\r\n allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);\r\n }\r\n }\r\n node.beingTargeted = false;\r\n}\r\n\r\nvar storedCycles = 0;\r\nHackingMission.prototype.process = function(numCycles=1) {\r\n if (!this.started) {return;}\r\n storedCycles += numCycles;\r\n if (storedCycles < 2) {return;} //Only process every 3 cycles minimum\r\n\r\n var res = false;\r\n //Process actions of all player nodes\r\n this.playerCores.forEach((node)=>{\r\n res |= this.processNode(node, storedCycles);\r\n });\r\n\r\n this.playerNodes.forEach((node)=>{\r\n if (node.type === NodeTypes.Transfer ||\r\n node.type === NodeTypes.Shield ||\r\n node.type === NodeTypes.Firewall) {\r\n res |= this.processNode(node, storedCycles);\r\n }\r\n });\r\n\r\n //Process actions of all enemy nodes\r\n this.enemyCores.forEach((node)=>{\r\n this.enemyAISelectAction(node);\r\n res |= this.processNode(node, storedCycles);\r\n });\r\n\r\n this.enemyNodes.forEach((node)=>{\r\n if (node.type === NodeTypes.Transfer ||\r\n node.type === NodeTypes.Shield ||\r\n node.type === NodeTypes.Firewall) {\r\n this.enemyAISelectAction(node);\r\n res |= this.processNode(node, storedCycles);\r\n }\r\n });\r\n\r\n //The hp of enemy databases increases slowly\r\n this.enemyDatabases.forEach((node)=>{\r\n node.maxhp += (0.1 * storedCycles);\r\n node.hp += (0.1 * storedCycles);\r\n });\r\n\r\n if (res) {\r\n this.calculateAttacks();\r\n this.calculateDefenses();\r\n }\r\n\r\n //Win if all enemy databases are conquered\r\n if (this.enemyDatabases.length === 0) {\r\n this.finishMission(true);\r\n return;\r\n }\r\n\r\n //Lose if all your cores are gone\r\n if (this.playerCores.length === 0) {\r\n this.finishMission(false);\r\n return;\r\n }\r\n\r\n //Defense/hp of misc nodes increases slowly over time\r\n this.miscNodes.forEach((node)=>{\r\n node.def += (0.1 * storedCycles);\r\n node.maxhp += (0.05 * storedCycles);\r\n node.hp += (0.1 * storedCycles);\r\n if (node.hp > node.maxhp) {node.hp = node.maxhp;}\r\n this.updateNodeDomElement(node);\r\n });\r\n\r\n //Update timer and check if player lost\r\n this.time -= (storedCycles * Engine._idleSpeed);\r\n if (this.time <= 0) {\r\n this.finishMission(false);\r\n return;\r\n }\r\n this.updateTimer();\r\n\r\n storedCycles = 0;\r\n}\r\n\r\n//Returns a bool representing whether defenses need to be re-calculated\r\nHackingMission.prototype.processNode = function(nodeObj, numCycles=1) {\r\n if (nodeObj.action == null) {\r\n return;\r\n }\r\n\r\n var targetNode = null, def, atk;\r\n if (nodeObj.conn) {\r\n if (nodeObj.conn.target != null) {\r\n targetNode = this.getNodeFromElement(nodeObj.conn.target);\r\n } else {\r\n targetNode = this.getNodeFromElement(nodeObj.conn.targetId);\r\n }\r\n\r\n if (targetNode == null) {\r\n //Player is in the middle of dragging the connection,\r\n //so the target node is null. Do nothing here\r\n } else if (targetNode.plyrCtrl) {\r\n def = this.playerDef;\r\n atk = this.enemyAtk;\r\n } else if (targetNode.enmyCtrl) {\r\n def = this.enemyDef;\r\n atk = this.playerAtk;\r\n } else { //Misc Node\r\n def = targetNode.def;\r\n nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;\r\n }\r\n }\r\n\r\n //Calculations are per second, so divide everything by 5\r\n var calcStats = false, plyr = nodeObj.plyrCtrl;\r\n var enmyHacking = this.difficulty * CONSTANTS.HackingMissionDifficultyToHacking;\r\n switch(nodeObj.action) {\r\n case NodeActions.Attack:\r\n if (targetNode == null) {break;}\r\n if (nodeObj.conn == null) {break;}\r\n var dmg = this.calculateAttackDamage(atk, def, plyr ? Player.hacking_skill : enmyHacking);\r\n targetNode.hp -= (dmg/5 * numCycles);\r\n break;\r\n case NodeActions.Scan:\r\n if (targetNode == null) {break;}\r\n if (nodeObj.conn == null) {break;}\r\n var eff = this.calculateScanEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);\r\n targetNode.def -= (eff/5 * numCycles);\r\n calcStats = true;\r\n break;\r\n case NodeActions.Weaken:\r\n if (targetNode == null) {break;}\r\n if (nodeObj.conn == null) {break;}\r\n var eff = this.calculateWeakenEffect(atk, def, plyr ? Player.hacking_skill : enmyHacking);\r\n targetNode.atk -= (eff/5 * numCycles);\r\n calcStats = true;\r\n break;\r\n case NodeActions.Fortify:\r\n var eff = this.calculateFortifyEffect(Player.hacking_skill);\r\n nodeObj.def += (eff/5 * numCycles);\r\n calcStats = true;\r\n break;\r\n case NodeActions.Overflow:\r\n var eff = this.calculateOverflowEffect(Player.hacking_skill);\r\n if (nodeObj.def < eff) {break;}\r\n nodeObj.def -= (eff/5 * numCycles);\r\n nodeObj.atk += (eff/5 * numCycles);\r\n calcStats = true;\r\n break;\r\n default:\r\n console.log(\"ERR: Invalid Node Action: \" + nodeObj.action);\r\n break;\r\n }\r\n\r\n //Stats can't go below 0\r\n if (nodeObj.atk < 0) {nodeObj.atk = 0;}\r\n if (nodeObj.def < 0) {nodeObj.def = 0;}\r\n if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}\r\n if (targetNode && targetNode.def < 0) {targetNode.def = 0;}\r\n\r\n //Conquering a node\r\n if (targetNode && targetNode.hp <= 0) {\r\n var conqueredByPlayer = nodeObj.plyrCtrl;\r\n targetNode.hp = targetNode.maxhp;\r\n targetNode.action = null;\r\n targetNode.conn = null;\r\n if (this.selectedNode == targetNode) {\r\n targetNode.deselect(this.actionButtons);\r\n }\r\n\r\n //The conquered node has its stats reduced\r\n targetNode.atk /= 2;\r\n targetNode.def /= 3.5;\r\n\r\n //Flag for whether the target node was a misc node\r\n var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;\r\n\r\n //Remove all connections from Node\r\n this.dropAllConnectionsToNode(targetNode);\r\n this.dropAllConnectionsFromNode(targetNode);\r\n\r\n //Changes the css class and turn the node into a JsPlumb Source/Target\r\n if (conqueredByPlayer) {\r\n targetNode.setControlledByPlayer();\r\n this.jsplumbinstance.unmakeTarget(targetNode.el);\r\n this.jsplumbinstance.makeSource(targetNode.el, {\r\n deleteEndpointsOnEmpty:true,\r\n maxConnections:1,\r\n anchor:\"Continuous\",\r\n connector:\"Flowchart\"\r\n });\r\n } else {\r\n targetNode.setControlledByEnemy();\r\n nodeObj.conn = null; //Clear connection\r\n this.jsplumbinstance.unmakeSource(targetNode.el);\r\n this.jsplumbinstance.makeTarget(targetNode.el, {\r\n maxConnections:-1,\r\n anchor:\"Continuous\",\r\n connector:[\"Flowchart\"]\r\n });\r\n }\r\n\r\n calcStats = true;\r\n\r\n //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays\r\n function swapNodes(orig, dest, targetNode) {\r\n for (var i = 0; i < orig.length; ++i) {\r\n if (orig[i] == targetNode) {\r\n var node = orig.splice(i, 1);\r\n node = node[0];\r\n dest.push(node);\r\n break;\r\n }\r\n }\r\n }\r\n\r\n switch(targetNode.type) {\r\n case NodeTypes.Core:\r\n if (conqueredByPlayer) {\r\n swapNodes(this.enemyCores, this.playerCores, targetNode);\r\n this.configurePlayerNodeElement(targetNode.el);\r\n } else {\r\n swapNodes(this.playerCores, this.enemyCores, targetNode);\r\n this.configureEnemyNodeElement(targetNode.el);\r\n }\r\n break;\r\n case NodeTypes.Firewall:\r\n if (conqueredByPlayer) {\r\n swapNodes(this.enemyNodes, this.playerNodes, targetNode);\r\n } else {\r\n swapNodes(this.playerNodes, this.enemyNodes, targetNode);\r\n this.configureEnemyNodeElement(targetNode.el);\r\n }\r\n break;\r\n case NodeTypes.Database:\r\n if (conqueredByPlayer) {\r\n swapNodes(this.enemyDatabases, this.playerNodes, targetNode);\r\n } else {\r\n swapNodes(this.playerNodes, this.enemyDatabases, targetNode);\r\n }\r\n break;\r\n case NodeTypes.Spam:\r\n if (conqueredByPlayer) {\r\n swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);\r\n //Conquering spam node increases time limit\r\n this.time += CONSTANTS.HackingMissionSpamTimeIncrease;\r\n } else {\r\n swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);\r\n }\r\n\r\n break;\r\n case NodeTypes.Transfer:\r\n //Conquering a Transfer node increases the attack of all cores by some percentages\r\n if (conqueredByPlayer) {\r\n swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);\r\n this.playerCores.forEach(function(node) {\r\n node.atk *= CONSTANTS.HackingMissionTransferAttackIncrease;\r\n });\r\n this.configurePlayerNodeElement(targetNode.el);\r\n } else {\r\n swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);\r\n this.enemyCores.forEach(function(node) {\r\n node.atk *= CONSTANTS.HackingMissionTransferAttackIncrease;\r\n });\r\n this.configureEnemyNodeElement(targetNode.el);\r\n }\r\n break;\r\n case NodeTypes.Shield:\r\n if (conqueredByPlayer) {\r\n swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);\r\n this.configurePlayerNodeElement(targetNode.el);\r\n } else {\r\n swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);\r\n this.configureEnemyNodeElement(targetNode.el);\r\n }\r\n break;\r\n }\r\n\r\n //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount\r\n if (isMiscNode) { //&& conqueredByPlayer) {\r\n this.miscNodes.forEach((node)=>{\r\n if (node.targetedCount === 0) {\r\n node.def *= CONSTANTS.HackingMissionMiscDefenseIncrease;\r\n }\r\n });\r\n }\r\n }\r\n\r\n //Update node DOMs\r\n this.updateNodeDomElement(nodeObj);\r\n if (targetNode) {this.updateNodeDomElement(targetNode);}\r\n return calcStats;\r\n}\r\n\r\n//Enemy \"AI\" for CPU Core and Transfer Nodes\r\nHackingMission.prototype.enemyAISelectAction = function(nodeObj) {\r\n if (nodeObj == null) {return;}\r\n switch(nodeObj.type) {\r\n case NodeTypes.Core:\r\n //Select a single RANDOM target from miscNodes and player's Nodes\r\n //If it is reachable, it will target it. If not, no target will\r\n //be selected for now, and the next time process() gets called this will repeat\r\n if (nodeObj.conn == null) {\r\n if (this.miscNodes.length === 0) {\r\n //Randomly pick a player node and attack it if its reachable\r\n var rand = getRandomInt(0, this.playerNodes.length-1);\r\n var node;\r\n if (this.playerNodes.length === 0) {\r\n node = null;\r\n } else {\r\n node = this.playerNodes[rand];\r\n }\r\n if (this.nodeReachableByEnemy(node)) {\r\n //Create connection\r\n nodeObj.conn = this.jsplumbinstance.connect({\r\n source:nodeObj.el,\r\n target:node.el\r\n });\r\n ++node.targetedCount;\r\n } else {\r\n //Randomly pick a player core and attack it if its reachable\r\n rand = getRandomInt(0, this.playerCores.length-1);\r\n if (this.playerCores.length === 0) {\r\n return; //No Misc Nodes, no player Nodes, no Player cores. Player lost\r\n } else {\r\n node = this.playerCores[rand];\r\n }\r\n\r\n if (this.nodeReachableByEnemy(node)) {\r\n //Create connection\r\n nodeObj.conn = this.jsplumbinstance.connect({\r\n source:nodeObj.el,\r\n target:node.el\r\n });\r\n ++node.targetedCount;\r\n }\r\n }\r\n } else {\r\n //Randomly pick a misc node and attack it if its reachable\r\n var rand = getRandomInt(0, this.miscNodes.length-1);\r\n var node = this.miscNodes[rand];\r\n if (this.nodeReachableByEnemy(node)) {\r\n nodeObj.conn = this.jsplumbinstance.connect({\r\n source:nodeObj.el,\r\n target:node.el,\r\n });\r\n ++node.targetedCount;\r\n }\r\n }\r\n\r\n //If no connection was made, set the Core to Fortify\r\n nodeObj.action = NodeActions.Fortify;\r\n } else {\r\n //If this node has a selected target\r\n var targetNode;\r\n if (nodeObj.conn.target) {\r\n targetNode = this.getNodeFromElement(nodeObj.conn.target);\r\n } else {\r\n targetNode = this.getNodeFromElement(nodeObj.conn.targetId);\r\n }\r\n if (targetNode == null) {\r\n console.log(\"Error getting Target node Object in enemyAISelectAction()\");\r\n }\r\n\r\n if (targetNode.def > this.enemyAtk + 15) {\r\n if (nodeObj.def < 50) {\r\n nodeObj.action = NodeActions.Fortify;\r\n } else {\r\n nodeObj.action = NodeActions.Overflow;\r\n }\r\n } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) {\r\n nodeObj.action = NodeActions.Scan;\r\n } else {\r\n nodeObj.action = NodeActions.Attack;\r\n }\r\n }\r\n break;\r\n case NodeTypes.Transfer:\r\n //Switch between fortifying and overflowing as necessary\r\n if (nodeObj.def < 125) {\r\n nodeObj.action = NodeActions.Fortify;\r\n } else {\r\n nodeObj.action = NodeActions.Overflow;\r\n }\r\n break;\r\n case NodeTypes.Firewall:\r\n case NodeTypes.Shield:\r\n nodeObj.action = NodeActions.Fortify;\r\n break;\r\n default:\r\n break;\r\n }\r\n}\r\n\r\nvar hackEffWeightSelf = 130; //Weight for Node actions on self\r\nvar hackEffWeightTarget = 25; //Weight for Node Actions against Target\r\nvar hackEffWeightAttack = 80; //Weight for Attack action\r\n\r\n//Returns damage per cycle based on stats\r\nHackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) {\r\n return Math.max(0.55 * (atk + (hacking / hackEffWeightAttack) - def), 1);\r\n}\r\n\r\nHackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) {\r\n return Math.max(0.6 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2);\r\n}\r\n\r\nHackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) {\r\n return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2);\r\n}\r\n\r\nHackingMission.prototype.calculateFortifyEffect = function(hacking=0) {\r\n return 0.9 * hacking / hackEffWeightSelf;\r\n}\r\n\r\nHackingMission.prototype.calculateOverflowEffect = function(hacking=0) {\r\n return 0.95 * hacking / hackEffWeightSelf;\r\n}\r\n\r\n//Updates timer display\r\nHackingMission.prototype.updateTimer = function() {\r\n var timer = document.getElementById(\"hacking-mission-timer\");\r\n\r\n //Convert time remaining to a string of the form mm:ss\r\n var seconds = Math.round(this.time / 1000);\r\n var minutes = Math.trunc(seconds / 60);\r\n seconds %= 60;\r\n var str = (\"0\" + minutes).slice(-2) + \":\" + (\"0\" + seconds).slice(-2);\r\n timer.innerText = \"Time left: \" + str;\r\n}\r\n\r\n//The 'win' argument is a bool for whether or not the player won\r\nHackingMission.prototype.finishMission = function(win) {\r\n inMission = false;\r\n currMission = null;\r\n\r\n if (win) {\r\n var favorMult = 1 + (this.faction.favor / 100);\r\n console.log(\"Hacking mission base reward: \" + this.reward);\r\n console.log(\"favorMult: \" + favorMult);\r\n console.log(\"rep mult: \" + Player.faction_rep_mult);\r\n var gain = this.reward * Player.faction_rep_mult * favorMult;\r\n dialogBoxCreate(\"Mission won! You earned \" +\r\n formatNumber(gain, 3) + \" reputation with \" + this.faction.name);\r\n Player.gainIntelligenceExp(this.difficulty * CONSTANTS.IntelligenceHackingMissionBaseExpGain);\r\n this.faction.playerReputation += gain;\r\n } else {\r\n dialogBoxCreate(\"Mission lost/forfeited! You did not gain any faction reputation.\");\r\n }\r\n\r\n //Clear mission container\r\n var container = document.getElementById(\"mission-container\");\r\n while(container.firstChild) {\r\n container.removeChild(container.firstChild);\r\n }\r\n\r\n //Return to Faction page\r\n document.getElementById(\"mainmenu-container\").style.visibility = \"visible\";\r\n document.getElementById(\"character-overview-wrapper\").style.visibility = \"visible\";\r\n Engine.loadFactionContent();\r\n displayFactionContent(this.faction.name);\r\n}\r\n\r\nexport {HackingMission, inMission, setInMission, currMission};\r\n","import {Programs} from \"./CreateProgram.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {SpecialServerIps} from \"./SpecialServerIps.js\";\r\nimport {post} from \"./Terminal.js\";\r\n\r\nimport {isValidIPAddress} from \"../utils/IPAddress.js\";\r\nimport {formatNumber} from \"../utils/StringHelperFunctions.js\";\r\n\r\n\r\n/* DarkWeb.js */\r\n//Posts a \"help\" message if connected to DarkWeb\r\nfunction checkIfConnectedToDarkweb() {\r\n if (SpecialServerIps.hasOwnProperty(\"Darkweb Server\")) {\r\n var darkwebIp = SpecialServerIps[\"Darkweb Server\"];\r\n if (!isValidIPAddress(darkwebIp)) {return;}\r\n if (darkwebIp == Player.getCurrentServer().ip) {\r\n post(\"You are now connected to the dark web. From the dark web you can purchase illegal items. \" +\r\n \"Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] \" +\r\n \"to purchase an item\");\r\n }\r\n }\r\n\r\n}\r\n\r\n//Handler for dark web commands. The terminal's executeCommand() function will pass\r\n//dark web-specific commands into this. It will pass in the raw split command array\r\n//rather than the command string\r\nfunction executeDarkwebTerminalCommand(commandArray) {\r\n if (commandArray.length == 0) {return;}\r\n switch (commandArray[0]) {\r\n case \"buy\":\r\n if (commandArray.length != 2) {\r\n post(\"Incorrect number of arguments. Usage: \");\r\n post(\"buy -l\");\r\n post(\"buy [item name]\");\r\n return;\r\n }\r\n var arg = commandArray[1];\r\n if (arg == \"-l\") {\r\n listAllDarkwebItems();\r\n } else {\r\n buyDarkwebItem(arg);\r\n }\r\n break;\r\n default:\r\n post(\"Command not found\");\r\n break;\r\n }\r\n}\r\n\r\nfunction listAllDarkwebItems() {\r\n for (var item in DarkWebItems) {\r\n\t\tif (DarkWebItems.hasOwnProperty(item)) {\r\n var item = DarkWebItems[item];\r\n //Convert string using toLocaleString\r\n var split = item.split(\" - \");\r\n if (split.length == 3 && split[1].charAt(0) == '$') {\r\n split[1] = split[1].slice(1);\r\n split[1] = split[1].replace(/,/g, '');\r\n var price = parseFloat(split[1]);\r\n if (isNaN(price)) {\r\n post(item);\r\n return;\r\n }\r\n price = formatNumber(price, 0);\r\n split[1] = \"$\" + price.toString();\r\n post(split.join(\" - \"));\r\n } else {\r\n post(item);\r\n }\r\n\t\t}\r\n\t}\r\n\r\n var priceString = split[1];\r\n //Check for errors\r\n if (priceString.length == 0 || priceString.charAt(0) != '$') {\r\n return -1;\r\n }\r\n //Remove dollar sign and commas\r\n priceString = priceString.slice(1);\r\n priceString = priceString.replace(/,/g, '');\r\n\r\n //Convert string to numeric\r\n var price = parseFloat(priceString);\r\n if (isNaN(price)) {return -1;}\r\n else {return price;}\r\n}\r\n\r\nfunction buyDarkwebItem(itemName) {\r\n if (itemName.toLowerCase() == Programs.BruteSSHProgram.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.BruteSSHProgram);\r\n post(\"You have purchased the BruteSSH.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.FTPCrackProgram.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.FTPCrackProgram);\r\n post(\"You have purchased the FTPCrack.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.RelaySMTPProgram.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.RelaySMTPProgram);\r\n post(\"You have purchased the relaySMTP.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.HTTPWormProgram.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.HTTPWormProgram);\r\n post(\"You have purchased the HTTPWorm.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.SQLInjectProgram.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.SQLInjectProgram);\r\n post(\"You have purchased the SQLInject.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.DeepscanV1.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.DeepscanV1);\r\n post(\"You have purchased the DeepscanV1.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else if (itemName.toLowerCase() == Programs.DeepscanV2.toLowerCase()) {\r\n var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);\r\n if (price > 0 && Player.money.gt(price)) {\r\n Player.loseMoney(price);\r\n Player.getHomeComputer().programs.push(Programs.DeepscanV2);\r\n post(\"You have purchased the DeepscanV2.exe program. The new program \" +\r\n \"can be found on your home computer.\");\r\n } else {\r\n post(\"Not enough money to purchase \" + itemName);\r\n }\r\n } else {\r\n post(\"Unrecognized item\");\r\n }\r\n}\r\n\r\nfunction parseDarkwebItemPrice(itemDesc) {\r\n var split = itemDesc.split(\" - \");\r\n if (split.length == 3) {\r\n var priceString = split[1];\r\n //Check for errors\r\n if (priceString.length == 0 || priceString.charAt(0) != '$') {\r\n return -1;\r\n }\r\n //Remove dollar sign and commas\r\n priceString = priceString.slice(1);\r\n priceString = priceString.replace(/,/g, '');\r\n\r\n //Convert string to numeric\r\n var price = parseFloat(priceString);\r\n if (isNaN(price)) {return -1;}\r\n else {return price;}\r\n } else {\r\n return -1;\r\n }\r\n}\r\n\r\nlet DarkWebItems = {\r\n BruteSSHProgram: \"BruteSSH.exe - $500,000 - Opens up SSH Ports\",\r\n FTPCrackProgram: \"FTPCrack.exe - $1,500,000 - Opens up FTP Ports\",\r\n RelaySMTPProgram: \"relaySMTP.exe - $5,000,000 - Opens up SMTP Ports\",\r\n HTTPWormProgram: \"HTTPWorm.exe - $30,000,000 - Opens up HTTP Ports\",\r\n SQLInjectProgram: \"SQLInject.exe - $250,000,000 - Opens up SQL Ports\",\r\n DeepScanV1Program: \"DeepscanV1.exe - $500,000 - Enables 'scan-analyze' with a depth up to 5\",\r\n DeepScanV2Program: \"DeepscanV2.exe - $25,000,000 - Enables 'scan-analyze' with a depth up to 10\",\r\n}\r\n\r\nexport {checkIfConnectedToDarkweb, executeDarkwebTerminalCommand,\r\n listAllDarkwebItems, buyDarkwebItem, parseDarkwebItemPrice,\r\n DarkWebItems};\r\n","/*\r\nacorn.js \r\nhttps://github.com/ternjs/acorn\r\n\r\nCopyright (C) 2012-2017 by various contributors (see AUTHORS)\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n*/\r\n\r\n(function (global, factory) {\r\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\r\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\r\n (factory((global.acorn = global.acorn || {})));\r\n}(this, (function (exports) { 'use strict';\r\n\r\n// Reserved word lists for various dialects of the language\r\n\r\nvar reservedWords = {\r\n 3: \"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile\",\r\n 5: \"class enum extends super const export import\",\r\n 6: \"enum\",\r\n strict: \"implements interface let package private protected public static yield\",\r\n strictBind: \"eval arguments\"\r\n}\r\n\r\n// And the keywords\r\n\r\nvar ecma5AndLessKeywords = \"break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this\"\r\n\r\nvar keywords = {\r\n 5: ecma5AndLessKeywords,\r\n 6: ecma5AndLessKeywords + \" const class extends export import super\"\r\n}\r\n\r\n// ## Character categories\r\n\r\n// Big ugly regular expressions that match characters in the\r\n// whitespace, identifier, and identifier-start categories. These\r\n// are only applied when a character is found to actually have a\r\n// code point above 128.\r\n// Generated by `bin/generate-identifier-regex.js`.\r\n\r\nvar nonASCIIidentifierStartChars = \"\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u037f\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u052f\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0-\\u08b4\\u08b6-\\u08bd\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0af9\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c39\\u0c3d\\u0c58-\\u0c5a\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d54-\\u0d56\\u0d5f-\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f5\\u13f8-\\u13fd\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f8\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191e\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19b0-\\u19c9\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1c80-\\u1c88\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2118-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309b-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fd5\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7ae\\ua7b0-\\ua7b7\\ua7f7-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\ua9e0-\\ua9e4\\ua9e6-\\ua9ef\\ua9fa-\\ua9fe\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa7e-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uab30-\\uab5a\\uab5c-\\uab65\\uab70-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\"\r\nvar nonASCIIidentifierChars = \"\\u200c\\u200d\\xb7\\u0300-\\u036f\\u0387\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u0669\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u06f0-\\u06f9\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07c0-\\u07c9\\u07eb-\\u07f3\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08d4-\\u08e1\\u08e3-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2\\u09e3\\u09e6-\\u09ef\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b62\\u0b63\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c00-\\u0c03\\u0c3e-\\u0c44\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0c66-\\u0c6f\\u0c81-\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0ce6-\\u0cef\\u0d01-\\u0d03\\u0d3e-\\u0d44\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0d62\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0de6-\\u0def\\u0df2\\u0df3\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0e50-\\u0e59\\u0eb1\\u0eb4-\\u0eb9\\u0ebb\\u0ebc\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102b-\\u103e\\u1040-\\u1049\\u1056-\\u1059\\u105e-\\u1060\\u1062-\\u1064\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u1369-\\u1371\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1b00-\\u1b04\\u1b34-\\u1b44\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1b80-\\u1b82\\u1ba1-\\u1bad\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c24-\\u1c37\\u1c40-\\u1c49\\u1c50-\\u1c59\\u1cd0-\\u1cd2\\u1cd4-\\u1ce8\\u1ced\\u1cf2-\\u1cf4\\u1cf8\\u1cf9\\u1dc0-\\u1df5\\u1dfb-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua620-\\ua629\\ua66f\\ua674-\\ua67d\\ua69e\\ua69f\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua823-\\ua827\\ua880\\ua881\\ua8b4-\\ua8c5\\ua8d0-\\ua8d9\\ua8e0-\\ua8f1\\ua900-\\ua909\\ua926-\\ua92d\\ua947-\\ua953\\ua980-\\ua983\\ua9b3-\\ua9c0\\ua9d0-\\ua9d9\\ua9e5\\ua9f0-\\ua9f9\\uaa29-\\uaa36\\uaa43\\uaa4c\\uaa4d\\uaa50-\\uaa59\\uaa7b-\\uaa7d\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uaaeb-\\uaaef\\uaaf5\\uaaf6\\uabe3-\\uabea\\uabec\\uabed\\uabf0-\\uabf9\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f\"\r\n\r\nvar nonASCIIidentifierStart = new RegExp(\"[\" + nonASCIIidentifierStartChars + \"]\")\r\nvar nonASCIIidentifier = new RegExp(\"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\")\r\n\r\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null\r\n\r\n// These are a run-length and offset encoded representation of the\r\n// >0xffff code points that are a valid part of identifiers. The\r\n// offset starts at 0x10000, and each pair of numbers represents an\r\n// offset to the next range, and then a size of the range. They were\r\n// generated by bin/generate-identifier-regex.js\r\n\r\n// eslint-disable-next-line comma-spacing\r\nvar astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541]\r\n\r\n// eslint-disable-next-line comma-spacing\r\nvar astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]\r\n\r\n// This has a complexity linear to the value of the code. The\r\n// assumption is that looking up astral identifier characters is\r\n// rare.\r\nfunction isInAstralSet(code, set) {\r\n var pos = 0x10000\r\n for (var i = 0; i < set.length; i += 2) {\r\n pos += set[i]\r\n if (pos > code) return false\r\n pos += set[i + 1]\r\n if (pos >= code) return true\r\n }\r\n}\r\n\r\n// Test whether a given character code starts an identifier.\r\n\r\nfunction isIdentifierStart(code, astral) {\r\n if (code < 65) return code === 36\r\n if (code < 91) return true\r\n if (code < 97) return code === 95\r\n if (code < 123) return true\r\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\r\n if (astral === false) return false\r\n return isInAstralSet(code, astralIdentifierStartCodes)\r\n}\r\n\r\n// Test whether a given character is part of an identifier.\r\n\r\nfunction isIdentifierChar(code, astral) {\r\n if (code < 48) return code === 36\r\n if (code < 58) return true\r\n if (code < 65) return false\r\n if (code < 91) return true\r\n if (code < 97) return code === 95\r\n if (code < 123) return true\r\n if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code))\r\n if (astral === false) return false\r\n return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)\r\n}\r\n\r\n// ## Token types\r\n\r\n// The assignment of fine-grained, information-carrying type objects\r\n// allows the tokenizer to store the information it has about a\r\n// token in a way that is very cheap for the parser to look up.\r\n\r\n// All token type variables start with an underscore, to make them\r\n// easy to recognize.\r\n\r\n// The `beforeExpr` property is used to disambiguate between regular\r\n// expressions and divisions. It is set on all token types that can\r\n// be followed by an expression (thus, a slash after them would be a\r\n// regular expression).\r\n//\r\n// The `startsExpr` property is used to check if the token ends a\r\n// `yield` expression. It is set on all token types that either can\r\n// directly start an expression (like a quotation mark) or can\r\n// continue an expression (like the body of a string).\r\n//\r\n// `isLoop` marks a keyword as starting a loop, which is important\r\n// to know when parsing a label, in order to allow or disallow\r\n// continue jumps to that label.\r\n\r\nvar TokenType = function TokenType(label, conf) {\r\n if ( conf === void 0 ) conf = {};\r\n\r\n this.label = label\r\n this.keyword = conf.keyword\r\n this.beforeExpr = !!conf.beforeExpr\r\n this.startsExpr = !!conf.startsExpr\r\n this.isLoop = !!conf.isLoop\r\n this.isAssign = !!conf.isAssign\r\n this.prefix = !!conf.prefix\r\n this.postfix = !!conf.postfix\r\n this.binop = conf.binop || null\r\n this.updateContext = null\r\n};\r\n\r\nfunction binop(name, prec) {\r\n return new TokenType(name, {beforeExpr: true, binop: prec})\r\n}\r\nvar beforeExpr = {beforeExpr: true};\r\nvar startsExpr = {startsExpr: true};\r\n// Map keyword names to token types.\r\n\r\nvar keywordTypes = {}\r\n\r\n// Succinct definitions of keyword token types\r\nfunction kw(name, options) {\r\n if ( options === void 0 ) options = {};\r\n\r\n options.keyword = name\r\n return keywordTypes[name] = new TokenType(name, options)\r\n}\r\n\r\nvar tt = {\r\n num: new TokenType(\"num\", startsExpr),\r\n regexp: new TokenType(\"regexp\", startsExpr),\r\n string: new TokenType(\"string\", startsExpr),\r\n name: new TokenType(\"name\", startsExpr),\r\n eof: new TokenType(\"eof\"),\r\n\r\n // Punctuation token types.\r\n bracketL: new TokenType(\"[\", {beforeExpr: true, startsExpr: true}),\r\n bracketR: new TokenType(\"]\"),\r\n braceL: new TokenType(\"{\", {beforeExpr: true, startsExpr: true}),\r\n braceR: new TokenType(\"}\"),\r\n parenL: new TokenType(\"(\", {beforeExpr: true, startsExpr: true}),\r\n parenR: new TokenType(\")\"),\r\n comma: new TokenType(\",\", beforeExpr),\r\n semi: new TokenType(\";\", beforeExpr),\r\n colon: new TokenType(\":\", beforeExpr),\r\n dot: new TokenType(\".\"),\r\n question: new TokenType(\"?\", beforeExpr),\r\n arrow: new TokenType(\"=>\", beforeExpr),\r\n template: new TokenType(\"template\"),\r\n ellipsis: new TokenType(\"...\", beforeExpr),\r\n backQuote: new TokenType(\"`\", startsExpr),\r\n dollarBraceL: new TokenType(\"${\", {beforeExpr: true, startsExpr: true}),\r\n\r\n // Operators. These carry several kinds of properties to help the\r\n // parser use them properly (the presence of these properties is\r\n // what categorizes them as operators).\r\n //\r\n // `binop`, when present, specifies that this operator is a binary\r\n // operator, and will refer to its precedence.\r\n //\r\n // `prefix` and `postfix` mark the operator as a prefix or postfix\r\n // unary operator.\r\n //\r\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\r\n // binary operators with a very low precedence, that should result\r\n // in AssignmentExpression nodes.\r\n\r\n eq: new TokenType(\"=\", {beforeExpr: true, isAssign: true}),\r\n assign: new TokenType(\"_=\", {beforeExpr: true, isAssign: true}),\r\n incDec: new TokenType(\"++/--\", {prefix: true, postfix: true, startsExpr: true}),\r\n prefix: new TokenType(\"prefix\", {beforeExpr: true, prefix: true, startsExpr: true}),\r\n logicalOR: binop(\"||\", 1),\r\n logicalAND: binop(\"&&\", 2),\r\n bitwiseOR: binop(\"|\", 3),\r\n bitwiseXOR: binop(\"^\", 4),\r\n bitwiseAND: binop(\"&\", 5),\r\n equality: binop(\"==/!=\", 6),\r\n relational: binop(\">\", 7),\r\n bitShift: binop(\"<>>\", 8),\r\n plusMin: new TokenType(\"+/-\", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),\r\n modulo: binop(\"%\", 10),\r\n star: binop(\"*\", 10),\r\n slash: binop(\"/\", 10),\r\n starstar: new TokenType(\"**\", {beforeExpr: true}),\r\n\r\n // Keyword token types.\r\n _break: kw(\"break\"),\r\n _case: kw(\"case\", beforeExpr),\r\n _catch: kw(\"catch\"),\r\n _continue: kw(\"continue\"),\r\n _debugger: kw(\"debugger\"),\r\n _default: kw(\"default\", beforeExpr),\r\n _do: kw(\"do\", {isLoop: true, beforeExpr: true}),\r\n _else: kw(\"else\", beforeExpr),\r\n _finally: kw(\"finally\"),\r\n _for: kw(\"for\", {isLoop: true}),\r\n _function: kw(\"function\", startsExpr),\r\n _if: kw(\"if\"),\r\n _return: kw(\"return\", beforeExpr),\r\n _switch: kw(\"switch\"),\r\n _throw: kw(\"throw\", beforeExpr),\r\n _try: kw(\"try\"),\r\n _var: kw(\"var\"),\r\n _const: kw(\"const\"),\r\n _while: kw(\"while\", {isLoop: true}),\r\n _with: kw(\"with\"),\r\n _new: kw(\"new\", {beforeExpr: true, startsExpr: true}),\r\n _this: kw(\"this\", startsExpr),\r\n _super: kw(\"super\", startsExpr),\r\n _class: kw(\"class\"),\r\n _extends: kw(\"extends\", beforeExpr),\r\n _export: kw(\"export\"),\r\n _import: kw(\"import\"),\r\n _null: kw(\"null\", startsExpr),\r\n _true: kw(\"true\", startsExpr),\r\n _false: kw(\"false\", startsExpr),\r\n _in: kw(\"in\", {beforeExpr: true, binop: 7}),\r\n _instanceof: kw(\"instanceof\", {beforeExpr: true, binop: 7}),\r\n _typeof: kw(\"typeof\", {beforeExpr: true, prefix: true, startsExpr: true}),\r\n _void: kw(\"void\", {beforeExpr: true, prefix: true, startsExpr: true}),\r\n _delete: kw(\"delete\", {beforeExpr: true, prefix: true, startsExpr: true})\r\n}\r\n\r\n// Matches a whole line break (where CRLF is considered a single\r\n// line break). Used to count lines.\r\n\r\nvar lineBreak = /\\r\\n?|\\n|\\u2028|\\u2029/\r\nvar lineBreakG = new RegExp(lineBreak.source, \"g\")\r\n\r\nfunction isNewLine(code) {\r\n return code === 10 || code === 13 || code === 0x2028 || code === 0x2029\r\n}\r\n\r\nvar nonASCIIwhitespace = /[\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000\\ufeff]/\r\n\r\nvar skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g\r\n\r\nvar ref = Object.prototype;\r\nvar hasOwnProperty = ref.hasOwnProperty;\r\nvar toString = ref.toString;\r\n\r\n// Checks if an object has a property.\r\n\r\nfunction has(obj, propName) {\r\n return hasOwnProperty.call(obj, propName)\r\n}\r\n\r\nvar isArray = Array.isArray || (function (obj) { return (\r\n toString.call(obj) === \"[object Array]\"\r\n); })\r\n\r\n// These are used when `options.locations` is on, for the\r\n// `startLoc` and `endLoc` properties.\r\n\r\nvar Position = function Position(line, col) {\r\n this.line = line\r\n this.column = col\r\n};\r\n\r\nPosition.prototype.offset = function offset (n) {\r\n return new Position(this.line, this.column + n)\r\n};\r\n\r\nvar SourceLocation = function SourceLocation(p, start, end) {\r\n this.start = start\r\n this.end = end\r\n if (p.sourceFile !== null) this.source = p.sourceFile\r\n};\r\n\r\n// The `getLineInfo` function is mostly useful when the\r\n// `locations` option is off (for performance reasons) and you\r\n// want to find the line/column position for a given character\r\n// offset. `input` should be the code string that the offset refers\r\n// into.\r\n\r\nfunction getLineInfo(input, offset) {\r\n for (var line = 1, cur = 0;;) {\r\n lineBreakG.lastIndex = cur\r\n var match = lineBreakG.exec(input)\r\n if (match && match.index < offset) {\r\n ++line\r\n cur = match.index + match[0].length\r\n } else {\r\n return new Position(line, offset - cur)\r\n }\r\n }\r\n}\r\n\r\n// A second optional argument can be given to further configure\r\n// the parser process. These options are recognized:\r\n\r\nvar defaultOptions = {\r\n // `ecmaVersion` indicates the ECMAScript version to parse. Must\r\n // be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support\r\n // for strict mode, the set of reserved words, and support for\r\n // new syntax features. The default is 7.\r\n ecmaVersion: 7,\r\n // `sourceType` indicates the mode the code should be parsed in.\r\n // Can be either `\"script\"` or `\"module\"`. This influences global\r\n // strict mode and parsing of `import` and `export` declarations.\r\n sourceType: \"script\",\r\n // `onInsertedSemicolon` can be a callback that will be called\r\n // when a semicolon is automatically inserted. It will be passed\r\n // th position of the comma as an offset, and if `locations` is\r\n // enabled, it is given the location as a `{line, column}` object\r\n // as second argument.\r\n onInsertedSemicolon: null,\r\n // `onTrailingComma` is similar to `onInsertedSemicolon`, but for\r\n // trailing commas.\r\n onTrailingComma: null,\r\n // By default, reserved words are only enforced if ecmaVersion >= 5.\r\n // Set `allowReserved` to a boolean value to explicitly turn this on\r\n // an off. When this option has the value \"never\", reserved words\r\n // and keywords can also not be used as property names.\r\n allowReserved: null,\r\n // When enabled, a return at the top level is not considered an\r\n // error.\r\n allowReturnOutsideFunction: false,\r\n // When enabled, import/export statements are not constrained to\r\n // appearing at the top of the program.\r\n allowImportExportEverywhere: false,\r\n // When enabled, hashbang directive in the beginning of file\r\n // is allowed and treated as a line comment.\r\n allowHashBang: false,\r\n // When `locations` is on, `loc` properties holding objects with\r\n // `start` and `end` properties in `{line, column}` form (with\r\n // line being 1-based and column 0-based) will be attached to the\r\n // nodes.\r\n locations: false,\r\n // A function can be passed as `onToken` option, which will\r\n // cause Acorn to call that function with object in the same\r\n // format as tokens returned from `tokenizer().getToken()`. Note\r\n // that you are not allowed to call the parser from the\r\n // callback—that will corrupt its internal state.\r\n onToken: null,\r\n // A function can be passed as `onComment` option, which will\r\n // cause Acorn to call that function with `(block, text, start,\r\n // end)` parameters whenever a comment is skipped. `block` is a\r\n // boolean indicating whether this is a block (`/* */`) comment,\r\n // `text` is the content of the comment, and `start` and `end` are\r\n // character offsets that denote the start and end of the comment.\r\n // When the `locations` option is on, two more parameters are\r\n // passed, the full `{line, column}` locations of the start and\r\n // end of the comments. Note that you are not allowed to call the\r\n // parser from the callback—that will corrupt its internal state.\r\n onComment: null,\r\n // Nodes have their start and end characters offsets recorded in\r\n // `start` and `end` properties (directly on the node, rather than\r\n // the `loc` object, which holds line/column data. To also add a\r\n // [semi-standardized][range] `range` property holding a `[start,\r\n // end]` array with the same numbers, set the `ranges` option to\r\n // `true`.\r\n //\r\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\r\n ranges: false,\r\n // It is possible to parse multiple files into a single AST by\r\n // passing the tree produced by parsing the first file as\r\n // `program` option in subsequent parses. This will add the\r\n // toplevel forms of the parsed file to the `Program` (top) node\r\n // of an existing parse tree.\r\n program: null,\r\n // When `locations` is on, you can pass this to record the source\r\n // file in every node's `loc` object.\r\n sourceFile: null,\r\n // This value, if given, is stored in every node, whether\r\n // `locations` is on or off.\r\n directSourceFile: null,\r\n // When enabled, parenthesized expressions are represented by\r\n // (non-standard) ParenthesizedExpression nodes\r\n preserveParens: false,\r\n plugins: {}\r\n}\r\n\r\n// Interpret and default an options object\r\n\r\nfunction getOptions(opts) {\r\n var options = {}\r\n\r\n for (var opt in defaultOptions)\r\n options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]\r\n\r\n if (options.ecmaVersion >= 2015)\r\n options.ecmaVersion -= 2009\r\n\r\n if (options.allowReserved == null)\r\n options.allowReserved = options.ecmaVersion < 5\r\n\r\n if (isArray(options.onToken)) {\r\n var tokens = options.onToken\r\n options.onToken = function (token) { return tokens.push(token); }\r\n }\r\n if (isArray(options.onComment))\r\n options.onComment = pushComment(options, options.onComment)\r\n\r\n return options\r\n}\r\n\r\nfunction pushComment(options, array) {\r\n return function(block, text, start, end, startLoc, endLoc) {\r\n var comment = {\r\n type: block ? \"Block\" : \"Line\",\r\n value: text,\r\n start: start,\r\n end: end\r\n }\r\n if (options.locations)\r\n comment.loc = new SourceLocation(this, startLoc, endLoc)\r\n if (options.ranges)\r\n comment.range = [start, end]\r\n array.push(comment)\r\n }\r\n}\r\n\r\n// Registered plugins\r\nvar plugins = {}\r\n\r\nfunction keywordRegexp(words) {\r\n return new RegExp(\"^(\" + words.replace(/ /g, \"|\") + \")$\")\r\n}\r\n\r\nvar Parser = function Parser(options, input, startPos) {\r\n this.options = options = getOptions(options)\r\n this.sourceFile = options.sourceFile\r\n this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])\r\n var reserved = \"\"\r\n if (!options.allowReserved) {\r\n for (var v = options.ecmaVersion;; v--)\r\n if (reserved = reservedWords[v]) break\r\n if (options.sourceType == \"module\") reserved += \" await\"\r\n }\r\n this.reservedWords = keywordRegexp(reserved)\r\n var reservedStrict = (reserved ? reserved + \" \" : \"\") + reservedWords.strict\r\n this.reservedWordsStrict = keywordRegexp(reservedStrict)\r\n this.reservedWordsStrictBind = keywordRegexp(reservedStrict + \" \" + reservedWords.strictBind)\r\n this.input = String(input)\r\n\r\n // Used to signal to callers of `readWord1` whether the word\r\n // contained any escape sequences. This is needed because words with\r\n // escape sequences must not be interpreted as keywords.\r\n this.containsEsc = false\r\n\r\n // Load plugins\r\n this.loadPlugins(options.plugins)\r\n\r\n // Set up token state\r\n\r\n // The current position of the tokenizer in the input.\r\n if (startPos) {\r\n this.pos = startPos\r\n this.lineStart = this.input.lastIndexOf(\"\\n\", startPos - 1) + 1\r\n this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length\r\n } else {\r\n this.pos = this.lineStart = 0\r\n this.curLine = 1\r\n }\r\n\r\n // Properties of the current token:\r\n // Its type\r\n this.type = tt.eof\r\n // For tokens that include more information than their type, the value\r\n this.value = null\r\n // Its start and end offset\r\n this.start = this.end = this.pos\r\n // And, if locations are used, the {line, column} object\r\n // corresponding to those offsets\r\n this.startLoc = this.endLoc = this.curPosition()\r\n\r\n // Position information for the previous token\r\n this.lastTokEndLoc = this.lastTokStartLoc = null\r\n this.lastTokStart = this.lastTokEnd = this.pos\r\n\r\n // The context stack is used to superficially track syntactic\r\n // context to predict whether a regular expression is allowed in a\r\n // given position.\r\n this.context = this.initialContext()\r\n this.exprAllowed = true\r\n\r\n // Figure out if it's a module code.\r\n this.inModule = options.sourceType === \"module\"\r\n this.strict = this.inModule || this.strictDirective(this.pos)\r\n\r\n // Used to signify the start of a potential arrow function\r\n this.potentialArrowAt = -1\r\n\r\n // Flags to track whether we are in a function, a generator, an async function.\r\n this.inFunction = this.inGenerator = this.inAsync = false\r\n // Positions to delayed-check that yield/await does not exist in default parameters.\r\n this.yieldPos = this.awaitPos = 0\r\n // Labels in scope.\r\n this.labels = []\r\n\r\n // If enabled, skip leading hashbang line.\r\n if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === \"#!\")\r\n this.skipLineComment(2)\r\n\r\n // Scope tracking for duplicate variable names (see scope.js)\r\n this.scopeStack = []\r\n this.enterFunctionScope()\r\n};\r\n\r\n// DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them\r\nParser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) };\r\nParser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) };\r\n\r\nParser.prototype.extend = function extend (name, f) {\r\n this[name] = f(this[name])\r\n};\r\n\r\nParser.prototype.loadPlugins = function loadPlugins (pluginConfigs) {\r\n var this$1 = this;\r\n\r\n for (var name in pluginConfigs) {\r\n var plugin = plugins[name]\r\n if (!plugin) throw new Error(\"Plugin '\" + name + \"' not found\")\r\n plugin(this$1, pluginConfigs[name])\r\n }\r\n};\r\n\r\nParser.prototype.parse = function parse () {\r\n var node = this.options.program || this.startNode()\r\n this.nextToken()\r\n return this.parseTopLevel(node)\r\n};\r\n\r\nvar pp = Parser.prototype\r\n\r\n// ## Parser utilities\r\n\r\nvar literal = /^(?:'((?:[^']|\\.)*)'|\"((?:[^\"]|\\.)*)\"|;)/\r\npp.strictDirective = function(start) {\r\n var this$1 = this;\r\n\r\n for (;;) {\r\n skipWhiteSpace.lastIndex = start\r\n start += skipWhiteSpace.exec(this$1.input)[0].length\r\n var match = literal.exec(this$1.input.slice(start))\r\n if (!match) return false\r\n if ((match[1] || match[2]) == \"use strict\") return true\r\n start += match[0].length\r\n }\r\n}\r\n\r\n// Predicate that tests whether the next token is of the given\r\n// type, and if yes, consumes it as a side effect.\r\n\r\npp.eat = function(type) {\r\n if (this.type === type) {\r\n this.next()\r\n return true\r\n } else {\r\n return false\r\n }\r\n}\r\n\r\n// Tests whether parsed token is a contextual keyword.\r\n\r\npp.isContextual = function(name) {\r\n return this.type === tt.name && this.value === name\r\n}\r\n\r\n// Consumes contextual keyword if possible.\r\n\r\npp.eatContextual = function(name) {\r\n return this.value === name && this.eat(tt.name)\r\n}\r\n\r\n// Asserts that following token is given contextual keyword.\r\n\r\npp.expectContextual = function(name) {\r\n if (!this.eatContextual(name)) this.unexpected()\r\n}\r\n\r\n// Test whether a semicolon can be inserted at the current position.\r\n\r\npp.canInsertSemicolon = function() {\r\n return this.type === tt.eof ||\r\n this.type === tt.braceR ||\r\n lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\r\n}\r\n\r\npp.insertSemicolon = function() {\r\n if (this.canInsertSemicolon()) {\r\n if (this.options.onInsertedSemicolon)\r\n this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc)\r\n return true\r\n }\r\n}\r\n\r\n// Consume a semicolon, or, failing that, see if we are allowed to\r\n// pretend that there is a semicolon at this position.\r\n\r\npp.semicolon = function() {\r\n if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected()\r\n}\r\n\r\npp.afterTrailingComma = function(tokType, notNext) {\r\n if (this.type == tokType) {\r\n if (this.options.onTrailingComma)\r\n this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc)\r\n if (!notNext)\r\n this.next()\r\n return true\r\n }\r\n}\r\n\r\n// Expect a token of a given type. If found, consume it, otherwise,\r\n// raise an unexpected token error.\r\n\r\npp.expect = function(type) {\r\n this.eat(type) || this.unexpected()\r\n}\r\n\r\n// Raise an unexpected token error.\r\n\r\npp.unexpected = function(pos) {\r\n this.raise(pos != null ? pos : this.start, \"Unexpected token\")\r\n}\r\n\r\nvar DestructuringErrors = function DestructuringErrors() {\r\n this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = -1\r\n};\r\n\r\npp.checkPatternErrors = function(refDestructuringErrors, isAssign) {\r\n if (!refDestructuringErrors) return\r\n if (refDestructuringErrors.trailingComma > -1)\r\n this.raiseRecoverable(refDestructuringErrors.trailingComma, \"Comma is not permitted after the rest element\")\r\n var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind\r\n if (parens > -1) this.raiseRecoverable(parens, \"Parenthesized pattern\")\r\n}\r\n\r\npp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {\r\n var pos = refDestructuringErrors ? refDestructuringErrors.shorthandAssign : -1\r\n if (!andThrow) return pos >= 0\r\n if (pos > -1) this.raise(pos, \"Shorthand property assignments are valid only in destructuring patterns\")\r\n}\r\n\r\npp.checkYieldAwaitInDefaultParams = function() {\r\n if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))\r\n this.raise(this.yieldPos, \"Yield expression cannot be a default value\")\r\n if (this.awaitPos)\r\n this.raise(this.awaitPos, \"Await expression cannot be a default value\")\r\n}\r\n\r\npp.isSimpleAssignTarget = function(expr) {\r\n if (expr.type === \"ParenthesizedExpression\")\r\n return this.isSimpleAssignTarget(expr.expression)\r\n return expr.type === \"Identifier\" || expr.type === \"MemberExpression\"\r\n}\r\n\r\nvar pp$1 = Parser.prototype\r\n\r\n// ### Statement parsing\r\n\r\n// Parse a program. Initializes the parser, reads any number of\r\n// statements, and wraps them in a Program node. Optionally takes a\r\n// `program` argument. If present, the statements will be appended\r\n// to its body instead of creating a new node.\r\n\r\npp$1.parseTopLevel = function(node) {\r\n var this$1 = this;\r\n\r\n var exports = {}\r\n if (!node.body) node.body = []\r\n while (this.type !== tt.eof) {\r\n var stmt = this$1.parseStatement(true, true, exports)\r\n node.body.push(stmt)\r\n }\r\n this.next()\r\n if (this.options.ecmaVersion >= 6) {\r\n node.sourceType = this.options.sourceType\r\n }\r\n return this.finishNode(node, \"Program\")\r\n}\r\n\r\nvar loopLabel = {kind: \"loop\"};\r\nvar switchLabel = {kind: \"switch\"};\r\npp$1.isLet = function() {\r\n if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != \"let\") return false\r\n skipWhiteSpace.lastIndex = this.pos\r\n var skip = skipWhiteSpace.exec(this.input)\r\n var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next)\r\n if (nextCh === 91 || nextCh == 123) return true // '{' and '['\r\n if (isIdentifierStart(nextCh, true)) {\r\n var pos = next + 1\r\n while (isIdentifierChar(this.input.charCodeAt(pos), true)) ++pos\r\n var ident = this.input.slice(next, pos)\r\n if (!this.isKeyword(ident)) return true\r\n }\r\n return false\r\n}\r\n\r\n// check 'async [no LineTerminator here] function'\r\n// - 'async /*foo*/ function' is OK.\r\n// - 'async /*\\n*/ function' is invalid.\r\npp$1.isAsyncFunction = function() {\r\n if (this.type !== tt.name || this.options.ecmaVersion < 8 || this.value != \"async\")\r\n return false\r\n\r\n skipWhiteSpace.lastIndex = this.pos\r\n var skip = skipWhiteSpace.exec(this.input)\r\n var next = this.pos + skip[0].length\r\n return !lineBreak.test(this.input.slice(this.pos, next)) &&\r\n this.input.slice(next, next + 8) === \"function\" &&\r\n (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))\r\n}\r\n\r\n// Parse a single statement.\r\n//\r\n// If expecting a statement and finding a slash operator, parse a\r\n// regular expression literal. This is to handle cases like\r\n// `if (foo) /blah/.exec(foo)`, where looking at the previous token\r\n// does not help.\r\n\r\npp$1.parseStatement = function(declaration, topLevel, exports) {\r\n var starttype = this.type, node = this.startNode(), kind\r\n\r\n if (this.isLet()) {\r\n starttype = tt._var\r\n kind = \"let\"\r\n }\r\n\r\n // Most types of statements are recognized by the keyword they\r\n // start with. Many are trivial to parse, some require a bit of\r\n // complexity.\r\n\r\n switch (starttype) {\r\n case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword)\r\n case tt._debugger: return this.parseDebuggerStatement(node)\r\n case tt._do: return this.parseDoStatement(node)\r\n case tt._for: return this.parseForStatement(node)\r\n case tt._function:\r\n if (!declaration && this.options.ecmaVersion >= 6) this.unexpected()\r\n return this.parseFunctionStatement(node, false)\r\n case tt._class:\r\n if (!declaration) this.unexpected()\r\n return this.parseClass(node, true)\r\n case tt._if: return this.parseIfStatement(node)\r\n case tt._return: return this.parseReturnStatement(node)\r\n case tt._switch: return this.parseSwitchStatement(node)\r\n case tt._throw: return this.parseThrowStatement(node)\r\n case tt._try: return this.parseTryStatement(node)\r\n case tt._const: case tt._var:\r\n kind = kind || this.value\r\n if (!declaration && kind != \"var\") this.unexpected()\r\n return this.parseVarStatement(node, kind)\r\n case tt._while: return this.parseWhileStatement(node)\r\n case tt._with: return this.parseWithStatement(node)\r\n case tt.braceL: return this.parseBlock()\r\n case tt.semi: return this.parseEmptyStatement(node)\r\n case tt._export:\r\n case tt._import:\r\n if (!this.options.allowImportExportEverywhere) {\r\n if (!topLevel)\r\n this.raise(this.start, \"'import' and 'export' may only appear at the top level\")\r\n if (!this.inModule)\r\n this.raise(this.start, \"'import' and 'export' may appear only with 'sourceType: module'\")\r\n }\r\n return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports)\r\n\r\n // If the statement does not start with a statement keyword or a\r\n // brace, it's an ExpressionStatement or LabeledStatement. We\r\n // simply start parsing an expression, and afterwards, if the\r\n // next token is a colon and the expression was a simple\r\n // Identifier node, we switch to interpreting it as a label.\r\n default:\r\n if (this.isAsyncFunction() && declaration) {\r\n this.next()\r\n return this.parseFunctionStatement(node, true)\r\n }\r\n\r\n var maybeName = this.value, expr = this.parseExpression()\r\n if (starttype === tt.name && expr.type === \"Identifier\" && this.eat(tt.colon))\r\n return this.parseLabeledStatement(node, maybeName, expr)\r\n else return this.parseExpressionStatement(node, expr)\r\n }\r\n}\r\n\r\npp$1.parseBreakContinueStatement = function(node, keyword) {\r\n var this$1 = this;\r\n\r\n var isBreak = keyword == \"break\"\r\n this.next()\r\n if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null\r\n else if (this.type !== tt.name) this.unexpected()\r\n else {\r\n node.label = this.parseIdent()\r\n this.semicolon()\r\n }\r\n\r\n // Verify that there is an actual destination to break or\r\n // continue to.\r\n var i = 0\r\n for (; i < this.labels.length; ++i) {\r\n var lab = this$1.labels[i]\r\n if (node.label == null || lab.name === node.label.name) {\r\n if (lab.kind != null && (isBreak || lab.kind === \"loop\")) break\r\n if (node.label && isBreak) break\r\n }\r\n }\r\n if (i === this.labels.length) this.raise(node.start, \"Unsyntactic \" + keyword)\r\n return this.finishNode(node, isBreak ? \"BreakStatement\" : \"ContinueStatement\")\r\n}\r\n\r\npp$1.parseDebuggerStatement = function(node) {\r\n this.next()\r\n this.semicolon()\r\n return this.finishNode(node, \"DebuggerStatement\")\r\n}\r\n\r\npp$1.parseDoStatement = function(node) {\r\n this.next()\r\n this.labels.push(loopLabel)\r\n node.body = this.parseStatement(false)\r\n this.labels.pop()\r\n this.expect(tt._while)\r\n node.test = this.parseParenExpression()\r\n if (this.options.ecmaVersion >= 6)\r\n this.eat(tt.semi)\r\n else\r\n this.semicolon()\r\n return this.finishNode(node, \"DoWhileStatement\")\r\n}\r\n\r\n// Disambiguating between a `for` and a `for`/`in` or `for`/`of`\r\n// loop is non-trivial. Basically, we have to parse the init `var`\r\n// statement or expression, disallowing the `in` operator (see\r\n// the second parameter to `parseExpression`), and then check\r\n// whether the next token is `in` or `of`. When there is no init\r\n// part (semicolon immediately after the opening parenthesis), it\r\n// is a regular `for` loop.\r\n\r\npp$1.parseForStatement = function(node) {\r\n this.next()\r\n this.labels.push(loopLabel)\r\n this.enterLexicalScope()\r\n this.expect(tt.parenL)\r\n if (this.type === tt.semi) return this.parseFor(node, null)\r\n var isLet = this.isLet()\r\n if (this.type === tt._var || this.type === tt._const || isLet) {\r\n var init$1 = this.startNode(), kind = isLet ? \"let\" : this.value\r\n this.next()\r\n this.parseVar(init$1, true, kind)\r\n this.finishNode(init$1, \"VariableDeclaration\")\r\n if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) && init$1.declarations.length === 1 &&\r\n !(kind !== \"var\" && init$1.declarations[0].init))\r\n return this.parseForIn(node, init$1)\r\n return this.parseFor(node, init$1)\r\n }\r\n var refDestructuringErrors = new DestructuringErrors\r\n var init = this.parseExpression(true, refDestructuringErrors)\r\n if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual(\"of\"))) {\r\n this.toAssignable(init)\r\n this.checkLVal(init)\r\n this.checkPatternErrors(refDestructuringErrors, true)\r\n return this.parseForIn(node, init)\r\n } else {\r\n this.checkExpressionErrors(refDestructuringErrors, true)\r\n }\r\n return this.parseFor(node, init)\r\n}\r\n\r\npp$1.parseFunctionStatement = function(node, isAsync) {\r\n this.next()\r\n return this.parseFunction(node, true, false, isAsync)\r\n}\r\n\r\npp$1.isFunction = function() {\r\n return this.type === tt._function || this.isAsyncFunction()\r\n}\r\n\r\npp$1.parseIfStatement = function(node) {\r\n this.next()\r\n node.test = this.parseParenExpression()\r\n // allow function declarations in branches, but only in non-strict mode\r\n node.consequent = this.parseStatement(!this.strict && this.isFunction())\r\n node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null\r\n return this.finishNode(node, \"IfStatement\")\r\n}\r\n\r\npp$1.parseReturnStatement = function(node) {\r\n if (!this.inFunction && !this.options.allowReturnOutsideFunction)\r\n this.raise(this.start, \"'return' outside of function\")\r\n this.next()\r\n\r\n // In `return` (and `break`/`continue`), the keywords with\r\n // optional arguments, we eagerly look for a semicolon or the\r\n // possibility to insert one.\r\n\r\n if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null\r\n else { node.argument = this.parseExpression(); this.semicolon() }\r\n return this.finishNode(node, \"ReturnStatement\")\r\n}\r\n\r\npp$1.parseSwitchStatement = function(node) {\r\n var this$1 = this;\r\n\r\n this.next()\r\n node.discriminant = this.parseParenExpression()\r\n node.cases = []\r\n this.expect(tt.braceL)\r\n this.labels.push(switchLabel)\r\n this.enterLexicalScope()\r\n\r\n // Statements under must be grouped (by label) in SwitchCase\r\n // nodes. `cur` is used to keep the node that we are currently\r\n // adding statements to.\r\n\r\n var cur\r\n for (var sawDefault = false; this.type != tt.braceR;) {\r\n if (this$1.type === tt._case || this$1.type === tt._default) {\r\n var isCase = this$1.type === tt._case\r\n if (cur) this$1.finishNode(cur, \"SwitchCase\")\r\n node.cases.push(cur = this$1.startNode())\r\n cur.consequent = []\r\n this$1.next()\r\n if (isCase) {\r\n cur.test = this$1.parseExpression()\r\n } else {\r\n if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, \"Multiple default clauses\")\r\n sawDefault = true\r\n cur.test = null\r\n }\r\n this$1.expect(tt.colon)\r\n } else {\r\n if (!cur) this$1.unexpected()\r\n cur.consequent.push(this$1.parseStatement(true))\r\n }\r\n }\r\n this.exitLexicalScope()\r\n if (cur) this.finishNode(cur, \"SwitchCase\")\r\n this.next() // Closing brace\r\n this.labels.pop()\r\n return this.finishNode(node, \"SwitchStatement\")\r\n}\r\n\r\npp$1.parseThrowStatement = function(node) {\r\n this.next()\r\n if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))\r\n this.raise(this.lastTokEnd, \"Illegal newline after throw\")\r\n node.argument = this.parseExpression()\r\n this.semicolon()\r\n return this.finishNode(node, \"ThrowStatement\")\r\n}\r\n\r\n// Reused empty array added for node fields that are always empty.\r\n\r\nvar empty = []\r\n\r\npp$1.parseTryStatement = function(node) {\r\n this.next()\r\n node.block = this.parseBlock()\r\n node.handler = null\r\n if (this.type === tt._catch) {\r\n var clause = this.startNode()\r\n this.next()\r\n this.expect(tt.parenL)\r\n clause.param = this.parseBindingAtom()\r\n this.enterLexicalScope()\r\n this.checkLVal(clause.param, \"let\")\r\n this.expect(tt.parenR)\r\n clause.body = this.parseBlock(false)\r\n this.exitLexicalScope()\r\n node.handler = this.finishNode(clause, \"CatchClause\")\r\n }\r\n node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null\r\n if (!node.handler && !node.finalizer)\r\n this.raise(node.start, \"Missing catch or finally clause\")\r\n return this.finishNode(node, \"TryStatement\")\r\n}\r\n\r\npp$1.parseVarStatement = function(node, kind) {\r\n this.next()\r\n this.parseVar(node, false, kind)\r\n this.semicolon()\r\n return this.finishNode(node, \"VariableDeclaration\")\r\n}\r\n\r\npp$1.parseWhileStatement = function(node) {\r\n this.next()\r\n node.test = this.parseParenExpression()\r\n this.labels.push(loopLabel)\r\n node.body = this.parseStatement(false)\r\n this.labels.pop()\r\n return this.finishNode(node, \"WhileStatement\")\r\n}\r\n\r\npp$1.parseWithStatement = function(node) {\r\n if (this.strict) this.raise(this.start, \"'with' in strict mode\")\r\n this.next()\r\n node.object = this.parseParenExpression()\r\n node.body = this.parseStatement(false)\r\n return this.finishNode(node, \"WithStatement\")\r\n}\r\n\r\npp$1.parseEmptyStatement = function(node) {\r\n this.next()\r\n return this.finishNode(node, \"EmptyStatement\")\r\n}\r\n\r\npp$1.parseLabeledStatement = function(node, maybeName, expr) {\r\n var this$1 = this;\r\n\r\n for (var i = 0; i < this.labels.length; ++i)\r\n if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, \"Label '\" + maybeName + \"' is already declared\")\r\n var kind = this.type.isLoop ? \"loop\" : this.type === tt._switch ? \"switch\" : null\r\n for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) {\r\n var label = this$1.labels[i$1]\r\n if (label.statementStart == node.start) {\r\n label.statementStart = this$1.start\r\n label.kind = kind\r\n } else break\r\n }\r\n this.labels.push({name: maybeName, kind: kind, statementStart: this.start})\r\n node.body = this.parseStatement(true)\r\n if (node.body.type == \"ClassDeclaration\" ||\r\n node.body.type == \"VariableDeclaration\" && node.body.kind != \"var\" ||\r\n node.body.type == \"FunctionDeclaration\" && (this.strict || node.body.generator))\r\n this.raiseRecoverable(node.body.start, \"Invalid labeled declaration\")\r\n this.labels.pop()\r\n node.label = expr\r\n return this.finishNode(node, \"LabeledStatement\")\r\n}\r\n\r\npp$1.parseExpressionStatement = function(node, expr) {\r\n node.expression = expr\r\n this.semicolon()\r\n return this.finishNode(node, \"ExpressionStatement\")\r\n}\r\n\r\n// Parse a semicolon-enclosed block of statements, handling `\"use\r\n// strict\"` declarations when `allowStrict` is true (used for\r\n// function bodies).\r\n\r\npp$1.parseBlock = function(createNewLexicalScope) {\r\n var this$1 = this;\r\n if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;\r\n\r\n var node = this.startNode()\r\n node.body = []\r\n this.expect(tt.braceL)\r\n if (createNewLexicalScope) {\r\n this.enterLexicalScope()\r\n }\r\n while (!this.eat(tt.braceR)) {\r\n var stmt = this$1.parseStatement(true)\r\n node.body.push(stmt)\r\n }\r\n if (createNewLexicalScope) {\r\n this.exitLexicalScope()\r\n }\r\n return this.finishNode(node, \"BlockStatement\")\r\n}\r\n\r\n// Parse a regular `for` loop. The disambiguation code in\r\n// `parseStatement` will already have parsed the init statement or\r\n// expression.\r\n\r\npp$1.parseFor = function(node, init) {\r\n node.init = init\r\n this.expect(tt.semi)\r\n node.test = this.type === tt.semi ? null : this.parseExpression()\r\n this.expect(tt.semi)\r\n node.update = this.type === tt.parenR ? null : this.parseExpression()\r\n this.expect(tt.parenR)\r\n this.exitLexicalScope()\r\n node.body = this.parseStatement(false)\r\n this.labels.pop()\r\n return this.finishNode(node, \"ForStatement\")\r\n}\r\n\r\n// Parse a `for`/`in` and `for`/`of` loop, which are almost\r\n// same from parser's perspective.\r\n\r\npp$1.parseForIn = function(node, init) {\r\n var type = this.type === tt._in ? \"ForInStatement\" : \"ForOfStatement\"\r\n this.next()\r\n node.left = init\r\n node.right = this.parseExpression()\r\n this.expect(tt.parenR)\r\n this.exitLexicalScope()\r\n node.body = this.parseStatement(false)\r\n this.labels.pop()\r\n return this.finishNode(node, type)\r\n}\r\n\r\n// Parse a list of variable declarations.\r\n\r\npp$1.parseVar = function(node, isFor, kind) {\r\n var this$1 = this;\r\n\r\n node.declarations = []\r\n node.kind = kind\r\n for (;;) {\r\n var decl = this$1.startNode()\r\n this$1.parseVarId(decl, kind)\r\n if (this$1.eat(tt.eq)) {\r\n decl.init = this$1.parseMaybeAssign(isFor)\r\n } else if (kind === \"const\" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual(\"of\")))) {\r\n this$1.unexpected()\r\n } else if (decl.id.type != \"Identifier\" && !(isFor && (this$1.type === tt._in || this$1.isContextual(\"of\")))) {\r\n this$1.raise(this$1.lastTokEnd, \"Complex binding patterns require an initialization value\")\r\n } else {\r\n decl.init = null\r\n }\r\n node.declarations.push(this$1.finishNode(decl, \"VariableDeclarator\"))\r\n if (!this$1.eat(tt.comma)) break\r\n }\r\n return node\r\n}\r\n\r\npp$1.parseVarId = function(decl, kind) {\r\n decl.id = this.parseBindingAtom(kind)\r\n this.checkLVal(decl.id, kind, false)\r\n}\r\n\r\n// Parse a function declaration or literal (depending on the\r\n// `isStatement` parameter).\r\n\r\npp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {\r\n this.initFunction(node)\r\n if (this.options.ecmaVersion >= 6 && !isAsync)\r\n node.generator = this.eat(tt.star)\r\n if (this.options.ecmaVersion >= 8)\r\n node.async = !!isAsync\r\n\r\n if (isStatement) {\r\n node.id = isStatement === \"nullableID\" && this.type != tt.name ? null : this.parseIdent()\r\n if (node.id) {\r\n this.checkLVal(node.id, \"var\")\r\n }\r\n }\r\n\r\n var oldInGen = this.inGenerator, oldInAsync = this.inAsync,\r\n oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction\r\n this.inGenerator = node.generator\r\n this.inAsync = node.async\r\n this.yieldPos = 0\r\n this.awaitPos = 0\r\n this.inFunction = true\r\n this.enterFunctionScope()\r\n\r\n if (!isStatement)\r\n node.id = this.type == tt.name ? this.parseIdent() : null\r\n\r\n this.parseFunctionParams(node)\r\n this.parseFunctionBody(node, allowExpressionBody)\r\n\r\n this.inGenerator = oldInGen\r\n this.inAsync = oldInAsync\r\n this.yieldPos = oldYieldPos\r\n this.awaitPos = oldAwaitPos\r\n this.inFunction = oldInFunc\r\n return this.finishNode(node, isStatement ? \"FunctionDeclaration\" : \"FunctionExpression\")\r\n}\r\n\r\npp$1.parseFunctionParams = function(node) {\r\n this.expect(tt.parenL)\r\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true)\r\n this.checkYieldAwaitInDefaultParams()\r\n}\r\n\r\n// Parse a class declaration or literal (depending on the\r\n// `isStatement` parameter).\r\n\r\npp$1.parseClass = function(node, isStatement) {\r\n var this$1 = this;\r\n\r\n this.next()\r\n\r\n this.parseClassId(node, isStatement)\r\n this.parseClassSuper(node)\r\n var classBody = this.startNode()\r\n var hadConstructor = false\r\n classBody.body = []\r\n this.expect(tt.braceL)\r\n while (!this.eat(tt.braceR)) {\r\n if (this$1.eat(tt.semi)) continue\r\n var method = this$1.startNode()\r\n var isGenerator = this$1.eat(tt.star)\r\n var isAsync = false\r\n var isMaybeStatic = this$1.type === tt.name && this$1.value === \"static\"\r\n this$1.parsePropertyName(method)\r\n method.static = isMaybeStatic && this$1.type !== tt.parenL\r\n if (method.static) {\r\n if (isGenerator) this$1.unexpected()\r\n isGenerator = this$1.eat(tt.star)\r\n this$1.parsePropertyName(method)\r\n }\r\n if (this$1.options.ecmaVersion >= 8 && !isGenerator && !method.computed &&\r\n method.key.type === \"Identifier\" && method.key.name === \"async\" && this$1.type !== tt.parenL &&\r\n !this$1.canInsertSemicolon()) {\r\n isAsync = true\r\n this$1.parsePropertyName(method)\r\n }\r\n method.kind = \"method\"\r\n var isGetSet = false\r\n if (!method.computed) {\r\n var key = method.key;\r\n if (!isGenerator && !isAsync && key.type === \"Identifier\" && this$1.type !== tt.parenL && (key.name === \"get\" || key.name === \"set\")) {\r\n isGetSet = true\r\n method.kind = key.name\r\n key = this$1.parsePropertyName(method)\r\n }\r\n if (!method.static && (key.type === \"Identifier\" && key.name === \"constructor\" ||\r\n key.type === \"Literal\" && key.value === \"constructor\")) {\r\n if (hadConstructor) this$1.raise(key.start, \"Duplicate constructor in the same class\")\r\n if (isGetSet) this$1.raise(key.start, \"Constructor can't have get/set modifier\")\r\n if (isGenerator) this$1.raise(key.start, \"Constructor can't be a generator\")\r\n if (isAsync) this$1.raise(key.start, \"Constructor can't be an async method\")\r\n method.kind = \"constructor\"\r\n hadConstructor = true\r\n }\r\n }\r\n this$1.parseClassMethod(classBody, method, isGenerator, isAsync)\r\n if (isGetSet) {\r\n var paramCount = method.kind === \"get\" ? 0 : 1\r\n if (method.value.params.length !== paramCount) {\r\n var start = method.value.start\r\n if (method.kind === \"get\")\r\n this$1.raiseRecoverable(start, \"getter should have no params\")\r\n else\r\n this$1.raiseRecoverable(start, \"setter should have exactly one param\")\r\n } else {\r\n if (method.kind === \"set\" && method.value.params[0].type === \"RestElement\")\r\n this$1.raiseRecoverable(method.value.params[0].start, \"Setter cannot use rest params\")\r\n }\r\n }\r\n }\r\n node.body = this.finishNode(classBody, \"ClassBody\")\r\n return this.finishNode(node, isStatement ? \"ClassDeclaration\" : \"ClassExpression\")\r\n}\r\n\r\npp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) {\r\n method.value = this.parseMethod(isGenerator, isAsync)\r\n classBody.body.push(this.finishNode(method, \"MethodDefinition\"))\r\n}\r\n\r\npp$1.parseClassId = function(node, isStatement) {\r\n node.id = this.type === tt.name ? this.parseIdent() : isStatement === true ? this.unexpected() : null\r\n}\r\n\r\npp$1.parseClassSuper = function(node) {\r\n node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null\r\n}\r\n\r\n// Parses module export declaration.\r\n\r\npp$1.parseExport = function(node, exports) {\r\n var this$1 = this;\r\n\r\n this.next()\r\n // export * from '...'\r\n if (this.eat(tt.star)) {\r\n this.expectContextual(\"from\")\r\n node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()\r\n this.semicolon()\r\n return this.finishNode(node, \"ExportAllDeclaration\")\r\n }\r\n if (this.eat(tt._default)) { // export default ...\r\n this.checkExport(exports, \"default\", this.lastTokStart)\r\n var isAsync\r\n if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {\r\n var fNode = this.startNode()\r\n this.next()\r\n if (isAsync) this.next()\r\n node.declaration = this.parseFunction(fNode, \"nullableID\", false, isAsync)\r\n } else if (this.type === tt._class) {\r\n var cNode = this.startNode()\r\n node.declaration = this.parseClass(cNode, \"nullableID\")\r\n } else {\r\n node.declaration = this.parseMaybeAssign()\r\n this.semicolon()\r\n }\r\n return this.finishNode(node, \"ExportDefaultDeclaration\")\r\n }\r\n // export var|const|let|function|class ...\r\n if (this.shouldParseExportStatement()) {\r\n node.declaration = this.parseStatement(true)\r\n if (node.declaration.type === \"VariableDeclaration\")\r\n this.checkVariableExport(exports, node.declaration.declarations)\r\n else\r\n this.checkExport(exports, node.declaration.id.name, node.declaration.id.start)\r\n node.specifiers = []\r\n node.source = null\r\n } else { // export { x, y as z } [from '...']\r\n node.declaration = null\r\n node.specifiers = this.parseExportSpecifiers(exports)\r\n if (this.eatContextual(\"from\")) {\r\n node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()\r\n } else {\r\n // check for keywords used as local names\r\n for (var i = 0; i < node.specifiers.length; i++) {\r\n if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) {\r\n this$1.unexpected(node.specifiers[i].local.start)\r\n }\r\n }\r\n\r\n node.source = null\r\n }\r\n this.semicolon()\r\n }\r\n return this.finishNode(node, \"ExportNamedDeclaration\")\r\n}\r\n\r\npp$1.checkExport = function(exports, name, pos) {\r\n if (!exports) return\r\n if (has(exports, name))\r\n this.raiseRecoverable(pos, \"Duplicate export '\" + name + \"'\")\r\n exports[name] = true\r\n}\r\n\r\npp$1.checkPatternExport = function(exports, pat) {\r\n var this$1 = this;\r\n\r\n var type = pat.type\r\n if (type == \"Identifier\")\r\n this.checkExport(exports, pat.name, pat.start)\r\n else if (type == \"ObjectPattern\")\r\n for (var i = 0; i < pat.properties.length; ++i)\r\n this$1.checkPatternExport(exports, pat.properties[i].value)\r\n else if (type == \"ArrayPattern\")\r\n for (var i$1 = 0; i$1 < pat.elements.length; ++i$1) {\r\n var elt = pat.elements[i$1]\r\n if (elt) this$1.checkPatternExport(exports, elt)\r\n }\r\n else if (type == \"AssignmentPattern\")\r\n this.checkPatternExport(exports, pat.left)\r\n else if (type == \"ParenthesizedExpression\")\r\n this.checkPatternExport(exports, pat.expression)\r\n}\r\n\r\npp$1.checkVariableExport = function(exports, decls) {\r\n var this$1 = this;\r\n\r\n if (!exports) return\r\n for (var i = 0; i < decls.length; i++)\r\n this$1.checkPatternExport(exports, decls[i].id)\r\n}\r\n\r\npp$1.shouldParseExportStatement = function() {\r\n return this.type.keyword === \"var\" ||\r\n this.type.keyword === \"const\" ||\r\n this.type.keyword === \"class\" ||\r\n this.type.keyword === \"function\" ||\r\n this.isLet() ||\r\n this.isAsyncFunction()\r\n}\r\n\r\n// Parses a comma-separated list of module exports.\r\n\r\npp$1.parseExportSpecifiers = function(exports) {\r\n var this$1 = this;\r\n\r\n var nodes = [], first = true\r\n // export { x, y as z } [from '...']\r\n this.expect(tt.braceL)\r\n while (!this.eat(tt.braceR)) {\r\n if (!first) {\r\n this$1.expect(tt.comma)\r\n if (this$1.afterTrailingComma(tt.braceR)) break\r\n } else first = false\r\n\r\n var node = this$1.startNode()\r\n node.local = this$1.parseIdent(true)\r\n node.exported = this$1.eatContextual(\"as\") ? this$1.parseIdent(true) : node.local\r\n this$1.checkExport(exports, node.exported.name, node.exported.start)\r\n nodes.push(this$1.finishNode(node, \"ExportSpecifier\"))\r\n }\r\n return nodes\r\n}\r\n\r\n// Parses import declaration.\r\n\r\npp$1.parseImport = function(node) {\r\n this.next()\r\n // import '...'\r\n if (this.type === tt.string) {\r\n node.specifiers = empty\r\n node.source = this.parseExprAtom()\r\n } else {\r\n node.specifiers = this.parseImportSpecifiers()\r\n this.expectContextual(\"from\")\r\n node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected()\r\n }\r\n this.semicolon()\r\n return this.finishNode(node, \"ImportDeclaration\")\r\n}\r\n\r\n// Parses a comma-separated list of module imports.\r\n\r\npp$1.parseImportSpecifiers = function() {\r\n var this$1 = this;\r\n\r\n var nodes = [], first = true\r\n if (this.type === tt.name) {\r\n // import defaultObj, { x, y as z } from '...'\r\n var node = this.startNode()\r\n node.local = this.parseIdent()\r\n this.checkLVal(node.local, \"let\")\r\n nodes.push(this.finishNode(node, \"ImportDefaultSpecifier\"))\r\n if (!this.eat(tt.comma)) return nodes\r\n }\r\n if (this.type === tt.star) {\r\n var node$1 = this.startNode()\r\n this.next()\r\n this.expectContextual(\"as\")\r\n node$1.local = this.parseIdent()\r\n this.checkLVal(node$1.local, \"let\")\r\n nodes.push(this.finishNode(node$1, \"ImportNamespaceSpecifier\"))\r\n return nodes\r\n }\r\n this.expect(tt.braceL)\r\n while (!this.eat(tt.braceR)) {\r\n if (!first) {\r\n this$1.expect(tt.comma)\r\n if (this$1.afterTrailingComma(tt.braceR)) break\r\n } else first = false\r\n\r\n var node$2 = this$1.startNode()\r\n node$2.imported = this$1.parseIdent(true)\r\n if (this$1.eatContextual(\"as\")) {\r\n node$2.local = this$1.parseIdent()\r\n } else {\r\n node$2.local = node$2.imported\r\n if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start)\r\n if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raiseRecoverable(node$2.local.start, \"The keyword '\" + node$2.local.name + \"' is reserved\")\r\n }\r\n this$1.checkLVal(node$2.local, \"let\")\r\n nodes.push(this$1.finishNode(node$2, \"ImportSpecifier\"))\r\n }\r\n return nodes\r\n}\r\n\r\nvar pp$2 = Parser.prototype\r\n\r\n// Convert existing expression atom to assignable pattern\r\n// if possible.\r\n\r\npp$2.toAssignable = function(node, isBinding) {\r\n var this$1 = this;\r\n\r\n if (this.options.ecmaVersion >= 6 && node) {\r\n switch (node.type) {\r\n case \"Identifier\":\r\n if (this.inAsync && node.name === \"await\")\r\n this.raise(node.start, \"Can not use 'await' as identifier inside an async function\")\r\n break\r\n\r\n case \"ObjectPattern\":\r\n case \"ArrayPattern\":\r\n break\r\n\r\n case \"ObjectExpression\":\r\n node.type = \"ObjectPattern\"\r\n for (var i = 0; i < node.properties.length; i++) {\r\n var prop = node.properties[i]\r\n if (prop.kind !== \"init\") this$1.raise(prop.key.start, \"Object pattern can't contain getter or setter\")\r\n this$1.toAssignable(prop.value, isBinding)\r\n }\r\n break\r\n\r\n case \"ArrayExpression\":\r\n node.type = \"ArrayPattern\"\r\n this.toAssignableList(node.elements, isBinding)\r\n break\r\n\r\n case \"AssignmentExpression\":\r\n if (node.operator === \"=\") {\r\n node.type = \"AssignmentPattern\"\r\n delete node.operator\r\n this.toAssignable(node.left, isBinding)\r\n // falls through to AssignmentPattern\r\n } else {\r\n this.raise(node.left.end, \"Only '=' operator can be used for specifying default value.\")\r\n break\r\n }\r\n\r\n case \"AssignmentPattern\":\r\n break\r\n\r\n case \"ParenthesizedExpression\":\r\n node.expression = this.toAssignable(node.expression, isBinding)\r\n break\r\n\r\n case \"MemberExpression\":\r\n if (!isBinding) break\r\n\r\n default:\r\n this.raise(node.start, \"Assigning to rvalue\")\r\n }\r\n }\r\n return node\r\n}\r\n\r\n// Convert list of expression atoms to binding list.\r\n\r\npp$2.toAssignableList = function(exprList, isBinding) {\r\n var this$1 = this;\r\n\r\n var end = exprList.length\r\n if (end) {\r\n var last = exprList[end - 1]\r\n if (last && last.type == \"RestElement\") {\r\n --end\r\n } else if (last && last.type == \"SpreadElement\") {\r\n last.type = \"RestElement\"\r\n var arg = last.argument\r\n this.toAssignable(arg, isBinding)\r\n if (arg.type !== \"Identifier\" && arg.type !== \"MemberExpression\" && arg.type !== \"ArrayPattern\")\r\n this.unexpected(arg.start)\r\n --end\r\n }\r\n\r\n if (isBinding && last && last.type === \"RestElement\" && last.argument.type !== \"Identifier\")\r\n this.unexpected(last.argument.start)\r\n }\r\n for (var i = 0; i < end; i++) {\r\n var elt = exprList[i]\r\n if (elt) this$1.toAssignable(elt, isBinding)\r\n }\r\n return exprList\r\n}\r\n\r\n// Parses spread element.\r\n\r\npp$2.parseSpread = function(refDestructuringErrors) {\r\n var node = this.startNode()\r\n this.next()\r\n node.argument = this.parseMaybeAssign(false, refDestructuringErrors)\r\n return this.finishNode(node, \"SpreadElement\")\r\n}\r\n\r\npp$2.parseRest = function(allowNonIdent) {\r\n var node = this.startNode()\r\n this.next()\r\n\r\n // RestElement inside of a function parameter must be an identifier\r\n if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected()\r\n else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected()\r\n\r\n return this.finishNode(node, \"RestElement\")\r\n}\r\n\r\n// Parses lvalue (assignable) atom.\r\n\r\npp$2.parseBindingAtom = function() {\r\n if (this.options.ecmaVersion < 6) return this.parseIdent()\r\n switch (this.type) {\r\n case tt.name:\r\n return this.parseIdent()\r\n\r\n case tt.bracketL:\r\n var node = this.startNode()\r\n this.next()\r\n node.elements = this.parseBindingList(tt.bracketR, true, true)\r\n return this.finishNode(node, \"ArrayPattern\")\r\n\r\n case tt.braceL:\r\n return this.parseObj(true)\r\n\r\n default:\r\n this.unexpected()\r\n }\r\n}\r\n\r\npp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) {\r\n var this$1 = this;\r\n\r\n var elts = [], first = true\r\n while (!this.eat(close)) {\r\n if (first) first = false\r\n else this$1.expect(tt.comma)\r\n if (allowEmpty && this$1.type === tt.comma) {\r\n elts.push(null)\r\n } else if (allowTrailingComma && this$1.afterTrailingComma(close)) {\r\n break\r\n } else if (this$1.type === tt.ellipsis) {\r\n var rest = this$1.parseRest(allowNonIdent)\r\n this$1.parseBindingListItem(rest)\r\n elts.push(rest)\r\n if (this$1.type === tt.comma) this$1.raise(this$1.start, \"Comma is not permitted after the rest element\")\r\n this$1.expect(close)\r\n break\r\n } else {\r\n var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc)\r\n this$1.parseBindingListItem(elem)\r\n elts.push(elem)\r\n }\r\n }\r\n return elts\r\n}\r\n\r\npp$2.parseBindingListItem = function(param) {\r\n return param\r\n}\r\n\r\n// Parses assignment pattern around given atom if possible.\r\n\r\npp$2.parseMaybeDefault = function(startPos, startLoc, left) {\r\n left = left || this.parseBindingAtom()\r\n if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left\r\n var node = this.startNodeAt(startPos, startLoc)\r\n node.left = left\r\n node.right = this.parseMaybeAssign()\r\n return this.finishNode(node, \"AssignmentPattern\")\r\n}\r\n\r\n// Verify that a node is an lval — something that can be assigned\r\n// to.\r\n// bindingType can be either:\r\n// 'var' indicating that the lval creates a 'var' binding\r\n// 'let' indicating that the lval creates a lexical ('let' or 'const') binding\r\n// 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references\r\n\r\npp$2.checkLVal = function(expr, bindingType, checkClashes) {\r\n var this$1 = this;\r\n\r\n switch (expr.type) {\r\n case \"Identifier\":\r\n if (this.strict && this.reservedWordsStrictBind.test(expr.name))\r\n this.raiseRecoverable(expr.start, (bindingType ? \"Binding \" : \"Assigning to \") + expr.name + \" in strict mode\")\r\n if (checkClashes) {\r\n if (has(checkClashes, expr.name))\r\n this.raiseRecoverable(expr.start, \"Argument name clash\")\r\n checkClashes[expr.name] = true\r\n }\r\n if (bindingType && bindingType !== \"none\") {\r\n if (\r\n bindingType === \"var\" && !this.canDeclareVarName(expr.name) ||\r\n bindingType !== \"var\" && !this.canDeclareLexicalName(expr.name)\r\n ) {\r\n this.raiseRecoverable(expr.start, (\"Identifier '\" + (expr.name) + \"' has already been declared\"))\r\n }\r\n if (bindingType === \"var\") {\r\n this.declareVarName(expr.name)\r\n } else {\r\n this.declareLexicalName(expr.name)\r\n }\r\n }\r\n break\r\n\r\n case \"MemberExpression\":\r\n if (bindingType) this.raiseRecoverable(expr.start, (bindingType ? \"Binding\" : \"Assigning to\") + \" member expression\")\r\n break\r\n\r\n case \"ObjectPattern\":\r\n for (var i = 0; i < expr.properties.length; i++)\r\n this$1.checkLVal(expr.properties[i].value, bindingType, checkClashes)\r\n break\r\n\r\n case \"ArrayPattern\":\r\n for (var i$1 = 0; i$1 < expr.elements.length; i$1++) {\r\n var elem = expr.elements[i$1]\r\n if (elem) this$1.checkLVal(elem, bindingType, checkClashes)\r\n }\r\n break\r\n\r\n case \"AssignmentPattern\":\r\n this.checkLVal(expr.left, bindingType, checkClashes)\r\n break\r\n\r\n case \"RestElement\":\r\n this.checkLVal(expr.argument, bindingType, checkClashes)\r\n break\r\n\r\n case \"ParenthesizedExpression\":\r\n this.checkLVal(expr.expression, bindingType, checkClashes)\r\n break\r\n\r\n default:\r\n this.raise(expr.start, (bindingType ? \"Binding\" : \"Assigning to\") + \" rvalue\")\r\n }\r\n}\r\n\r\n// A recursive descent parser operates by defining functions for all\r\n// syntactic elements, and recursively calling those, each function\r\n// advancing the input stream and returning an AST node. Precedence\r\n// of constructs (for example, the fact that `!x[1]` means `!(x[1])`\r\n// instead of `(!x)[1]` is handled by the fact that the parser\r\n// function that parses unary prefix operators is called first, and\r\n// in turn calls the function that parses `[]` subscripts — that\r\n// way, it'll receive the node for `x[1]` already parsed, and wraps\r\n// *that* in the unary operator node.\r\n//\r\n// Acorn uses an [operator precedence parser][opp] to handle binary\r\n// operator precedence, because it is much more compact than using\r\n// the technique outlined above, which uses different, nesting\r\n// functions to specify precedence, for all of the ten binary\r\n// precedence levels that JavaScript defines.\r\n//\r\n// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser\r\n\r\nvar pp$3 = Parser.prototype\r\n\r\n// Check if property name clashes with already added.\r\n// Object/class getters and setters are not allowed to clash —\r\n// either with each other or with an init property — and in\r\n// strict mode, init properties are also not allowed to be repeated.\r\n\r\npp$3.checkPropClash = function(prop, propHash) {\r\n if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))\r\n return\r\n var key = prop.key;\r\n var name\r\n switch (key.type) {\r\n case \"Identifier\": name = key.name; break\r\n case \"Literal\": name = String(key.value); break\r\n default: return\r\n }\r\n var kind = prop.kind;\r\n if (this.options.ecmaVersion >= 6) {\r\n if (name === \"__proto__\" && kind === \"init\") {\r\n if (propHash.proto) this.raiseRecoverable(key.start, \"Redefinition of __proto__ property\")\r\n propHash.proto = true\r\n }\r\n return\r\n }\r\n name = \"$\" + name\r\n var other = propHash[name]\r\n if (other) {\r\n var redefinition\r\n if (kind === \"init\") {\r\n redefinition = this.strict && other.init || other.get || other.set\r\n } else {\r\n redefinition = other.init || other[kind]\r\n }\r\n if (redefinition)\r\n this.raiseRecoverable(key.start, \"Redefinition of property\")\r\n } else {\r\n other = propHash[name] = {\r\n init: false,\r\n get: false,\r\n set: false\r\n }\r\n }\r\n other[kind] = true\r\n}\r\n\r\n// ### Expression parsing\r\n\r\n// These nest, from the most general expression type at the top to\r\n// 'atomic', nondivisible expression types at the bottom. Most of\r\n// the functions will simply let the function(s) below them parse,\r\n// and, *if* the syntactic construct they handle is present, wrap\r\n// the AST node that the inner parser gave them in another node.\r\n\r\n// Parse a full expression. The optional arguments are used to\r\n// forbid the `in` operator (in for loops initalization expressions)\r\n// and provide reference for storing '=' operator inside shorthand\r\n// property assignment in contexts where both object expression\r\n// and object pattern might appear (so it's possible to raise\r\n// delayed syntax error at correct position).\r\n\r\npp$3.parseExpression = function(noIn, refDestructuringErrors) {\r\n var this$1 = this;\r\n\r\n var startPos = this.start, startLoc = this.startLoc\r\n var expr = this.parseMaybeAssign(noIn, refDestructuringErrors)\r\n if (this.type === tt.comma) {\r\n var node = this.startNodeAt(startPos, startLoc)\r\n node.expressions = [expr]\r\n while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors))\r\n return this.finishNode(node, \"SequenceExpression\")\r\n }\r\n return expr\r\n}\r\n\r\n// Parse an assignment expression. This includes applications of\r\n// operators like `+=`.\r\n\r\npp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {\r\n if (this.inGenerator && this.isContextual(\"yield\")) return this.parseYield()\r\n\r\n var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1\r\n if (refDestructuringErrors) {\r\n oldParenAssign = refDestructuringErrors.parenthesizedAssign\r\n oldTrailingComma = refDestructuringErrors.trailingComma\r\n refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1\r\n } else {\r\n refDestructuringErrors = new DestructuringErrors\r\n ownDestructuringErrors = true\r\n }\r\n\r\n var startPos = this.start, startLoc = this.startLoc\r\n if (this.type == tt.parenL || this.type == tt.name)\r\n this.potentialArrowAt = this.start\r\n var left = this.parseMaybeConditional(noIn, refDestructuringErrors)\r\n if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)\r\n if (this.type.isAssign) {\r\n this.checkPatternErrors(refDestructuringErrors, true)\r\n if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors)\r\n var node = this.startNodeAt(startPos, startLoc)\r\n node.operator = this.value\r\n node.left = this.type === tt.eq ? this.toAssignable(left) : left\r\n refDestructuringErrors.shorthandAssign = -1 // reset because shorthand default was used correctly\r\n this.checkLVal(left)\r\n this.next()\r\n node.right = this.parseMaybeAssign(noIn)\r\n return this.finishNode(node, \"AssignmentExpression\")\r\n } else {\r\n if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true)\r\n }\r\n if (oldParenAssign > -1) refDestructuringErrors.parenthesizedAssign = oldParenAssign\r\n if (oldTrailingComma > -1) refDestructuringErrors.trailingComma = oldTrailingComma\r\n return left\r\n}\r\n\r\n// Parse a ternary conditional (`?:`) operator.\r\n\r\npp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {\r\n var startPos = this.start, startLoc = this.startLoc\r\n var expr = this.parseExprOps(noIn, refDestructuringErrors)\r\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\r\n if (this.eat(tt.question)) {\r\n var node = this.startNodeAt(startPos, startLoc)\r\n node.test = expr\r\n node.consequent = this.parseMaybeAssign()\r\n this.expect(tt.colon)\r\n node.alternate = this.parseMaybeAssign(noIn)\r\n return this.finishNode(node, \"ConditionalExpression\")\r\n }\r\n return expr\r\n}\r\n\r\n// Start the precedence parser.\r\n\r\npp$3.parseExprOps = function(noIn, refDestructuringErrors) {\r\n var startPos = this.start, startLoc = this.startLoc\r\n var expr = this.parseMaybeUnary(refDestructuringErrors, false)\r\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\r\n return expr.start == startPos && expr.type === \"ArrowFunctionExpression\" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)\r\n}\r\n\r\n// Parse binary operators with the operator precedence parsing\r\n// algorithm. `left` is the left-hand side of the operator.\r\n// `minPrec` provides context that allows the function to stop and\r\n// defer further parser to one of its callers when it encounters an\r\n// operator that has a lower precedence than the set it is parsing.\r\n\r\npp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {\r\n var prec = this.type.binop\r\n if (prec != null && (!noIn || this.type !== tt._in)) {\r\n if (prec > minPrec) {\r\n var logical = this.type === tt.logicalOR || this.type === tt.logicalAND\r\n var op = this.value\r\n this.next()\r\n var startPos = this.start, startLoc = this.startLoc\r\n var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn)\r\n var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical)\r\n return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)\r\n }\r\n }\r\n return left\r\n}\r\n\r\npp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {\r\n var node = this.startNodeAt(startPos, startLoc)\r\n node.left = left\r\n node.operator = op\r\n node.right = right\r\n return this.finishNode(node, logical ? \"LogicalExpression\" : \"BinaryExpression\")\r\n}\r\n\r\n// Parse unary operators, both prefix and postfix.\r\n\r\npp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {\r\n var this$1 = this;\r\n\r\n var startPos = this.start, startLoc = this.startLoc, expr\r\n if (this.inAsync && this.isContextual(\"await\")) {\r\n expr = this.parseAwait(refDestructuringErrors)\r\n sawUnary = true\r\n } else if (this.type.prefix) {\r\n var node = this.startNode(), update = this.type === tt.incDec\r\n node.operator = this.value\r\n node.prefix = true\r\n this.next()\r\n node.argument = this.parseMaybeUnary(null, true)\r\n this.checkExpressionErrors(refDestructuringErrors, true)\r\n if (update) this.checkLVal(node.argument)\r\n else if (this.strict && node.operator === \"delete\" &&\r\n node.argument.type === \"Identifier\")\r\n this.raiseRecoverable(node.start, \"Deleting local variable in strict mode\")\r\n else sawUnary = true\r\n expr = this.finishNode(node, update ? \"UpdateExpression\" : \"UnaryExpression\")\r\n } else {\r\n expr = this.parseExprSubscripts(refDestructuringErrors)\r\n if (this.checkExpressionErrors(refDestructuringErrors)) return expr\r\n while (this.type.postfix && !this.canInsertSemicolon()) {\r\n var node$1 = this$1.startNodeAt(startPos, startLoc)\r\n node$1.operator = this$1.value\r\n node$1.prefix = false\r\n node$1.argument = expr\r\n this$1.checkLVal(expr)\r\n this$1.next()\r\n expr = this$1.finishNode(node$1, \"UpdateExpression\")\r\n }\r\n }\r\n\r\n if (!sawUnary && this.eat(tt.starstar))\r\n return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), \"**\", false)\r\n else\r\n return expr\r\n}\r\n\r\n// Parse call, dot, and `[]`-subscript expressions.\r\n\r\npp$3.parseExprSubscripts = function(refDestructuringErrors) {\r\n var startPos = this.start, startLoc = this.startLoc\r\n var expr = this.parseExprAtom(refDestructuringErrors)\r\n var skipArrowSubscripts = expr.type === \"ArrowFunctionExpression\" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== \")\"\r\n if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr\r\n var result = this.parseSubscripts(expr, startPos, startLoc)\r\n if (refDestructuringErrors && result.type === \"MemberExpression\") {\r\n if (refDestructuringErrors.parenthesizedAssign >= result.start) refDestructuringErrors.parenthesizedAssign = -1\r\n if (refDestructuringErrors.parenthesizedBind >= result.start) refDestructuringErrors.parenthesizedBind = -1\r\n }\r\n return result\r\n}\r\n\r\npp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {\r\n var this$1 = this;\r\n\r\n var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === \"Identifier\" && base.name === \"async\" &&\r\n this.lastTokEnd == base.end && !this.canInsertSemicolon()\r\n for (var computed;;) {\r\n if ((computed = this$1.eat(tt.bracketL)) || this$1.eat(tt.dot)) {\r\n var node = this$1.startNodeAt(startPos, startLoc)\r\n node.object = base\r\n node.property = computed ? this$1.parseExpression() : this$1.parseIdent(true)\r\n node.computed = !!computed\r\n if (computed) this$1.expect(tt.bracketR)\r\n base = this$1.finishNode(node, \"MemberExpression\")\r\n } else if (!noCalls && this$1.eat(tt.parenL)) {\r\n var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos\r\n this$1.yieldPos = 0\r\n this$1.awaitPos = 0\r\n var exprList = this$1.parseExprList(tt.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors)\r\n if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(tt.arrow)) {\r\n this$1.checkPatternErrors(refDestructuringErrors, false)\r\n this$1.checkYieldAwaitInDefaultParams()\r\n this$1.yieldPos = oldYieldPos\r\n this$1.awaitPos = oldAwaitPos\r\n return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true)\r\n }\r\n this$1.checkExpressionErrors(refDestructuringErrors, true)\r\n this$1.yieldPos = oldYieldPos || this$1.yieldPos\r\n this$1.awaitPos = oldAwaitPos || this$1.awaitPos\r\n var node$1 = this$1.startNodeAt(startPos, startLoc)\r\n node$1.callee = base\r\n node$1.arguments = exprList\r\n base = this$1.finishNode(node$1, \"CallExpression\")\r\n } else if (this$1.type === tt.backQuote) {\r\n var node$2 = this$1.startNodeAt(startPos, startLoc)\r\n node$2.tag = base\r\n node$2.quasi = this$1.parseTemplate()\r\n base = this$1.finishNode(node$2, \"TaggedTemplateExpression\")\r\n } else {\r\n return base\r\n }\r\n }\r\n}\r\n\r\n// Parse an atomic expression — either a single token that is an\r\n// expression, an expression started by a keyword like `function` or\r\n// `new`, or an expression wrapped in punctuation like `()`, `[]`,\r\n// or `{}`.\r\n\r\npp$3.parseExprAtom = function(refDestructuringErrors) {\r\n var node, canBeArrow = this.potentialArrowAt == this.start\r\n switch (this.type) {\r\n case tt._super:\r\n if (!this.inFunction)\r\n this.raise(this.start, \"'super' outside of function or class\")\r\n\r\n case tt._this:\r\n var type = this.type === tt._this ? \"ThisExpression\" : \"Super\"\r\n node = this.startNode()\r\n this.next()\r\n return this.finishNode(node, type)\r\n\r\n case tt.name:\r\n var startPos = this.start, startLoc = this.startLoc\r\n var id = this.parseIdent(this.type !== tt.name)\r\n if (this.options.ecmaVersion >= 8 && id.name === \"async\" && !this.canInsertSemicolon() && this.eat(tt._function))\r\n return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true)\r\n if (canBeArrow && !this.canInsertSemicolon()) {\r\n if (this.eat(tt.arrow))\r\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false)\r\n if (this.options.ecmaVersion >= 8 && id.name === \"async\" && this.type === tt.name) {\r\n id = this.parseIdent()\r\n if (this.canInsertSemicolon() || !this.eat(tt.arrow))\r\n this.unexpected()\r\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)\r\n }\r\n }\r\n return id\r\n\r\n case tt.regexp:\r\n var value = this.value\r\n node = this.parseLiteral(value.value)\r\n node.regex = {pattern: value.pattern, flags: value.flags}\r\n return node\r\n\r\n case tt.num: case tt.string:\r\n return this.parseLiteral(this.value)\r\n\r\n case tt._null: case tt._true: case tt._false:\r\n node = this.startNode()\r\n node.value = this.type === tt._null ? null : this.type === tt._true\r\n node.raw = this.type.keyword\r\n this.next()\r\n return this.finishNode(node, \"Literal\")\r\n\r\n case tt.parenL:\r\n var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow)\r\n if (refDestructuringErrors) {\r\n if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))\r\n refDestructuringErrors.parenthesizedAssign = start\r\n if (refDestructuringErrors.parenthesizedBind < 0)\r\n refDestructuringErrors.parenthesizedBind = start\r\n }\r\n return expr\r\n\r\n case tt.bracketL:\r\n node = this.startNode()\r\n this.next()\r\n node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors)\r\n return this.finishNode(node, \"ArrayExpression\")\r\n\r\n case tt.braceL:\r\n return this.parseObj(false, refDestructuringErrors)\r\n\r\n case tt._function:\r\n node = this.startNode()\r\n this.next()\r\n return this.parseFunction(node, false)\r\n\r\n case tt._class:\r\n return this.parseClass(this.startNode(), false)\r\n\r\n case tt._new:\r\n return this.parseNew()\r\n\r\n case tt.backQuote:\r\n return this.parseTemplate()\r\n\r\n default:\r\n this.unexpected()\r\n }\r\n}\r\n\r\npp$3.parseLiteral = function(value) {\r\n var node = this.startNode()\r\n node.value = value\r\n node.raw = this.input.slice(this.start, this.end)\r\n this.next()\r\n return this.finishNode(node, \"Literal\")\r\n}\r\n\r\npp$3.parseParenExpression = function() {\r\n this.expect(tt.parenL)\r\n var val = this.parseExpression()\r\n this.expect(tt.parenR)\r\n return val\r\n}\r\n\r\npp$3.parseParenAndDistinguishExpression = function(canBeArrow) {\r\n var this$1 = this;\r\n\r\n var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8\r\n if (this.options.ecmaVersion >= 6) {\r\n this.next()\r\n\r\n var innerStartPos = this.start, innerStartLoc = this.startLoc\r\n var exprList = [], first = true, lastIsComma = false\r\n var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart\r\n this.yieldPos = 0\r\n this.awaitPos = 0\r\n while (this.type !== tt.parenR) {\r\n first ? first = false : this$1.expect(tt.comma)\r\n if (allowTrailingComma && this$1.afterTrailingComma(tt.parenR, true)) {\r\n lastIsComma = true\r\n break\r\n } else if (this$1.type === tt.ellipsis) {\r\n spreadStart = this$1.start\r\n exprList.push(this$1.parseParenItem(this$1.parseRest()))\r\n if (this$1.type === tt.comma) this$1.raise(this$1.start, \"Comma is not permitted after the rest element\")\r\n break\r\n } else {\r\n if (this$1.type === tt.parenL && !innerParenStart) {\r\n innerParenStart = this$1.start\r\n }\r\n exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem))\r\n }\r\n }\r\n var innerEndPos = this.start, innerEndLoc = this.startLoc\r\n this.expect(tt.parenR)\r\n\r\n if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) {\r\n this.checkPatternErrors(refDestructuringErrors, false)\r\n this.checkYieldAwaitInDefaultParams()\r\n if (innerParenStart) this.unexpected(innerParenStart)\r\n this.yieldPos = oldYieldPos\r\n this.awaitPos = oldAwaitPos\r\n return this.parseParenArrowList(startPos, startLoc, exprList)\r\n }\r\n\r\n if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart)\r\n if (spreadStart) this.unexpected(spreadStart)\r\n this.checkExpressionErrors(refDestructuringErrors, true)\r\n this.yieldPos = oldYieldPos || this.yieldPos\r\n this.awaitPos = oldAwaitPos || this.awaitPos\r\n\r\n if (exprList.length > 1) {\r\n val = this.startNodeAt(innerStartPos, innerStartLoc)\r\n val.expressions = exprList\r\n this.finishNodeAt(val, \"SequenceExpression\", innerEndPos, innerEndLoc)\r\n } else {\r\n val = exprList[0]\r\n }\r\n } else {\r\n val = this.parseParenExpression()\r\n }\r\n\r\n if (this.options.preserveParens) {\r\n var par = this.startNodeAt(startPos, startLoc)\r\n par.expression = val\r\n return this.finishNode(par, \"ParenthesizedExpression\")\r\n } else {\r\n return val\r\n }\r\n}\r\n\r\npp$3.parseParenItem = function(item) {\r\n return item\r\n}\r\n\r\npp$3.parseParenArrowList = function(startPos, startLoc, exprList) {\r\n return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)\r\n}\r\n\r\n// New's precedence is slightly tricky. It must allow its argument to\r\n// be a `[]` or dot subscript expression, but not a call — at least,\r\n// not without wrapping it in parentheses. Thus, it uses the noCalls\r\n// argument to parseSubscripts to prevent it from consuming the\r\n// argument list.\r\n\r\nvar empty$1 = []\r\n\r\npp$3.parseNew = function() {\r\n var node = this.startNode()\r\n var meta = this.parseIdent(true)\r\n if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) {\r\n node.meta = meta\r\n node.property = this.parseIdent(true)\r\n if (node.property.name !== \"target\")\r\n this.raiseRecoverable(node.property.start, \"The only valid meta property for new is new.target\")\r\n if (!this.inFunction)\r\n this.raiseRecoverable(node.start, \"new.target can only be used in functions\")\r\n return this.finishNode(node, \"MetaProperty\")\r\n }\r\n var startPos = this.start, startLoc = this.startLoc\r\n node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true)\r\n if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false)\r\n else node.arguments = empty$1\r\n return this.finishNode(node, \"NewExpression\")\r\n}\r\n\r\n// Parse template expression.\r\n\r\npp$3.parseTemplateElement = function() {\r\n var elem = this.startNode()\r\n elem.value = {\r\n raw: this.input.slice(this.start, this.end).replace(/\\r\\n?/g, \"\\n\"),\r\n cooked: this.value\r\n }\r\n this.next()\r\n elem.tail = this.type === tt.backQuote\r\n return this.finishNode(elem, \"TemplateElement\")\r\n}\r\n\r\npp$3.parseTemplate = function() {\r\n var this$1 = this;\r\n\r\n var node = this.startNode()\r\n this.next()\r\n node.expressions = []\r\n var curElt = this.parseTemplateElement()\r\n node.quasis = [curElt]\r\n while (!curElt.tail) {\r\n this$1.expect(tt.dollarBraceL)\r\n node.expressions.push(this$1.parseExpression())\r\n this$1.expect(tt.braceR)\r\n node.quasis.push(curElt = this$1.parseTemplateElement())\r\n }\r\n this.next()\r\n return this.finishNode(node, \"TemplateLiteral\")\r\n}\r\n\r\n// Parse an object literal or binding pattern.\r\n\r\npp$3.parseObj = function(isPattern, refDestructuringErrors) {\r\n var this$1 = this;\r\n\r\n var node = this.startNode(), first = true, propHash = {}\r\n node.properties = []\r\n this.next()\r\n while (!this.eat(tt.braceR)) {\r\n if (!first) {\r\n this$1.expect(tt.comma)\r\n if (this$1.afterTrailingComma(tt.braceR)) break\r\n } else first = false\r\n\r\n var prop = this$1.startNode(), isGenerator, isAsync, startPos, startLoc\r\n if (this$1.options.ecmaVersion >= 6) {\r\n prop.method = false\r\n prop.shorthand = false\r\n if (isPattern || refDestructuringErrors) {\r\n startPos = this$1.start\r\n startLoc = this$1.startLoc\r\n }\r\n if (!isPattern)\r\n isGenerator = this$1.eat(tt.star)\r\n }\r\n this$1.parsePropertyName(prop)\r\n if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && !prop.computed &&\r\n prop.key.type === \"Identifier\" && prop.key.name === \"async\" && this$1.type !== tt.parenL &&\r\n this$1.type !== tt.colon && !this$1.canInsertSemicolon()) {\r\n isAsync = true\r\n this$1.parsePropertyName(prop, refDestructuringErrors)\r\n } else {\r\n isAsync = false\r\n }\r\n this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors)\r\n this$1.checkPropClash(prop, propHash)\r\n node.properties.push(this$1.finishNode(prop, \"Property\"))\r\n }\r\n return this.finishNode(node, isPattern ? \"ObjectPattern\" : \"ObjectExpression\")\r\n}\r\n\r\npp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) {\r\n if ((isGenerator || isAsync) && this.type === tt.colon)\r\n this.unexpected()\r\n\r\n if (this.eat(tt.colon)) {\r\n prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors)\r\n prop.kind = \"init\"\r\n } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) {\r\n if (isPattern) this.unexpected()\r\n prop.kind = \"init\"\r\n prop.method = true\r\n prop.value = this.parseMethod(isGenerator, isAsync)\r\n } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === \"Identifier\" &&\r\n (prop.key.name === \"get\" || prop.key.name === \"set\") &&\r\n (this.type != tt.comma && this.type != tt.braceR)) {\r\n if (isGenerator || isAsync || isPattern) this.unexpected()\r\n prop.kind = prop.key.name\r\n this.parsePropertyName(prop)\r\n prop.value = this.parseMethod(false)\r\n var paramCount = prop.kind === \"get\" ? 0 : 1\r\n if (prop.value.params.length !== paramCount) {\r\n var start = prop.value.start\r\n if (prop.kind === \"get\")\r\n this.raiseRecoverable(start, \"getter should have no params\")\r\n else\r\n this.raiseRecoverable(start, \"setter should have exactly one param\")\r\n } else {\r\n if (prop.kind === \"set\" && prop.value.params[0].type === \"RestElement\")\r\n this.raiseRecoverable(prop.value.params[0].start, \"Setter cannot use rest params\")\r\n }\r\n } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === \"Identifier\") {\r\n if (this.keywords.test(prop.key.name) ||\r\n (this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) ||\r\n (this.inGenerator && prop.key.name == \"yield\") ||\r\n (this.inAsync && prop.key.name == \"await\"))\r\n this.raiseRecoverable(prop.key.start, \"'\" + prop.key.name + \"' can not be used as shorthand property\")\r\n prop.kind = \"init\"\r\n if (isPattern) {\r\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\r\n } else if (this.type === tt.eq && refDestructuringErrors) {\r\n if (refDestructuringErrors.shorthandAssign < 0)\r\n refDestructuringErrors.shorthandAssign = this.start\r\n prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key)\r\n } else {\r\n prop.value = prop.key\r\n }\r\n prop.shorthand = true\r\n } else this.unexpected()\r\n}\r\n\r\npp$3.parsePropertyName = function(prop) {\r\n if (this.options.ecmaVersion >= 6) {\r\n if (this.eat(tt.bracketL)) {\r\n prop.computed = true\r\n prop.key = this.parseMaybeAssign()\r\n this.expect(tt.bracketR)\r\n return prop.key\r\n } else {\r\n prop.computed = false\r\n }\r\n }\r\n return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true)\r\n}\r\n\r\n// Initialize empty function node.\r\n\r\npp$3.initFunction = function(node) {\r\n node.id = null\r\n if (this.options.ecmaVersion >= 6) {\r\n node.generator = false\r\n node.expression = false\r\n }\r\n if (this.options.ecmaVersion >= 8)\r\n node.async = false\r\n}\r\n\r\n// Parse object or class method.\r\n\r\npp$3.parseMethod = function(isGenerator, isAsync) {\r\n var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync,\r\n oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction\r\n\r\n this.initFunction(node)\r\n if (this.options.ecmaVersion >= 6)\r\n node.generator = isGenerator\r\n if (this.options.ecmaVersion >= 8)\r\n node.async = !!isAsync\r\n\r\n this.inGenerator = node.generator\r\n this.inAsync = node.async\r\n this.yieldPos = 0\r\n this.awaitPos = 0\r\n this.inFunction = true\r\n this.enterFunctionScope()\r\n\r\n this.expect(tt.parenL)\r\n node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8)\r\n this.checkYieldAwaitInDefaultParams()\r\n this.parseFunctionBody(node, false)\r\n\r\n this.inGenerator = oldInGen\r\n this.inAsync = oldInAsync\r\n this.yieldPos = oldYieldPos\r\n this.awaitPos = oldAwaitPos\r\n this.inFunction = oldInFunc\r\n return this.finishNode(node, \"FunctionExpression\")\r\n}\r\n\r\n// Parse arrow function expression with given parameters.\r\n\r\npp$3.parseArrowExpression = function(node, params, isAsync) {\r\n var oldInGen = this.inGenerator, oldInAsync = this.inAsync,\r\n oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldInFunc = this.inFunction\r\n\r\n this.enterFunctionScope()\r\n this.initFunction(node)\r\n if (this.options.ecmaVersion >= 8)\r\n node.async = !!isAsync\r\n\r\n this.inGenerator = false\r\n this.inAsync = node.async\r\n this.yieldPos = 0\r\n this.awaitPos = 0\r\n this.inFunction = true\r\n\r\n node.params = this.toAssignableList(params, true)\r\n this.parseFunctionBody(node, true)\r\n\r\n this.inGenerator = oldInGen\r\n this.inAsync = oldInAsync\r\n this.yieldPos = oldYieldPos\r\n this.awaitPos = oldAwaitPos\r\n this.inFunction = oldInFunc\r\n return this.finishNode(node, \"ArrowFunctionExpression\")\r\n}\r\n\r\n// Parse function body and check parameters.\r\n\r\npp$3.parseFunctionBody = function(node, isArrowFunction) {\r\n var isExpression = isArrowFunction && this.type !== tt.braceL\r\n var oldStrict = this.strict, useStrict = false\r\n\r\n if (isExpression) {\r\n node.body = this.parseMaybeAssign()\r\n node.expression = true\r\n this.checkParams(node, false)\r\n } else {\r\n var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)\r\n if (!oldStrict || nonSimple) {\r\n useStrict = this.strictDirective(this.end)\r\n // If this is a strict mode function, verify that argument names\r\n // are not repeated, and it does not try to bind the words `eval`\r\n // or `arguments`.\r\n if (useStrict && nonSimple)\r\n this.raiseRecoverable(node.start, \"Illegal 'use strict' directive in function with non-simple parameter list\")\r\n }\r\n // Start a new scope with regard to labels and the `inFunction`\r\n // flag (restore them to their old value afterwards).\r\n var oldLabels = this.labels\r\n this.labels = []\r\n if (useStrict) this.strict = true\r\n\r\n // Add the params to varDeclaredNames to ensure that an error is thrown\r\n // if a let/const declaration in the function clashes with one of the params.\r\n this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && this.isSimpleParamList(node.params))\r\n node.body = this.parseBlock(false)\r\n node.expression = false\r\n this.labels = oldLabels\r\n }\r\n this.exitFunctionScope()\r\n\r\n if (this.strict && node.id) {\r\n // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'\r\n this.checkLVal(node.id, \"none\")\r\n }\r\n this.strict = oldStrict\r\n}\r\n\r\npp$3.isSimpleParamList = function(params) {\r\n for (var i = 0; i < params.length; i++)\r\n if (params[i].type !== \"Identifier\") return false\r\n return true\r\n}\r\n\r\n// Checks function params for various disallowed patterns such as using \"eval\"\r\n// or \"arguments\" and duplicate parameters.\r\n\r\npp$3.checkParams = function(node, allowDuplicates) {\r\n var this$1 = this;\r\n\r\n var nameHash = {}\r\n for (var i = 0; i < node.params.length; i++) this$1.checkLVal(node.params[i], \"var\", allowDuplicates ? null : nameHash)\r\n}\r\n\r\n// Parses a comma-separated list of expressions, and returns them as\r\n// an array. `close` is the token type that ends the list, and\r\n// `allowEmpty` can be turned on to allow subsequent commas with\r\n// nothing in between them to be parsed as `null` (which is needed\r\n// for array literals).\r\n\r\npp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {\r\n var this$1 = this;\r\n\r\n var elts = [], first = true\r\n while (!this.eat(close)) {\r\n if (!first) {\r\n this$1.expect(tt.comma)\r\n if (allowTrailingComma && this$1.afterTrailingComma(close)) break\r\n } else first = false\r\n\r\n var elt\r\n if (allowEmpty && this$1.type === tt.comma)\r\n elt = null\r\n else if (this$1.type === tt.ellipsis) {\r\n elt = this$1.parseSpread(refDestructuringErrors)\r\n if (refDestructuringErrors && this$1.type === tt.comma && refDestructuringErrors.trailingComma < 0)\r\n refDestructuringErrors.trailingComma = this$1.start\r\n } else {\r\n elt = this$1.parseMaybeAssign(false, refDestructuringErrors)\r\n }\r\n elts.push(elt)\r\n }\r\n return elts\r\n}\r\n\r\n// Parse the next token as an identifier. If `liberal` is true (used\r\n// when parsing properties), it will also convert keywords into\r\n// identifiers.\r\n\r\npp$3.parseIdent = function(liberal) {\r\n var node = this.startNode()\r\n if (liberal && this.options.allowReserved == \"never\") liberal = false\r\n if (this.type === tt.name) {\r\n if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) &&\r\n (this.options.ecmaVersion >= 6 ||\r\n this.input.slice(this.start, this.end).indexOf(\"\\\\\") == -1))\r\n this.raiseRecoverable(this.start, \"The keyword '\" + this.value + \"' is reserved\")\r\n if (this.inGenerator && this.value === \"yield\")\r\n this.raiseRecoverable(this.start, \"Can not use 'yield' as identifier inside a generator\")\r\n if (this.inAsync && this.value === \"await\")\r\n this.raiseRecoverable(this.start, \"Can not use 'await' as identifier inside an async function\")\r\n node.name = this.value\r\n } else if (liberal && this.type.keyword) {\r\n node.name = this.type.keyword\r\n } else {\r\n this.unexpected()\r\n }\r\n this.next()\r\n return this.finishNode(node, \"Identifier\")\r\n}\r\n\r\n// Parses yield expression inside generator.\r\n\r\npp$3.parseYield = function() {\r\n if (!this.yieldPos) this.yieldPos = this.start\r\n\r\n var node = this.startNode()\r\n this.next()\r\n if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) {\r\n node.delegate = false\r\n node.argument = null\r\n } else {\r\n node.delegate = this.eat(tt.star)\r\n node.argument = this.parseMaybeAssign()\r\n }\r\n return this.finishNode(node, \"YieldExpression\")\r\n}\r\n\r\npp$3.parseAwait = function() {\r\n if (!this.awaitPos) this.awaitPos = this.start\r\n\r\n var node = this.startNode()\r\n this.next()\r\n node.argument = this.parseMaybeUnary(null, true)\r\n return this.finishNode(node, \"AwaitExpression\")\r\n}\r\n\r\nvar pp$4 = Parser.prototype\r\n\r\n// This function is used to raise exceptions on parse errors. It\r\n// takes an offset integer (into the current `input`) to indicate\r\n// the location of the error, attaches the position to the end\r\n// of the error message, and then raises a `SyntaxError` with that\r\n// message.\r\n\r\npp$4.raise = function(pos, message) {\r\n var loc = getLineInfo(this.input, pos)\r\n message += \" (\" + loc.line + \":\" + loc.column + \")\"\r\n var err = new SyntaxError(message)\r\n err.pos = pos; err.loc = loc; err.raisedAt = this.pos\r\n throw err\r\n}\r\n\r\npp$4.raiseRecoverable = pp$4.raise\r\n\r\npp$4.curPosition = function() {\r\n if (this.options.locations) {\r\n return new Position(this.curLine, this.pos - this.lineStart)\r\n }\r\n}\r\n\r\nvar pp$5 = Parser.prototype\r\n\r\n// Object.assign polyfill\r\nvar assign = Object.assign || function(target) {\r\n var sources = [], len = arguments.length - 1;\r\n while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];\r\n\r\n for (var i = 0; i < sources.length; i++) {\r\n var source = sources[i]\r\n for (var key in source) {\r\n if (has(source, key)) {\r\n target[key] = source[key]\r\n }\r\n }\r\n }\r\n return target\r\n}\r\n\r\n// The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.\r\n\r\npp$5.enterFunctionScope = function() {\r\n // var: a hash of var-declared names in the current lexical scope\r\n // lexical: a hash of lexically-declared names in the current lexical scope\r\n // childVar: a hash of var-declared names in all child lexical scopes of the current lexical scope (within the current function scope)\r\n // parentLexical: a hash of lexically-declared names in all parent lexical scopes of the current lexical scope (within the current function scope)\r\n this.scopeStack.push({var: {}, lexical: {}, childVar: {}, parentLexical: {}})\r\n}\r\n\r\npp$5.exitFunctionScope = function() {\r\n this.scopeStack.pop()\r\n}\r\n\r\npp$5.enterLexicalScope = function() {\r\n var parentScope = this.scopeStack[this.scopeStack.length - 1]\r\n var childScope = {var: {}, lexical: {}, childVar: {}, parentLexical: {}}\r\n\r\n this.scopeStack.push(childScope)\r\n assign(childScope.parentLexical, parentScope.lexical, parentScope.parentLexical)\r\n}\r\n\r\npp$5.exitLexicalScope = function() {\r\n var childScope = this.scopeStack.pop()\r\n var parentScope = this.scopeStack[this.scopeStack.length - 1]\r\n\r\n assign(parentScope.childVar, childScope.var, childScope.childVar)\r\n}\r\n\r\n/**\r\n * A name can be declared with `var` if there are no variables with the same name declared with `let`/`const`\r\n * in the current lexical scope or any of the parent lexical scopes in this function.\r\n */\r\npp$5.canDeclareVarName = function(name) {\r\n var currentScope = this.scopeStack[this.scopeStack.length - 1]\r\n\r\n return !has(currentScope.lexical, name) && !has(currentScope.parentLexical, name)\r\n}\r\n\r\n/**\r\n * A name can be declared with `let`/`const` if there are no variables with the same name declared with `let`/`const`\r\n * in the current scope, and there are no variables with the same name declared with `var` in the current scope or in\r\n * any child lexical scopes in this function.\r\n */\r\npp$5.canDeclareLexicalName = function(name) {\r\n var currentScope = this.scopeStack[this.scopeStack.length - 1]\r\n\r\n return !has(currentScope.lexical, name) && !has(currentScope.var, name) && !has(currentScope.childVar, name)\r\n}\r\n\r\npp$5.declareVarName = function(name) {\r\n this.scopeStack[this.scopeStack.length - 1].var[name] = true\r\n}\r\n\r\npp$5.declareLexicalName = function(name) {\r\n this.scopeStack[this.scopeStack.length - 1].lexical[name] = true\r\n}\r\n\r\nvar Node = function Node(parser, pos, loc) {\r\n this.type = \"\"\r\n this.start = pos\r\n this.end = 0\r\n if (parser.options.locations)\r\n this.loc = new SourceLocation(parser, loc)\r\n if (parser.options.directSourceFile)\r\n this.sourceFile = parser.options.directSourceFile\r\n if (parser.options.ranges)\r\n this.range = [pos, 0]\r\n};\r\n\r\n// Start an AST node, attaching a start offset.\r\n\r\nvar pp$6 = Parser.prototype\r\n\r\npp$6.startNode = function() {\r\n return new Node(this, this.start, this.startLoc)\r\n}\r\n\r\npp$6.startNodeAt = function(pos, loc) {\r\n return new Node(this, pos, loc)\r\n}\r\n\r\n// Finish an AST node, adding `type` and `end` properties.\r\n\r\nfunction finishNodeAt(node, type, pos, loc) {\r\n node.type = type\r\n node.end = pos\r\n if (this.options.locations)\r\n node.loc.end = loc\r\n if (this.options.ranges)\r\n node.range[1] = pos\r\n return node\r\n}\r\n\r\npp$6.finishNode = function(node, type) {\r\n return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)\r\n}\r\n\r\n// Finish node at given position\r\n\r\npp$6.finishNodeAt = function(node, type, pos, loc) {\r\n return finishNodeAt.call(this, node, type, pos, loc)\r\n}\r\n\r\n// The algorithm used to determine whether a regexp can appear at a\r\n// given point in the program is loosely based on sweet.js' approach.\r\n// See https://github.com/mozilla/sweet.js/wiki/design\r\n\r\nvar TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {\r\n this.token = token\r\n this.isExpr = !!isExpr\r\n this.preserveSpace = !!preserveSpace\r\n this.override = override\r\n this.generator = !!generator\r\n};\r\n\r\nvar types = {\r\n b_stat: new TokContext(\"{\", false),\r\n b_expr: new TokContext(\"{\", true),\r\n b_tmpl: new TokContext(\"${\", true),\r\n p_stat: new TokContext(\"(\", false),\r\n p_expr: new TokContext(\"(\", true),\r\n q_tmpl: new TokContext(\"`\", true, true, function (p) { return p.readTmplToken(); }),\r\n f_expr: new TokContext(\"function\", true),\r\n f_expr_gen: new TokContext(\"function\", true, false, null, true),\r\n f_gen: new TokContext(\"function\", false, false, null, true)\r\n}\r\n\r\nvar pp$7 = Parser.prototype\r\n\r\npp$7.initialContext = function() {\r\n return [types.b_stat]\r\n}\r\n\r\npp$7.braceIsBlock = function(prevType) {\r\n if (prevType === tt.colon) {\r\n var parent = this.curContext()\r\n if (parent === types.b_stat || parent === types.b_expr)\r\n return !parent.isExpr\r\n }\r\n if (prevType === tt._return)\r\n return lineBreak.test(this.input.slice(this.lastTokEnd, this.start))\r\n if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR || prevType == tt.arrow)\r\n return true\r\n if (prevType == tt.braceL)\r\n return this.curContext() === types.b_stat\r\n return !this.exprAllowed\r\n}\r\n\r\npp$7.inGeneratorContext = function() {\r\n var this$1 = this;\r\n\r\n for (var i = this.context.length - 1; i >= 0; i--)\r\n if (this$1.context[i].generator) return true\r\n return false\r\n}\r\n\r\npp$7.updateContext = function(prevType) {\r\n var update, type = this.type\r\n if (type.keyword && prevType == tt.dot)\r\n this.exprAllowed = false\r\n else if (update = type.updateContext)\r\n update.call(this, prevType)\r\n else\r\n this.exprAllowed = type.beforeExpr\r\n}\r\n\r\n// Token-specific context update code\r\n\r\ntt.parenR.updateContext = tt.braceR.updateContext = function() {\r\n if (this.context.length == 1) {\r\n this.exprAllowed = true\r\n return\r\n }\r\n var out = this.context.pop(), cur\r\n if (out === types.b_stat && (cur = this.curContext()) && cur.token === \"function\") {\r\n this.context.pop()\r\n this.exprAllowed = false\r\n } else if (out === types.b_tmpl) {\r\n this.exprAllowed = true\r\n } else {\r\n this.exprAllowed = !out.isExpr\r\n }\r\n}\r\n\r\ntt.braceL.updateContext = function(prevType) {\r\n this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr)\r\n this.exprAllowed = true\r\n}\r\n\r\ntt.dollarBraceL.updateContext = function() {\r\n this.context.push(types.b_tmpl)\r\n this.exprAllowed = true\r\n}\r\n\r\ntt.parenL.updateContext = function(prevType) {\r\n var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while\r\n this.context.push(statementParens ? types.p_stat : types.p_expr)\r\n this.exprAllowed = true\r\n}\r\n\r\ntt.incDec.updateContext = function() {\r\n // tokExprAllowed stays unchanged\r\n}\r\n\r\ntt._function.updateContext = function(prevType) {\r\n if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else &&\r\n !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat))\r\n this.context.push(types.f_expr)\r\n this.exprAllowed = false\r\n}\r\n\r\ntt.backQuote.updateContext = function() {\r\n if (this.curContext() === types.q_tmpl)\r\n this.context.pop()\r\n else\r\n this.context.push(types.q_tmpl)\r\n this.exprAllowed = false\r\n}\r\n\r\ntt.star.updateContext = function(prevType) {\r\n if (prevType == tt._function) {\r\n if (this.curContext() === types.f_expr)\r\n this.context[this.context.length - 1] = types.f_expr_gen\r\n else\r\n this.context.push(types.f_gen)\r\n }\r\n this.exprAllowed = true\r\n}\r\n\r\ntt.name.updateContext = function(prevType) {\r\n var allowed = false\r\n if (this.options.ecmaVersion >= 6) {\r\n if (this.value == \"of\" && !this.exprAllowed ||\r\n this.value == \"yield\" && this.inGeneratorContext())\r\n allowed = true\r\n }\r\n this.exprAllowed = allowed\r\n}\r\n\r\n// Object type used to represent tokens. Note that normally, tokens\r\n// simply exist as properties on the parser object. This is only\r\n// used for the onToken callback and the external tokenizer.\r\n\r\nvar Token = function Token(p) {\r\n this.type = p.type\r\n this.value = p.value\r\n this.start = p.start\r\n this.end = p.end\r\n if (p.options.locations)\r\n this.loc = new SourceLocation(p, p.startLoc, p.endLoc)\r\n if (p.options.ranges)\r\n this.range = [p.start, p.end]\r\n};\r\n\r\n// ## Tokenizer\r\n\r\nvar pp$8 = Parser.prototype\r\n\r\n// Are we running under Rhino?\r\nvar isRhino = typeof Packages == \"object\" && Object.prototype.toString.call(Packages) == \"[object JavaPackage]\"\r\n\r\n// Move to the next token\r\n\r\npp$8.next = function() {\r\n if (this.options.onToken)\r\n this.options.onToken(new Token(this))\r\n\r\n this.lastTokEnd = this.end\r\n this.lastTokStart = this.start\r\n this.lastTokEndLoc = this.endLoc\r\n this.lastTokStartLoc = this.startLoc\r\n this.nextToken()\r\n}\r\n\r\npp$8.getToken = function() {\r\n this.next()\r\n return new Token(this)\r\n}\r\n\r\n// If we're in an ES6 environment, make parsers iterable\r\nif (typeof Symbol !== \"undefined\")\r\n pp$8[Symbol.iterator] = function() {\r\n var this$1 = this;\r\n\r\n return {\r\n next: function () {\r\n var token = this$1.getToken()\r\n return {\r\n done: token.type === tt.eof,\r\n value: token\r\n }\r\n }\r\n }\r\n }\r\n\r\n// Toggle strict mode. Re-reads the next number or string to please\r\n// pedantic tests (`\"use strict\"; 010;` should fail).\r\n\r\npp$8.curContext = function() {\r\n return this.context[this.context.length - 1]\r\n}\r\n\r\n// Read a single token, updating the parser object's token-related\r\n// properties.\r\n\r\npp$8.nextToken = function() {\r\n var curContext = this.curContext()\r\n if (!curContext || !curContext.preserveSpace) this.skipSpace()\r\n\r\n this.start = this.pos\r\n if (this.options.locations) this.startLoc = this.curPosition()\r\n if (this.pos >= this.input.length) return this.finishToken(tt.eof)\r\n\r\n if (curContext.override) return curContext.override(this)\r\n else this.readToken(this.fullCharCodeAtPos())\r\n}\r\n\r\npp$8.readToken = function(code) {\r\n // Identifier or keyword. '\\uXXXX' sequences are allowed in\r\n // identifiers, so '\\' also dispatches to that.\r\n if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\\' */)\r\n return this.readWord()\r\n\r\n return this.getTokenFromCode(code)\r\n}\r\n\r\npp$8.fullCharCodeAtPos = function() {\r\n var code = this.input.charCodeAt(this.pos)\r\n if (code <= 0xd7ff || code >= 0xe000) return code\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n return (code << 10) + next - 0x35fdc00\r\n}\r\n\r\npp$8.skipBlockComment = function() {\r\n var this$1 = this;\r\n\r\n var startLoc = this.options.onComment && this.curPosition()\r\n var start = this.pos, end = this.input.indexOf(\"*/\", this.pos += 2)\r\n if (end === -1) this.raise(this.pos - 2, \"Unterminated comment\")\r\n this.pos = end + 2\r\n if (this.options.locations) {\r\n lineBreakG.lastIndex = start\r\n var match\r\n while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {\r\n ++this$1.curLine\r\n this$1.lineStart = match.index + match[0].length\r\n }\r\n }\r\n if (this.options.onComment)\r\n this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,\r\n startLoc, this.curPosition())\r\n}\r\n\r\npp$8.skipLineComment = function(startSkip) {\r\n var this$1 = this;\r\n\r\n var start = this.pos\r\n var startLoc = this.options.onComment && this.curPosition()\r\n var ch = this.input.charCodeAt(this.pos += startSkip)\r\n while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {\r\n ++this$1.pos\r\n ch = this$1.input.charCodeAt(this$1.pos)\r\n }\r\n if (this.options.onComment)\r\n this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,\r\n startLoc, this.curPosition())\r\n}\r\n\r\n// Called at the start of the parse and after every token. Skips\r\n// whitespace and comments, and.\r\n\r\npp$8.skipSpace = function() {\r\n var this$1 = this;\r\n\r\n loop: while (this.pos < this.input.length) {\r\n var ch = this$1.input.charCodeAt(this$1.pos)\r\n switch (ch) {\r\n case 32: case 160: // ' '\r\n ++this$1.pos\r\n break\r\n case 13:\r\n if (this$1.input.charCodeAt(this$1.pos + 1) === 10) {\r\n ++this$1.pos\r\n }\r\n case 10: case 8232: case 8233:\r\n ++this$1.pos\r\n if (this$1.options.locations) {\r\n ++this$1.curLine\r\n this$1.lineStart = this$1.pos\r\n }\r\n break\r\n case 47: // '/'\r\n switch (this$1.input.charCodeAt(this$1.pos + 1)) {\r\n case 42: // '*'\r\n this$1.skipBlockComment()\r\n break\r\n case 47:\r\n this$1.skipLineComment(2)\r\n break\r\n default:\r\n break loop\r\n }\r\n break\r\n default:\r\n if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {\r\n ++this$1.pos\r\n } else {\r\n break loop\r\n }\r\n }\r\n }\r\n}\r\n\r\n// Called at the end of every token. Sets `end`, `val`, and\r\n// maintains `context` and `exprAllowed`, and skips the space after\r\n// the token, so that the next one's `start` will point at the\r\n// right position.\r\n\r\npp$8.finishToken = function(type, val) {\r\n this.end = this.pos\r\n if (this.options.locations) this.endLoc = this.curPosition()\r\n var prevType = this.type\r\n this.type = type\r\n this.value = val\r\n\r\n this.updateContext(prevType)\r\n}\r\n\r\n// ### Token reading\r\n\r\n// This is the function that is called to fetch the next token. It\r\n// is somewhat obscure, because it works in character codes rather\r\n// than characters, and because operator parsing has been inlined\r\n// into it.\r\n//\r\n// All in the name of speed.\r\n//\r\npp$8.readToken_dot = function() {\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n if (next >= 48 && next <= 57) return this.readNumber(true)\r\n var next2 = this.input.charCodeAt(this.pos + 2)\r\n if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'\r\n this.pos += 3\r\n return this.finishToken(tt.ellipsis)\r\n } else {\r\n ++this.pos\r\n return this.finishToken(tt.dot)\r\n }\r\n}\r\n\r\npp$8.readToken_slash = function() { // '/'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n if (this.exprAllowed) { ++this.pos; return this.readRegexp() }\r\n if (next === 61) return this.finishOp(tt.assign, 2)\r\n return this.finishOp(tt.slash, 1)\r\n}\r\n\r\npp$8.readToken_mult_modulo_exp = function(code) { // '%*'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n var size = 1\r\n var tokentype = code === 42 ? tt.star : tt.modulo\r\n\r\n // exponentiation operator ** and **=\r\n if (this.options.ecmaVersion >= 7 && next === 42) {\r\n ++size\r\n tokentype = tt.starstar\r\n next = this.input.charCodeAt(this.pos + 2)\r\n }\r\n\r\n if (next === 61) return this.finishOp(tt.assign, size + 1)\r\n return this.finishOp(tokentype, size)\r\n}\r\n\r\npp$8.readToken_pipe_amp = function(code) { // '|&'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)\r\n if (next === 61) return this.finishOp(tt.assign, 2)\r\n return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)\r\n}\r\n\r\npp$8.readToken_caret = function() { // '^'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n if (next === 61) return this.finishOp(tt.assign, 2)\r\n return this.finishOp(tt.bitwiseXOR, 1)\r\n}\r\n\r\npp$8.readToken_plus_min = function(code) { // '+-'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n if (next === code) {\r\n if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&\r\n lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {\r\n // A `-->` line comment\r\n this.skipLineComment(3)\r\n this.skipSpace()\r\n return this.nextToken()\r\n }\r\n return this.finishOp(tt.incDec, 2)\r\n }\r\n if (next === 61) return this.finishOp(tt.assign, 2)\r\n return this.finishOp(tt.plusMin, 1)\r\n}\r\n\r\npp$8.readToken_lt_gt = function(code) { // '<>'\r\n var next = this.input.charCodeAt(this.pos + 1)\r\n var size = 1\r\n if (next === code) {\r\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\r\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\r\n return this.finishOp(tt.bitShift, size)\r\n }\r\n if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&\r\n this.input.charCodeAt(this.pos + 3) == 45) {\r\n if (this.inModule) this.unexpected()\r\n // `0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(0>position)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit(\\\"removeListener\\\",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)\\\"removeListener\\\"!==key&&this.removeAllListeners(key);return this.removeAllListeners(\\\"removeListener\\\"),this._events={},this\\n}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){var ret;return ret=this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.listenerCount=function(emitter,type){var ret;return ret=emitter._events&&emitter._events[type]?isFunction(emitter._events[type])?1:emitter._events[type].length:0}},{}],\\\"/node_modules/jshint/data/ascii-identifier-data.js\\\":[function(_dereq_,module){for(var identifierStartTable=[],i=0;128>i;i++)identifierStartTable[i]=36===i||i>=65&&90>=i||95===i||i>=97&&122>=i;for(var identifierPartTable=[],i=0;128>i;i++)identifierPartTable[i]=identifierStartTable[i]||i>=48&&57>=i;module.exports={asciiIdentifierStartTable:identifierStartTable,asciiIdentifierPartTable:identifierPartTable}},{}],\\\"/node_modules/jshint/lodash.js\\\":[function(_dereq_,module,exports){(function(global){(function(){function baseFindIndex(array,predicate,fromRight){for(var length=array.length,index=fromRight?length:-1;fromRight?index--:length>++index;)if(predicate(array[index],index,array))return index;return-1}function baseIndexOf(array,value,fromIndex){if(value!==value)return indexOfNaN(array,fromIndex);for(var index=fromIndex-1,length=array.length;length>++index;)if(array[index]===value)return index;return-1}function baseIsFunction(value){return\\\"function\\\"==typeof value||!1}function baseToString(value){return\\\"string\\\"==typeof value?value:null==value?\\\"\\\":value+\\\"\\\"}function indexOfNaN(array,fromIndex,fromRight){for(var length=array.length,index=fromIndex+(fromRight?0:-1);fromRight?index--:length>++index;){var other=array[index];if(other!==other)return index}return-1}function isObjectLike(value){return!!value&&\\\"object\\\"==typeof value}function lodash(){}function arrayCopy(source,array){var index=-1,length=source.length;for(array||(array=Array(length));length>++index;)array[index]=source[index];return array}function arrayEach(array,iteratee){for(var index=-1,length=array.length;length>++index&&iteratee(array[index],index,array)!==!1;);return array}function arrayFilter(array,predicate){for(var index=-1,length=array.length,resIndex=-1,result=[];length>++index;){var value=array[index];predicate(value,index,array)&&(result[++resIndex]=value)}return result}function arrayMap(array,iteratee){for(var index=-1,length=array.length,result=Array(length);length>++index;)result[index]=iteratee(array[index],index,array);return result}function arrayMax(array){for(var index=-1,length=array.length,result=NEGATIVE_INFINITY;length>++index;){var value=array[index];value>result&&(result=value)}return result}function arraySome(array,predicate){for(var index=-1,length=array.length;length>++index;)if(predicate(array[index],index,array))return!0;return!1}function assignWith(object,source,customizer){var props=keys(source);push.apply(props,getSymbols(source));for(var index=-1,length=props.length;length>++index;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(value!==undefined||key in object)||(object[key]=result)}return object}function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;length>++index;){var key=props[index];object[key]=source[key]}return object}function baseCallback(func,thisArg,argCount){var type=typeof func;return\\\"function\\\"==type?thisArg===undefined?func:bindCallback(func,thisArg,argCount):null==func?identity:\\\"object\\\"==type?baseMatches(func):thisArg===undefined?property(func):baseMatchesProperty(func,thisArg)}function baseClone(value,isDeep,customizer,key,object,stackA,stackB){var result;if(customizer&&(result=object?customizer(value,key,object):customizer(value)),result!==undefined)return result;if(!isObject(value))return value;var isArr=isArray(value);if(isArr){if(result=initCloneArray(value),!isDeep)return arrayCopy(value,result)}else{var tag=objToString.call(value),isFunc=tag==funcTag;if(tag!=objectTag&&tag!=argsTag&&(!isFunc||object))return cloneableTags[tag]?initCloneByTag(value,tag,isDeep):object?value:{};if(result=initCloneObject(isFunc?{}:value),!isDeep)return baseAssign(result,value)}stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==value)return stackB[length];return stackA.push(value),stackB.push(result),(isArr?arrayEach:baseForOwn)(value,function(subValue,key){result[key]=baseClone(subValue,isDeep,customizer,key,value,stackA,stackB)}),result}function baseFilter(collection,predicate){var result=[];return baseEach(collection,function(value,index,collection){predicate(value,index,collection)&&result.push(value)}),result}function baseForIn(object,iteratee){return baseFor(object,iteratee,keysIn)}function baseForOwn(object,iteratee){return baseFor(object,iteratee,keys)}function baseGet(object,path,pathKey){if(null!=object){pathKey!==undefined&&pathKey in toObject(object)&&(path=[pathKey]);for(var index=-1,length=path.length;null!=object&&length>++index;)var result=object=object[path[index]];return result}}function baseIsEqual(value,other,customizer,isLoose,stackA,stackB){if(value===other)return 0!==value||1/value==1/other;var valType=typeof value,othType=typeof other;return\\\"function\\\"!=valType&&\\\"object\\\"!=valType&&\\\"function\\\"!=othType&&\\\"object\\\"!=othType||null==value||null==other?value!==value&&other!==other:baseIsEqualDeep(value,other,baseIsEqual,customizer,isLoose,stackA,stackB)}function baseIsEqualDeep(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objIsArr=isArray(object),othIsArr=isArray(other),objTag=arrayTag,othTag=arrayTag;objIsArr||(objTag=objToString.call(object),objTag==argsTag?objTag=objectTag:objTag!=objectTag&&(objIsArr=isTypedArray(object))),othIsArr||(othTag=objToString.call(other),othTag==argsTag?othTag=objectTag:othTag!=objectTag&&(othIsArr=isTypedArray(other)));var objIsObj=objTag==objectTag,othIsObj=othTag==objectTag,isSameTag=objTag==othTag;if(isSameTag&&!objIsArr&&!objIsObj)return equalByTag(object,other,objTag);if(!isLoose){var valWrapped=objIsObj&&hasOwnProperty.call(object,\\\"__wrapped__\\\"),othWrapped=othIsObj&&hasOwnProperty.call(other,\\\"__wrapped__\\\");if(valWrapped||othWrapped)return equalFunc(valWrapped?object.value():object,othWrapped?other.value():other,customizer,isLoose,stackA,stackB)}if(!isSameTag)return!1;stackA||(stackA=[]),stackB||(stackB=[]);for(var length=stackA.length;length--;)if(stackA[length]==object)return stackB[length]==other;stackA.push(object),stackB.push(other);var result=(objIsArr?equalArrays:equalObjects)(object,other,equalFunc,customizer,isLoose,stackA,stackB);return stackA.pop(),stackB.pop(),result}function baseIsMatch(object,props,values,strictCompareFlags,customizer){for(var index=-1,length=props.length,noCustomizer=!customizer;length>++index;)if(noCustomizer&&strictCompareFlags[index]?values[index]!==object[props[index]]:!(props[index]in object))return!1;for(index=-1;length>++index;){var key=props[index],objValue=object[key],srcValue=values[index];if(noCustomizer&&strictCompareFlags[index])var result=objValue!==undefined||key in object;else result=customizer?customizer(objValue,srcValue,key):undefined,result===undefined&&(result=baseIsEqual(srcValue,objValue,customizer,!0));if(!result)return!1}return!0}function baseMatches(source){var props=keys(source),length=props.length;if(!length)return constant(!0);if(1==length){var key=props[0],value=source[key];if(isStrictComparable(value))return function(object){return null==object?!1:object[key]===value&&(value!==undefined||key in toObject(object))}}for(var values=Array(length),strictCompareFlags=Array(length);length--;)value=source[props[length]],values[length]=value,strictCompareFlags[length]=isStrictComparable(value);return function(object){return null!=object&&baseIsMatch(toObject(object),props,values,strictCompareFlags)}}function baseMatchesProperty(path,value){var isArr=isArray(path),isCommon=isKey(path)&&isStrictComparable(value),pathKey=path+\\\"\\\";return path=toPath(path),function(object){if(null==object)return!1;var key=pathKey;if(object=toObject(object),!(!isArr&&isCommon||key in object)){if(object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),null==object)return!1;key=last(path),object=toObject(object)}return object[key]===value?value!==undefined||key in object:baseIsEqual(value,object[key],null,!0)}}function baseMerge(object,source,customizer,stackA,stackB){if(!isObject(object))return object;var isSrcArr=isLength(source.length)&&(isArray(source)||isTypedArray(source));if(!isSrcArr){var props=keys(source);push.apply(props,getSymbols(source))}return arrayEach(props||source,function(srcValue,key){if(props&&(key=srcValue,srcValue=source[key]),isObjectLike(srcValue))stackA||(stackA=[]),stackB||(stackB=[]),baseMergeDeep(object,source,key,baseMerge,customizer,stackA,stackB);else{var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue),!isSrcArr&&result===undefined||!isCommon&&(result===result?result===value:value!==value)||(object[key]=result)}}),object}function baseMergeDeep(object,source,key,mergeFunc,customizer,stackA,stackB){for(var length=stackA.length,srcValue=source[key];length--;)if(stackA[length]==srcValue)return object[key]=stackB[length],undefined;var value=object[key],result=customizer?customizer(value,srcValue,key,object,source):undefined,isCommon=result===undefined;isCommon&&(result=srcValue,isLength(srcValue.length)&&(isArray(srcValue)||isTypedArray(srcValue))?result=isArray(value)?value:getLength(value)?arrayCopy(value):[]:isPlainObject(srcValue)||isArguments(srcValue)?result=isArguments(value)?toPlainObject(value):isPlainObject(value)?value:{}:isCommon=!1),stackA.push(srcValue),stackB.push(result),isCommon?object[key]=mergeFunc(result,srcValue,customizer,stackA,stackB):(result===result?result!==value:value===value)&&(object[key]=result)}function baseProperty(key){return function(object){return null==object?undefined:object[key]}}function basePropertyDeep(path){var pathKey=path+\\\"\\\";return path=toPath(path),function(object){return baseGet(object,path,pathKey)}}function baseSlice(array,start,end){var index=-1,length=array.length;start=null==start?0:+start||0,0>start&&(start=-start>length?0:length+start),end=end===undefined||end>length?length:+end||0,0>end&&(end+=length),length=start>end?0:end-start>>>0,start>>>=0;for(var result=Array(length);length>++index;)result[index]=array[index+start];return result}function baseSome(collection,predicate){var result;return baseEach(collection,function(value,index,collection){return result=predicate(value,index,collection),!result}),!!result}function baseValues(object,props){for(var index=-1,length=props.length,result=Array(length);length>++index;)result[index]=object[props[index]];return result}function binaryIndex(array,value,retHighest){var low=0,high=array?array.length:low;if(\\\"number\\\"==typeof value&&value===value&&HALF_MAX_ARRAY_LENGTH>=high){for(;high>low;){var mid=low+high>>>1,computed=array[mid];(retHighest?value>=computed:value>computed)?low=mid+1:high=mid}return high}return binaryIndexBy(array,value,identity,retHighest)}function binaryIndexBy(array,value,iteratee,retHighest){value=iteratee(value);for(var low=0,high=array?array.length:0,valIsNaN=value!==value,valIsUndef=value===undefined;high>low;){var mid=floor((low+high)/2),computed=iteratee(array[mid]),isReflexive=computed===computed;if(valIsNaN)var setLow=isReflexive||retHighest;else setLow=valIsUndef?isReflexive&&(retHighest||computed!==undefined):retHighest?value>=computed:value>computed;setLow?low=mid+1:high=mid}return nativeMin(high,MAX_ARRAY_INDEX)}function bindCallback(func,thisArg,argCount){if(\\\"function\\\"!=typeof func)return identity;if(thisArg===undefined)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function bufferClone(buffer){return bufferSlice.call(buffer,0)}function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2&&sources[length-2],guard=length>2&&sources[2],thisArg=length>1&&sources[length-1];for(\\\"function\\\"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer=\\\"function\\\"==typeof thisArg?thisArg:null,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?null:customizer,length=1);length>++index;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}function createBaseEach(eachFunc,fromRight){return function(collection,iteratee){var length=collection?getLength(collection):0;if(!isLength(length))return eachFunc(collection,iteratee);for(var index=fromRight?length:-1,iterable=toObject(collection);(fromRight?index--:length>++index)&&iteratee(iterable[index],index,iterable)!==!1;);return collection}}function createBaseFor(fromRight){return function(object,iteratee,keysFunc){for(var iterable=toObject(object),props=keysFunc(object),length=props.length,index=fromRight?length:-1;fromRight?index--:length>++index;){var key=props[index];if(iteratee(iterable[key],key,iterable)===!1)break}return object}}function createFindIndex(fromRight){return function(array,predicate,thisArg){return array&&array.length?(predicate=getCallback(predicate,thisArg,3),baseFindIndex(array,predicate,fromRight)):-1}}function createForEach(arrayFunc,eachFunc){return function(collection,iteratee,thisArg){return\\\"function\\\"==typeof iteratee&&thisArg===undefined&&isArray(collection)?arrayFunc(collection,iteratee):eachFunc(collection,bindCallback(iteratee,thisArg,3))}}function equalArrays(array,other,equalFunc,customizer,isLoose,stackA,stackB){var index=-1,arrLength=array.length,othLength=other.length,result=!0;if(arrLength!=othLength&&!(isLoose&&othLength>arrLength))return!1;for(;result&&arrLength>++index;){var arrValue=array[index],othValue=other[index];if(result=undefined,customizer&&(result=isLoose?customizer(othValue,arrValue,index):customizer(arrValue,othValue,index)),result===undefined)if(isLoose)for(var othIndex=othLength;othIndex--&&(othValue=other[othIndex],!(result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB))););else result=arrValue&&arrValue===othValue||equalFunc(arrValue,othValue,customizer,isLoose,stackA,stackB)}return!!result}function equalByTag(object,other,tag){switch(tag){case boolTag:case dateTag:return+object==+other;case errorTag:return object.name==other.name&&object.message==other.message;case numberTag:return object!=+object?other!=+other:0==object?1/object==1/other:object==+other;case regexpTag:case stringTag:return object==other+\\\"\\\"}return!1}function equalObjects(object,other,equalFunc,customizer,isLoose,stackA,stackB){var objProps=keys(object),objLength=objProps.length,othProps=keys(other),othLength=othProps.length;if(objLength!=othLength&&!isLoose)return!1;for(var skipCtor=isLoose,index=-1;objLength>++index;){var key=objProps[index],result=isLoose?key in other:hasOwnProperty.call(other,key);if(result){var objValue=object[key],othValue=other[key];result=undefined,customizer&&(result=isLoose?customizer(othValue,objValue,key):customizer(objValue,othValue,key)),result===undefined&&(result=objValue&&objValue===othValue||equalFunc(objValue,othValue,customizer,isLoose,stackA,stackB))}if(!result)return!1;skipCtor||(skipCtor=\\\"constructor\\\"==key)}if(!skipCtor){var objCtor=object.constructor,othCtor=other.constructor;if(objCtor!=othCtor&&\\\"constructor\\\"in object&&\\\"constructor\\\"in other&&!(\\\"function\\\"==typeof objCtor&&objCtor instanceof objCtor&&\\\"function\\\"==typeof othCtor&&othCtor instanceof othCtor))return!1}return!0}function getCallback(func,thisArg,argCount){var result=lodash.callback||callback;return result=result===callback?baseCallback:result,argCount?result(func,thisArg,argCount):result}function getIndexOf(collection,target,fromIndex){var result=lodash.indexOf||indexOf;return result=result===indexOf?baseIndexOf:result,collection?result(collection,target,fromIndex):result}function initCloneArray(array){var length=array.length,result=new array.constructor(length);return length&&\\\"string\\\"==typeof array[0]&&hasOwnProperty.call(array,\\\"index\\\")&&(result.index=array.index,result.input=array.input),result}function initCloneObject(object){var Ctor=object.constructor;return\\\"function\\\"==typeof Ctor&&Ctor instanceof Ctor||(Ctor=Object),new Ctor}function initCloneByTag(object,tag,isDeep){var Ctor=object.constructor;switch(tag){case arrayBufferTag:return bufferClone(object);case boolTag:case dateTag:return new Ctor(+object);case float32Tag:case float64Tag:case int8Tag:case int16Tag:case int32Tag:case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:var buffer=object.buffer;return new Ctor(isDeep?bufferClone(buffer):buffer,object.byteOffset,object.length);case numberTag:case stringTag:return new Ctor(object);case regexpTag:var result=new Ctor(object.source,reFlags.exec(object));result.lastIndex=object.lastIndex}return result}function isIndex(value,length){return value=+value,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&0==value%1&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if(\\\"number\\\"==type)var length=getLength(object),prereq=isLength(length)&&isIndex(index,length);else prereq=\\\"string\\\"==type&&index in object;if(prereq){var other=object[index];return value===value?value===other:other!==other}return!1}function isKey(value,object){var type=typeof value;if(\\\"string\\\"==type&&reIsPlainProp.test(value)||\\\"number\\\"==type)return!0;if(isArray(value))return!1;var result=!reIsDeepProp.test(value);return result||null!=object&&value in toObject(object)}function isLength(value){return\\\"number\\\"==typeof value&&value>-1&&0==value%1&&MAX_SAFE_INTEGER>=value}function isStrictComparable(value){return value===value&&(0===value?1/value>0:!isObject(value))}function shimIsPlainObject(value){var Ctor;if(lodash.support,!isObjectLike(value)||objToString.call(value)!=objectTag||!hasOwnProperty.call(value,\\\"constructor\\\")&&(Ctor=value.constructor,\\\"function\\\"==typeof Ctor&&!(Ctor instanceof Ctor)))return!1;var result;return baseForIn(value,function(subValue,key){result=key}),result===undefined||hasOwnProperty.call(value,result)}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,support=lodash.support,allowIndexes=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object)),index=-1,result=[];propsLength>++index;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function toObject(value){return isObject(value)?value:Object(value)}function toPath(value){if(isArray(value))return value;var result=[];return baseToString(value).replace(rePropName,function(match,number,quote,string){result.push(quote?string.replace(reEscapeChar,\\\"$1\\\"):number||match)}),result}function indexOf(array,value,fromIndex){var length=array?array.length:0;if(!length)return-1;if(\\\"number\\\"==typeof fromIndex)fromIndex=0>fromIndex?nativeMax(length+fromIndex,0):fromIndex;else if(fromIndex){var index=binaryIndex(array,value),other=array[index];return(value===value?value===other:other!==other)?index:-1}return baseIndexOf(array,value,fromIndex||0)}function last(array){var length=array?array.length:0;return length?array[length-1]:undefined}function slice(array,start,end){var length=array?array.length:0;return length?(end&&\\\"number\\\"!=typeof end&&isIterateeCall(array,start,end)&&(start=0,end=length),baseSlice(array,start,end)):[]}function unzip(array){for(var index=-1,length=(array&&array.length&&arrayMax(arrayMap(array,getLength)))>>>0,result=Array(length);length>++index;)result[index]=arrayMap(array,baseProperty(index));return result}function includes(collection,target,fromIndex,guard){var length=collection?getLength(collection):0;return isLength(length)||(collection=values(collection),length=collection.length),length?(fromIndex=\\\"number\\\"!=typeof fromIndex||guard&&isIterateeCall(target,fromIndex,guard)?0:0>fromIndex?nativeMax(length+fromIndex,0):fromIndex||0,\\\"string\\\"==typeof collection||!isArray(collection)&&isString(collection)?length>fromIndex&&collection.indexOf(target,fromIndex)>-1:getIndexOf(collection,target,fromIndex)>-1):!1}function reject(collection,predicate,thisArg){var func=isArray(collection)?arrayFilter:baseFilter;return predicate=getCallback(predicate,thisArg,3),func(collection,function(value,index,collection){return!predicate(value,index,collection)})}function some(collection,predicate,thisArg){var func=isArray(collection)?arraySome:baseSome;return thisArg&&isIterateeCall(collection,predicate,thisArg)&&(predicate=null),(\\\"function\\\"!=typeof predicate||thisArg!==undefined)&&(predicate=getCallback(predicate,thisArg,3)),func(collection,predicate)}function restParam(func,start){if(\\\"function\\\"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(start===undefined?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);length>++index;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;start>++index;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}function clone(value,isDeep,customizer,thisArg){return isDeep&&\\\"boolean\\\"!=typeof isDeep&&isIterateeCall(value,isDeep,customizer)?isDeep=!1:\\\"function\\\"==typeof isDeep&&(thisArg=customizer,customizer=isDeep,isDeep=!1),customizer=\\\"function\\\"==typeof customizer&&bindCallback(customizer,thisArg,1),baseClone(value,isDeep,customizer)}function isArguments(value){var length=isObjectLike(value)?value.length:undefined;return isLength(length)&&objToString.call(value)==argsTag}function isEmpty(value){if(null==value)return!0;var length=getLength(value);return isLength(length)&&(isArray(value)||isString(value)||isArguments(value)||isObjectLike(value)&&isFunction(value.splice))?!length:!keys(value).length}function isObject(value){var type=typeof value;return\\\"function\\\"==type||!!value&&\\\"object\\\"==type}function isNative(value){return null==value?!1:objToString.call(value)==funcTag?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}function isNumber(value){return\\\"number\\\"==typeof value||isObjectLike(value)&&objToString.call(value)==numberTag}function isString(value){return\\\"string\\\"==typeof value||isObjectLike(value)&&objToString.call(value)==stringTag}function isTypedArray(value){return isObjectLike(value)&&isLength(value.length)&&!!typedArrayTags[objToString.call(value)]}function toPlainObject(value){return baseCopy(value,keysIn(value))}function has(object,path){if(null==object)return!1;var result=hasOwnProperty.call(object,path);return result||isKey(path)||(path=toPath(path),object=1==path.length?object:baseGet(object,baseSlice(path,0,-1)),path=last(path),result=null!=object&&hasOwnProperty.call(object,path)),result}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||support.nonEnumArgs&&isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto=\\\"function\\\"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;length>++index;)result[index]=index+\\\"\\\";for(var key in object)skipIndexes&&isIndex(key,length)||\\\"constructor\\\"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}function values(object){return baseValues(object,keys(object))}function escapeRegExp(string){return string=baseToString(string),string&&reHasRegExpChars.test(string)?string.replace(reRegExpChars,\\\"\\\\\\\\$&\\\"):string}function callback(func,thisArg,guard){return guard&&isIterateeCall(func,thisArg,guard)&&(thisArg=null),baseCallback(func,thisArg)}function constant(value){return function(){return value}}function identity(value){return value}function property(path){return isKey(path)?baseProperty(path):basePropertyDeep(path)}var undefined,VERSION=\\\"3.7.0\\\",FUNC_ERROR_TEXT=\\\"Expected a function\\\",argsTag=\\\"[object Arguments]\\\",arrayTag=\\\"[object Array]\\\",boolTag=\\\"[object Boolean]\\\",dateTag=\\\"[object Date]\\\",errorTag=\\\"[object Error]\\\",funcTag=\\\"[object Function]\\\",mapTag=\\\"[object Map]\\\",numberTag=\\\"[object Number]\\\",objectTag=\\\"[object Object]\\\",regexpTag=\\\"[object RegExp]\\\",setTag=\\\"[object Set]\\\",stringTag=\\\"[object String]\\\",weakMapTag=\\\"[object WeakMap]\\\",arrayBufferTag=\\\"[object ArrayBuffer]\\\",float32Tag=\\\"[object Float32Array]\\\",float64Tag=\\\"[object Float64Array]\\\",int8Tag=\\\"[object Int8Array]\\\",int16Tag=\\\"[object Int16Array]\\\",int32Tag=\\\"[object Int32Array]\\\",uint8Tag=\\\"[object Uint8Array]\\\",uint8ClampedTag=\\\"[object Uint8ClampedArray]\\\",uint16Tag=\\\"[object Uint16Array]\\\",uint32Tag=\\\"[object Uint32Array]\\\",reIsDeepProp=/\\\\.|\\\\[(?:[^[\\\\]]+|([\\\"'])(?:(?!\\\\1)[^\\\\n\\\\\\\\]|\\\\\\\\.)*?)\\\\1\\\\]/,reIsPlainProp=/^\\\\w*$/,rePropName=/[^.[\\\\]]+|\\\\[(?:(-?\\\\d+(?:\\\\.\\\\d+)?)|([\\\"'])((?:(?!\\\\2)[^\\\\n\\\\\\\\]|\\\\\\\\.)*?)\\\\2)\\\\]/g,reRegExpChars=/[.*+?^${}()|[\\\\]\\\\/\\\\\\\\]/g,reHasRegExpChars=RegExp(reRegExpChars.source),reEscapeChar=/\\\\\\\\(\\\\\\\\)?/g,reFlags=/\\\\w*$/,reIsHostCtor=/^\\\\[object .+?Constructor\\\\]$/,typedArrayTags={};typedArrayTags[float32Tag]=typedArrayTags[float64Tag]=typedArrayTags[int8Tag]=typedArrayTags[int16Tag]=typedArrayTags[int32Tag]=typedArrayTags[uint8Tag]=typedArrayTags[uint8ClampedTag]=typedArrayTags[uint16Tag]=typedArrayTags[uint32Tag]=!0,typedArrayTags[argsTag]=typedArrayTags[arrayTag]=typedArrayTags[arrayBufferTag]=typedArrayTags[boolTag]=typedArrayTags[dateTag]=typedArrayTags[errorTag]=typedArrayTags[funcTag]=typedArrayTags[mapTag]=typedArrayTags[numberTag]=typedArrayTags[objectTag]=typedArrayTags[regexpTag]=typedArrayTags[setTag]=typedArrayTags[stringTag]=typedArrayTags[weakMapTag]=!1;var cloneableTags={};cloneableTags[argsTag]=cloneableTags[arrayTag]=cloneableTags[arrayBufferTag]=cloneableTags[boolTag]=cloneableTags[dateTag]=cloneableTags[float32Tag]=cloneableTags[float64Tag]=cloneableTags[int8Tag]=cloneableTags[int16Tag]=cloneableTags[int32Tag]=cloneableTags[numberTag]=cloneableTags[objectTag]=cloneableTags[regexpTag]=cloneableTags[stringTag]=cloneableTags[uint8Tag]=cloneableTags[uint8ClampedTag]=cloneableTags[uint16Tag]=cloneableTags[uint32Tag]=!0,cloneableTags[errorTag]=cloneableTags[funcTag]=cloneableTags[mapTag]=cloneableTags[setTag]=cloneableTags[weakMapTag]=!1;var objectTypes={\\\"function\\\":!0,object:!0},freeExports=objectTypes[typeof exports]&&exports&&!exports.nodeType&&exports,freeModule=objectTypes[typeof module]&&module&&!module.nodeType&&module,freeGlobal=freeExports&&freeModule&&\\\"object\\\"==typeof global&&global&&global.Object&&global,freeSelf=objectTypes[typeof self]&&self&&self.Object&&self,freeWindow=objectTypes[typeof window]&&window&&window.Object&&window,moduleExports=freeModule&&freeModule.exports===freeExports&&freeExports,root=freeGlobal||freeWindow!==(this&&this.window)&&freeWindow||freeSelf||this,arrayProto=Array.prototype,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp(\\\"^\\\"+escapeRegExp(objToString).replace(/toString|(function).*?(?=\\\\\\\\\\\\()| for .+?(?=\\\\\\\\\\\\])/g,\\\"$1.*?\\\")+\\\"$\\\"),ArrayBuffer=isNative(ArrayBuffer=root.ArrayBuffer)&&ArrayBuffer,bufferSlice=isNative(bufferSlice=ArrayBuffer&&new ArrayBuffer(0).slice)&&bufferSlice,floor=Math.floor,getOwnPropertySymbols=isNative(getOwnPropertySymbols=Object.getOwnPropertySymbols)&&getOwnPropertySymbols,getPrototypeOf=isNative(getPrototypeOf=Object.getPrototypeOf)&&getPrototypeOf,push=arrayProto.push,preventExtensions=isNative(Object.preventExtensions=Object.preventExtensions)&&preventExtensions,propertyIsEnumerable=objectProto.propertyIsEnumerable,Uint8Array=isNative(Uint8Array=root.Uint8Array)&&Uint8Array,Float64Array=function(){try{var func=isNative(func=root.Float64Array)&&func,result=new func(new ArrayBuffer(10),0,1)&&func}catch(e){}return result}(),nativeAssign=function(){var object={1:0},func=preventExtensions&&isNative(func=Object.assign)&&func;try{func(preventExtensions(object),\\\"xo\\\")}catch(e){}return!object[1]&&func}(),nativeIsArray=isNative(nativeIsArray=Array.isArray)&&nativeIsArray,nativeKeys=isNative(nativeKeys=Object.keys)&&nativeKeys,nativeMax=Math.max,nativeMin=Math.min,NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,MAX_ARRAY_LENGTH=Math.pow(2,32)-1,MAX_ARRAY_INDEX=MAX_ARRAY_LENGTH-1,HALF_MAX_ARRAY_LENGTH=MAX_ARRAY_LENGTH>>>1,FLOAT64_BYTES_PER_ELEMENT=Float64Array?Float64Array.BYTES_PER_ELEMENT:0,MAX_SAFE_INTEGER=Math.pow(2,53)-1,support=lodash.support={};(function(x){var Ctor=function(){this.x=x},props=[];Ctor.prototype={valueOf:x,y:x};for(var key in new Ctor)props.push(key);support.funcDecomp=/\\\\bthis\\\\b/.test(function(){return this}),support.funcNames=\\\"string\\\"==typeof Function.name;try{support.nonEnumArgs=!propertyIsEnumerable.call(arguments,1)}catch(e){support.nonEnumArgs=!0}})(1,0);var baseAssign=nativeAssign||function(object,source){return null==source?object:baseCopy(source,getSymbols(source),baseCopy(source,keys(source),object))},baseEach=createBaseEach(baseForOwn),baseFor=createBaseFor();bufferSlice||(bufferClone=ArrayBuffer&&Uint8Array?function(buffer){var byteLength=buffer.byteLength,floatLength=Float64Array?floor(byteLength/FLOAT64_BYTES_PER_ELEMENT):0,offset=floatLength*FLOAT64_BYTES_PER_ELEMENT,result=new ArrayBuffer(byteLength);if(floatLength){var view=new Float64Array(result,0,floatLength);view.set(new Float64Array(buffer,0,floatLength))}return byteLength!=offset&&(view=new Uint8Array(result,offset),view.set(new Uint8Array(buffer,offset))),result}:constant(null));var getLength=baseProperty(\\\"length\\\"),getSymbols=getOwnPropertySymbols?function(object){return getOwnPropertySymbols(toObject(object))}:constant([]),findLastIndex=createFindIndex(!0),zip=restParam(unzip),forEach=createForEach(arrayEach,baseEach),isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag},isFunction=baseIsFunction(/x/)||Uint8Array&&!baseIsFunction(Uint8Array)?function(value){return objToString.call(value)==funcTag}:baseIsFunction,isPlainObject=getPrototypeOf?function(value){if(!value||objToString.call(value)!=objectTag)return!1;var valueOf=value.valueOf,objProto=isNative(valueOf)&&(objProto=getPrototypeOf(valueOf))&&getPrototypeOf(objProto);return objProto?value==objProto||getPrototypeOf(value)==objProto:shimIsPlainObject(value)}:shimIsPlainObject,assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)}),keys=nativeKeys?function(object){if(object)var Ctor=object.constructor,length=object.length;return\\\"function\\\"==typeof Ctor&&Ctor.prototype===object||\\\"function\\\"!=typeof object&&isLength(length)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys,merge=createAssigner(baseMerge);lodash.assign=assign,lodash.callback=callback,lodash.constant=constant,lodash.forEach=forEach,lodash.keys=keys,lodash.keysIn=keysIn,lodash.merge=merge,lodash.property=property,lodash.reject=reject,lodash.restParam=restParam,lodash.slice=slice,lodash.toPlainObject=toPlainObject,lodash.unzip=unzip,lodash.values=values,lodash.zip=zip,lodash.each=forEach,lodash.extend=assign,lodash.iteratee=callback,lodash.clone=clone,lodash.escapeRegExp=escapeRegExp,lodash.findLastIndex=findLastIndex,lodash.has=has,lodash.identity=identity,lodash.includes=includes,lodash.indexOf=indexOf,lodash.isArguments=isArguments,lodash.isArray=isArray,lodash.isEmpty=isEmpty,lodash.isFunction=isFunction,lodash.isNative=isNative,lodash.isNumber=isNumber,lodash.isObject=isObject,lodash.isPlainObject=isPlainObject,lodash.isString=isString,lodash.isTypedArray=isTypedArray,lodash.last=last,lodash.some=some,lodash.any=some,lodash.contains=includes,lodash.include=includes,lodash.VERSION=VERSION,freeExports&&freeModule?moduleExports?(freeModule.exports=lodash)._=lodash:freeExports._=lodash:root._=lodash\\n}).call(this)}).call(this,\\\"undefined\\\"!=typeof global?global:\\\"undefined\\\"!=typeof self?self:\\\"undefined\\\"!=typeof window?window:{})},{}],\\\"/node_modules/jshint/src/jshint.js\\\":[function(_dereq_,module,exports){var _=_dereq_(\\\"../lodash\\\"),events=_dereq_(\\\"events\\\"),vars=_dereq_(\\\"./vars.js\\\"),messages=_dereq_(\\\"./messages.js\\\"),Lexer=_dereq_(\\\"./lex.js\\\").Lexer,reg=_dereq_(\\\"./reg.js\\\"),state=_dereq_(\\\"./state.js\\\").state,style=_dereq_(\\\"./style.js\\\"),options=_dereq_(\\\"./options.js\\\"),scopeManager=_dereq_(\\\"./scope-manager.js\\\"),JSHINT=function(){\\\"use strict\\\";function checkOption(name,t){return name=name.trim(),/^[+-]W\\\\d{3}$/g.test(name)?!0:-1!==options.validNames.indexOf(name)||\\\"jslint\\\"===t.type||_.has(options.removed,name)?!0:(error(\\\"E001\\\",t,name),!1)}function isString(obj){return\\\"[object String]\\\"===Object.prototype.toString.call(obj)}function isIdentifier(tkn,value){return tkn?tkn.identifier&&tkn.value===value?!0:!1:!1}function isReserved(token){if(!token.reserved)return!1;var meta=token.meta;if(meta&&meta.isFutureReservedWord&&state.inES5()){if(!meta.es5)return!1;if(meta.strictOnly&&!state.option.strict&&!state.isStrict())return!1;if(token.isProperty)return!1}return!0}function supplant(str,data){return str.replace(/\\\\{([^{}]*)\\\\}/g,function(a,b){var r=data[b];return\\\"string\\\"==typeof r||\\\"number\\\"==typeof r?r:a})}function combine(dest,src){Object.keys(src).forEach(function(name){_.has(JSHINT.blacklist,name)||(dest[name]=src[name])})}function processenforceall(){if(state.option.enforceall){for(var enforceopt in options.bool.enforcing)void 0!==state.option[enforceopt]||options.noenforceall[enforceopt]||(state.option[enforceopt]=!0);for(var relaxopt in options.bool.relaxing)void 0===state.option[relaxopt]&&(state.option[relaxopt]=!1)}}function assume(){processenforceall(),state.option.esversion||state.option.moz||(state.option.esversion=state.option.es3?3:state.option.esnext?6:5),state.inES5()&&combine(predefined,vars.ecmaIdentifiers[5]),state.inES6()&&combine(predefined,vars.ecmaIdentifiers[6]),state.option.module&&(state.option.strict===!0&&(state.option.strict=\\\"global\\\"),state.inES6()||warning(\\\"W134\\\",state.tokens.next,\\\"module\\\",6)),state.option.couch&&combine(predefined,vars.couch),state.option.qunit&&combine(predefined,vars.qunit),state.option.rhino&&combine(predefined,vars.rhino),state.option.shelljs&&(combine(predefined,vars.shelljs),combine(predefined,vars.node)),state.option.typed&&combine(predefined,vars.typed),state.option.phantom&&(combine(predefined,vars.phantom),state.option.strict===!0&&(state.option.strict=\\\"global\\\")),state.option.prototypejs&&combine(predefined,vars.prototypejs),state.option.node&&(combine(predefined,vars.node),combine(predefined,vars.typed),state.option.strict===!0&&(state.option.strict=\\\"global\\\")),state.option.devel&&combine(predefined,vars.devel),state.option.dojo&&combine(predefined,vars.dojo),state.option.browser&&(combine(predefined,vars.browser),combine(predefined,vars.typed)),state.option.browserify&&(combine(predefined,vars.browser),combine(predefined,vars.typed),combine(predefined,vars.browserify),state.option.strict===!0&&(state.option.strict=\\\"global\\\")),state.option.nonstandard&&combine(predefined,vars.nonstandard),state.option.jasmine&&combine(predefined,vars.jasmine),state.option.jquery&&combine(predefined,vars.jquery),state.option.mootools&&combine(predefined,vars.mootools),state.option.worker&&combine(predefined,vars.worker),state.option.wsh&&combine(predefined,vars.wsh),state.option.globalstrict&&state.option.strict!==!1&&(state.option.strict=\\\"global\\\"),state.option.yui&&combine(predefined,vars.yui),state.option.mocha&&combine(predefined,vars.mocha)}function quit(code,line,chr){var percentage=Math.floor(100*(line/state.lines.length)),message=messages.errors[code].desc;throw{name:\\\"JSHintError\\\",line:line,character:chr,message:message+\\\" (\\\"+percentage+\\\"% scanned).\\\",raw:message,code:code}}function removeIgnoredMessages(){var ignored=state.ignoredLines;_.isEmpty(ignored)||(JSHINT.errors=_.reject(JSHINT.errors,function(err){return ignored[err.line]}))}function warning(code,t,a,b,c,d){var ch,l,w,msg;if(/^W\\\\d{3}$/.test(code)){if(state.ignored[code])return;msg=messages.warnings[code]}else/E\\\\d{3}/.test(code)?msg=messages.errors[code]:/I\\\\d{3}/.test(code)&&(msg=messages.info[code]);return t=t||state.tokens.next||{},\\\"(end)\\\"===t.id&&(t=state.tokens.curr),l=t.line||0,ch=t.from||0,w={id:\\\"(error)\\\",raw:msg.desc,code:msg.code,evidence:state.lines[l-1]||\\\"\\\",line:l,character:ch,scope:JSHINT.scope,a:a,b:b,c:c,d:d},w.reason=supplant(msg.desc,w),JSHINT.errors.push(w),removeIgnoredMessages(),JSHINT.errors.length>=state.option.maxerr&&quit(\\\"E043\\\",l,ch),w}function warningAt(m,l,ch,a,b,c,d){return warning(m,{line:l,from:ch},a,b,c,d)}function error(m,t,a,b,c,d){warning(m,t,a,b,c,d)}function errorAt(m,l,ch,a,b,c,d){return error(m,{line:l,from:ch},a,b,c,d)}function addInternalSrc(elem,src){var i;return i={id:\\\"(internal)\\\",elem:elem,value:src},JSHINT.internals.push(i),i}function doOption(){var nt=state.tokens.next,body=nt.body.match(/(-\\\\s+)?[^\\\\s,:]+(?:\\\\s*:\\\\s*(-\\\\s+)?[^\\\\s,]+)?/g)||[],predef={};if(\\\"globals\\\"===nt.type){body.forEach(function(g,idx){g=g.split(\\\":\\\");var key=(g[0]||\\\"\\\").trim(),val=(g[1]||\\\"\\\").trim();if(\\\"-\\\"===key||!key.length){if(idx>0&&idx===body.length-1)return;return error(\\\"E002\\\",nt),void 0}\\\"-\\\"===key.charAt(0)?(key=key.slice(1),val=!1,JSHINT.blacklist[key]=key,delete predefined[key]):predef[key]=\\\"true\\\"===val}),combine(predefined,predef);for(var key in predef)_.has(predef,key)&&(declared[key]=nt)}\\\"exported\\\"===nt.type&&body.forEach(function(e,idx){if(!e.length){if(idx>0&&idx===body.length-1)return;return error(\\\"E002\\\",nt),void 0}state.funct[\\\"(scope)\\\"].addExported(e)}),\\\"members\\\"===nt.type&&(membersOnly=membersOnly||{},body.forEach(function(m){var ch1=m.charAt(0),ch2=m.charAt(m.length-1);ch1!==ch2||'\\\"'!==ch1&&\\\"'\\\"!==ch1||(m=m.substr(1,m.length-2).replace('\\\\\\\\\\\"','\\\"')),membersOnly[m]=!1}));var numvals=[\\\"maxstatements\\\",\\\"maxparams\\\",\\\"maxdepth\\\",\\\"maxcomplexity\\\",\\\"maxerr\\\",\\\"maxlen\\\",\\\"indent\\\"];(\\\"jshint\\\"===nt.type||\\\"jslint\\\"===nt.type)&&(body.forEach(function(g){g=g.split(\\\":\\\");var key=(g[0]||\\\"\\\").trim(),val=(g[1]||\\\"\\\").trim();if(checkOption(key,nt))if(numvals.indexOf(key)>=0)if(\\\"false\\\"!==val){if(val=+val,\\\"number\\\"!=typeof val||!isFinite(val)||0>=val||Math.floor(val)!==val)return error(\\\"E032\\\",nt,g[1].trim()),void 0;state.option[key]=val}else state.option[key]=\\\"indent\\\"===key?4:!1;else{if(\\\"validthis\\\"===key)return state.funct[\\\"(global)\\\"]?void error(\\\"E009\\\"):\\\"true\\\"!==val&&\\\"false\\\"!==val?void error(\\\"E002\\\",nt):(state.option.validthis=\\\"true\\\"===val,void 0);if(\\\"quotmark\\\"!==key)if(\\\"shadow\\\"!==key)if(\\\"unused\\\"!==key)if(\\\"latedef\\\"!==key)if(\\\"ignore\\\"!==key)if(\\\"strict\\\"!==key){\\\"module\\\"===key&&(hasParsedCode(state.funct)||error(\\\"E055\\\",state.tokens.next,\\\"module\\\"));var esversions={es3:3,es5:5,esnext:6};if(!_.has(esversions,key)){if(\\\"esversion\\\"===key){switch(val){case\\\"5\\\":state.inES5(!0)&&warning(\\\"I003\\\");case\\\"3\\\":case\\\"6\\\":state.option.moz=!1,state.option.esversion=+val;break;case\\\"2015\\\":state.option.moz=!1,state.option.esversion=6;break;default:error(\\\"E002\\\",nt)}return hasParsedCode(state.funct)||error(\\\"E055\\\",state.tokens.next,\\\"esversion\\\"),void 0}var match=/^([+-])(W\\\\d{3})$/g.exec(key);if(match)return state.ignored[match[2]]=\\\"-\\\"===match[1],void 0;var tn;return\\\"true\\\"===val||\\\"false\\\"===val?(\\\"jslint\\\"===nt.type?(tn=options.renamed[key]||key,state.option[tn]=\\\"true\\\"===val,void 0!==options.inverted[tn]&&(state.option[tn]=!state.option[tn])):state.option[key]=\\\"true\\\"===val,\\\"newcap\\\"===key&&(state.option[\\\"(explicitNewcap)\\\"]=!0),void 0):(error(\\\"E002\\\",nt),void 0)}switch(val){case\\\"true\\\":state.option.moz=!1,state.option.esversion=esversions[key];break;case\\\"false\\\":state.option.moz||(state.option.esversion=5);break;default:error(\\\"E002\\\",nt)}}else switch(val){case\\\"true\\\":state.option.strict=!0;break;case\\\"false\\\":state.option.strict=!1;break;case\\\"func\\\":case\\\"global\\\":case\\\"implied\\\":state.option.strict=val;break;default:error(\\\"E002\\\",nt)}else switch(val){case\\\"line\\\":state.ignoredLines[nt.line]=!0,removeIgnoredMessages();break;default:error(\\\"E002\\\",nt)}else switch(val){case\\\"true\\\":state.option.latedef=!0;break;case\\\"false\\\":state.option.latedef=!1;break;case\\\"nofunc\\\":state.option.latedef=\\\"nofunc\\\";break;default:error(\\\"E002\\\",nt)}else switch(val){case\\\"true\\\":state.option.unused=!0;break;case\\\"false\\\":state.option.unused=!1;break;case\\\"vars\\\":case\\\"strict\\\":state.option.unused=val;break;default:error(\\\"E002\\\",nt)}else switch(val){case\\\"true\\\":state.option.shadow=!0;break;case\\\"outer\\\":state.option.shadow=\\\"outer\\\";break;case\\\"false\\\":case\\\"inner\\\":state.option.shadow=\\\"inner\\\";break;default:error(\\\"E002\\\",nt)}else switch(val){case\\\"true\\\":case\\\"false\\\":state.option.quotmark=\\\"true\\\"===val;break;case\\\"double\\\":case\\\"single\\\":state.option.quotmark=val;break;default:error(\\\"E002\\\",nt)}}}),assume())}function peek(p){var t,i=p||0,j=lookahead.length;if(j>i)return lookahead[i];for(;i>=j;)t=lookahead[j],t||(t=lookahead[j]=lex.token()),j+=1;return t||\\\"(end)\\\"!==state.tokens.next.id?t:state.tokens.next}function peekIgnoreEOL(){var t,i=0;do t=peek(i++);while(\\\"(endline)\\\"===t.id);return t}function advance(id,t){switch(state.tokens.curr.id){case\\\"(number)\\\":\\\".\\\"===state.tokens.next.id&&warning(\\\"W005\\\",state.tokens.curr);break;case\\\"-\\\":(\\\"-\\\"===state.tokens.next.id||\\\"--\\\"===state.tokens.next.id)&&warning(\\\"W006\\\");break;case\\\"+\\\":(\\\"+\\\"===state.tokens.next.id||\\\"++\\\"===state.tokens.next.id)&&warning(\\\"W007\\\")}for(id&&state.tokens.next.id!==id&&(t?\\\"(end)\\\"===state.tokens.next.id?error(\\\"E019\\\",t,t.id):error(\\\"E020\\\",state.tokens.next,id,t.id,t.line,state.tokens.next.value):(\\\"(identifier)\\\"!==state.tokens.next.type||state.tokens.next.value!==id)&&warning(\\\"W116\\\",state.tokens.next,id,state.tokens.next.value)),state.tokens.prev=state.tokens.curr,state.tokens.curr=state.tokens.next;;){if(state.tokens.next=lookahead.shift()||lex.token(),state.tokens.next||quit(\\\"E041\\\",state.tokens.curr.line),\\\"(end)\\\"===state.tokens.next.id||\\\"(error)\\\"===state.tokens.next.id)return;if(state.tokens.next.check&&state.tokens.next.check(),state.tokens.next.isSpecial)\\\"falls through\\\"===state.tokens.next.type?state.tokens.curr.caseFallsThrough=!0:doOption();else if(\\\"(endline)\\\"!==state.tokens.next.id)break}}function isInfix(token){return token.infix||!token.identifier&&!token.template&&!!token.led}function isEndOfExpr(){var curr=state.tokens.curr,next=state.tokens.next;return\\\";\\\"===next.id||\\\"}\\\"===next.id||\\\":\\\"===next.id?!0:isInfix(next)===isInfix(curr)||\\\"yield\\\"===curr.id&&state.inMoz()?curr.line!==startLine(next):!1}function isBeginOfExpr(prev){return!prev.left&&\\\"unary\\\"!==prev.arity}function expression(rbp,initial){var left,isArray=!1,isObject=!1,isLetExpr=!1;state.nameStack.push(),initial||\\\"let\\\"!==state.tokens.next.value||\\\"(\\\"!==peek(0).value||(state.inMoz()||warning(\\\"W118\\\",state.tokens.next,\\\"let expressions\\\"),isLetExpr=!0,state.funct[\\\"(scope)\\\"].stack(),advance(\\\"let\\\"),advance(\\\"(\\\"),state.tokens.prev.fud(),advance(\\\")\\\")),\\\"(end)\\\"===state.tokens.next.id&&error(\\\"E006\\\",state.tokens.curr);var isDangerous=state.option.asi&&state.tokens.prev.line!==startLine(state.tokens.curr)&&_.contains([\\\"]\\\",\\\")\\\"],state.tokens.prev.id)&&_.contains([\\\"[\\\",\\\"(\\\"],state.tokens.curr.id);if(isDangerous&&warning(\\\"W014\\\",state.tokens.curr,state.tokens.curr.id),advance(),initial&&(state.funct[\\\"(verb)\\\"]=state.tokens.curr.value,state.tokens.curr.beginsStmt=!0),initial===!0&&state.tokens.curr.fud)left=state.tokens.curr.fud();else for(state.tokens.curr.nud?left=state.tokens.curr.nud():error(\\\"E030\\\",state.tokens.curr,state.tokens.curr.id);(state.tokens.next.lbp>rbp||\\\"(template)\\\"===state.tokens.next.type)&&!isEndOfExpr();)isArray=\\\"Array\\\"===state.tokens.curr.value,isObject=\\\"Object\\\"===state.tokens.curr.value,left&&(left.value||left.first&&left.first.value)&&(\\\"new\\\"!==left.value||left.first&&left.first.value&&\\\".\\\"===left.first.value)&&(isArray=!1,left.value!==state.tokens.curr.value&&(isObject=!1)),advance(),isArray&&\\\"(\\\"===state.tokens.curr.id&&\\\")\\\"===state.tokens.next.id&&warning(\\\"W009\\\",state.tokens.curr),isObject&&\\\"(\\\"===state.tokens.curr.id&&\\\")\\\"===state.tokens.next.id&&warning(\\\"W010\\\",state.tokens.curr),left&&state.tokens.curr.led?left=state.tokens.curr.led(left):error(\\\"E033\\\",state.tokens.curr,state.tokens.curr.id);return isLetExpr&&state.funct[\\\"(scope)\\\"].unstack(),state.nameStack.pop(),left}function startLine(token){return token.startLine||token.line}function nobreaknonadjacent(left,right){left=left||state.tokens.curr,right=right||state.tokens.next,state.option.laxbreak||left.line===startLine(right)||warning(\\\"W014\\\",right,right.value)}function nolinebreak(t){t=t||state.tokens.curr,t.line!==startLine(state.tokens.next)&&warning(\\\"E022\\\",t,t.value)}function nobreakcomma(left,right){left.line!==startLine(right)&&(state.option.laxcomma||(comma.first&&(warning(\\\"I001\\\"),comma.first=!1),warning(\\\"W014\\\",left,right.value)))}function comma(opts){if(opts=opts||{},opts.peek?nobreakcomma(state.tokens.prev,state.tokens.curr):(nobreakcomma(state.tokens.curr,state.tokens.next),advance(\\\",\\\")),state.tokens.next.identifier&&(!opts.property||!state.inES5()))switch(state.tokens.next.value){case\\\"break\\\":case\\\"case\\\":case\\\"catch\\\":case\\\"continue\\\":case\\\"default\\\":case\\\"do\\\":case\\\"else\\\":case\\\"finally\\\":case\\\"for\\\":case\\\"if\\\":case\\\"in\\\":case\\\"instanceof\\\":case\\\"return\\\":case\\\"switch\\\":case\\\"throw\\\":case\\\"try\\\":case\\\"var\\\":case\\\"let\\\":case\\\"while\\\":case\\\"with\\\":return error(\\\"E024\\\",state.tokens.next,state.tokens.next.value),!1}if(\\\"(punctuator)\\\"===state.tokens.next.type)switch(state.tokens.next.value){case\\\"}\\\":case\\\"]\\\":case\\\",\\\":if(opts.allowTrailing)return!0;case\\\")\\\":return error(\\\"E024\\\",state.tokens.next,state.tokens.next.value),!1}return!0}function symbol(s,p){var x=state.syntax[s];return x&&\\\"object\\\"==typeof x||(state.syntax[s]=x={id:s,lbp:p,value:s}),x}function delim(s){var x=symbol(s,0);return x.delim=!0,x}function stmt(s,f){var x=delim(s);return x.identifier=x.reserved=!0,x.fud=f,x}function blockstmt(s,f){var x=stmt(s,f);return x.block=!0,x}function reserveName(x){var c=x.id.charAt(0);return(c>=\\\"a\\\"&&\\\"z\\\">=c||c>=\\\"A\\\"&&\\\"Z\\\">=c)&&(x.identifier=x.reserved=!0),x}function prefix(s,f){var x=symbol(s,150);return reserveName(x),x.nud=\\\"function\\\"==typeof f?f:function(){return this.arity=\\\"unary\\\",this.right=expression(150),(\\\"++\\\"===this.id||\\\"--\\\"===this.id)&&(state.option.plusplus?warning(\\\"W016\\\",this,this.id):!this.right||this.right.identifier&&!isReserved(this.right)||\\\".\\\"===this.right.id||\\\"[\\\"===this.right.id||warning(\\\"W017\\\",this),this.right&&this.right.isMetaProperty?error(\\\"E031\\\",this):this.right&&this.right.identifier&&state.funct[\\\"(scope)\\\"].block.modify(this.right.value,this)),this},x}function type(s,f){var x=delim(s);return x.type=s,x.nud=f,x}function reserve(name,func){var x=type(name,func);return x.identifier=!0,x.reserved=!0,x}function FutureReservedWord(name,meta){var x=type(name,meta&&meta.nud||function(){return this});return meta=meta||{},meta.isFutureReservedWord=!0,x.value=name,x.identifier=!0,x.reserved=!0,x.meta=meta,x}function reservevar(s,v){return reserve(s,function(){return\\\"function\\\"==typeof v&&v(this),this})}function infix(s,f,p,w){var x=symbol(s,p);return reserveName(x),x.infix=!0,x.led=function(left){return w||nobreaknonadjacent(state.tokens.prev,state.tokens.curr),\\\"in\\\"!==s&&\\\"instanceof\\\"!==s||\\\"!\\\"!==left.id||warning(\\\"W018\\\",left,\\\"!\\\"),\\\"function\\\"==typeof f?f(left,this):(this.left=left,this.right=expression(p),this)},x}function application(s){var x=symbol(s,42);return x.led=function(left){return nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left,this.right=doFunction({type:\\\"arrow\\\",loneArg:left}),this},x}function relation(s,f){var x=symbol(s,100);return x.led=function(left){nobreaknonadjacent(state.tokens.prev,state.tokens.curr),this.left=left;var right=this.right=expression(100);return isIdentifier(left,\\\"NaN\\\")||isIdentifier(right,\\\"NaN\\\")?warning(\\\"W019\\\",this):f&&f.apply(this,[left,right]),left&&right||quit(\\\"E041\\\",state.tokens.curr.line),\\\"!\\\"===left.id&&warning(\\\"W018\\\",left,\\\"!\\\"),\\\"!\\\"===right.id&&warning(\\\"W018\\\",right,\\\"!\\\"),this},x}function isPoorRelation(node){return node&&(\\\"(number)\\\"===node.type&&0===+node.value||\\\"(string)\\\"===node.type&&\\\"\\\"===node.value||\\\"null\\\"===node.type&&!state.option.eqnull||\\\"true\\\"===node.type||\\\"false\\\"===node.type||\\\"undefined\\\"===node.type)}function isTypoTypeof(left,right,state){var values;return state.option.notypeof?!1:left&&right?(values=state.inES6()?typeofValues.es6:typeofValues.es3,\\\"(identifier)\\\"===right.type&&\\\"typeof\\\"===right.value&&\\\"(string)\\\"===left.type?!_.contains(values,left.value):!1):!1}function isGlobalEval(left,state){var isGlobal=!1;return\\\"this\\\"===left.type&&null===state.funct[\\\"(context)\\\"]?isGlobal=!0:\\\"(identifier)\\\"===left.type&&(state.option.node&&\\\"global\\\"===left.value?isGlobal=!0:!state.option.browser||\\\"window\\\"!==left.value&&\\\"document\\\"!==left.value||(isGlobal=!0)),isGlobal}function findNativePrototype(left){function walkPrototype(obj){return\\\"object\\\"==typeof obj?\\\"prototype\\\"===obj.right?obj:walkPrototype(obj.left):void 0}function walkNative(obj){for(;!obj.identifier&&\\\"object\\\"==typeof obj.left;)obj=obj.left;return obj.identifier&&natives.indexOf(obj.value)>=0?obj.value:void 0}var natives=[\\\"Array\\\",\\\"ArrayBuffer\\\",\\\"Boolean\\\",\\\"Collator\\\",\\\"DataView\\\",\\\"Date\\\",\\\"DateTimeFormat\\\",\\\"Error\\\",\\\"EvalError\\\",\\\"Float32Array\\\",\\\"Float64Array\\\",\\\"Function\\\",\\\"Infinity\\\",\\\"Intl\\\",\\\"Int16Array\\\",\\\"Int32Array\\\",\\\"Int8Array\\\",\\\"Iterator\\\",\\\"Number\\\",\\\"NumberFormat\\\",\\\"Object\\\",\\\"RangeError\\\",\\\"ReferenceError\\\",\\\"RegExp\\\",\\\"StopIteration\\\",\\\"String\\\",\\\"SyntaxError\\\",\\\"TypeError\\\",\\\"Uint16Array\\\",\\\"Uint32Array\\\",\\\"Uint8Array\\\",\\\"Uint8ClampedArray\\\",\\\"URIError\\\"],prototype=walkPrototype(left);return prototype?walkNative(prototype):void 0}function checkLeftSideAssign(left,assignToken,options){var allowDestructuring=options&&options.allowDestructuring;if(assignToken=assignToken||left,state.option.freeze){var nativeObject=findNativePrototype(left);nativeObject&&warning(\\\"W121\\\",left,nativeObject)}return left.identifier&&!left.isMetaProperty&&state.funct[\\\"(scope)\\\"].block.reassign(left.value,left),\\\".\\\"===left.id?((!left.left||\\\"arguments\\\"===left.left.value&&!state.isStrict())&&warning(\\\"E031\\\",assignToken),state.nameStack.set(state.tokens.prev),!0):\\\"{\\\"===left.id||\\\"[\\\"===left.id?(allowDestructuring&&state.tokens.curr.left.destructAssign?state.tokens.curr.left.destructAssign.forEach(function(t){t.id&&state.funct[\\\"(scope)\\\"].block.modify(t.id,t.token)}):\\\"{\\\"!==left.id&&left.left?\\\"arguments\\\"!==left.left.value||state.isStrict()||warning(\\\"E031\\\",assignToken):warning(\\\"E031\\\",assignToken),\\\"[\\\"===left.id&&state.nameStack.set(left.right),!0):left.isMetaProperty?(error(\\\"E031\\\",assignToken),!0):left.identifier&&!isReserved(left)?(\\\"exception\\\"===state.funct[\\\"(scope)\\\"].labeltype(left.value)&&warning(\\\"W022\\\",left),state.nameStack.set(left),!0):(left===state.syntax[\\\"function\\\"]&&warning(\\\"W023\\\",state.tokens.curr),!1)}function assignop(s,f,p){var x=infix(s,\\\"function\\\"==typeof f?f:function(left,that){return that.left=left,left&&checkLeftSideAssign(left,that,{allowDestructuring:!0})?(that.right=expression(10),that):(error(\\\"E031\\\",that),void 0)},p);return x.exps=!0,x.assign=!0,x}function bitwise(s,f,p){var x=symbol(s,p);return reserveName(x),x.led=\\\"function\\\"==typeof f?f:function(left){return state.option.bitwise&&warning(\\\"W016\\\",this,this.id),this.left=left,this.right=expression(p),this},x}function bitwiseassignop(s){return assignop(s,function(left,that){return state.option.bitwise&&warning(\\\"W016\\\",that,that.id),left&&checkLeftSideAssign(left,that)?(that.right=expression(10),that):(error(\\\"E031\\\",that),void 0)},20)}function suffix(s){var x=symbol(s,150);return x.led=function(left){return state.option.plusplus?warning(\\\"W016\\\",this,this.id):left.identifier&&!isReserved(left)||\\\".\\\"===left.id||\\\"[\\\"===left.id||warning(\\\"W017\\\",this),left.isMetaProperty?error(\\\"E031\\\",this):left&&left.identifier&&state.funct[\\\"(scope)\\\"].block.modify(left.value,left),this.left=left,this},x}function optionalidentifier(fnparam,prop,preserve){if(state.tokens.next.identifier){preserve||advance();var curr=state.tokens.curr,val=state.tokens.curr.value;return isReserved(curr)?prop&&state.inES5()?val:fnparam&&\\\"undefined\\\"===val?val:(warning(\\\"W024\\\",state.tokens.curr,state.tokens.curr.id),val):val}}function identifier(fnparam,prop){var i=optionalidentifier(fnparam,prop,!1);if(i)return i;if(\\\"...\\\"===state.tokens.next.value){if(state.inES6(!0)||warning(\\\"W119\\\",state.tokens.next,\\\"spread/rest operator\\\",\\\"6\\\"),advance(),checkPunctuator(state.tokens.next,\\\"...\\\"))for(warning(\\\"E024\\\",state.tokens.next,\\\"...\\\");checkPunctuator(state.tokens.next,\\\"...\\\");)advance();return state.tokens.next.identifier?identifier(fnparam,prop):(warning(\\\"E024\\\",state.tokens.curr,\\\"...\\\"),void 0)}error(\\\"E030\\\",state.tokens.next,state.tokens.next.value),\\\";\\\"!==state.tokens.next.id&&advance()}function reachable(controlToken){var t,i=0;if(\\\";\\\"===state.tokens.next.id&&!controlToken.inBracelessBlock)for(;;){do t=peek(i),i+=1;while(\\\"(end)\\\"!==t.id&&\\\"(comment)\\\"===t.id);if(t.reach)return;if(\\\"(endline)\\\"!==t.id){if(\\\"function\\\"===t.id){state.option.latedef===!0&&warning(\\\"W026\\\",t);break}warning(\\\"W027\\\",t,t.value,controlToken.value);break}}}function parseFinalSemicolon(){if(\\\";\\\"!==state.tokens.next.id){if(state.tokens.next.isUnclosed)return advance();var sameLine=startLine(state.tokens.next)===state.tokens.curr.line&&\\\"(end)\\\"!==state.tokens.next.id,blockEnd=checkPunctuator(state.tokens.next,\\\"}\\\");sameLine&&!blockEnd?errorAt(\\\"E058\\\",state.tokens.curr.line,state.tokens.curr.character):state.option.asi||(blockEnd&&!state.option.lastsemic||!sameLine)&&warningAt(\\\"W033\\\",state.tokens.curr.line,state.tokens.curr.character)}else advance(\\\";\\\")}function statement(){var r,i=indent,t=state.tokens.next,hasOwnScope=!1;if(\\\";\\\"===t.id)return advance(\\\";\\\"),void 0;var res=isReserved(t);if(res&&t.meta&&t.meta.isFutureReservedWord&&\\\":\\\"===peek().id&&(warning(\\\"W024\\\",t,t.id),res=!1),t.identifier&&!res&&\\\":\\\"===peek().id&&(advance(),advance(\\\":\\\"),hasOwnScope=!0,state.funct[\\\"(scope)\\\"].stack(),state.funct[\\\"(scope)\\\"].block.addBreakLabel(t.value,{token:state.tokens.curr}),state.tokens.next.labelled||\\\"{\\\"===state.tokens.next.value||warning(\\\"W028\\\",state.tokens.next,t.value,state.tokens.next.value),state.tokens.next.label=t.value,t=state.tokens.next),\\\"{\\\"===t.id){var iscase=\\\"case\\\"===state.funct[\\\"(verb)\\\"]&&\\\":\\\"===state.tokens.curr.value;return block(!0,!0,!1,!1,iscase),void 0}return r=expression(0,!0),!r||r.identifier&&\\\"function\\\"===r.value||\\\"(punctuator)\\\"===r.type&&r.left&&r.left.identifier&&\\\"function\\\"===r.left.value||state.isStrict()||\\\"global\\\"!==state.option.strict||warning(\\\"E007\\\"),t.block||(state.option.expr||r&&r.exps?state.option.nonew&&r&&r.left&&\\\"(\\\"===r.id&&\\\"new\\\"===r.left.id&&warning(\\\"W031\\\",t):warning(\\\"W030\\\",state.tokens.curr),parseFinalSemicolon()),indent=i,hasOwnScope&&state.funct[\\\"(scope)\\\"].unstack(),r}function statements(){for(var p,a=[];!state.tokens.next.reach&&\\\"(end)\\\"!==state.tokens.next.id;)\\\";\\\"===state.tokens.next.id?(p=peek(),(!p||\\\"(\\\"!==p.id&&\\\"[\\\"!==p.id)&&warning(\\\"W032\\\"),advance(\\\";\\\")):a.push(statement());return a}function directives(){for(var i,p,pn;\\\"(string)\\\"===state.tokens.next.id;){if(p=peek(0),\\\"(endline)\\\"===p.id){i=1;do pn=peek(i++);while(\\\"(endline)\\\"===pn.id);if(\\\";\\\"===pn.id)p=pn;else{if(\\\"[\\\"===pn.value||\\\".\\\"===pn.value)break;state.option.asi&&\\\"(\\\"!==pn.value||warning(\\\"W033\\\",state.tokens.next)}}else{if(\\\".\\\"===p.id||\\\"[\\\"===p.id)break;\\\";\\\"!==p.id&&warning(\\\"W033\\\",p)}advance();var directive=state.tokens.curr.value;(state.directive[directive]||\\\"use strict\\\"===directive&&\\\"implied\\\"===state.option.strict)&&warning(\\\"W034\\\",state.tokens.curr,directive),state.directive[directive]=!0,\\\";\\\"===p.id&&advance(\\\";\\\")}state.isStrict()&&(state.option[\\\"(explicitNewcap)\\\"]||(state.option.newcap=!0),state.option.undef=!0)}function block(ordinary,stmt,isfunc,isfatarrow,iscase){var a,m,t,line,d,b=inblock,old_indent=indent;inblock=ordinary,t=state.tokens.next;var metrics=state.funct[\\\"(metrics)\\\"];if(metrics.nestedBlockDepth+=1,metrics.verifyMaxNestedBlockDepthPerFunction(),\\\"{\\\"===state.tokens.next.id){if(advance(\\\"{\\\"),state.funct[\\\"(scope)\\\"].stack(),line=state.tokens.curr.line,\\\"}\\\"!==state.tokens.next.id){for(indent+=state.option.indent;!ordinary&&state.tokens.next.from>indent;)indent+=state.option.indent;if(isfunc){m={};for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);directives(),state.option.strict&&state.funct[\\\"(context)\\\"][\\\"(global)\\\"]&&(m[\\\"use strict\\\"]||state.isStrict()||warning(\\\"E007\\\"))}a=statements(),metrics.statementCount+=a.length,indent-=state.option.indent}advance(\\\"}\\\",t),isfunc&&(state.funct[\\\"(scope)\\\"].validateParams(),m&&(state.directive=m)),state.funct[\\\"(scope)\\\"].unstack(),indent=old_indent}else if(ordinary)state.funct[\\\"(noblockscopedvar)\\\"]=\\\"for\\\"!==state.tokens.next.id,state.funct[\\\"(scope)\\\"].stack(),(!stmt||state.option.curly)&&warning(\\\"W116\\\",state.tokens.next,\\\"{\\\",state.tokens.next.value),state.tokens.next.inBracelessBlock=!0,indent+=state.option.indent,a=[statement()],indent-=state.option.indent,state.funct[\\\"(scope)\\\"].unstack(),delete state.funct[\\\"(noblockscopedvar)\\\"];else if(isfunc){if(state.funct[\\\"(scope)\\\"].stack(),m={},!stmt||isfatarrow||state.inMoz()||error(\\\"W118\\\",state.tokens.curr,\\\"function closure expressions\\\"),!stmt)for(d in state.directive)_.has(state.directive,d)&&(m[d]=state.directive[d]);expression(10),state.option.strict&&state.funct[\\\"(context)\\\"][\\\"(global)\\\"]&&(m[\\\"use strict\\\"]||state.isStrict()||warning(\\\"E007\\\")),state.funct[\\\"(scope)\\\"].unstack()}else error(\\\"E021\\\",state.tokens.next,\\\"{\\\",state.tokens.next.value);switch(state.funct[\\\"(verb)\\\"]){case\\\"break\\\":case\\\"continue\\\":case\\\"return\\\":case\\\"throw\\\":if(iscase)break;default:state.funct[\\\"(verb)\\\"]=null}return inblock=b,!ordinary||!state.option.noempty||a&&0!==a.length||warning(\\\"W035\\\",state.tokens.prev),metrics.nestedBlockDepth-=1,a}function countMember(m){membersOnly&&\\\"boolean\\\"!=typeof membersOnly[m]&&warning(\\\"W036\\\",state.tokens.curr,m),\\\"number\\\"==typeof member[m]?member[m]+=1:member[m]=1}function comprehensiveArrayExpression(){var res={};res.exps=!0,state.funct[\\\"(comparray)\\\"].stack();var reversed=!1;return\\\"for\\\"!==state.tokens.next.value&&(reversed=!0,state.inMoz()||warning(\\\"W116\\\",state.tokens.next,\\\"for\\\",state.tokens.next.value),state.funct[\\\"(comparray)\\\"].setState(\\\"use\\\"),res.right=expression(10)),advance(\\\"for\\\"),\\\"each\\\"===state.tokens.next.value&&(advance(\\\"each\\\"),state.inMoz()||warning(\\\"W118\\\",state.tokens.curr,\\\"for each\\\")),advance(\\\"(\\\"),state.funct[\\\"(comparray)\\\"].setState(\\\"define\\\"),res.left=expression(130),_.contains([\\\"in\\\",\\\"of\\\"],state.tokens.next.value)?advance():error(\\\"E045\\\",state.tokens.curr),state.funct[\\\"(comparray)\\\"].setState(\\\"generate\\\"),expression(10),advance(\\\")\\\"),\\\"if\\\"===state.tokens.next.value&&(advance(\\\"if\\\"),advance(\\\"(\\\"),state.funct[\\\"(comparray)\\\"].setState(\\\"filter\\\"),res.filter=expression(10),advance(\\\")\\\")),reversed||(state.funct[\\\"(comparray)\\\"].setState(\\\"use\\\"),res.right=expression(10)),advance(\\\"]\\\"),state.funct[\\\"(comparray)\\\"].unstack(),res}function isMethod(){return state.funct[\\\"(statement)\\\"]&&\\\"class\\\"===state.funct[\\\"(statement)\\\"].type||state.funct[\\\"(context)\\\"]&&\\\"class\\\"===state.funct[\\\"(context)\\\"][\\\"(verb)\\\"]}function isPropertyName(token){return token.identifier||\\\"(string)\\\"===token.id||\\\"(number)\\\"===token.id}function propertyName(preserveOrToken){var id,preserve=!0;return\\\"object\\\"==typeof preserveOrToken?id=preserveOrToken:(preserve=preserveOrToken,id=optionalidentifier(!1,!0,preserve)),id?\\\"object\\\"==typeof id&&(\\\"(string)\\\"===id.id||\\\"(identifier)\\\"===id.id?id=id.value:\\\"(number)\\\"===id.id&&(id=\\\"\\\"+id.value)):\\\"(string)\\\"===state.tokens.next.id?(id=state.tokens.next.value,preserve||advance()):\\\"(number)\\\"===state.tokens.next.id&&(id=\\\"\\\"+state.tokens.next.value,preserve||advance()),\\\"hasOwnProperty\\\"===id&&warning(\\\"W001\\\"),id}function functionparams(options){function addParam(addParamArgs){state.funct[\\\"(scope)\\\"].addParam.apply(state.funct[\\\"(scope)\\\"],addParamArgs)}var next,ident,t,paramsIds=[],tokens=[],pastDefault=!1,pastRest=!1,arity=0,loneArg=options&&options.loneArg;if(loneArg&&loneArg.identifier===!0)return state.funct[\\\"(scope)\\\"].addParam(loneArg.value,loneArg),{arity:1,params:[loneArg.value]};if(next=state.tokens.next,options&&options.parsedOpening||advance(\\\"(\\\"),\\\")\\\"===state.tokens.next.id)return advance(\\\")\\\"),void 0;for(;;){arity++;var currentParams=[];if(_.contains([\\\"{\\\",\\\"[\\\"],state.tokens.next.id)){tokens=destructuringPattern();for(t in tokens)t=tokens[t],t.id&&(paramsIds.push(t.id),currentParams.push([t.id,t.token]))}else if(checkPunctuator(state.tokens.next,\\\"...\\\")&&(pastRest=!0),ident=identifier(!0))paramsIds.push(ident),currentParams.push([ident,state.tokens.curr]);else for(;!checkPunctuators(state.tokens.next,[\\\",\\\",\\\")\\\"]);)advance();if(pastDefault&&\\\"=\\\"!==state.tokens.next.id&&error(\\\"W138\\\",state.tokens.current),\\\"=\\\"===state.tokens.next.id&&(state.inES6()||warning(\\\"W119\\\",state.tokens.next,\\\"default parameters\\\",\\\"6\\\"),advance(\\\"=\\\"),pastDefault=!0,expression(10)),currentParams.forEach(addParam),\\\",\\\"!==state.tokens.next.id)return advance(\\\")\\\",next),{arity:arity,params:paramsIds};pastRest&&warning(\\\"W131\\\",state.tokens.next),comma()}}function functor(name,token,overwrites){var funct={\\\"(name)\\\":name,\\\"(breakage)\\\":0,\\\"(loopage)\\\":0,\\\"(tokens)\\\":{},\\\"(properties)\\\":{},\\\"(catch)\\\":!1,\\\"(global)\\\":!1,\\\"(line)\\\":null,\\\"(character)\\\":null,\\\"(metrics)\\\":null,\\\"(statement)\\\":null,\\\"(context)\\\":null,\\\"(scope)\\\":null,\\\"(comparray)\\\":null,\\\"(generator)\\\":null,\\\"(arrow)\\\":null,\\\"(params)\\\":null};return token&&_.extend(funct,{\\\"(line)\\\":token.line,\\\"(character)\\\":token.character,\\\"(metrics)\\\":createMetrics(token)}),_.extend(funct,overwrites),funct[\\\"(context)\\\"]&&(funct[\\\"(scope)\\\"]=funct[\\\"(context)\\\"][\\\"(scope)\\\"],funct[\\\"(comparray)\\\"]=funct[\\\"(context)\\\"][\\\"(comparray)\\\"]),funct}function isFunctor(token){return\\\"(scope)\\\"in token}function hasParsedCode(funct){return funct[\\\"(global)\\\"]&&!funct[\\\"(verb)\\\"]}function doTemplateLiteral(left){function end(){if(state.tokens.curr.template&&state.tokens.curr.tail&&state.tokens.curr.context===ctx)return!0;var complete=state.tokens.next.template&&state.tokens.next.tail&&state.tokens.next.context===ctx;return complete&&advance(),complete||state.tokens.next.isUnclosed}var ctx=this.context,noSubst=this.noSubst,depth=this.depth;if(!noSubst)for(;!end();)!state.tokens.next.template||state.tokens.next.depth>depth?expression(0):advance();return{id:\\\"(template)\\\",type:\\\"(template)\\\",tag:left}}function doFunction(options){var f,token,name,statement,classExprBinding,isGenerator,isArrow,ignoreLoopFunc,oldOption=state.option,oldIgnored=state.ignored;options&&(name=options.name,statement=options.statement,classExprBinding=options.classExprBinding,isGenerator=\\\"generator\\\"===options.type,isArrow=\\\"arrow\\\"===options.type,ignoreLoopFunc=options.ignoreLoopFunc),state.option=Object.create(state.option),state.ignored=Object.create(state.ignored),state.funct=functor(name||state.nameStack.infer(),state.tokens.next,{\\\"(statement)\\\":statement,\\\"(context)\\\":state.funct,\\\"(arrow)\\\":isArrow,\\\"(generator)\\\":isGenerator}),f=state.funct,token=state.tokens.curr,token.funct=state.funct,functions.push(state.funct),state.funct[\\\"(scope)\\\"].stack(\\\"functionouter\\\");var internallyAccessibleName=name||classExprBinding;internallyAccessibleName&&state.funct[\\\"(scope)\\\"].block.add(internallyAccessibleName,classExprBinding?\\\"class\\\":\\\"function\\\",state.tokens.curr,!1),state.funct[\\\"(scope)\\\"].stack(\\\"functionparams\\\");var paramsInfo=functionparams(options);return paramsInfo?(state.funct[\\\"(params)\\\"]=paramsInfo.params,state.funct[\\\"(metrics)\\\"].arity=paramsInfo.arity,state.funct[\\\"(metrics)\\\"].verifyMaxParametersPerFunction()):state.funct[\\\"(metrics)\\\"].arity=0,isArrow&&(state.inES6(!0)||warning(\\\"W119\\\",state.tokens.curr,\\\"arrow function syntax (=>)\\\",\\\"6\\\"),options.loneArg||advance(\\\"=>\\\")),block(!1,!0,!0,isArrow),!state.option.noyield&&isGenerator&&\\\"yielded\\\"!==state.funct[\\\"(generator)\\\"]&&warning(\\\"W124\\\",state.tokens.curr),state.funct[\\\"(metrics)\\\"].verifyMaxStatementsPerFunction(),state.funct[\\\"(metrics)\\\"].verifyMaxComplexityPerFunction(),state.funct[\\\"(unusedOption)\\\"]=state.option.unused,state.option=oldOption,state.ignored=oldIgnored,state.funct[\\\"(last)\\\"]=state.tokens.curr.line,state.funct[\\\"(lastcharacter)\\\"]=state.tokens.curr.character,state.funct[\\\"(scope)\\\"].unstack(),state.funct[\\\"(scope)\\\"].unstack(),state.funct=state.funct[\\\"(context)\\\"],ignoreLoopFunc||state.option.loopfunc||!state.funct[\\\"(loopage)\\\"]||f[\\\"(isCapturing)\\\"]&&warning(\\\"W083\\\",token),f}function createMetrics(functionStartToken){return{statementCount:0,nestedBlockDepth:-1,ComplexityCount:1,arity:0,verifyMaxStatementsPerFunction:function(){state.option.maxstatements&&this.statementCount>state.option.maxstatements&&warning(\\\"W071\\\",functionStartToken,this.statementCount)\\n},verifyMaxParametersPerFunction:function(){_.isNumber(state.option.maxparams)&&this.arity>state.option.maxparams&&warning(\\\"W072\\\",functionStartToken,this.arity)},verifyMaxNestedBlockDepthPerFunction:function(){state.option.maxdepth&&this.nestedBlockDepth>0&&this.nestedBlockDepth===state.option.maxdepth+1&&warning(\\\"W073\\\",null,this.nestedBlockDepth)},verifyMaxComplexityPerFunction:function(){var max=state.option.maxcomplexity,cc=this.ComplexityCount;max&&cc>max&&warning(\\\"W074\\\",functionStartToken,cc)}}}function increaseComplexityCount(){state.funct[\\\"(metrics)\\\"].ComplexityCount+=1}function checkCondAssignment(expr){var id,paren;switch(expr&&(id=expr.id,paren=expr.paren,\\\",\\\"===id&&(expr=expr.exprs[expr.exprs.length-1])&&(id=expr.id,paren=paren||expr.paren)),id){case\\\"=\\\":case\\\"+=\\\":case\\\"-=\\\":case\\\"*=\\\":case\\\"%=\\\":case\\\"&=\\\":case\\\"|=\\\":case\\\"^=\\\":case\\\"/=\\\":paren||state.option.boss||warning(\\\"W084\\\")}}function checkProperties(props){if(state.inES5())for(var name in props)props[name]&&props[name].setterToken&&!props[name].getterToken&&warning(\\\"W078\\\",props[name].setterToken)}function metaProperty(name,c){if(checkPunctuator(state.tokens.next,\\\".\\\")){var left=state.tokens.curr.id;advance(\\\".\\\");var id=identifier();return state.tokens.curr.isMetaProperty=!0,name!==id?error(\\\"E057\\\",state.tokens.prev,left,id):c(),state.tokens.curr}}function destructuringPattern(options){var isAssignment=options&&options.assignment;return state.inES6()||warning(\\\"W104\\\",state.tokens.curr,isAssignment?\\\"destructuring assignment\\\":\\\"destructuring binding\\\",\\\"6\\\"),destructuringPatternRecursive(options)}function destructuringPatternRecursive(options){var ids,identifiers=[],openingParsed=options&&options.openingParsed,isAssignment=options&&options.assignment,recursiveOptions=isAssignment?{assignment:isAssignment}:null,firstToken=openingParsed?state.tokens.curr:state.tokens.next,nextInnerDE=function(){var ident;if(checkPunctuators(state.tokens.next,[\\\"[\\\",\\\"{\\\"])){ids=destructuringPatternRecursive(recursiveOptions);for(var id in ids)id=ids[id],identifiers.push({id:id.id,token:id.token})}else if(checkPunctuator(state.tokens.next,\\\",\\\"))identifiers.push({id:null,token:state.tokens.curr});else{if(!checkPunctuator(state.tokens.next,\\\"(\\\")){var is_rest=checkPunctuator(state.tokens.next,\\\"...\\\");if(isAssignment){var identifierToken=is_rest?peek(0):state.tokens.next;identifierToken.identifier||warning(\\\"E030\\\",identifierToken,identifierToken.value);var assignTarget=expression(155);assignTarget&&(checkLeftSideAssign(assignTarget),assignTarget.identifier&&(ident=assignTarget.value))}else ident=identifier();return ident&&identifiers.push({id:ident,token:state.tokens.curr}),is_rest}advance(\\\"(\\\"),nextInnerDE(),advance(\\\")\\\")}return!1},assignmentProperty=function(){var id;checkPunctuator(state.tokens.next,\\\"[\\\")?(advance(\\\"[\\\"),expression(10),advance(\\\"]\\\"),advance(\\\":\\\"),nextInnerDE()):\\\"(string)\\\"===state.tokens.next.id||\\\"(number)\\\"===state.tokens.next.id?(advance(),advance(\\\":\\\"),nextInnerDE()):(id=identifier(),checkPunctuator(state.tokens.next,\\\":\\\")?(advance(\\\":\\\"),nextInnerDE()):id&&(isAssignment&&checkLeftSideAssign(state.tokens.curr),identifiers.push({id:id,token:state.tokens.curr})))};if(checkPunctuator(firstToken,\\\"[\\\")){openingParsed||advance(\\\"[\\\"),checkPunctuator(state.tokens.next,\\\"]\\\")&&warning(\\\"W137\\\",state.tokens.curr);for(var element_after_rest=!1;!checkPunctuator(state.tokens.next,\\\"]\\\");)nextInnerDE()&&!element_after_rest&&checkPunctuator(state.tokens.next,\\\",\\\")&&(warning(\\\"W130\\\",state.tokens.next),element_after_rest=!0),checkPunctuator(state.tokens.next,\\\"=\\\")&&(checkPunctuator(state.tokens.prev,\\\"...\\\")?advance(\\\"]\\\"):advance(\\\"=\\\"),\\\"undefined\\\"===state.tokens.next.id&&warning(\\\"W080\\\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\\\"]\\\")||advance(\\\",\\\");advance(\\\"]\\\")}else if(checkPunctuator(firstToken,\\\"{\\\")){for(openingParsed||advance(\\\"{\\\"),checkPunctuator(state.tokens.next,\\\"}\\\")&&warning(\\\"W137\\\",state.tokens.curr);!checkPunctuator(state.tokens.next,\\\"}\\\")&&(assignmentProperty(),checkPunctuator(state.tokens.next,\\\"=\\\")&&(advance(\\\"=\\\"),\\\"undefined\\\"===state.tokens.next.id&&warning(\\\"W080\\\",state.tokens.prev,state.tokens.prev.value),expression(10)),checkPunctuator(state.tokens.next,\\\"}\\\")||(advance(\\\",\\\"),!checkPunctuator(state.tokens.next,\\\"}\\\"))););advance(\\\"}\\\")}return identifiers}function destructuringPatternMatch(tokens,value){var first=value.first;first&&_.zip(tokens,Array.isArray(first)?first:[first]).forEach(function(val){var token=val[0],value=val[1];token&&value?token.first=value:token&&token.first&&!value&&warning(\\\"W080\\\",token.first,token.first.value)})}function blockVariableStatement(type,statement,context){var tokens,lone,value,letblock,prefix=context&&context.prefix,inexport=context&&context.inexport,isLet=\\\"let\\\"===type,isConst=\\\"const\\\"===type;for(state.inES6()||warning(\\\"W104\\\",state.tokens.curr,type,\\\"6\\\"),isLet&&\\\"(\\\"===state.tokens.next.value?(state.inMoz()||warning(\\\"W118\\\",state.tokens.next,\\\"let block\\\"),advance(\\\"(\\\"),state.funct[\\\"(scope)\\\"].stack(),letblock=!0):state.funct[\\\"(noblockscopedvar)\\\"]&&error(\\\"E048\\\",state.tokens.curr,isConst?\\\"Const\\\":\\\"Let\\\"),statement.first=[];;){var names=[];_.contains([\\\"{\\\",\\\"[\\\"],state.tokens.next.value)?(tokens=destructuringPattern(),lone=!1):(tokens=[{id:identifier(),token:state.tokens.curr}],lone=!0),!prefix&&isConst&&\\\"=\\\"!==state.tokens.next.id&&warning(\\\"E012\\\",state.tokens.curr,state.tokens.curr.value);for(var t in tokens)tokens.hasOwnProperty(t)&&(t=tokens[t],state.funct[\\\"(scope)\\\"].block.isGlobal()&&predefined[t.id]===!1&&warning(\\\"W079\\\",t.token,t.id),t.id&&!state.funct[\\\"(noblockscopedvar)\\\"]&&(state.funct[\\\"(scope)\\\"].addlabel(t.id,{type:type,token:t.token}),names.push(t.token),lone&&inexport&&state.funct[\\\"(scope)\\\"].setExported(t.token.value,t.token)));if(\\\"=\\\"===state.tokens.next.id&&(advance(\\\"=\\\"),prefix||\\\"undefined\\\"!==state.tokens.next.id||warning(\\\"W080\\\",state.tokens.prev,state.tokens.prev.value),!prefix&&\\\"=\\\"===peek(0).id&&state.tokens.next.identifier&&warning(\\\"W120\\\",state.tokens.next,state.tokens.next.value),value=expression(prefix?120:10),lone?tokens[0].first=value:destructuringPatternMatch(names,value)),statement.first=statement.first.concat(names),\\\",\\\"!==state.tokens.next.id)break;comma()}return letblock&&(advance(\\\")\\\"),block(!0,!0),statement.block=!0,state.funct[\\\"(scope)\\\"].unstack()),statement}function classdef(isStatement){return state.inES6()||warning(\\\"W104\\\",state.tokens.curr,\\\"class\\\",\\\"6\\\"),isStatement?(this.name=identifier(),state.funct[\\\"(scope)\\\"].addlabel(this.name,{type:\\\"class\\\",token:state.tokens.curr})):state.tokens.next.identifier&&\\\"extends\\\"!==state.tokens.next.value?(this.name=identifier(),this.namedExpr=!0):this.name=state.nameStack.infer(),classtail(this),this}function classtail(c){var wasInClassBody=state.inClassBody;\\\"extends\\\"===state.tokens.next.value&&(advance(\\\"extends\\\"),c.heritage=expression(10)),state.inClassBody=!0,advance(\\\"{\\\"),c.body=classbody(c),advance(\\\"}\\\"),state.inClassBody=wasInClassBody}function classbody(c){for(var name,isStatic,isGenerator,getset,computed,props=Object.create(null),staticProps=Object.create(null),i=0;\\\"}\\\"!==state.tokens.next.id;++i)if(name=state.tokens.next,isStatic=!1,isGenerator=!1,getset=null,\\\";\\\"!==name.id){if(\\\"*\\\"===name.id&&(isGenerator=!0,advance(\\\"*\\\"),name=state.tokens.next),\\\"[\\\"===name.id)name=computedPropertyName(),computed=!0;else{if(!isPropertyName(name)){warning(\\\"W052\\\",state.tokens.next,state.tokens.next.value||state.tokens.next.type),advance();continue}advance(),computed=!1,name.identifier&&\\\"static\\\"===name.value&&(checkPunctuator(state.tokens.next,\\\"*\\\")&&(isGenerator=!0,advance(\\\"*\\\")),(isPropertyName(state.tokens.next)||\\\"[\\\"===state.tokens.next.id)&&(computed=\\\"[\\\"===state.tokens.next.id,isStatic=!0,name=state.tokens.next,\\\"[\\\"===state.tokens.next.id?name=computedPropertyName():advance())),!name.identifier||\\\"get\\\"!==name.value&&\\\"set\\\"!==name.value||(isPropertyName(state.tokens.next)||\\\"[\\\"===state.tokens.next.id)&&(computed=\\\"[\\\"===state.tokens.next.id,getset=name,name=state.tokens.next,\\\"[\\\"===state.tokens.next.id?name=computedPropertyName():advance())}if(!checkPunctuator(state.tokens.next,\\\"(\\\")){for(error(\\\"E054\\\",state.tokens.next,state.tokens.next.value);\\\"}\\\"!==state.tokens.next.id&&!checkPunctuator(state.tokens.next,\\\"(\\\");)advance();\\\"(\\\"!==state.tokens.next.value&&doFunction({statement:c})}if(computed||(getset?saveAccessor(getset.value,isStatic?staticProps:props,name.value,name,!0,isStatic):(\\\"constructor\\\"===name.value?state.nameStack.set(c):state.nameStack.set(name),saveProperty(isStatic?staticProps:props,name.value,name,!0,isStatic))),getset&&\\\"constructor\\\"===name.value){var propDesc=\\\"get\\\"===getset.value?\\\"class getter method\\\":\\\"class setter method\\\";error(\\\"E049\\\",name,propDesc,\\\"constructor\\\")}else\\\"prototype\\\"===name.value&&error(\\\"E049\\\",name,\\\"class method\\\",\\\"prototype\\\");propertyName(name),doFunction({statement:c,type:isGenerator?\\\"generator\\\":null,classExprBinding:c.namedExpr?c.name:null})}else warning(\\\"W032\\\"),advance(\\\";\\\");checkProperties(props)}function saveProperty(props,name,tkn,isClass,isStatic){var msg=[\\\"key\\\",\\\"class method\\\",\\\"static class method\\\"];msg=msg[(isClass||!1)+(isStatic||!1)],tkn.identifier&&(name=tkn.value),props[name]&&\\\"__proto__\\\"!==name?warning(\\\"W075\\\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name].basic=!0,props[name].basictkn=tkn}function saveAccessor(accessorType,props,name,tkn,isClass,isStatic){var flagName=\\\"get\\\"===accessorType?\\\"getterToken\\\":\\\"setterToken\\\",msg=\\\"\\\";isClass?(isStatic&&(msg+=\\\"static \\\"),msg+=accessorType+\\\"ter method\\\"):msg=\\\"key\\\",state.tokens.curr.accessorType=accessorType,state.nameStack.set(tkn),props[name]?(props[name].basic||props[name][flagName])&&\\\"__proto__\\\"!==name&&warning(\\\"W075\\\",state.tokens.next,msg,name):props[name]=Object.create(null),props[name][flagName]=tkn}function computedPropertyName(){advance(\\\"[\\\"),state.inES6()||warning(\\\"W119\\\",state.tokens.curr,\\\"computed property names\\\",\\\"6\\\");var value=expression(10);return advance(\\\"]\\\"),value}function checkPunctuators(token,values){return\\\"(punctuator)\\\"===token.type?_.contains(values,token.value):!1}function checkPunctuator(token,value){return\\\"(punctuator)\\\"===token.type&&token.value===value}function destructuringAssignOrJsonValue(){var block=lookupBlockType();block.notJson?(!state.inES6()&&block.isDestAssign&&warning(\\\"W104\\\",state.tokens.curr,\\\"destructuring assignment\\\",\\\"6\\\"),statements()):(state.option.laxbreak=!0,state.jsonMode=!0,jsonValue())}function jsonValue(){function jsonObject(){var o={},t=state.tokens.next;if(advance(\\\"{\\\"),\\\"}\\\"!==state.tokens.next.id)for(;;){if(\\\"(end)\\\"===state.tokens.next.id)error(\\\"E026\\\",state.tokens.next,t.line);else{if(\\\"}\\\"===state.tokens.next.id){warning(\\\"W094\\\",state.tokens.curr);break}\\\",\\\"===state.tokens.next.id?error(\\\"E028\\\",state.tokens.next):\\\"(string)\\\"!==state.tokens.next.id&&warning(\\\"W095\\\",state.tokens.next,state.tokens.next.value)}if(o[state.tokens.next.value]===!0?warning(\\\"W075\\\",state.tokens.next,\\\"key\\\",state.tokens.next.value):\\\"__proto__\\\"===state.tokens.next.value&&!state.option.proto||\\\"__iterator__\\\"===state.tokens.next.value&&!state.option.iterator?warning(\\\"W096\\\",state.tokens.next,state.tokens.next.value):o[state.tokens.next.value]=!0,advance(),advance(\\\":\\\"),jsonValue(),\\\",\\\"!==state.tokens.next.id)break;advance(\\\",\\\")}advance(\\\"}\\\")}function jsonArray(){var t=state.tokens.next;if(advance(\\\"[\\\"),\\\"]\\\"!==state.tokens.next.id)for(;;){if(\\\"(end)\\\"===state.tokens.next.id)error(\\\"E027\\\",state.tokens.next,t.line);else{if(\\\"]\\\"===state.tokens.next.id){warning(\\\"W094\\\",state.tokens.curr);break}\\\",\\\"===state.tokens.next.id&&error(\\\"E028\\\",state.tokens.next)}if(jsonValue(),\\\",\\\"!==state.tokens.next.id)break;advance(\\\",\\\")}advance(\\\"]\\\")}switch(state.tokens.next.id){case\\\"{\\\":jsonObject();break;case\\\"[\\\":jsonArray();break;case\\\"true\\\":case\\\"false\\\":case\\\"null\\\":case\\\"(number)\\\":case\\\"(string)\\\":advance();break;case\\\"-\\\":advance(\\\"-\\\"),advance(\\\"(number)\\\");break;default:error(\\\"E003\\\",state.tokens.next)}}var api,declared,functions,inblock,indent,lookahead,lex,member,membersOnly,predefined,stack,urls,bang={\\\"<\\\":!0,\\\"<=\\\":!0,\\\"==\\\":!0,\\\"===\\\":!0,\\\"!==\\\":!0,\\\"!=\\\":!0,\\\">\\\":!0,\\\">=\\\":!0,\\\"+\\\":!0,\\\"-\\\":!0,\\\"*\\\":!0,\\\"/\\\":!0,\\\"%\\\":!0},functionicity=[\\\"closure\\\",\\\"exception\\\",\\\"global\\\",\\\"label\\\",\\\"outer\\\",\\\"unused\\\",\\\"var\\\"],extraModules=[],emitter=new events.EventEmitter,typeofValues={};typeofValues.legacy=[\\\"xml\\\",\\\"unknown\\\"],typeofValues.es3=[\\\"undefined\\\",\\\"boolean\\\",\\\"number\\\",\\\"string\\\",\\\"function\\\",\\\"object\\\"],typeofValues.es3=typeofValues.es3.concat(typeofValues.legacy),typeofValues.es6=typeofValues.es3.concat(\\\"symbol\\\"),type(\\\"(number)\\\",function(){return this}),type(\\\"(string)\\\",function(){return this}),state.syntax[\\\"(identifier)\\\"]={type:\\\"(identifier)\\\",lbp:0,identifier:!0,nud:function(){var v=this.value;return\\\"=>\\\"===state.tokens.next.id?this:(state.funct[\\\"(comparray)\\\"].check(v)||state.funct[\\\"(scope)\\\"].block.use(v,state.tokens.curr),this)},led:function(){error(\\\"E033\\\",state.tokens.next,state.tokens.next.value)}};var baseTemplateSyntax={lbp:0,identifier:!1,template:!0};state.syntax[\\\"(template)\\\"]=_.extend({type:\\\"(template)\\\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!1},baseTemplateSyntax),state.syntax[\\\"(template middle)\\\"]=_.extend({type:\\\"(template middle)\\\",middle:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\\\"(template tail)\\\"]=_.extend({type:\\\"(template tail)\\\",tail:!0,noSubst:!1},baseTemplateSyntax),state.syntax[\\\"(no subst template)\\\"]=_.extend({type:\\\"(template)\\\",nud:doTemplateLiteral,led:doTemplateLiteral,noSubst:!0,tail:!0},baseTemplateSyntax),type(\\\"(regexp)\\\",function(){return this}),delim(\\\"(endline)\\\"),delim(\\\"(begin)\\\"),delim(\\\"(end)\\\").reach=!0,delim(\\\"(error)\\\").reach=!0,delim(\\\"}\\\").reach=!0,delim(\\\")\\\"),delim(\\\"]\\\"),delim('\\\"').reach=!0,delim(\\\"'\\\").reach=!0,delim(\\\";\\\"),delim(\\\":\\\").reach=!0,delim(\\\"#\\\"),reserve(\\\"else\\\"),reserve(\\\"case\\\").reach=!0,reserve(\\\"catch\\\"),reserve(\\\"default\\\").reach=!0,reserve(\\\"finally\\\"),reservevar(\\\"arguments\\\",function(x){state.isStrict()&&state.funct[\\\"(global)\\\"]&&warning(\\\"E008\\\",x)}),reservevar(\\\"eval\\\"),reservevar(\\\"false\\\"),reservevar(\\\"Infinity\\\"),reservevar(\\\"null\\\"),reservevar(\\\"this\\\",function(x){state.isStrict()&&!isMethod()&&!state.option.validthis&&(state.funct[\\\"(statement)\\\"]&&state.funct[\\\"(name)\\\"].charAt(0)>\\\"Z\\\"||state.funct[\\\"(global)\\\"])&&warning(\\\"W040\\\",x)}),reservevar(\\\"true\\\"),reservevar(\\\"undefined\\\"),assignop(\\\"=\\\",\\\"assign\\\",20),assignop(\\\"+=\\\",\\\"assignadd\\\",20),assignop(\\\"-=\\\",\\\"assignsub\\\",20),assignop(\\\"*=\\\",\\\"assignmult\\\",20),assignop(\\\"/=\\\",\\\"assigndiv\\\",20).nud=function(){error(\\\"E014\\\")},assignop(\\\"%=\\\",\\\"assignmod\\\",20),bitwiseassignop(\\\"&=\\\"),bitwiseassignop(\\\"|=\\\"),bitwiseassignop(\\\"^=\\\"),bitwiseassignop(\\\"<<=\\\"),bitwiseassignop(\\\">>=\\\"),bitwiseassignop(\\\">>>=\\\"),infix(\\\",\\\",function(left,that){var expr;if(that.exprs=[left],state.option.nocomma&&warning(\\\"W127\\\"),!comma({peek:!0}))return that;for(;;){if(!(expr=expression(10)))break;if(that.exprs.push(expr),\\\",\\\"!==state.tokens.next.value||!comma())break}return that},10,!0),infix(\\\"?\\\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(10),advance(\\\":\\\"),that[\\\"else\\\"]=expression(10),that},30);var orPrecendence=40;infix(\\\"||\\\",function(left,that){return increaseComplexityCount(),that.left=left,that.right=expression(orPrecendence),that},orPrecendence),infix(\\\"&&\\\",\\\"and\\\",50),bitwise(\\\"|\\\",\\\"bitor\\\",70),bitwise(\\\"^\\\",\\\"bitxor\\\",80),bitwise(\\\"&\\\",\\\"bitand\\\",90),relation(\\\"==\\\",function(left,right){var eqnull=state.option.eqnull&&(\\\"null\\\"===(left&&left.value)||\\\"null\\\"===(right&&right.value));switch(!0){case!eqnull&&state.option.eqeqeq:this.from=this.character,warning(\\\"W116\\\",this,\\\"===\\\",\\\"==\\\");break;case isPoorRelation(left):warning(\\\"W041\\\",this,\\\"===\\\",left.value);break;case isPoorRelation(right):warning(\\\"W041\\\",this,\\\"===\\\",right.value);break;case isTypoTypeof(right,left,state):warning(\\\"W122\\\",this,right.value);break;case isTypoTypeof(left,right,state):warning(\\\"W122\\\",this,left.value)}return this}),relation(\\\"===\\\",function(left,right){return isTypoTypeof(right,left,state)?warning(\\\"W122\\\",this,right.value):isTypoTypeof(left,right,state)&&warning(\\\"W122\\\",this,left.value),this}),relation(\\\"!=\\\",function(left,right){var eqnull=state.option.eqnull&&(\\\"null\\\"===(left&&left.value)||\\\"null\\\"===(right&&right.value));return!eqnull&&state.option.eqeqeq?(this.from=this.character,warning(\\\"W116\\\",this,\\\"!==\\\",\\\"!=\\\")):isPoorRelation(left)?warning(\\\"W041\\\",this,\\\"!==\\\",left.value):isPoorRelation(right)?warning(\\\"W041\\\",this,\\\"!==\\\",right.value):isTypoTypeof(right,left,state)?warning(\\\"W122\\\",this,right.value):isTypoTypeof(left,right,state)&&warning(\\\"W122\\\",this,left.value),this}),relation(\\\"!==\\\",function(left,right){return isTypoTypeof(right,left,state)?warning(\\\"W122\\\",this,right.value):isTypoTypeof(left,right,state)&&warning(\\\"W122\\\",this,left.value),this}),relation(\\\"<\\\"),relation(\\\">\\\"),relation(\\\"<=\\\"),relation(\\\">=\\\"),bitwise(\\\"<<\\\",\\\"shiftleft\\\",120),bitwise(\\\">>\\\",\\\"shiftright\\\",120),bitwise(\\\">>>\\\",\\\"shiftrightunsigned\\\",120),infix(\\\"in\\\",\\\"in\\\",120),infix(\\\"instanceof\\\",\\\"instanceof\\\",120),infix(\\\"+\\\",function(left,that){var right;return that.left=left,that.right=right=expression(130),left&&right&&\\\"(string)\\\"===left.id&&\\\"(string)\\\"===right.id?(left.value+=right.value,left.character=right.character,!state.option.scripturl&®.javascriptURL.test(left.value)&&warning(\\\"W050\\\",left),left):that},130),prefix(\\\"+\\\",\\\"num\\\"),prefix(\\\"+++\\\",function(){return warning(\\\"W007\\\"),this.arity=\\\"unary\\\",this.right=expression(150),this}),infix(\\\"+++\\\",function(left){return warning(\\\"W007\\\"),this.left=left,this.right=expression(130),this},130),infix(\\\"-\\\",\\\"sub\\\",130),prefix(\\\"-\\\",\\\"neg\\\"),prefix(\\\"---\\\",function(){return warning(\\\"W006\\\"),this.arity=\\\"unary\\\",this.right=expression(150),this}),infix(\\\"---\\\",function(left){return warning(\\\"W006\\\"),this.left=left,this.right=expression(130),this},130),infix(\\\"*\\\",\\\"mult\\\",140),infix(\\\"/\\\",\\\"div\\\",140),infix(\\\"%\\\",\\\"mod\\\",140),suffix(\\\"++\\\"),prefix(\\\"++\\\",\\\"preinc\\\"),state.syntax[\\\"++\\\"].exps=!0,suffix(\\\"--\\\"),prefix(\\\"--\\\",\\\"predec\\\"),state.syntax[\\\"--\\\"].exps=!0,prefix(\\\"delete\\\",function(){var p=expression(10);return p?(\\\".\\\"!==p.id&&\\\"[\\\"!==p.id&&warning(\\\"W051\\\"),this.first=p,p.identifier&&!state.isStrict()&&(p.forgiveUndef=!0),this):this}).exps=!0,prefix(\\\"~\\\",function(){return state.option.bitwise&&warning(\\\"W016\\\",this,\\\"~\\\"),this.arity=\\\"unary\\\",this.right=expression(150),this}),prefix(\\\"...\\\",function(){return state.inES6(!0)||warning(\\\"W119\\\",this,\\\"spread/rest operator\\\",\\\"6\\\"),state.tokens.next.identifier||\\\"(string)\\\"===state.tokens.next.type||checkPunctuators(state.tokens.next,[\\\"[\\\",\\\"(\\\"])||error(\\\"E030\\\",state.tokens.next,state.tokens.next.value),expression(150),this}),prefix(\\\"!\\\",function(){return this.arity=\\\"unary\\\",this.right=expression(150),this.right||quit(\\\"E041\\\",this.line||0),bang[this.right.id]===!0&&warning(\\\"W018\\\",this,\\\"!\\\"),this}),prefix(\\\"typeof\\\",function(){var p=expression(150);return this.first=this.right=p,p||quit(\\\"E041\\\",this.line||0,this.character||0),p.identifier&&(p.forgiveUndef=!0),this}),prefix(\\\"new\\\",function(){var mp=metaProperty(\\\"target\\\",function(){state.inES6(!0)||warning(\\\"W119\\\",state.tokens.prev,\\\"new.target\\\",\\\"6\\\");for(var inFunction,c=state.funct;c&&(inFunction=!c[\\\"(global)\\\"],c[\\\"(arrow)\\\"]);)c=c[\\\"(context)\\\"];inFunction||warning(\\\"W136\\\",state.tokens.prev,\\\"new.target\\\")});if(mp)return mp;var i,c=expression(155);if(c&&\\\"function\\\"!==c.id)if(c.identifier)switch(c[\\\"new\\\"]=!0,c.value){case\\\"Number\\\":case\\\"String\\\":case\\\"Boolean\\\":case\\\"Math\\\":case\\\"JSON\\\":warning(\\\"W053\\\",state.tokens.prev,c.value);break;case\\\"Symbol\\\":state.inES6()&&warning(\\\"W053\\\",state.tokens.prev,c.value);break;case\\\"Function\\\":state.option.evil||warning(\\\"W054\\\");break;case\\\"Date\\\":case\\\"RegExp\\\":case\\\"this\\\":break;default:\\\"function\\\"!==c.id&&(i=c.value.substr(0,1),state.option.newcap&&(\\\"A\\\">i||i>\\\"Z\\\")&&!state.funct[\\\"(scope)\\\"].isPredefined(c.value)&&warning(\\\"W055\\\",state.tokens.curr))}else\\\".\\\"!==c.id&&\\\"[\\\"!==c.id&&\\\"(\\\"!==c.id&&warning(\\\"W056\\\",state.tokens.curr);else state.option.supernew||warning(\\\"W057\\\",this);return\\\"(\\\"===state.tokens.next.id||state.option.supernew||warning(\\\"W058\\\",state.tokens.curr,state.tokens.curr.value),this.first=this.right=c,this}),state.syntax[\\\"new\\\"].exps=!0,prefix(\\\"void\\\").exps=!0,infix(\\\".\\\",function(left,that){var m=identifier(!1,!0);return\\\"string\\\"==typeof m&&countMember(m),that.left=left,that.right=m,m&&\\\"hasOwnProperty\\\"===m&&\\\"=\\\"===state.tokens.next.value&&warning(\\\"W001\\\"),!left||\\\"arguments\\\"!==left.value||\\\"callee\\\"!==m&&\\\"caller\\\"!==m?state.option.evil||!left||\\\"document\\\"!==left.value||\\\"write\\\"!==m&&\\\"writeln\\\"!==m||warning(\\\"W060\\\",left):state.option.noarg?warning(\\\"W059\\\",left,m):state.isStrict()&&error(\\\"E008\\\"),state.option.evil||\\\"eval\\\"!==m&&\\\"execScript\\\"!==m||isGlobalEval(left,state)&&warning(\\\"W061\\\"),that},160,!0),infix(\\\"(\\\",function(left,that){state.option.immed&&left&&!left.immed&&\\\"function\\\"===left.id&&warning(\\\"W062\\\");var n=0,p=[];if(left&&\\\"(identifier)\\\"===left.type&&left.value.match(/^[A-Z]([A-Z0-9_$]*[a-z][A-Za-z0-9_$]*)?$/)&&-1===\\\"Array Number String Boolean Date Object Error Symbol\\\".indexOf(left.value)&&(\\\"Math\\\"===left.value?warning(\\\"W063\\\",left):state.option.newcap&&warning(\\\"W064\\\",left)),\\\")\\\"!==state.tokens.next.id)for(;p[p.length]=expression(10),n+=1,\\\",\\\"===state.tokens.next.id;)comma();return advance(\\\")\\\"),\\\"object\\\"==typeof left&&(state.inES5()||\\\"parseInt\\\"!==left.value||1!==n||warning(\\\"W065\\\",state.tokens.curr),state.option.evil||(\\\"eval\\\"===left.value||\\\"Function\\\"===left.value||\\\"execScript\\\"===left.value?(warning(\\\"W061\\\",left),p[0]&&\\\"(string)\\\"===[0].id&&addInternalSrc(left,p[0].value)):!p[0]||\\\"(string)\\\"!==p[0].id||\\\"setTimeout\\\"!==left.value&&\\\"setInterval\\\"!==left.value?!p[0]||\\\"(string)\\\"!==p[0].id||\\\".\\\"!==left.value||\\\"window\\\"!==left.left.value||\\\"setTimeout\\\"!==left.right&&\\\"setInterval\\\"!==left.right||(warning(\\\"W066\\\",left),addInternalSrc(left,p[0].value)):(warning(\\\"W066\\\",left),addInternalSrc(left,p[0].value))),left.identifier||\\\".\\\"===left.id||\\\"[\\\"===left.id||\\\"=>\\\"===left.id||\\\"(\\\"===left.id||\\\"&&\\\"===left.id||\\\"||\\\"===left.id||\\\"?\\\"===left.id||state.inES6()&&left[\\\"(name)\\\"]||warning(\\\"W067\\\",that)),that.left=left,that},155,!0).exps=!0,prefix(\\\"(\\\",function(){var pn1,ret,triggerFnExpr,first,last,pn=state.tokens.next,i=-1,parens=1,opening=state.tokens.curr,preceeding=state.tokens.prev,isNecessary=!state.option.singleGroups;do\\\"(\\\"===pn.value?parens+=1:\\\")\\\"===pn.value&&(parens-=1),i+=1,pn1=pn,pn=peek(i);while((0!==parens||\\\")\\\"!==pn1.value)&&\\\";\\\"!==pn.value&&\\\"(end)\\\"!==pn.type);if(\\\"function\\\"===state.tokens.next.id&&(triggerFnExpr=state.tokens.next.immed=!0),\\\"=>\\\"===pn.value)return doFunction({type:\\\"arrow\\\",parsedOpening:!0});var exprs=[];if(\\\")\\\"!==state.tokens.next.id)for(;exprs.push(expression(10)),\\\",\\\"===state.tokens.next.id;)state.option.nocomma&&warning(\\\"W127\\\"),comma();return advance(\\\")\\\",this),state.option.immed&&exprs[0]&&\\\"function\\\"===exprs[0].id&&\\\"(\\\"!==state.tokens.next.id&&\\\".\\\"!==state.tokens.next.id&&\\\"[\\\"!==state.tokens.next.id&&warning(\\\"W068\\\",this),exprs.length?(exprs.length>1?(ret=Object.create(state.syntax[\\\",\\\"]),ret.exprs=exprs,first=exprs[0],last=exprs[exprs.length-1],isNecessary||(isNecessary=preceeding.assign||preceeding.delim)):(ret=first=last=exprs[0],isNecessary||(isNecessary=opening.beginsStmt&&(\\\"{\\\"===ret.id||triggerFnExpr||isFunctor(ret))||triggerFnExpr&&(!isEndOfExpr()||\\\"}\\\"!==state.tokens.prev.id)||isFunctor(ret)&&!isEndOfExpr()||\\\"{\\\"===ret.id&&\\\"=>\\\"===preceeding.id||\\\"(number)\\\"===ret.type&&checkPunctuator(pn,\\\".\\\")&&/^\\\\d+$/.test(ret.value))),ret&&(!isNecessary&&(first.left||first.right||ret.exprs)&&(isNecessary=!isBeginOfExpr(preceeding)&&first.lbp<=preceeding.lbp||!isEndOfExpr()&&last.lbp
\" +\r\n \"You gained:
\" +\r\n formatNumber(inst.hackingExpGained, 3) + \" hacking exp
\" +\r\n formatNumber(inst.strExpGained, 3) + \" str exp
\" +\r\n formatNumber(inst.defExpGained, 3) + \" def exp
\" +\r\n formatNumber(inst.dexExpGained, 3) + \" dex exp
\" +\r\n formatNumber(inst.agiExpGained, 3) + \" agi exp
\" +\r\n formatNumber(inst.chaExpGained, 3) + \" cha exp
\");\r\n return;\r\n }\r\n var facValue = totalValue * Player.faction_rep_mult *\r\n CONSTANTS.InfiltrationRepValue * BitNodeMultipliers.InfiltrationRep;\r\n var moneyValue = totalValue * CONSTANTS.InfiltrationMoneyValue * BitNodeMultipliers.InfiltrationMoney;\r\n infiltrationSetText(\"You can sell the classified documents and secrets \" +\r\n \"you stole from \" + inst.companyName + \" for $\" +\r\n formatNumber(moneyValue, 2) + \" on the black market or you can give it \" +\r\n \"to a faction to gain \" + formatNumber(facValue, 3) + \" reputation with \" +\r\n \"that faction.\");\r\n var selector = document.getElementById(\"infiltration-faction-select\");\r\n selector.innerHTML = \"\";\r\n for (var i = 0; i < Player.factions.length; ++i) {\r\n if (Player.factions[i] === \"Bladeburners\") {continue;}\r\n selector.innerHTML += \"\";\r\n }\r\n\r\n var sellButton = clearEventListeners(\"infiltration-box-sell\");\r\n setTimeout(function() {\r\n sellButton.addEventListener(\"click\", function() {\r\n Player.gainMoney(moneyValue);\r\n dialogBoxCreate(\"You sold the classified information you stole from \" + inst.companyName +\r\n \" for $\" + moneyValue + \" on the black market!
\" +\r\n \"You gained:
\" +\r\n formatNumber(inst.hackingExpGained, 3) + \" hacking exp
\" +\r\n formatNumber(inst.strExpGained, 3) + \" str exp
\" +\r\n formatNumber(inst.defExpGained, 3) + \" def exp
\" +\r\n formatNumber(inst.dexExpGained, 3) + \" dex exp
\" +\r\n formatNumber(inst.agiExpGained, 3) + \" agi exp
\" +\r\n formatNumber(inst.chaExpGained, 3) + \" cha exp
\");\r\n infiltrationBoxClose();\r\n return false;\r\n });\r\n }, 750);\r\n\r\n var factionButton = clearEventListeners(\"infiltration-box-faction\");\r\n setTimeout(function() {\r\n factionButton.addEventListener(\"click\", function() {\r\n var facName = selector.options[selector.selectedIndex].value;\r\n var faction = Factions[facName];\r\n if (faction == null) {\r\n dialogBoxCreate(\"Error finding faction. This is a bug please report to developer\");\r\n return false;\r\n }\r\n faction.playerReputation += facValue;\r\n dialogBoxCreate(\"You gave the classified information you stole from \" + inst.companyName +\r\n \" to \" + facName + \" and gained \" + formatNumber(facValue, 3) + \" reputation with the faction.
\" +\r\n \"You gained:
\" +\r\n formatNumber(inst.hackingExpGained, 3) + \" hacking exp
\" +\r\n formatNumber(inst.strExpGained, 3) + \" str exp
\" +\r\n formatNumber(inst.defExpGained, 3) + \" def exp
\" +\r\n formatNumber(inst.dexExpGained, 3) + \" dex exp
\" +\r\n formatNumber(inst.agiExpGained, 3) + \" agi exp
\" +\r\n formatNumber(inst.chaExpGained, 3) + \" cha exp
\");\r\n infiltrationBoxClose();\r\n return false;\r\n });\r\n }, 750);\r\n infiltrationBoxOpen();\r\n}\r\n\r\nexport {infiltrationBoxCreate};\r\n","import {BitNodeMultipliers} from \"./BitNode.js\";\r\nimport {CONSTANTS} from \"./Constants.js\";\r\nimport {Engine} from \"./engine.js\";\r\nimport {Player} from \"./Player.js\";\r\nimport {dialogBoxCreate} from \"../utils/DialogBox.js\";\r\nimport {clearEventListeners, getRandomInt} from \"../utils/HelperFunctions.js\";\r\nimport {infiltrationBoxCreate} from \"../utils/InfiltrationBox.js\";\r\nimport {formatNumber} from \"../utils/StringHelperFunctions.js\";\r\n\r\n/* Infiltration.js\r\n *\r\n * Kill\r\n * Knockout (nonlethal)\r\n * Stealth Knockout (nonlethal)\r\n * Assassinate\r\n *\r\n * Hack Security\r\n * Destroy Security\r\n * Sneak past Security\r\n *\r\n * Pick the locked door\r\n *\r\n * Bribe security\r\n *\r\n * Escape\r\n */\r\n\r\nlet InfiltrationScenarios = {\r\n Guards: \"You see an armed security guard patrolling the area.\",\r\n TechOnly: \"The area is equipped with a state-of-the-art security system: cameras, laser tripwires, and sentry turrets.\",\r\n TechOrLockedDoor: \"The area is equipped with a state-of-the-art security system. There is a locked door on the side of the \" +\r\n \"room that can be used to bypass security.\",\r\n Bots: \"You see a few security bots patrolling the area.\",\r\n}\r\n\r\nfunction InfiltrationInstance(companyName, startLevel, val, maxClearance, diff) {\r\n this.companyName = companyName;\r\n this.clearanceLevel = 0;\r\n this.maxClearanceLevel = maxClearance;\r\n this.securityLevel = startLevel;\r\n this.difficulty = diff; //Affects how much security level increases. Represents a percentage\r\n this.baseValue = val; //Base value of company secrets\r\n this.secretsStolen = []; //Numbers representing value of stolen secrets\r\n\r\n this.hackingExpGained = 0;\r\n this.strExpGained = 0;\r\n this.defExpGained = 0;\r\n this.dexExpGained = 0;\r\n this.agiExpGained = 0;\r\n this.chaExpGained = 0;\r\n this.intExpGained = 0;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainHackingExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.hackingExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainStrengthExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.strExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainDefenseExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.defExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainDexterityExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.dexExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainAgilityExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.agiExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainCharismaExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.chaExpGained += amt;\r\n}\r\n\r\nInfiltrationInstance.prototype.gainIntelligenceExp = function(amt) {\r\n if (isNaN(amt)) {return;}\r\n this.intExpGained += amt;\r\n}\r\n\r\nfunction beginInfiltration(companyName, startLevel, val, maxClearance, diff) {\r\n var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff);\r\n clearInfiltrationStatusText();\r\n nextInfiltrationLevel(inst);\r\n}\r\n\r\nfunction endInfiltration(inst, success) {\r\n if (success) {infiltrationBoxCreate(inst);}\r\n\r\n clearEventListeners(\"infiltration-kill\");\r\n clearEventListeners(\"infiltration-knockout\");\r\n clearEventListeners(\"infiltration-stealthknockout\");\r\n clearEventListeners(\"infiltration-assassinate\");\r\n clearEventListeners(\"infiltration-hacksecurity\");\r\n clearEventListeners(\"infiltration-destroysecurity\");\r\n clearEventListeners(\"infiltration-sneak\");\r\n clearEventListeners(\"infiltration-pickdoor\");\r\n clearEventListeners(\"infiltration-bribe\");\r\n clearEventListeners(\"infiltration-escape\");\r\n\r\n Engine.loadWorldContent();\r\n}\r\n\r\nfunction nextInfiltrationLevel(inst) {\r\n ++inst.clearanceLevel;\r\n updateInfiltrationLevelText(inst);\r\n\r\n //Buttons\r\n var killButton = clearEventListeners(\"infiltration-kill\");\r\n var knockoutButton = clearEventListeners(\"infiltration-knockout\");\r\n var stealthKnockoutButton = clearEventListeners(\"infiltration-stealthknockout\");\r\n var assassinateButton = clearEventListeners(\"infiltration-assassinate\");\r\n var hackSecurityButton = clearEventListeners(\"infiltration-hacksecurity\");\r\n var destroySecurityButton = clearEventListeners(\"infiltration-destroysecurity\");\r\n var sneakButton = clearEventListeners(\"infiltration-sneak\");\r\n var pickdoorButton = clearEventListeners(\"infiltration-pickdoor\");\r\n var bribeButton = clearEventListeners(\"infiltration-bribe\");\r\n var escapeButton = clearEventListeners(\"infiltration-escape\");\r\n\r\n killButton.style.display = \"none\";\r\n knockoutButton.style.display = \"none\";\r\n stealthKnockoutButton.style.display = \"none\";\r\n assassinateButton.style.display = \"none\";\r\n hackSecurityButton.style.display = \"none\";\r\n destroySecurityButton.style.display = \"none\";\r\n sneakButton.style.display = \"none\";\r\n pickdoorButton.style.display = \"none\";\r\n bribeButton.style.display = \"none\";\r\n escapeButton.style.display = \"none\";\r\n\r\n var rand = getRandomInt(0, 5); //This needs to change if more scenarios are added\r\n var scenario = null;\r\n switch (rand) {\r\n case 1:\r\n scenario = InfiltrationScenarios.TechOnly;\r\n hackSecurityButton.style.display = \"block\";\r\n destroySecurityButton.style.display = \"block\";\r\n sneakButton.style.display = \"block\";\r\n escapeButton.style.display = \"block\";\r\n break;\r\n case 2:\r\n scenario = InfiltrationScenarios.TechOrLockedDoor;\r\n hackSecurityButton.style.display = \"block\";\r\n destroySecurityButton.style.display = \"block\";\r\n sneakButton.style.display = \"block\";\r\n pickdoorButton.style.display = \"block\";\r\n escapeButton.style.display = \"block\";\r\n break;\r\n case 3:\r\n scenario = InfiltrationScenarios.Bots;\r\n killButton.style.display = \"block\";\r\n killButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationKill(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY killed the security bots! Unfortunately you alerted the \" +\r\n \"rest of the facility's security. The facility's security \" +\r\n \"level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n Player.karma -= 1;\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n var dmgTaken = Math.max(1, Math.round(1.5 * inst.securityLevel / Player.defense));\r\n writeInfiltrationStatusText(\"You FAILED to kill the security bots. The bots fight back \" +\r\n \"and raise the alarm! You take \" + dmgTaken + \" damage and \" +\r\n \"the facility's security level increases by \" +\r\n formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n if (Player.takeDamage(dmgTaken)) {\r\n endInfiltration(inst, false);\r\n }\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n });\r\n assassinateButton.style.display = \"block\";\r\n assassinateButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationAssassinate(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY assassinated the security bots without being detected!\");\r\n Player.karma -= 1;\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to assassinate the security bots. The bots have not detected \" +\r\n \"you but are now more alert for an intruder. The facility's security level \" +\r\n \"has increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n });\r\n hackSecurityButton.style.display = \"block\";\r\n sneakButton.style.display = \"block\";\r\n escapeButton.style.display = \"block\";\r\n break;\r\n default: //0, 4-5\r\n scenario = InfiltrationScenarios.Guards;\r\n killButton.style.display = \"block\";\r\n killButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationKill(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY killed the security guard! Unfortunately you alerted the \" +\r\n \"rest of the facility's security. The facility's security \" +\r\n \"level has increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n Player.karma -= 3;\r\n ++Player.numPeopleKilled;\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));\r\n writeInfiltrationStatusText(\"You FAILED to kill the security guard. The guard fights back \" +\r\n \"and raises the alarm! You take \" + dmgTaken + \" damage and \" +\r\n \"the facility's security level has increased by \" +\r\n formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n if (Player.takeDamage(dmgTaken)) {\r\n endInfiltration(inst, false);\r\n }\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n });\r\n knockoutButton.style.display = \"block\";\r\n stealthKnockoutButton.style.display = \"block\";\r\n assassinateButton.style.display = \"block\";\r\n assassinateButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationAssassinate(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY assassinated the security guard without being detected!\");\r\n Player.karma -= 3;\r\n ++Player.numPeopleKilled;\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to assassinate the security guard. The guard has not detected \" +\r\n \"you but is now more alert for an intruder. The facility's security level \" +\r\n \"has increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n });\r\n sneakButton.style.display = \"block\";\r\n bribeButton.style.display = \"block\";\r\n escapeButton.style.display = \"block\";\r\n break;\r\n }\r\n\r\n knockoutButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationKnockout(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY knocked out the security guard! \" +\r\n \"Unfortunately you made a lot of noise and alerted other security.\");\r\n writeInfiltrationStatusText(\"The facility's security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));\r\n writeInfiltrationStatusText(\"You FAILED to knockout the security guard. The guard \" +\r\n \"raises the alarm and fights back! You take \" + dmgTaken + \" damage and \" +\r\n \"the facility's security level increases by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n if (Player.takeDamage(dmgTaken)) {\r\n endInfiltration(inst, false);\r\n }\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n stealthKnockoutButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationStealthKnockout(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY knocked out the security guard without making \" +\r\n \"any noise!\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n var dmgTaken = Math.max(1, Math.round(inst.securityLevel / Player.defense));\r\n writeInfiltrationStatusText(\"You FAILED to stealthily knockout the security guard. The guard \" +\r\n \"raises the alarm and fights back! You take \" + dmgTaken + \" damage and \" +\r\n \"the facility's security level increases by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n if (Player.takeDamage(dmgTaken)) {\r\n endInfiltration(inst, false);\r\n }\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n hackSecurityButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationHack(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY hacked and disabled the security system!\");\r\n writeInfiltrationStatusText(\"The facility's security level increased by \" + ((res[1]*100) - 100).toString() + \"%\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to hack the security system. The facility's \" +\r\n \"security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n destroySecurityButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationDestroySecurity(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY and violently destroy the security system!\");\r\n writeInfiltrationStatusText(\"The facility's security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to destroy the security system. The facility's \" +\r\n \"security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n sneakButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationSneak(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY sneak past the security undetected!\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED and were detected while trying to sneak past security! The facility's \" +\r\n \"security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n pickdoorButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationPickLockedDoor(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY pick the locked door!\");\r\n writeInfiltrationStatusText(\"The facility's security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to pick the locked door. The facility's security level \" +\r\n \"increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n bribeButton.addEventListener(\"click\", function() {\r\n var bribeAmt = CONSTANTS.InfiltrationBribeBaseAmount * inst.clearanceLevel;\r\n if (Player.money.lt(bribeAmt)) {\r\n writeInfiltrationStatusText(\"You do not have enough money to bribe the guard. \" +\r\n \"You need $\" + bribeAmt);\r\n return false;\r\n }\r\n var res = attemptInfiltrationBribe(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY bribed a guard to let you through \" +\r\n \"to the next clearance level for $\" + bribeAmt);\r\n Player.loseMoney(bribeAmt);\r\n endInfiltrationLevel(inst);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to bribe a guard! The guard is alerting \" +\r\n \"other security guards about your presence! The facility's \" +\r\n \"security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n escapeButton.addEventListener(\"click\", function() {\r\n var res = attemptInfiltrationEscape(inst);\r\n if (res[0]) {\r\n writeInfiltrationStatusText(\"You SUCCESSFULLY escape from the facility with the stolen classified \" +\r\n \"documents and company secrets!\");\r\n endInfiltration(inst, true);\r\n return false;\r\n } else {\r\n writeInfiltrationStatusText(\"You FAILED to escape from the facility. You took 1 damage. The facility's \" +\r\n \"security level increased by \" + formatNumber((res[1]*100)-100, 2).toString() + \"%\");\r\n if (Player.takeDamage(1)) {\r\n endInfiltration(inst, false);\r\n }\r\n }\r\n updateInfiltrationButtons(inst, scenario);\r\n updateInfiltrationLevelText(inst);\r\n return false;\r\n });\r\n\r\n updateInfiltrationButtons(inst, scenario);\r\n writeInfiltrationStatusText(\"\");\r\n writeInfiltrationStatusText(\"You are now on clearance level \" + inst.clearanceLevel + \".
\" +\r\n scenario);\r\n}\r\n\r\n\r\nfunction endInfiltrationLevel(inst) {\r\n //Check if you gained any secrets\r\n if (inst.clearanceLevel % 5 == 0) {\r\n var baseSecretValue = inst.baseValue * inst.clearanceLevel / 2;\r\n var secretValue = baseSecretValue * Player.faction_rep_mult *\r\n CONSTANTS.InfiltrationRepValue * BitNodeMultipliers.InfiltrationRep;\r\n var secretMoneyValue = baseSecretValue * CONSTANTS.InfiltrationMoneyValue *\r\n BitNodeMultipliers.InfiltrationMoney;\r\n inst.secretsStolen.push(baseSecretValue);\r\n dialogBoxCreate(\"You found and stole a set of classified documents from the company. \" +\r\n \"These classified secrets could probably be sold for money ($\" +\r\n formatNumber(secretMoneyValue, 2) + \"), or they \" +\r\n \"could be given to factions for reputation (\" + formatNumber(secretValue, 3) + \" rep)\");\r\n }\r\n\r\n //Increase security level based on difficulty\r\n inst.securityLevel *= (1 + (inst.difficulty / 100));\r\n writeInfiltrationStatusText(\"You move on to the facility's next clearance level. This \" +\r\n \"clearance level has \" + inst.difficulty + \"% higher security\");\r\n\r\n //If this is max level, force endInfiltration\r\n if (inst.clearanceLevel >= inst.maxClearanceLevel) {\r\n endInfiltration(inst, true);\r\n } else {\r\n nextInfiltrationLevel(inst);\r\n }\r\n}\r\n\r\nfunction writeInfiltrationStatusText(txt) {\r\n var statusTxt = document.getElementById(\"infiltration-status-text\");\r\n statusTxt.innerHTML += (txt + \"
\");\r\n statusTxt.parentElement.scrollTop = statusTxt.scrollHeight;\r\n}\r\n\r\nfunction clearInfiltrationStatusText() {\r\n document.getElementById(\"infiltration-status-text\").innerHTML = \"\";\r\n}\r\n\r\nfunction updateInfiltrationLevelText(inst) {\r\n var totalValue = 0;\r\n var totalMoneyValue = 0;\r\n for (var i = 0; i < inst.secretsStolen.length; ++i) {\r\n totalValue += (inst.secretsStolen[i] * Player.faction_rep_mult *\r\n CONSTANTS.InfiltrationRepValue * BitNodeMultipliers.InfiltrationRep);\r\n totalMoneyValue += inst.secretsStolen[i] * CONSTANTS.InfiltrationMoneyValue *\r\n BitNodeMultipliers.InfiltrationMoney;\r\n }\r\n\r\n var expMultiplier = 2 * inst.clearanceLevel / inst.maxClearanceLevel;\r\n document.getElementById(\"infiltration-level-text\").innerHTML =\r\n \"Facility name: \" + inst.companyName + \"
\" +\r\n \"Clearance Level: \" + inst.clearanceLevel + \"
\" +\r\n \"Security Level: \" + formatNumber(inst.securityLevel, 3) + \"
\" +\r\n \"Total reputation value of secrets stolen: \" + formatNumber(totalValue, 3) + \"
\" +\r\n \"Total monetary value of secrets stolen: $\" + formatNumber(totalMoneyValue, 2) + \"
\" +\r\n \"Hack exp gained: \" + formatNumber(inst.hackingExpGained * expMultiplier, 3) + \"
\" +\r\n \"Str exp gained: \" + formatNumber(inst.strExpGained * expMultiplier, 3) + \"
\" +\r\n \"Def exp gained: \" + formatNumber(inst.defExpGained * expMultiplier, 3) + \"
\" +\r\n \"Dex exp gained: \" + formatNumber(inst.dexExpGained * expMultiplier, 3) + \"
\" +\r\n \"Agi exp gained: \" + formatNumber(inst.agiExpGained * expMultiplier, 3) + \"
\" +\r\n \"Cha exp gained: \" + formatNumber(inst.chaExpGained * expMultiplier, 3);\r\n}\r\n\r\nfunction updateInfiltrationButtons(inst, scenario) {\r\n var killChance = getInfiltrationKillChance(inst);\r\n var knockoutChance = getInfiltrationKnockoutChance(inst);\r\n var stealthKnockoutChance = getInfiltrationStealthKnockoutChance(inst);\r\n var assassinateChance = getInfiltrationAssassinateChance(inst);\r\n var destroySecurityChance = getInfiltrationDestroySecurityChance(inst);\r\n var hackChance = getInfiltrationHackChance(inst);\r\n var sneakChance = getInfiltrationSneakChance(inst);\r\n var lockpickChance = getInfiltrationPickLockedDoorChance(inst);\r\n var bribeChance = getInfiltrationBribeChance(inst);\r\n var escapeChance = getInfiltrationEscapeChance(inst);\r\n\r\n document.getElementById(\"infiltration-escape\").innerHTML = \"Escape\" +\r\n \"\" +\r\n \"Attempt to escape the facility with the classified secrets and \" +\r\n \"documents you have stolen. You have a \" +\r\n formatNumber(escapeChance*100, 2) + \"% chance of success. If you fail, \" +\r\n \"the security level will increase by 5%.\";\r\n\r\n switch(scenario) {\r\n case InfiltrationScenarios.TechOrLockedDoor:\r\n document.getElementById(\"infiltration-pickdoor\").innerHTML = \"Lockpick\" +\r\n \"\" +\r\n \"Attempt to pick the locked door. You have a \" +\r\n formatNumber(lockpickChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increased by 1%. If you fail, the \" +\r\n \"security level will increase by 3%.\";\r\n case InfiltrationScenarios.TechOnly:\r\n document.getElementById(\"infiltration-hacksecurity\").innerHTML = \"Hack\" +\r\n \"\" +\r\n \"Attempt to hack and disable the security system. You have a \" +\r\n formatNumber(hackChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 3%. If you fail, \" +\r\n \"the security level will increase by 5%.\";\r\n\r\n document.getElementById(\"infiltration-destroysecurity\").innerHTML = \"Destroy security\" +\r\n \"\" +\r\n \"Attempt to violently destroy the security system. You have a \" +\r\n formatNumber(destroySecurityChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 5%. If you fail, the \" +\r\n \"security level will increase by 10%. \";\r\n\r\n document.getElementById(\"infiltration-sneak\").innerHTML = \"Sneak\" +\r\n \"\" +\r\n \"Attempt to sneak past the security system. You have a \" +\r\n formatNumber(sneakChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 8%. \";\r\n break;\r\n case InfiltrationScenarios.Bots:\r\n document.getElementById(\"infiltration-kill\").innerHTML = \"Destroy bots\" +\r\n \"\" +\r\n \"Attempt to destroy the security bots through combat. You have a \" +\r\n formatNumber(killChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 5%. If you fail, \" +\r\n \"the security level will increase by 10%. \";\r\n\r\n document.getElementById(\"infiltration-assassinate\").innerHTML = \"Assassinate bots\" +\r\n \"\" +\r\n \"Attempt to stealthily destroy the security bots through assassination. You have a \" +\r\n formatNumber(assassinateChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 10%. \";\r\n\r\n document.getElementById(\"infiltration-hacksecurity\").innerHTML = \"Hack bots\" +\r\n \"\" +\r\n \"Attempt to disable the security bots by hacking them. You have a \" +\r\n formatNumber(hackChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 3%. If you fail, \" +\r\n \"the security level will increase by 5%. \";\r\n\r\n document.getElementById(\"infiltration-sneak\").innerHTML = \"Sneak\" +\r\n \"\" +\r\n \"Attempt to sneak past the security bots. You have a \" +\r\n formatNumber(sneakChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 8%. \";\r\n break;\r\n\r\n case InfiltrationScenarios.Guards:\r\n default:\r\n document.getElementById(\"infiltration-kill\").innerHTML = \"Kill\" +\r\n \"\" +\r\n \"Attempt to kill the security guard. You have a \" +\r\n formatNumber(killChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 5%. If you fail, \" +\r\n \"the security level will decrease by 10%. \";\r\n\r\n document.getElementById(\"infiltration-knockout\").innerHTML = \"Knockout\" +\r\n \"\" +\r\n \"Attempt to knockout the security guard. You have a \" +\r\n formatNumber(knockoutChance*100, 2) + \"% chance of success. \" +\r\n \"If you succeed, the security level will increase by 3%. If you fail, the \" +\r\n \"security level will increase by 10%. \";\r\n\r\n document.getElementById(\"infiltration-stealthknockout\").innerHTML = \"Stealth Knockout\" +\r\n \"\" +\r\n \"Attempt to stealthily knockout the security guard. You have a \" +\r\n formatNumber(stealthKnockoutChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 10%. \";\r\n\r\n document.getElementById(\"infiltration-assassinate\").innerHTML = \"Assassinate\" +\r\n \"\" +\r\n \"Attempt to assassinate the security guard. You have a \" +\r\n formatNumber(assassinateChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 5%. \";\r\n\r\n document.getElementById(\"infiltration-sneak\").innerHTML = \"Sneak\" +\r\n \"\" +\r\n \"Attempt to sneak past the security guard. You have a \" +\r\n formatNumber(sneakChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 8%. \";\r\n\r\n document.getElementById(\"infiltration-bribe\").innerHTML = \"Bribe\" +\r\n \"\" +\r\n \"Attempt to bribe the security guard. You have a \" +\r\n formatNumber(bribeChance*100, 2) + \"% chance of success. \" +\r\n \"If you fail, the security level will increase by 15%. \";\r\n break;\r\n }\r\n}\r\n\r\nlet intWgt = CONSTANTS.IntelligenceInfiltrationWeight;\r\n\r\n//Kill\r\n//Success: 5%, Failure 10%, -Karma\r\nfunction attemptInfiltrationKill(inst) {\r\n var chance = getInfiltrationKillChance(inst);\r\n inst.gainStrengthExp(inst.securityLevel / 85) * Player.strength_exp_mult;\r\n inst.gainDefenseExp(inst.securityLevel / 85) * Player.defense_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 85) * Player.dexterity_exp_mult;\r\n inst.gainAgilityExp(inst.securityLevel / 85) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n inst.securityLevel *= 1.05;\r\n return [true, 1.05];\r\n } else {\r\n inst.securityLevel *= 1.1;\r\n return [false, 1.1];\r\n }\r\n}\r\n\r\nfunction getInfiltrationKillChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.strength +\r\n Player.dexterity +\r\n Player.agility) / (1.45 * lvl));\r\n}\r\n\r\n\r\n//Knockout\r\n//Success: 3%, Failure: 10%\r\nfunction attemptInfiltrationKnockout(inst) {\r\n var chance = getInfiltrationKnockoutChance(inst);\r\n inst.gainStrengthExp(inst.securityLevel / 80) * Player.strength_exp_mult;\r\n inst.gainDefenseExp(inst.securityLevel / 80) * Player.defense_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 80) * Player.dexterity_exp_mult;\r\n inst.gainAgilityExp(inst.securityLevel / 80) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n inst.securityLevel *= 1.03;\r\n return [true, 1.03];\r\n } else {\r\n inst.securityLevel *= 1.1;\r\n return [false, 1.1];\r\n }\r\n}\r\n\r\nfunction getInfiltrationKnockoutChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.strength +\r\n Player.dexterity +\r\n Player.agility) / (1.7 * lvl));\r\n}\r\n\r\n//Stealth knockout\r\n//Success: 0%, Failure: 10%\r\nfunction attemptInfiltrationStealthKnockout(inst) {\r\n var chance = getInfiltrationStealthKnockoutChance(inst);\r\n inst.gainStrengthExp(inst.securityLevel / 85) * Player.strength_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 65) * Player.dexterity_exp_mult;\r\n inst.gainAgilityExp(inst.securityLevel / 65) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n return [true, 1];\r\n } else {\r\n inst.securityLevel *= 1.1;\r\n return [false, 1.1];\r\n }\r\n}\r\n\r\nfunction getInfiltrationStealthKnockoutChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (0.55 * Player.strength +\r\n 2 * Player.dexterity +\r\n 2 * Player.agility +\r\n intWgt * Player.intelligence) / (3 * lvl));\r\n}\r\n\r\n//Assassination\r\n//Success: 0%, Failure: 5%, -Karma\r\nfunction attemptInfiltrationAssassinate(inst) {\r\n var chance = getInfiltrationAssassinateChance(inst);\r\n inst.gainStrengthExp(inst.securityLevel / 85) * Player.strength_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 65) * Player.dexterity_exp_mult;\r\n inst.gainAgilityExp(inst.securityLevel / 65) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n return [true, 1];\r\n } else {\r\n inst.securityLevel *= 1.05;\r\n return [false, 1.05];\r\n }\r\n}\r\n\r\nfunction getInfiltrationAssassinateChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.dexterity +\r\n 0.5 * Player.agility +\r\n intWgt * Player.intelligence) / (2 * lvl));\r\n}\r\n\r\n\r\n//Destroy security\r\n//Success: 5%, Failure: 10%\r\nfunction attemptInfiltrationDestroySecurity(inst) {\r\n var chance = getInfiltrationDestroySecurityChance(inst);\r\n inst.gainStrengthExp(inst.securityLevel / 85) * Player.strength_exp_mult;\r\n inst.gainDefenseExp(inst.securityLevel / 85) * Player.defense_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 85) * Player.dexterity_exp_mult;\r\n inst.gainAgilityExp(inst.securityLevel / 85) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n inst.securityLevel *= 1.05;\r\n return [true, 1.05];\r\n } else {\r\n inst.securityLevel *= 1.1;\r\n return [false, 1.1];\r\n }\r\n\r\n}\r\n\r\nfunction getInfiltrationDestroySecurityChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.strength +\r\n Player.dexterity +\r\n Player.agility) / (2 * lvl));\r\n}\r\n\r\n\r\n//Hack security\r\n//Success: 3%, Failure: 5%\r\nfunction attemptInfiltrationHack(inst) {\r\n var chance = getInfiltrationHackChance(inst);\r\n inst.gainHackingExp(inst.securityLevel / 40) * Player.hacking_exp_mult;\r\n inst.gainIntelligenceExp(inst.securityLevel / 690);\r\n if (Math.random() <= chance) {\r\n inst.securityLevel *= 1.03;\r\n return [true, 1.03];\r\n } else {\r\n inst.securityLevel *= 1.05;\r\n return [false, 1.05];\r\n }\r\n\r\n}\r\n\r\nfunction getInfiltrationHackChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.hacking_skill +\r\n (intWgt * Player.intelligence)) / lvl);\r\n}\r\n\r\n//Sneak past security\r\n//Success: 0%, Failure: 8%\r\nfunction attemptInfiltrationSneak(inst) {\r\n var chance = getInfiltrationSneakChance(inst);\r\n inst.gainAgilityExp(inst.securityLevel / 40) * Player.agility_exp_mult;\r\n if (Math.random() <= chance) {\r\n return [true, 1];\r\n } else {\r\n inst.securityLevel *= 1.08;\r\n return [false, 1.08];\r\n }\r\n}\r\n\r\nfunction getInfiltrationSneakChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.agility +\r\n 0.5 * Player.dexterity +\r\n intWgt * Player.intelligence) / (2 * lvl));\r\n}\r\n\r\n//Pick locked door\r\n//Success: 1%, Failure: 3%\r\nfunction attemptInfiltrationPickLockedDoor(inst) {\r\n var chance = getInfiltrationPickLockedDoorChance(inst);\r\n inst.gainDexterityExp(inst.securityLevel / 30) * Player.dexterity_exp_mult;\r\n if (Math.random() <= chance) {\r\n inst.securityLevel *= 1.01;\r\n return [true, 1.01];\r\n } else {\r\n inst.securityLevel *= 1.03;\r\n return [false, 1.03];\r\n }\r\n}\r\n\r\nfunction getInfiltrationPickLockedDoorChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.dexterity +\r\n intWgt * Player.intelligence) / lvl);\r\n}\r\n\r\n//Bribe\r\n//Success: 0%, Failure: 15%,\r\nfunction attemptInfiltrationBribe(inst) {\r\n var chance = getInfiltrationBribeChance(inst);\r\n inst.gainCharismaExp(inst.securityLevel / 10) * Player.charisma_exp_mult;\r\n if (Math.random() <= chance) {\r\n return [true, 1];\r\n } else {\r\n inst.securityLevel *= 1.15;\r\n return [false, 1.15];\r\n }\r\n}\r\n\r\nfunction getInfiltrationBribeChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (Player.charisma) / lvl);\r\n}\r\n\r\n//Escape\r\n//Failure: 5%\r\nfunction attemptInfiltrationEscape(inst) {\r\n var chance = getInfiltrationEscapeChance(inst);\r\n inst.gainAgilityExp(inst.securityLevel / 35) * Player.agility_exp_mult;\r\n inst.gainDexterityExp(inst.securityLevel / 35) * Player.dexterity_exp_mult;\r\n if (Math.random() <= chance) {\r\n return [true, 1];\r\n } else {\r\n inst.securityLevel *= 1.05;\r\n return [false, 1.05];\r\n }\r\n}\r\n\r\nfunction getInfiltrationEscapeChance(inst) {\r\n var lvl = inst.securityLevel;\r\n return Math.min(0.95,\r\n (2 * Player.agility +\r\n Player.dexterity +\r\n intWgt * Player.intelligence) / lvl);\r\n}\r\n\r\nexport {beginInfiltration};\r\n","/* FileSaver.js\n * A saveAs() FileSaver implementation.\n * 1.3.2\n * 2016-06-16 18:25:19\n *\n * By Eli Grey, http://eligrey.com\n * License: MIT\n * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md\n */\n\n/*global self */\n/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */\n\n/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */\n\nvar saveAs = saveAs || (function(view) {\n\t\"use strict\";\n\t// IE <10 is explicitly unsupported\n\tif (typeof view === \"undefined\" || typeof navigator !== \"undefined\" && /MSIE [1-9]\\./.test(navigator.userAgent)) {\n\t\treturn;\n\t}\n\tvar\n\t\t doc = view.document\n\t\t // only get URL when necessary in case Blob.js hasn't overridden it yet\n\t\t, get_URL = function() {\n\t\t\treturn view.URL || view.webkitURL || view;\n\t\t}\n\t\t, save_link = doc.createElementNS(\"http://www.w3.org/1999/xhtml\", \"a\")\n\t\t, can_use_save_link = \"download\" in save_link\n\t\t, click = function(node) {\n\t\t\tvar event = new MouseEvent(\"click\");\n\t\t\tnode.dispatchEvent(event);\n\t\t}\n\t\t, is_safari = /constructor/i.test(view.HTMLElement) || view.safari\n\t\t, is_chrome_ios =/CriOS\\/[\\d]+/.test(navigator.userAgent)\n\t\t, throw_outside = function(ex) {\n\t\t\t(view.setImmediate || view.setTimeout)(function() {\n\t\t\t\tthrow ex;\n\t\t\t}, 0);\n\t\t}\n\t\t, force_saveable_type = \"application/octet-stream\"\n\t\t// the Blob API is fundamentally broken as there is no \"downloadfinished\" event to subscribe to\n\t\t, arbitrary_revoke_timeout = 1000 * 40 // in ms\n\t\t, revoke = function(file) {\n\t\t\tvar revoker = function() {\n\t\t\t\tif (typeof file === \"string\") { // file is an object URL\n\t\t\t\t\tget_URL().revokeObjectURL(file);\n\t\t\t\t} else { // file is a File\n\t\t\t\t\tfile.remove();\n\t\t\t\t}\n\t\t\t};\n\t\t\tsetTimeout(revoker, arbitrary_revoke_timeout);\n\t\t}\n\t\t, dispatch = function(filesaver, event_types, event) {\n\t\t\tevent_types = [].concat(event_types);\n\t\t\tvar i = event_types.length;\n\t\t\twhile (i--) {\n\t\t\t\tvar listener = filesaver[\"on\" + event_types[i]];\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlistener.call(filesaver, event || filesaver);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tthrow_outside(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t, auto_bom = function(blob) {\n\t\t\t// prepend BOM for UTF-8 XML and text/* types (including HTML)\n\t\t\t// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF\n\t\t\tif (/^\\s*(?:text\\/\\S*|application\\/xml|\\S*\\/\\S*\\+xml)\\s*;.*charset\\s*=\\s*utf-8/i.test(blob.type)) {\n\t\t\t\treturn new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});\n\t\t\t}\n\t\t\treturn blob;\n\t\t}\n\t\t, FileSaver = function(blob, name, no_auto_bom) {\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\t// First try a.download, then web filesystem, then object URLs\n\t\t\tvar\n\t\t\t\t filesaver = this\n\t\t\t\t, type = blob.type\n\t\t\t\t, force = type === force_saveable_type\n\t\t\t\t, object_url\n\t\t\t\t, dispatch_all = function() {\n\t\t\t\t\tdispatch(filesaver, \"writestart progress write writeend\".split(\" \"));\n\t\t\t\t}\n\t\t\t\t// on any filesys errors revert to saving with object URLs\n\t\t\t\t, fs_error = function() {\n\t\t\t\t\tif ((is_chrome_ios || (force && is_safari)) && view.FileReader) {\n\t\t\t\t\t\t// Safari doesn't allow downloading of blob urls\n\t\t\t\t\t\tvar reader = new FileReader();\n\t\t\t\t\t\treader.onloadend = function() {\n\t\t\t\t\t\t\tvar url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');\n\t\t\t\t\t\t\tvar popup = view.open(url, '_blank');\n\t\t\t\t\t\t\tif(!popup) view.location.href = url;\n\t\t\t\t\t\t\turl=undefined; // release reference before dispatching\n\t\t\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\t\t\tdispatch_all();\n\t\t\t\t\t\t};\n\t\t\t\t\t\treader.readAsDataURL(blob);\n\t\t\t\t\t\tfilesaver.readyState = filesaver.INIT;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\t// don't create more object URLs than needed\n\t\t\t\t\tif (!object_url) {\n\t\t\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\t\t}\n\t\t\t\t\tif (force) {\n\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar opened = view.open(object_url, \"_blank\");\n\t\t\t\t\t\tif (!opened) {\n\t\t\t\t\t\t\t// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html\n\t\t\t\t\t\t\tview.location.href = object_url;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t}\n\t\t\t;\n\t\t\tfilesaver.readyState = filesaver.INIT;\n\n\t\t\tif (can_use_save_link) {\n\t\t\t\tobject_url = get_URL().createObjectURL(blob);\n\t\t\t\tsetTimeout(function() {\n\t\t\t\t\tsave_link.href = object_url;\n\t\t\t\t\tsave_link.download = name;\n\t\t\t\t\tclick(save_link);\n\t\t\t\t\tdispatch_all();\n\t\t\t\t\trevoke(object_url);\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfs_error();\n\t\t}\n\t\t, FS_proto = FileSaver.prototype\n\t\t, saveAs = function(blob, name, no_auto_bom) {\n\t\t\treturn new FileSaver(blob, name || blob.name || \"download\", no_auto_bom);\n\t\t}\n\t;\n\t// IE 10+ (native saveAs)\n\tif (typeof navigator !== \"undefined\" && navigator.msSaveOrOpenBlob) {\n\t\treturn function(blob, name, no_auto_bom) {\n\t\t\tname = name || blob.name || \"download\";\n\n\t\t\tif (!no_auto_bom) {\n\t\t\t\tblob = auto_bom(blob);\n\t\t\t}\n\t\t\treturn navigator.msSaveOrOpenBlob(blob, name);\n\t\t};\n\t}\n\n\tFS_proto.abort = function(){};\n\tFS_proto.readyState = FS_proto.INIT = 0;\n\tFS_proto.WRITING = 1;\n\tFS_proto.DONE = 2;\n\n\tFS_proto.error =\n\tFS_proto.onwritestart =\n\tFS_proto.onprogress =\n\tFS_proto.onwrite =\n\tFS_proto.onabort =\n\tFS_proto.onerror =\n\tFS_proto.onwriteend =\n\t\tnull;\n\n\treturn saveAs;\n}(\n\t typeof self !== \"undefined\" && self\n\t|| typeof window !== \"undefined\" && window\n\t|| this.content\n));\n// `self` is undefined in Firefox for Android content script context\n// while `this` is nsIContentFrameMessageManager\n// with an attribute `content` that corresponds to the window\n\nif (typeof module !== \"undefined\" && module.exports) {\n module.exports.saveAs = saveAs;\n} else if ((typeof define !== \"undefined\" && define !== null) && (define.amd !== null)) {\n define(\"FileSaver.js\", function() {\n return saveAs;\n });\n}\n","'use strict';\n\n/**\n * Representation a of zip file in js\n * @constructor\n */\nfunction JSZip() {\n // if this constructor is used without `new`, it adds `new` before itself:\n if(!(this instanceof JSZip)) {\n return new JSZip();\n }\n\n if(arguments.length) {\n throw new Error(\"The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.\");\n }\n\n // object containing the files :\n // {\n // \"folder/\" : {...},\n // \"folder/data.txt\" : {...}\n // }\n this.files = {};\n\n this.comment = null;\n\n // Where we are in the hierarchy\n this.root = \"\";\n this.clone = function() {\n var newObj = new JSZip();\n for (var i in this) {\n if (typeof this[i] !== \"function\") {\n newObj[i] = this[i];\n }\n }\n return newObj;\n };\n}\nJSZip.prototype = require('./object');\nJSZip.prototype.loadAsync = require('./load');\nJSZip.support = require('./support');\nJSZip.defaults = require('./defaults');\n\n// TODO find a better way to handle this version,\n// a require('package.json').version doesn't work with webpack, see #327\nJSZip.version = \"3.1.5\";\n\nJSZip.loadAsync = function (content, options) {\n return new JSZip().loadAsync(content, options);\n};\n\nJSZip.external = require(\"./external\");\nmodule.exports = JSZip;\n","var config = require('../config');\nvar flag = require('./flag');\nvar getProperties = require('./getProperties');\nvar isProxyEnabled = require('./isProxyEnabled');\n\n/*!\n * Chai - proxify utility\n * Copyright(c) 2012-2014 Jake Luer