0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g 0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g
" +
+ "This is the first BitNode that you play through. It has no special " +
+ "modifications or mechanics.
" +
+ "Destroying this BitNode will give you Source-File 1, or if you already have " +
+ "this Source-File it will upgrade its level up to a maximum of 3. This Source-File " +
+ "lets the player start with 32GB of RAM on his/her home computer when entering a " +
+ "new BitNode, and also increases all of the player's multipliers by:
" +
+ "Level 1: 16%
" +
+ "Level 2: 24%
" +
+ "Level 3: 28%");
+ BitNodes["BitNode2"] = new BitNode(2, "Rise of the Underworld", "From the shadows, they rose", //Gangs
+ "From the shadows, they rose.
Organized crime groups quickly filled the void of power " +
+ "left behind from the collapse of Western government in the 2050's. As society and civlization broke down, " +
+ "people quickly succumbed to the innate human impulse of evil and savagery. The organized crime " +
+ "factions quickly rose to the top of the modern world.
" +
+ "In this BitNode:
The maximum amount of money available on a server is significantly decreased
" +
+ "The amount of money gained from crimes and Infiltration is tripled
" +
+ "Certain Factions (Slum Snakes, Tetrads, The Syndicate, The Dark Army, Speakers for the Dead, " +
+ "NiteSec, The Black Hand) give the player the ability to form and manage their own gangs. These gangs " +
+ "will earn the player money and reputation with the corresponding Faction
" +
+ "Every Augmentation in the game will be available through the Factions listed above
" +
+ "For every Faction NOT listed above, reputation gains are halved
" +
+ "You will no longer gain passive reputation with Factions
" +
+ "Destroying this BitNode will give you Source-File 2, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File increases the player's crime success rate, " +
+ "crime money, and charisma multipliers by:
" +
+ "Level 1: 20%
" +
+ "Level 2: 30%
" +
+ "Level 3: 35%");
+ BitNodes["BitNode3"] = new BitNode(3, "Corporatocracy", "The Price of Civilization",
+ "Our greatest illusion is that a healthy society can revolve around a " +
+ "single-minded pursuit of wealth.
" +
+ "Sometime in the early 21st century economic and political globalization turned " +
+ "the world into a corporatocracy, and it never looked back. Now, the privileged " +
+ "elite will happily bankrupt their own countrymen, decimate their own community, " +
+ "and evict their neighbors from houses in their desperate bid to increase their wealth.
" +
+ "In this BitNode you can create and manage your own corporation. Running a successful corporation " +
+ "has the potential of generating massive profits. All other forms of income are reduced by 75%. Furthermore:
" +
+ "The price and reputation cost of all Augmentations is tripled
" +
+ "The starting and maximum amount of money on servers is reduced by 75%
" +
+ "Server growth rate is reduced by 80%
" +
+ "You will start out with $150b so that you can start your corporation
" +
+ "You now only need 75 reputation with a faction in order to donate to it, rather than 150
" +
+ "Destroying this BitNode will give you Source-File 3, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File lets you create corporations on other BitNodes (although " +
+ "some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by:
" +
+ "Level 1: 8%
" +
+ "Level 2: 12%
" +
+ "Level 3: 14%");
+ BitNodes["BitNode4"] = new BitNode(4, "The Singularity", "The Man and the Machine", "The Singularity has arrived. The human race is gone, replaced " +
+ "by artificially superintelligent beings that are more machine than man.
" +
+ "In this BitNode, progressing is significantly harder. Experience gain rates " +
+ "for all stats are reduced. Most methods of earning money will now give significantly less.
" +
+ "In this BitNode you will gain access to a new set of Netscript Functions known as Singularity Functions. " +
+ "These functions allow you to control most aspects of the game through scripts, including working for factions/companies, " +
+ "purchasing/installing Augmentations, and creating programs.
" +
+ "Destroying this BitNode will give you Source-File 4, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File lets you access and use the Singularity " +
+ "Functions in other BitNodes. Each level of this Source-File will open up more Singularity Functions " +
+ "that you can use.");
+ BitNodes["BitNode5"] = new BitNode(5, "Artificial Intelligence", "Posthuman", "They said it couldn't be done. They said the human brain, " +
+ "along with its consciousness and intelligence, couldn't be replicated. They said the complexity " +
+ "of the brain results from unpredictable, nonlinear interactions that couldn't be modeled " +
+ "by 1's and 0's. They were wrong.
" +
+ "In this BitNode:
" +
+ "The base security level of servers is doubled
" +
+ "The starting money on servers is halved, but the maximum money remains the same
" +
+ "Most methods of earning money now give significantly less
" +
+ "Infiltration gives 50% more reputation and money
" +
+ "Corporations have 50% lower valuations and are therefore less profitable
" +
+ "Augmentations are more expensive
" +
+ "Hacking experience gain rates are reduced
" +
+ "Destroying this BitNode will give you Source-File 5, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File grants you a special new stat called Intelligence. " +
+ "Intelligence is unique because it is permanent and persistent (it never gets reset back to 1). However " +
+ "gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't know " +
+ "when you gain experience and how much). Higher Intelligence levels will boost your production for many actions " +
+ "in the game.
" +
+ "In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function, " +
+ "and will also raise all of your hacking-related multipliers by:
" +
+ "Level 1: 4%
" +
+ "Level 2: 6%
" +
+ "Level 3: 7%");
+ BitNodes["BitNode6"] = new BitNode(6, "Bladeburners", "Like Tears in Rain",
+ "In the middle of the 21st century, OmniTek Incorporated began designing and manufacturing advanced synthetic " +
+ "androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth generation " +
+ "of their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was " +
+ "the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more intelligent " +
+ "than the humans that had created them.
" +
+ "In this BitNode you will be able to access the Bladeburner Division at the NSA, which provides a new mechanic " +
+ "for progression. Furthermore:
" +
+ "Hacking and Hacknet Nodes will be significantly less profitable
" +
+ "Your hacking level is reduced by 50%
" +
+ "Hacking experience gain from scripts is reduced by 75%
" +
+ "Corporations have 80% lower valuations and are therefore less profitable
" +
+ "Working for companies is 50% less profitable
" +
+ "Crimes and Infiltration are 50% less profitable
" +
+ "Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " +
+ "its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other " +
+ "BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:
" +
+ "Level 1: 8%
" +
+ "Level 2: 12%
" +
+ "Level 3: 14%");
+ BitNodes["BitNode7"] = new BitNode(7, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic
+ BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps",
+ "You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.
" +
+ "In this BitNode:
" +
+ "You start with $100 million
" +
+ "The only way to earn money is by trading on the stock market
" +
+ "You start with a WSE membership and access to the TIX API
" +
+ "You are able to short stocks and place different types of orders (limit/stop)
" +
+ "You can immediately donate to factions to gain reputation
" +
+ "Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:
" +
+ "Level 1: Permanent access to WSE and TIX API
" +
+ "Level 2: Ability to short stocks in other BitNodes
" +
+ "Level 3: Ability to use limit/stop orders in other BitNodes
" +
+ "This Source-File also increases your hacking growth multipliers by: " +
+ "
Level 1: 8%
Level 2: 12%
Level 3: 14%");
+ BitNodes["BitNode9"] = new BitNode(9, "Do Androids Dream?", "COMING SOON");
+ BitNodes["BitNode10"] = new BitNode(10, "MegaCorp", "COMING SOON"); //Not sure yet
+ BitNodes["BitNode11"] = new BitNode(11, "The Big Crash", "Okay. Sell it all.",
+ "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 " +
+ "of disorder that eventually lead to the governmental reformation of many global superpowers, most notably " +
+ "the USA and China. But just as the world was slowly beginning to recover from these dark times, financial catastrophe hit.
" +
+ "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 " +
+ "were able to steal billions of dollars from the world's largest electronic banks, prompting an international banking crisis as " +
+ "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.
" +
+ "In this BitNode:
" +
+ "The starting and maximum amount of money available on servers is significantly decreased
" +
+ "The growth rate of servers is halved
" +
+ "Weakening a server is twice as effective
" +
+ "Company wages are decreased by 50%
" +
+ "Corporation valuations are 99% lower and are therefore significantly less profitable
" +
+ "Hacknet Node production is significantly decreased
" +
+ "Crime and Infiltration are more lucrative
" +
+ "Augmentations are twice as expensive
" +
+ "Destroying this BitNode will give you Source-File 11, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File makes it so that company favor increases BOTH " +
+ "the player's salary and reputation gain rate at that company by 1% per favor (rather than just the reputation gain). " +
+ "This Source-File also increases the player's company salary and reputation gain multipliers by:
" +
+ "Level 1: 24%
" +
+ "Level 2: 36%
" +
+ "Level 3: 42%");
+
+ //Books: Frontera, Shiner
+ BitNodes["BitNode12"] = new BitNode(12, "fOS", "COMING SOON"); //Unlocks the new game mode and the rest of the BitNodes
+ BitNodes["BitNode13"] = new BitNode(13, "", "COMING SOON");
+ BitNodes["BitNode14"] = new BitNode(14, "", "COMING SOON");
+ BitNodes["BitNode15"] = new BitNode(15, "", "COMING SOON");
+ BitNodes["BitNode16"] = new BitNode(16, "", "COMING SOON");
+ BitNodes["BitNode17"] = new BitNode(17, "", "COMING SOON");
+ BitNodes["BitNode18"] = new BitNode(18, "", "COMING SOON");
+ BitNodes["BitNode19"] = new BitNode(19, "", "COMING SOON");
+ BitNodes["BitNode20"] = new BitNode(20, "", "COMING SOON");
+ BitNodes["BitNode21"] = new BitNode(21, "", "COMING SOON");
+ BitNodes["BitNode22"] = new BitNode(22, "", "COMING SOON");
+ BitNodes["BitNode23"] = new BitNode(23, "", "COMING SOON");
+ BitNodes["BitNode24"] = new BitNode(24, "", "COMING SOON");
+}
+
+let BitNodeMultipliers = {
+ HackingLevelMultiplier: 1,
+
+ ServerMaxMoney: 1,
+ ServerStartingMoney: 1,
+ ServerGrowthRate: 1,
+ ServerWeakenRate: 1,
+ ServerStartingSecurity: 1,
+
+ ManualHackMoney: 1,
+ ScriptHackMoney: 1,
+ CompanyWorkMoney: 1,
+ CrimeMoney: 1,
+ HacknetNodeMoney: 1,
+
+ CompanyWorkExpGain: 1,
+ ClassGymExpGain: 1,
+ FactionWorkExpGain: 1,
+ HackExpGain: 1,
+ CrimeExpGain: 1,
+
+ FactionWorkRepGain: 1,
+ FactionPassiveRepGain: 1,
+ RepToDonateToFaction: 1,
+
+ AugmentationRepCost: 1,
+ AugmentationMoneyCost: 1,
+
+ InfiltrationMoney: 1,
+ InfiltrationRep: 1,
+
+ CorporationValuation: 1,
+}
+
+function initBitNodeMultipliers() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN == null) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN = 1;
+ }
+ for (var mult in BitNodeMultipliers) {
+ if (BitNodeMultipliers.hasOwnProperty(mult)) {
+ BitNodeMultipliers[mult] = 1;
+ }
+ }
+
+ switch (_Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN) {
+ case 1: //Source Genesis (every multiplier is 1)
+ break;
+ case 2: //Rise of the Underworld
+ BitNodeMultipliers.ServerMaxMoney = 0.2;
+ BitNodeMultipliers.ServerStartingMoney = 0.4;
+ BitNodeMultipliers.CrimeMoney = 3;
+ BitNodeMultipliers.InfiltrationMoney = 3;
+ BitNodeMultipliers.FactionWorkRepGain = 0.5;
+ BitNodeMultipliers.FactionPassiveRepGain = 0;
+ break;
+ case 3: //Corporatocracy
+ BitNodeMultipliers.RepToDonateToFaction = 0.5;
+ BitNodeMultipliers.AugmentationRepCost = 3;
+ BitNodeMultipliers.AugmentationMoneyCost = 3;
+ BitNodeMultipliers.ServerMaxMoney = 0.25;
+ BitNodeMultipliers.ServerStartingMoney = 0.25;
+ BitNodeMultipliers.ServerGrowthRate = 0.20;
+ BitNodeMultipliers.ScriptHackMoney = 0.25;
+ BitNodeMultipliers.CompanyWorkMoney = 0.25;
+ BitNodeMultipliers.CrimeMoney = 0.25;
+ BitNodeMultipliers.HacknetNodeMoney = 0.25;
+ break;
+ case 4: //The Singularity
+ BitNodeMultipliers.ServerMaxMoney = 0.15;
+ BitNodeMultipliers.ServerStartingMoney = 0.75;
+ BitNodeMultipliers.ScriptHackMoney = 0.2;
+ BitNodeMultipliers.CompanyWorkMoney = 0.1;
+ BitNodeMultipliers.CrimeMoney = 0.2;
+ BitNodeMultipliers.HacknetNodeMoney = 0.05;
+ BitNodeMultipliers.CompanyWorkExpGain = 0.5;
+ BitNodeMultipliers.ClassGymExpGain = 0.5;
+ BitNodeMultipliers.FactionWorkExpGain = 0.5;
+ BitNodeMultipliers.HackExpGain = 0.4;
+ BitNodeMultipliers.CrimeExpGain = 0.5;
+ BitNodeMultipliers.FactionWorkRepGain = 0.75;
+ break;
+ case 5: //Artificial intelligence
+ BitNodeMultipliers.ServerMaxMoney = 2;
+ BitNodeMultipliers.ServerStartingSecurity = 2;
+ BitNodeMultipliers.ServerStartingMoney = 0.5;
+ BitNodeMultipliers.ScriptHackMoney = 0.15;
+ BitNodeMultipliers.HacknetNodeMoney = 0.2;
+ BitNodeMultipliers.CrimeMoney = 0.5;
+ BitNodeMultipliers.InfiltrationRep = 1.5;
+ BitNodeMultipliers.InfiltrationMoney = 1.5;
+ BitNodeMultipliers.AugmentationMoneyCost = 2;
+ BitNodeMultipliers.HackExpGain = 0.5;
+ BitNodeMultipliers.CorporationValuation = 0.5;
+ break;
+ case 6: //Bladeburner
+ BitNodeMultipliers.HackingLevelMultiplier = 0.5;
+ BitNodeMultipliers.ServerMaxMoney = 0.5;
+ BitNodeMultipliers.ServerStartingMoney = 0.5;
+ BitNodeMultipliers.ServerStartingSecurity = 1.5;
+ BitNodeMultipliers.ScriptHackMoney = 0.5;
+ BitNodeMultipliers.CompanyWorkMoney = 0.5;
+ BitNodeMultipliers.CrimeMoney = 0.5;
+ BitNodeMultipliers.InfiltrationMoney = 0.5;
+ BitNodeMultipliers.CorporationValuation = 0.2;
+ BitNodeMultipliers.HacknetNodeMoney = 0.2;
+ BitNodeMultipliers.FactionPassiveRepGain = 0;
+ BitNodeMultipliers.HackExpGain = 0.25;
+ break;
+ case 8: //Ghost of Wall Street
+ BitNodeMultipliers.ScriptHackMoney = 0;
+ BitNodeMultipliers.ManualHackMoney = 0;
+ BitNodeMultipliers.CompanyWorkMoney = 0;
+ BitNodeMultipliers.CrimeMoney = 0;
+ BitNodeMultipliers.HacknetNodeMoney = 0;
+ BitNodeMultipliers.InfiltrationMoney = 0;
+ BitNodeMultipliers.RepToDonateToFaction = 0;
+ BitNodeMultipliers.CorporationValuation = 0;
+ break;
+ case 11: //The Big Crash
+ BitNodeMultipliers.ServerMaxMoney = 0.1;
+ BitNodeMultipliers.ServerStartingMoney = 0.1;
+ BitNodeMultipliers.ServerGrowthRate = 0.5;
+ BitNodeMultipliers.ServerWeakenRate = 2;
+ BitNodeMultipliers.CrimeMoney = 3;
+ BitNodeMultipliers.CompanyWorkMoney = 0.5;
+ BitNodeMultipliers.HacknetNodeMoney = 0.1;
+ BitNodeMultipliers.AugmentationMoneyCost = 2;
+ BitNodeMultipliers.InfiltrationMoney = 2.5;
+ BitNodeMultipliers.InfiltrationRep = 2.5;
+ BitNodeMultipliers.CorporationValuation = 0.01;
+ break;
+ default:
+ console.log("WARNING: Player.bitNodeN invalid");
+ break;
+ }
+}
+
+
+
+
+/***/ }),
+/* 13 */
+/*!****************************!*\
+ !*** ./utils/IPAddress.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRandomIp", function() { return createRandomIp; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ipExists", function() { return ipExists; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidIPAddress", function() { return isValidIPAddress; });
+/* harmony import */ var _src_Server_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/Server.js */ 14);
+
+/* Functions to deal with manipulating IP addresses*/
+
+//Generate a random IP address
+//Will not return an IP address that already exists in the AllServers array
+function createRandomIp() {
+ var ip = createRandomByte(99) +'.' +
+ createRandomByte(9) +'.' +
+ createRandomByte(9) +'.' +
+ createRandomByte(9);
+
+ //If the Ip already exists, recurse to create a new one
+ if (ipExists(ip)) {
+ return createRandomIp();
+ }
+ return ip;
+}
+
+//Returns true if the IP already exists in one of the game's servers
+function ipExists(ip) {
+ for (var property in _src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"]) {
+ if (_src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"].hasOwnProperty(property)) {
+ if (property == ip) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function createRandomByte(n=9) {
+ return Math.round(Math.random()*n);
+}
+
+function isValidIPAddress(ipaddress) {
+ if (/^(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))
+ {
+ return true;
+ }
+ return false;
+}
+
+
+
+
+/***/ }),
+/* 14 */
/*!***********************!*\
!*** ./src/Server.js ***!
\***********************/
@@ -9791,15 +10119,15 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initForeignServers", function() { return initForeignServers; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeAllServers", function() { return prestigeAllServers; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeHomeComputer", function() { return prestigeHomeComputer; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 17);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Script.js */ 26);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/IPAddress.js */ 13);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
@@ -10719,2036 +11047,8 @@ Directory.prototype.getPath = function(name) {
-/***/ }),
-/* 11 */
-/*!************************!*\
- !*** ./src/Faction.js ***!
- \************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNextNeurofluxLevel", function() { return getNextNeurofluxLevel; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Factions", function() { return Factions; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initFactions", function() { return initFactions; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inviteToFaction", function() { return inviteToFaction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "joinFaction", function() { return joinFaction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayFactionContent", function() { return displayFactionContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processPassiveFactionRepGain", function() { return processPassiveFactionRepGain; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFactions", function() { return loadFactions; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Faction", function() { return Faction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseAugmentation", function() { return purchaseAugmentation; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factionExists", function() { return factionExists; });
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FactionInfo.js */ 28);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Location.js */ 4);
-/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 34);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/FactionInvitationBox.js */ 116);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! numeral/min/numeral.min */ 13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-function Faction(name="") {
- this.name = name;
- this.augmentations = []; //Name of augmentation only
- this.info = ""; //Introductory/informational text about the faction
-
- //Player-related properties for faction
- this.isMember = false; //Whether player is member
- this.isBanned = false; //Whether or not player is banned from joining this faction
- this.playerReputation = 0; //"Reputation" within faction
- this.alreadyInvited = false;
-
- //Multipliers for unlocking and purchasing augmentations
- this.augmentationPriceMult = 1;
- this.augmentationRepRequirementMult = 1;
-
- //Faction favor
- this.favor = 0;
- this.rolloverRep = 0;
-};
-
-Faction.prototype.setAugmentationMultipliers = function(price, rep) {
- this.augmentationPriceMult = price;
- this.augmentationRepRequirementMult = rep;
-}
-
-Faction.prototype.setInfo = function(inf) {
- this.info = inf;
-}
-
-Faction.prototype.gainFavor = function() {
- if (this.favor == null || this.favor == undefined) {this.favor = 0;}
- if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
- var res = this.getFavorGain();
- if (res.length != 2) {
- console.log("Error: invalid result from getFavorGain() function");
- return;
- }
- this.favor += res[0];
- this.rolloverRep = res[1];
-}
-
-//Returns an array with [How much favor would be gained, how much favor would be left over]
-Faction.prototype.getFavorGain = function() {
- if (this.favor == null || this.favor == undefined) {this.favor = 0;}
- if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
- var favorGain = 0, rep = this.playerReputation + this.rolloverRep;
- var reqdRep = _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorBase *
- Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorMult, this.favor);
- while(rep > 0) {
- if (rep >= reqdRep) {
- ++favorGain;
- rep -= reqdRep;
- } else {
- break;
- }
- reqdRep *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorMult;
- }
- return [favorGain, rep];
-}
-
-//Adds all Augmentations to this faction.
-Faction.prototype.addAllAugmentations = function() {
- this.augmentations.length = 0;
- for (var name in _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"]) {
- if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"].hasOwnProperty(name)) {
- this.augmentations.push(name);
- }
- }
-}
-
-Faction.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Generic_toJSON"])("Faction", this);
-}
-
-Faction.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Generic_fromJSON"])(Faction, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Reviver"].constructors.Faction = Faction;
-
-//Map of factions indexed by faction name
-let Factions = {}
-
-function loadFactions(saveString) {
- Factions = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Reviver"]);
-}
-
-function AddToFactions(faction) {
- var name = faction.name;
- Factions[name] = faction;
-}
-
-function factionExists(name) {
- return Factions.hasOwnProperty(name);
-}
-
-//TODO Augmentation price and rep requirement mult are 1 for everything right now,
-// This might change in the future for balance
-function initFactions() {
- //Endgame
- var Illuminati = new Faction("Illuminati");
- Illuminati.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].IlluminatiInfo);
- resetFaction(Illuminati);
-
- var Daedalus = new Faction("Daedalus");
- Daedalus.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].DaedalusInfo);
- resetFaction(Daedalus);
-
- var Covenant = new Faction("The Covenant");
- Covenant.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].CovenantInfo);
- resetFaction(Covenant);
-
- //Megacorporations, each forms its own faction
- var ECorp = new Faction("ECorp");
- ECorp.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ECorpInfo);
- resetFaction(ECorp);
-
- var MegaCorp = new Faction("MegaCorp");
- MegaCorp.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].MegaCorpInfo);
- resetFaction(MegaCorp);
-
- var BachmanAndAssociates = new Faction("Bachman & Associates");
- BachmanAndAssociates.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BachmanAndAssociatesInfo);
- resetFaction(BachmanAndAssociates);
-
- var BladeIndustries = new Faction("Blade Industries");
- BladeIndustries.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BladeIndustriesInfo);
- resetFaction(BladeIndustries);
-
- var NWO = new Faction("NWO");
- NWO.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NWOInfo);
- resetFaction(NWO);
-
- var ClarkeIncorporated = new Faction("Clarke Incorporated");
- ClarkeIncorporated.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ClarkeIncorporatedInfo);
- resetFaction(ClarkeIncorporated);
-
- var OmniTekIncorporated = new Faction("OmniTek Incorporated");
- OmniTekIncorporated.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].OmniTekIncorporatedInfo);
- resetFaction(OmniTekIncorporated);
-
- var FourSigma = new Faction("Four Sigma");
- FourSigma.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].FourSigmaInfo);
- resetFaction(FourSigma);
-
- var KuaiGongInternational = new Faction("KuaiGong International");
- KuaiGongInternational.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].KuaiGongInternationalInfo);
- resetFaction(KuaiGongInternational);
-
- //Other corporations
- var FulcrumTechnologies = new Faction("Fulcrum Secret Technologies");
- FulcrumTechnologies.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].FulcrumSecretTechnologiesInfo);
- resetFaction(FulcrumTechnologies);
-
- //Hacker groups
- var BitRunners = new Faction("BitRunners");
- BitRunners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BitRunnersInfo);
- resetFaction(BitRunners);
-
- var BlackHand = new Faction("The Black Hand");
- BlackHand.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BlackHandInfo);
- resetFaction(BlackHand);
-
- var NiteSec = new Faction("NiteSec");
- NiteSec.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NiteSecInfo);
- resetFaction(NiteSec);
-
- //City factions, essentially governments
- var Chongqing = new Faction("Chongqing");
- Chongqing.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ChongqingInfo);
- resetFaction(Chongqing);
-
- var Sector12 = new Faction("Sector-12");
- Sector12.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].Sector12Info);
- resetFaction(Sector12);
-
- var NewTokyo = new Faction("New Tokyo");
- NewTokyo.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NewTokyoInfo);
- resetFaction(NewTokyo);
-
- var Aevum = new Faction("Aevum");
- Aevum.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].AevumInfo);
- resetFaction(Aevum);
-
- var Ishima = new Faction("Ishima");
- Ishima.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].Ishima);
- resetFaction(Ishima);
-
- var Volhaven = new Faction("Volhaven");
- Volhaven.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].VolhavenInfo);
- resetFaction(Volhaven);
-
- //Criminal Organizations/Gangs
- var SpeakersForTheDead = new Faction("Speakers for the Dead");
- SpeakersForTheDead.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SpeakersForTheDeadInfo);
- resetFaction(SpeakersForTheDead);
-
- var DarkArmy = new Faction("The Dark Army");
- DarkArmy.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].DarkArmyInfo);
- resetFaction(DarkArmy);
-
- var TheSyndicate = new Faction("The Syndicate");
- TheSyndicate.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TheSyndicateInfo);
- resetFaction(TheSyndicate);
-
- var Silhouette = new Faction("Silhouette");
- Silhouette.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SilhouetteInfo);
- resetFaction(Silhouette);
-
- var Tetrads = new Faction("Tetrads"); //Low-medium level asian crime gang
- Tetrads.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TetradsInfo);
- resetFaction(Tetrads);
-
- var SlumSnakes = new Faction("Slum Snakes"); //Low level crime gang
- SlumSnakes.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SlumSnakesInfo);
- resetFaction(SlumSnakes);
-
- //Earlygame factions - factions the player will prestige with early on that don't
- //belong in other categories
- var Netburners = new Faction("Netburners");
- Netburners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NetburnersInfo);
- resetFaction(Netburners);
-
- var TianDiHui = new Faction("Tian Di Hui"); //Society of the Heaven and Earth
- TianDiHui.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TianDiHuiInfo);
- resetFaction(TianDiHui);
-
- var CyberSec = new Faction("CyberSec");
- CyberSec.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].CyberSecInfo);
- resetFaction(CyberSec);
-
- //Special Factions
- var Bladeburners = new Faction("Bladeburners");
- Bladeburners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BladeburnersInfo);
- resetFaction(Bladeburners);
-}
-
-//Resets a faction during (re-)initialization. Saves the favor in the new
-//Faction object and deletes the old Faction Object from "Factions". Then
-//reinserts the new Faction object
-function resetFaction(newFactionObject) {
- if (!(newFactionObject instanceof Faction)) {
- throw new Error("Invalid argument 'newFactionObject' passed into resetFaction()");
- }
- var factionName = newFactionObject.name;
- if (factionExists(factionName)) {
- newFactionObject.favor = Factions[factionName].favor;
- delete Factions[factionName];
- }
- AddToFactions(newFactionObject);
-}
-
-function inviteToFaction(faction) {
- if (_Settings_js__WEBPACK_IMPORTED_MODULE_8__["Settings"].SuppressFactionInvites) {
- faction.alreadyInvited = true;
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].factionInvitations.push(faction.name);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Factions) {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionsContent();
- }
- } else {
- Object(_utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__["factionInvitationBoxCreate"])(faction);
- }
-}
-
-function joinFaction(faction) {
- faction.isMember = true;
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].factions.push(faction.name);
-
- //Determine what factions you are banned from now that you have joined this faction
- if (faction.name == "Chongqing") {
- Factions["Sector-12"].isBanned = true;
- Factions["Aevum"].isBanned = true;
- Factions["Volhaven"].isBanned = true;
- } else if (faction.name == "Sector-12") {
- Factions["Chongqing"].isBanned = true;
- Factions["New Tokyo"].isBanned = true;
- Factions["Ishima"].isBanned = true;
- Factions["Volhaven"].isBanned = true;
- } else if (faction.name == "New Tokyo") {
- Factions["Sector-12"].isBanned = true;
- Factions["Aevum"].isBanned = true;
- Factions["Volhaven"].isBanned = true;
- } else if (faction.name == "Aevum") {
- Factions["Chongqing"].isBanned = true;
- Factions["New Tokyo"].isBanned = true;
- Factions["Ishima"].isBanned = true;
- Factions["Volhaven"].isBanned = true;
- } else if (faction.name == "Ishima") {
- Factions["Sector-12"].isBanned = true;
- Factions["Aevum"].isBanned = true;
- Factions["Volhaven"].isBanned = true;
- } else if (faction.name == "Volhaven") {
- Factions["Chongqing"].isBanned = true;
- Factions["Sector-12"].isBanned = true;
- Factions["New Tokyo"].isBanned = true;
- Factions["Aevum"].isBanned = true;
- Factions["Ishima"].isBanned = true;
- }
-}
-
-//Displays the HTML content for a specific faction
-function displayFactionContent(factionName) {
- var faction = Factions[factionName];
- if (faction == null) {
- throw new Error("Invalid factionName passed into displayFactionContent: " + factionName);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent);
- var elements = [];
-
- //Header and faction info
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("h1", {
- innerText:factionName
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("pre", {
- innerHTML:"" + faction.info + ""
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"---------------",
- }));
-
- //Faction reputation and favor
- var favorGain = faction.getFavorGain();
- if (favorGain.length != 2) {favorGain = 0;}
- favorGain = favorGain[0];
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText: "Reputation: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(faction.playerReputation, 4),
- tooltip:"You will earn " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(favorGain, 4) +
- " faction favor upon resetting after installing an Augmentation"
- }))
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"---------------",
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Faction Favor: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(faction.favor, 4),
- tooltip:"Faction favor increases the rate at which " +
- "you earn reputation for this faction by 1% per favor. Faction favor " +
- "is gained whenever you reset after installing an Augmentation. The amount of " +
- "favor you gain depends on how much reputation you have with the faction"
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"---------------",
- }));
-
- //Faction Work Description Text
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("pre", {
- id:"faction-work-description-text",
- innerText:"Perform work/carry out assignments for your faction to help further its cause! By doing so " +
- "you will earn reputation for your faction. You will also gain reputation passively over time, " +
- "although at a very slow rate. Earning reputation will allow you to purchase Augmentations " +
- "through this faction, which are powerful upgrades that enhance your abilities. Note that you cannot " +
- "use your terminal or create scripts when you are performing a task!"
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
-
- //Hacking Mission Option
- var hackMissionDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-hack-mission-div", class:"faction-work-div",
- });
- var hackMissionDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- hackMissionDiv.appendChild(hackMissionDivWrapper);
- hackMissionDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Hacking Mission",
- clickListener:()=>{
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadMissionContent();
- var mission = new _Missions_js__WEBPACK_IMPORTED_MODULE_6__["HackingMission"](faction.playerReputation, faction);
- Object(_Missions_js__WEBPACK_IMPORTED_MODULE_6__["setInMission"])(true, mission); //Sets inMission flag to true
- mission.init();
- return false;
- }
- }));
- hackMissionDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Attempt a hacking mission for your faction. " +
- "A mission is a mini game that, if won, earns you " +
- "significant reputation with this faction. (Recommended hacking level: 200+)"
- }));
- elements.push(hackMissionDiv);
-
- //Hacking Contracts Option
- var hackDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-hack-div", class:"faction-work-div",
- });
- var hackDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- hackDiv.appendChild(hackDivWrapper);
- hackDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Hacking Contracts",
- clickListener:()=>{
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionHackWork(faction);
- return false;
- }
- }));
- hackDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Complete hacking contracts for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on your hacking skill. " +
- "You will gain hacking exp."
- }));
- elements.push(hackDiv);
-
- //Field Work Option
- var fieldWorkDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-fieldwork-div", class:"faction-work-div"
- });
- var fieldWorkDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- fieldWorkDiv.appendChild(fieldWorkDivWrapper);
- fieldWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Field Work",
- clickListener:()=>{
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionFieldWork(faction);
- return false;
- }
- }));
- fieldWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Carry out field missions for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on all of your stats. " +
- "You will gain exp for all stats."
- }));
- elements.push(fieldWorkDiv);
-
- //Security Work Option
- var securityWorkDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-securitywork-div", class:"faction-work-div"
- });
- var securityWorkDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- securityWorkDiv.appendChild(securityWorkDivWrapper);
- securityWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Security Work",
- clickListener:()=>{
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionSecurityWork(faction);
- return false;
- }
- }));
- securityWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Serve in a security detail for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on your combat stats. " +
- "You will gain exp for all combat stats."
- }));
- elements.push(securityWorkDiv);
-
- //Donate for reputation
- var donateDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-donate-div", class:"faction-work-div"
- });
- var donateDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- donateDiv.appendChild(donateDivWrapper);
- var donateRepGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"This donation will result in 0 reputation gain"
- });
- var donateAmountInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("input", {
- placeholder:"Donation amount",
- inputListener:()=>{
- var amt = parseFloat(donateAmountInput.value);
- if (isNaN(amt) || amt < 0) {
- donateRepGain.innerText = "Invalid donate amount entered!";
- } else {
- var repGain = amt / 1e6 * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
- donateRepGain.innerText = "This donation will result in " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(repGain, 3) + " reputation gain";
- }
- },
- });
- donateDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Donate Money",
- clickListener:()=>{
- var amt = parseFloat(donateAmountInput.value);
- if (isNaN(amt) || amt < 0) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid amount entered!");
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].money.lt(amt)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You cannot afford to donate this much money!");
- } else {
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].loseMoney(amt);
- var repGain = amt / 1e6 * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
- faction.playerReputation += repGain;
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You just donated " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13___default()(amt).format("$0.000a") + " to " +
- faction.name + " to gain " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(repGain, 3) + " reputation");
- displayFactionContent(factionName);
- }
- }
- }));
- donateDivWrapper.appendChild(donateAmountInput);
- donateDivWrapper.appendChild(donateRepGain);
- elements.push(donateDiv);
-
- //Purchase Augmentations
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("pre", {
- innerHTML: "
As your reputation with this faction rises, you will " +
- "unlock Augmentations, which you can purchase to enhance " +
- "your abilities.
"
- }));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Purchase Augmentations",
- clickListener:()=>{
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].hideAllContent();
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionAugmentationsContent.style.display = "block";
-
-
- displayFactionAugmentations(factionName);
- return false;
- }
- }));
-
- //Gang (BitNode-2)
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].bitNodeN == 2 && (factionName == "Slum Snakes" || factionName == "Tetrads" ||
- factionName == "The Syndicate" || factionName == "The Dark Army" || factionName == "Speakers for the Dead" ||
- factionName == "NiteSec" || factionName == "The Black Hand")) {
- //Set everything else to invisible
- hackMissionDiv.style.display = "none";
- hackDiv.style.display = "none";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- donateDiv.style.display = "none";
-
- //Create the 'Manage Gang' button
- var gangDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
- id:"faction-gang-div", class:"faction-work-div", display:"inline"
- });
- var gangDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
- gangDiv.appendChild(gangDivWrapper);
- gangDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- class:"a-link-button", innerText:"Manage Gang",
- clickListener:()=>{
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].inGang()) {
- var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Create Gang";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", () => {
- var hacking = false;
- if (factionName === "NiteSec" || factionName === "The Black Hand") {hacking = true;}
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startGang(factionName, hacking);
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadGangContent();
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
- });
- noBtn.addEventListener("click", () => {
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
- });
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxCreate"])("Would you like to create a new Gang with " + factionName + "?
" +
- "Note that this will prevent you from creating a Gang with any other Faction until " +
- "this BitNode is destroyed. There are NO differences between the Factions you can " +
- "create a Gang with and each of these Factions have all Augmentations available");
- } else {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadGangContent();
- }
- }
- }));
- gangDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- innerText:"Create and manage a gang for this Faction. " +
- "Gangs will earn you money and faction reputation."
- }));
- //Manage Gang button goes before Faction work stuff
- elements.splice(7, 1, gangDiv);
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].inGang() && _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].gang.facName != factionName) {
- //If the player has a gang but its not for this faction
- gangDiv.style.display = "none";
- }
- //Display all elements
- for (var i = 0; i < elements.length; ++i) {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent.appendChild(elements[i]);
- }
- return;
- }
-
- if (faction.isMember) {
- if (faction.favor >= (150 * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].RepToDonateToFaction)) {
- donateDiv.style.display = "inline";
- } else {
- donateDiv.style.display = "none";
- }
-
- switch(faction.name) {
- case "Illuminati":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "Daedalus":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "The Covenant":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "ECorp":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "MegaCorp":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Bachman & Associates":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Blade Industries":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "NWO":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Clarke Incorporated":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "OmniTek Incorporated":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Four Sigma":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "KuaiGong International":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Fulcrum Secret Technologies":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "inline";
- break;
- case "BitRunners":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- break;
- case "The Black Hand":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "NiteSec":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- break;
- case "Chongqing":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Sector-12":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "New Tokyo":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Aevum":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Ishima":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Volhaven":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Speakers for the Dead":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "The Dark Army":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "The Syndicate":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Silhouette":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "none";
- break;
- case "Tetrads":
- hackMissionDiv.style.display = "none";
- hackDiv.style.display = "none";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Slum Snakes":
- hackMissionDiv.style.display = "none";
- hackDiv.style.display = "none";
- fieldWorkDiv.style.display = "inline";
- securityWorkDiv.style.display = "inline";
- break;
- case "Netburners":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- break;
- case "Tian Di Hui":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "inline";
- break;
- case "CyberSec":
- hackMissionDiv.style.display = "inline";
- hackDiv.style.display = "inline";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- break;
- case "Bladeburners":
- hackMissionDiv.style.display = "none";
- hackDiv.style.display = "none";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- break;
- default:
- console.log("Faction does not exist");
- break;
- }
- } else {
- throw new Error("Not a member of this faction, cannot display faction information");
- }
-
- //Display all elements
- for (var i = 0; i < elements.length; ++i) {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent.appendChild(elements[i]);
- }
-}
-
-var confirmingPurchases = true;
-var sortOption = null;
-function displayFactionAugmentations(factionName) {
- var faction = Factions[factionName];
- if (faction == null) {
- throw new Error("Could not find faction " + factionName + " in displayFactionAugmentations");
- }
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionAugmentationsContent);
- var elements = [];
-
- //Back button
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- innerText:"Back", class:"a-link-button",
- clickListener:()=>{
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionContent();
- displayFactionContent(factionName);
- return false;
- }
- }));
-
- //Header text
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("h1", {innerText:"Faction Augmentations"}));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- id:"faction-augmentations-page-desc",
- innerHTML:"Lists all Augmentations that are available to purchase from " + factionName + "
" +
- "Augmentations are powerful upgrades that will enhance your abilities."
- }));
-
- //Confirming not confirming button
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("label", {
- for:"faction-augmentations-confirming-checkbox",innerText:"Confirm Purchases",
- color:"white", margin:"4px", padding:"4px",
- }));
- var confirmingPurchasesCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("input", {
- type:"checkbox", id:"faction-augmentations-confirming-checkbox", checked:confirmingPurchases,
- margin:"4px", padding:"4px",
- clickListener:()=>{
- confirmingPurchases = confirmingPurchasesCheckbox.checked;
- }
- });
- elements.push(confirmingPurchasesCheckbox);
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
- elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
-
- //Augmentations List
- var augmentationsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("ul");
-
- //Sort buttons
- var sortByCostBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- innerText:"Sort by Cost", class:"a-link-button",
- clickListener:()=>{
- sortOption = "cost";
- var augs = faction.augmentations.slice();
- augs.sort((augName1, augName2)=>{
- var aug1 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
- if (aug1 == null || aug2 == null) {
- throw new Error("Invalid Augmentation Names");
- }
- return aug1.baseCost - aug2.baseCost;
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
- }
- });
- var sortByRepBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- innerText:"Sort by Reputation", class:"a-link-button",
- clickListener:()=>{
- sortOption = "reputation";
- var augs = faction.augmentations.slice();
- augs.sort((augName1, augName2)=>{
- var aug1 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
- if (aug1 == null || aug2 == null) {
- throw new Error("Invalid Augmentation Names");
- }
- return aug1.baseRepRequirement - aug2.baseRepRequirement;
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
- }
- });
- var defaultSortBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- innerText:"Sort by Default Order", class:"a-link-button",
- clickListener:()=>{
- sortOption = "default";
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, faction.augmentations, faction);
- }
- });
- elements.push(sortByCostBtn);
- elements.push(sortByRepBtn);
- elements.push(defaultSortBtn);
- switch(sortOption) {
- case "cost":
- sortByCostBtn.click();
- break;
- case "reputation":
- sortByRepBtn.click();
- break;
- default:
- defaultSortBtn.click();
- break;
- }
-
- elements.push(augmentationsList);
-
- for (var i = 0; i < elements.length; ++i) {
- _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionAugmentationsContent.appendChild(elements[i]);
- }
-}
-
-//Takes in an array of Augmentation Names, constructs DOM elements
-//to list them on the faction page, and appends them to the given
-//DOM element
-// @augmentationsList DOM List to append Aug DOM elements to
-// @augs Array of Aug names
-// @faction Faction for which to display Augmentations
-function createFactionAugmentationDisplayElements(augmentationsList, augs, faction) {
- for (var i = 0; i < augs.length; ++i) {
- (function () {
- var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augs[i]];
- if (aug == null) {
- throw new Error("Invalid Augmentation when trying to create Augmentation display Elements");
- }
- var owned = false;
- for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++j) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[j].name == aug.name) {
- owned = true;
- break;
- }
- }
- for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations.length; ++j) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[j].name == aug.name) {
- owned = true;
- break;
- }
- }
-
- var item = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("li");
- var span = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("span", {display:"inline-block"});
- var aDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {tooltip:aug.info});
- var aElem = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
- innerText:aug.name, display:"inline",
- clickListener:()=>{
- if (confirmingPurchases) {
- purchaseAugmentationBoxCreate(aug, faction);
- } else {
- purchaseAugmentation(aug, faction);
- }
- return false;
- }
- });
- if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
- aElem.innerText += " - Level " + (getNextNeurofluxLevel());
- }
- var pElem = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
- display:"inline",
- })
- var req = aug.baseRepRequirement * faction.augmentationRepRequirementMult;
- var hasPrereqs = hasAugmentationPrereqs(aug);
- if (!hasPrereqs) {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "LOCKED (Requires " + aug.prereqs.join(",") + " as prerequisite(s))";
- pElem.style.color = "red";
- } else if (aug.name != _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor && (aug.owned || owned)) {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "ALREADY OWNED";
- } else if (faction.playerReputation >= req) {
- aElem.setAttribute("class", "a-link-button");
- pElem.innerHTML = "UNLOCKED - " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13___default()(aug.baseCost * faction.augmentationPriceMult).format("$0.000a");
- } else {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "LOCKED (Requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(req, 1) + " faction reputation) - " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_13___default()(aug.baseCost * faction.augmentationPriceMult).format("$0.000a");
- pElem.style.color = "red";
- }
- aDiv.appendChild(aElem);
- span.appendChild(aDiv);
- span.appendChild(pElem);
- item.appendChild(span);
- augmentationsList.appendChild(item);
- }()); //Immediate invocation closure
- }
-}
-
-function purchaseAugmentationBoxCreate(aug, fac) {
- var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Purchase";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", function() {
- purchaseAugmentation(aug, fac);
- });
- noBtn.addEventListener("click", function() {
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
- });
-
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxCreate"])("" + aug.name + "
" +
- aug.info + "
" +
- "
Would you like to purchase the " + aug.name + " Augmentation for $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(aug.baseCost * fac.augmentationPriceMult, 2) + "?");
-}
-
-//Returns a boolean indicating whether the player has the prerequisites for the
-//specified Augmentation
-function hasAugmentationPrereqs(aug) {
- var hasPrereqs = true;
- if (aug.prereqs && aug.prereqs.length > 0) {
- for (var i = 0; i < aug.prereqs.length; ++i) {
- var prereqAug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][aug.prereqs[i]];
- if (prereqAug == null) {
- console.log("ERROR: Invalid prereq Augmentation: " + aug.prereqs[i]);
- continue;
- }
- if (prereqAug.owned === false) {
- hasPrereqs = false;
-
- //Check if the aug is purchased
- for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++j) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[j].name === prereqAug.name) {
- hasPrereqs = true;
- break;
- }
- }
- }
- }
- }
- return hasPrereqs;
-}
-
-function purchaseAugmentation(aug, fac, sing=false) {
- var hasPrereqs = hasAugmentationPrereqs(aug);
- if (!hasPrereqs) {
- var txt = "You must first purchase or install " + aug.prereqs.join(",") + " before you can " +
- "purchase this one.";
- if (sing) {return txt;} else {Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])(txt);}
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].money.lt(aug.baseCost * fac.augmentationPriceMult)) {
- let txt = "You don't have enough money to purchase " + aug.name;
- if (sing) {return txt;}
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])(txt);
- } else if (fac.playerReputation < aug.baseRepRequirement) {
- let txt = "You don't have enough faction reputation to purchase " + aug.name;
- if (sing) {return txt;}
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])(txt);
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].money.gte(aug.baseCost * fac.augmentationPriceMult)) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].firstAugPurchased === false) {
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].firstAugPurchased = true;
- document.getElementById("augmentations-tab").style.display = "list-item";
- document.getElementById("character-menu-header").click();
- document.getElementById("character-menu-header").click();
- }
-
- var queuedAugmentation = new _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["PlayerOwnedAugmentation"](aug.name);
- if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
- queuedAugmentation.level = getNextNeurofluxLevel();
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.push(queuedAugmentation);
-
- _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].loseMoney((aug.baseCost * fac.augmentationPriceMult));
-
- //If you just purchased Neuroflux Governor, recalculate the cost
- if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
- var nextLevel = getNextNeurofluxLevel();
- --nextLevel;
- var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].NeuroFluxGovernorLevelMult, nextLevel);
- aug.baseRepRequirement = 500 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].AugmentationRepMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].AugmentationRepCost;
- aug.baseCost = 750e3 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].AugmentationCostMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].AugmentationMoneyCost;
-
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length-1; ++i) {
- aug.baseCost *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].MultipleAugMultiplier;
- }
- }
-
- for (var name in _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"]) {
- if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"].hasOwnProperty(name)) {
- _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][name].baseCost *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].MultipleAugMultiplier;
- }
- }
-
- if (sing) {
- return "You purchased " + aug.name;
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You purchased " + aug.name + ". It's enhancements will not take " +
- "effect until they are installed. To install your augmentations, go to the " +
- "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " +
- "augmentations will now be more expensive.");
- }
-
- displayFactionAugmentations(fac.name);
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Hmm, something went wrong when trying to purchase an Augmentation. " +
- "Please report this to the game developer with an explanation of how to " +
- "reproduce this.");
- }
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
-}
-
-function getNextNeurofluxLevel() {
- var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor];
- if (aug == null) {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[i].name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
- aug = _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[i];
- }
- }
- if (aug == null) {
- console.log("WARNING: Could not find NeuroFlux Governor aug. This is OK if " +
- "it happens during the loading/initialization of the game, but probably " +
- "indicates something seriously wrong at other times");
- return 1;
- }
- }
- var nextLevel = aug.level + 1;
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[i].name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
- ++nextLevel;
- }
- }
- return nextLevel;
-}
-
-function processPassiveFactionRepGain(numCycles) {
- var numTimesGain = (numCycles / 600) * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
- for (var name in Factions) {
- if (Factions.hasOwnProperty(name)) {
- var faction = Factions[name];
-
- //TODO Get hard value of 1 rep per "rep gain cycle"" for now..
- //maybe later make this based on
- //a player's 'status' like how powerful they are and how much money they have
- if (faction.isMember) {faction.playerReputation += (numTimesGain * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].FactionPassiveRepGain);}
- }
- }
-}
-
-
-
-
-/***/ }),
-/* 12 */
-/*!***************************!*\
- !*** ./utils/YesNoBox.js ***!
- \***************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxCreate", function() { return yesNoBoxCreate; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxCreate", function() { return yesNoTxtInpBoxCreate; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxGetYesButton", function() { return yesNoBoxGetYesButton; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxGetNoButton", function() { return yesNoBoxGetNoButton; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetYesButton", function() { return yesNoTxtInpBoxGetYesButton; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetNoButton", function() { return yesNoTxtInpBoxGetNoButton; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetInput", function() { return yesNoTxtInpBoxGetInput; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxClose", function() { return yesNoBoxClose; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxClose", function() { return yesNoTxtInpBoxClose; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxOpen", function() { return yesNoBoxOpen; });
-/* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelperFunctions.js */ 1);
-
-/* Generic Yes-No Pop-up box
- * Can be used to create pop-up boxes that require a yes/no response from player
- */
-var yesNoBoxOpen = false;
-function yesNoBoxClose() {
- var container = document.getElementById("yes-no-box-container");
- if (container) {
- container.style.display = "none";
- } else {
- console.log("ERROR: Container not found for YesNoBox");
- }
- yesNoBoxOpen = false;
- return false; //So that 'return yesNoBoxClose()' is return false in event listeners
-}
-
-function yesNoBoxGetYesButton() {
- return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-box-yes");
-}
-
-function yesNoBoxGetNoButton() {
- return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-box-no");
-}
-
-function yesNoBoxCreate(txt) {
- if (yesNoBoxOpen) {return false;} //Already open
- yesNoBoxOpen = true;
- var textElement = document.getElementById("yes-no-box-text");
- if (textElement) {
- textElement.innerHTML = txt;
- }
-
- var c = document.getElementById("yes-no-box-container");
- if (c) {
- c.style.display = "block";
- } else {
- console.log("ERROR: Container not found for YesNoBox");
- }
- return true;
-}
-
-/* Generic Yes-No POp-up Box with Text input */
-function yesNoTxtInpBoxClose() {
- var c = document.getElementById("yes-no-text-input-box-container");
- if (c) {
- c.style.display = "none";
- } else {
- console.log("ERROR: Container not found for YesNoTextInputBox");
- }
- yesNoBoxOpen = false;
- document.getElementById("yes-no-text-input-box-input").value = "";
- return false;
-}
-
-function yesNoTxtInpBoxGetYesButton() {
- return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-text-input-box-yes");
-}
-
-function yesNoTxtInpBoxGetNoButton() {
- return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-text-input-box-no");
-}
-
-function yesNoTxtInpBoxGetInput() {
- var val = document.getElementById("yes-no-text-input-box-input").value;
- val = val.replace(/\s+/g, '');
- return val;
-}
-
-function yesNoTxtInpBoxCreate(txt) {
- yesNoBoxOpen = true;
- var txtE = document.getElementById("yes-no-text-input-box-text");
- if (txtE) {
- txtE.innerHTML = txt;
- }
-
- var c = document.getElementById("yes-no-text-input-box-container");
- if (c) {
- c.style.display = "block";
- } else {
- console.log("ERROR: Container not found for YesNoTextInputBox");
- }
-
- document.getElementById("yes-no-text-input-box-input").focus();
-}
-
-
-
-
-/***/ }),
-/* 13 */
-/*!*************************************************!*\
- !*** ./node_modules/numeral/min/numeral.min.js ***!
- \*************************************************/
-/***/ (function(module, exports, __webpack_require__) {
-
-var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve
- * numeral.js
- * version : 2.0.6
- * author : Adam Draper
- * license : MIT
- * http://adamwdraper.github.com/Numeral-js/
- */
-!function(a,b){ true?!(__WEBPACK_AMD_DEFINE_FACTORY__ = (b),
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
- (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
- __WEBPACK_AMD_DEFINE_FACTORY__),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):undefined}(this,function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.6",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat,scalePercentBy100:g.scalePercentBy100};return b=function(d){var f,g,i,j;if(b.isNumeral(d))f=d.value();else if(0===d||"undefined"==typeof d)f=0;else if(null===d||c.isNaN(d))f=null;else if("string"==typeof d)if(h.zeroFormat&&d===h.zeroFormat)f=0;else if(h.nullFormat&&d===h.nullFormat||!d.replace(/[^0-9]+/g,"").length)f=null;else{for(g in e)if(j="function"==typeof e[g].regexps.unformat?e[g].regexps.unformat():e[g].regexps.unformat,j&&d.match(j)){i=e[g].unformat;break}i=i||b._.stringToNumber,f=i(d)}else f=Number(d)||null;return new a(d,f)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={numberToFormat:function(a,c,d){var e,g,h,i,j,k,l,m=f[b.options.currentLocale],n=!1,o=!1,p=0,q="",r=1e12,s=1e9,t=1e6,u=1e3,v="",w=!1;if(a=a||0,g=Math.abs(a),b._.includes(c,"(")?(n=!0,c=c.replace(/[\(|\)]/g,"")):(b._.includes(c,"+")||b._.includes(c,"-"))&&(j=b._.includes(c,"+")?c.indexOf("+"):0>a?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,b._.includes(c," a")&&(q=" "),c=c.replace(new RegExp(q+"a[kmbt]?"),""),g>=r&&!e||"t"===e?(q+=m.abbreviations.trillion,a/=r):r>g&&g>=s&&!e||"b"===e?(q+=m.abbreviations.billion,a/=s):s>g&&g>=t&&!e||"m"===e?(q+=m.abbreviations.million,a/=t):(t>g&&g>=u&&!e||"k"===e)&&(q+=m.abbreviations.thousand,a/=u)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),p=(c.split(".")[0].split(",")[0].match(/0/g)||[]).length,i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),v=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):v=b._.toFixed(a,i.length,d),h=v.split(".")[0],v=b._.includes(v,".")?m.delimiters.decimal+v.split(".")[1]:"",o&&0===Number(v.slice(1))&&(v="")):h=b._.toFixed(a,0,d),q&&!e&&Number(h)>=1e3&&q!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),q){case m.abbreviations.thousand:q=m.abbreviations.million;break;case m.abbreviations.million:q=m.abbreviations.billion;break;case m.abbreviations.billion:q=m.abbreviations.trillion}if(b._.includes(h,"-")&&(h=h.slice(1),w=!0),h.length
" +
- "This is the first BitNode that you play through. It has no special " +
- "modifications or mechanics.
" +
- "Destroying this BitNode will give you Source-File 1, or if you already have " +
- "this Source-File it will upgrade its level up to a maximum of 3. This Source-File " +
- "lets the player start with 32GB of RAM on his/her home computer when entering a " +
- "new BitNode, and also increases all of the player's multipliers by:
" +
- "Level 1: 16%
" +
- "Level 2: 24%
" +
- "Level 3: 28%");
- BitNodes["BitNode2"] = new BitNode(2, "Rise of the Underworld", "From the shadows, they rose", //Gangs
- "From the shadows, they rose.
Organized crime groups quickly filled the void of power " +
- "left behind from the collapse of Western government in the 2050's. As society and civlization broke down, " +
- "people quickly succumbed to the innate human impulse of evil and savagery. The organized crime " +
- "factions quickly rose to the top of the modern world.
" +
- "In this BitNode:
The maximum amount of money available on a server is significantly decreased
" +
- "The amount of money gained from crimes and Infiltration is tripled
" +
- "Certain Factions (Slum Snakes, Tetrads, The Syndicate, The Dark Army, Speakers for the Dead, " +
- "NiteSec, The Black Hand) give the player the ability to form and manage their own gangs. These gangs " +
- "will earn the player money and reputation with the corresponding Faction
" +
- "Every Augmentation in the game will be available through the Factions listed above
" +
- "For every Faction NOT listed above, reputation gains are halved
" +
- "You will no longer gain passive reputation with Factions
" +
- "Destroying this BitNode will give you Source-File 2, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File increases the player's crime success rate, " +
- "crime money, and charisma multipliers by:
" +
- "Level 1: 20%
" +
- "Level 2: 30%
" +
- "Level 3: 35%");
- BitNodes["BitNode3"] = new BitNode(3, "Corporatocracy", "The Price of Civilization",
- "Our greatest illusion is that a healthy society can revolve around a " +
- "single-minded pursuit of wealth.
" +
- "Sometime in the early 21st century economic and political globalization turned " +
- "the world into a corporatocracy, and it never looked back. Now, the privileged " +
- "elite will happily bankrupt their own countrymen, decimate their own community, " +
- "and evict their neighbors from houses in their desperate bid to increase their wealth.
" +
- "In this BitNode you can create and manage your own corporation. Running a successful corporation " +
- "has the potential of generating massive profits. All other forms of income are reduced by 75%. Furthermore:
" +
- "The price and reputation cost of all Augmentations is tripled
" +
- "The starting and maximum amount of money on servers is reduced by 75%
" +
- "Server growth rate is reduced by 80%
" +
- "You will start out with $150b so that you can start your corporation
" +
- "You now only need 75 reputation with a faction in order to donate to it, rather than 150
" +
- "Destroying this BitNode will give you Source-File 3, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File lets you create corporations on other BitNodes (although " +
- "some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by:
" +
- "Level 1: 8%
" +
- "Level 2: 12%
" +
- "Level 3: 14%");
- BitNodes["BitNode4"] = new BitNode(4, "The Singularity", "The Man and the Machine", "The Singularity has arrived. The human race is gone, replaced " +
- "by artificially superintelligent beings that are more machine than man.
" +
- "In this BitNode, progressing is significantly harder. Experience gain rates " +
- "for all stats are reduced. Most methods of earning money will now give significantly less.
" +
- "In this BitNode you will gain access to a new set of Netscript Functions known as Singularity Functions. " +
- "These functions allow you to control most aspects of the game through scripts, including working for factions/companies, " +
- "purchasing/installing Augmentations, and creating programs.
" +
- "Destroying this BitNode will give you Source-File 4, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File lets you access and use the Singularity " +
- "Functions in other BitNodes. Each level of this Source-File will open up more Singularity Functions " +
- "that you can use.");
- BitNodes["BitNode5"] = new BitNode(5, "Artificial Intelligence", "Posthuman", "They said it couldn't be done. They said the human brain, " +
- "along with its consciousness and intelligence, couldn't be replicated. They said the complexity " +
- "of the brain results from unpredictable, nonlinear interactions that couldn't be modeled " +
- "by 1's and 0's. They were wrong.
" +
- "In this BitNode:
" +
- "The base security level of servers is doubled
" +
- "The starting money on servers is halved, but the maximum money remains the same
" +
- "Most methods of earning money now give significantly less
" +
- "Infiltration gives 50% more reputation and money
" +
- "Corporations have 50% lower valuations and are therefore less profitable
" +
- "Augmentations are more expensive
" +
- "Hacking experience gain rates are reduced
" +
- "Destroying this BitNode will give you Source-File 5, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File grants you a special new stat called Intelligence. " +
- "Intelligence is unique because it is permanent and persistent (it never gets reset back to 1). However " +
- "gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't know " +
- "when you gain experience and how much). Higher Intelligence levels will boost your production for many actions " +
- "in the game.
" +
- "In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function, " +
- "and will also raise all of your hacking-related multipliers by:
" +
- "Level 1: 4%
" +
- "Level 2: 6%
" +
- "Level 3: 7%");
- BitNodes["BitNode6"] = new BitNode(6, "Bladeburners", "Like Tears in Rain",
- "In the middle of the 21st century, OmniTek Incorporated began designing and manufacturing advanced synthetic " +
- "androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth generation " +
- "of their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was " +
- "the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more intelligent " +
- "than the humans that had created them.
" +
- "In this BitNode you will be able to access the Bladeburner Division at the NSA, which provides a new mechanic " +
- "for progression. Furthermore:
" +
- "Hacking and Hacknet Nodes will be significantly less profitable
" +
- "Your hacking level is reduced by 50%
" +
- "Hacking experience gain from scripts is reduced by 75%
" +
- "Corporations have 80% lower valuations and are therefore less profitable
" +
- "Working for companies is 50% less profitable
" +
- "Crimes and Infiltration are 50% less profitable
" +
- "Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " +
- "its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other " +
- "BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:
" +
- "Level 1: 8%
" +
- "Level 2: 12%
" +
- "Level 3: 14%");
- BitNodes["BitNode7"] = new BitNode(7, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic
- BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps",
- "You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.
" +
- "In this BitNode:
" +
- "You start with $100 million
" +
- "The only way to earn money is by trading on the stock market
" +
- "You start with a WSE membership and access to the TIX API
" +
- "You are able to short stocks and place different types of orders (limit/stop)
" +
- "You can immediately donate to factions to gain reputation
" +
- "Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:
" +
- "Level 1: Permanent access to WSE and TIX API
" +
- "Level 2: Ability to short stocks in other BitNodes
" +
- "Level 3: Ability to use limit/stop orders in other BitNodes
" +
- "This Source-File also increases your hacking growth multipliers by: " +
- "
Level 1: 8%
Level 2: 12%
Level 3: 14%");
- BitNodes["BitNode9"] = new BitNode(9, "Do Androids Dream?", "COMING SOON");
- BitNodes["BitNode10"] = new BitNode(10, "MegaCorp", "COMING SOON"); //Not sure yet
- BitNodes["BitNode11"] = new BitNode(11, "The Big Crash", "Okay. Sell it all.",
- "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 " +
- "of disorder that eventually lead to the governmental reformation of many global superpowers, most notably " +
- "the USA and China. But just as the world was slowly beginning to recover from these dark times, financial catastrophe hit.
" +
- "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 " +
- "were able to steal billions of dollars from the world's largest electronic banks, prompting an international banking crisis as " +
- "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.
" +
- "In this BitNode:
" +
- "The starting and maximum amount of money available on servers is significantly decreased
" +
- "The growth rate of servers is halved
" +
- "Weakening a server is twice as effective
" +
- "Company wages are decreased by 50%
" +
- "Corporation valuations are 99% lower and are therefore significantly less profitable
" +
- "Hacknet Node production is significantly decreased
" +
- "Crime and Infiltration are more lucrative
" +
- "Augmentations are twice as expensive
" +
- "Destroying this BitNode will give you Source-File 11, or if you already have this Source-File it will " +
- "upgrade its level up to a maximum of 3. This Source-File makes it so that company favor increases BOTH " +
- "the player's salary and reputation gain rate at that company by 1% per favor (rather than just the reputation gain). " +
- "This Source-File also increases the player's company salary and reputation gain multipliers by:
" +
- "Level 1: 24%
" +
- "Level 2: 36%
" +
- "Level 3: 42%");
-
- //Books: Frontera, Shiner
- BitNodes["BitNode12"] = new BitNode(12, "fOS", "COMING SOON"); //Unlocks the new game mode and the rest of the BitNodes
- BitNodes["BitNode13"] = new BitNode(13, "", "COMING SOON");
- BitNodes["BitNode14"] = new BitNode(14, "", "COMING SOON");
- BitNodes["BitNode15"] = new BitNode(15, "", "COMING SOON");
- BitNodes["BitNode16"] = new BitNode(16, "", "COMING SOON");
- BitNodes["BitNode17"] = new BitNode(17, "", "COMING SOON");
- BitNodes["BitNode18"] = new BitNode(18, "", "COMING SOON");
- BitNodes["BitNode19"] = new BitNode(19, "", "COMING SOON");
- BitNodes["BitNode20"] = new BitNode(20, "", "COMING SOON");
- BitNodes["BitNode21"] = new BitNode(21, "", "COMING SOON");
- BitNodes["BitNode22"] = new BitNode(22, "", "COMING SOON");
- BitNodes["BitNode23"] = new BitNode(23, "", "COMING SOON");
- BitNodes["BitNode24"] = new BitNode(24, "", "COMING SOON");
-}
-
-let BitNodeMultipliers = {
- HackingLevelMultiplier: 1,
-
- ServerMaxMoney: 1,
- ServerStartingMoney: 1,
- ServerGrowthRate: 1,
- ServerWeakenRate: 1,
- ServerStartingSecurity: 1,
-
- ManualHackMoney: 1,
- ScriptHackMoney: 1,
- CompanyWorkMoney: 1,
- CrimeMoney: 1,
- HacknetNodeMoney: 1,
-
- CompanyWorkExpGain: 1,
- ClassGymExpGain: 1,
- FactionWorkExpGain: 1,
- HackExpGain: 1,
- CrimeExpGain: 1,
-
- FactionWorkRepGain: 1,
- FactionPassiveRepGain: 1,
- RepToDonateToFaction: 1,
-
- AugmentationRepCost: 1,
- AugmentationMoneyCost: 1,
-
- InfiltrationMoney: 1,
- InfiltrationRep: 1,
-
- CorporationValuation: 1,
-}
-
-function initBitNodeMultipliers() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN == null) {
- _Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN = 1;
- }
- for (var mult in BitNodeMultipliers) {
- if (BitNodeMultipliers.hasOwnProperty(mult)) {
- BitNodeMultipliers[mult] = 1;
- }
- }
-
- switch (_Player_js__WEBPACK_IMPORTED_MODULE_0__["Player"].bitNodeN) {
- case 1: //Source Genesis (every multiplier is 1)
- break;
- case 2: //Rise of the Underworld
- BitNodeMultipliers.ServerMaxMoney = 0.2;
- BitNodeMultipliers.ServerStartingMoney = 0.4;
- BitNodeMultipliers.CrimeMoney = 3;
- BitNodeMultipliers.InfiltrationMoney = 3;
- BitNodeMultipliers.FactionWorkRepGain = 0.5;
- BitNodeMultipliers.FactionPassiveRepGain = 0;
- break;
- case 3: //Corporatocracy
- BitNodeMultipliers.RepToDonateToFaction = 0.5;
- BitNodeMultipliers.AugmentationRepCost = 3;
- BitNodeMultipliers.AugmentationMoneyCost = 3;
- BitNodeMultipliers.ServerMaxMoney = 0.25;
- BitNodeMultipliers.ServerStartingMoney = 0.25;
- BitNodeMultipliers.ServerGrowthRate = 0.20;
- BitNodeMultipliers.ScriptHackMoney = 0.25;
- BitNodeMultipliers.CompanyWorkMoney = 0.25;
- BitNodeMultipliers.CrimeMoney = 0.25;
- BitNodeMultipliers.HacknetNodeMoney = 0.25;
- break;
- case 4: //The Singularity
- BitNodeMultipliers.ServerMaxMoney = 0.15;
- BitNodeMultipliers.ServerStartingMoney = 0.75;
- BitNodeMultipliers.ScriptHackMoney = 0.2;
- BitNodeMultipliers.CompanyWorkMoney = 0.1;
- BitNodeMultipliers.CrimeMoney = 0.2;
- BitNodeMultipliers.HacknetNodeMoney = 0.05;
- BitNodeMultipliers.CompanyWorkExpGain = 0.5;
- BitNodeMultipliers.ClassGymExpGain = 0.5;
- BitNodeMultipliers.FactionWorkExpGain = 0.5;
- BitNodeMultipliers.HackExpGain = 0.4;
- BitNodeMultipliers.CrimeExpGain = 0.5;
- BitNodeMultipliers.FactionWorkRepGain = 0.75;
- break;
- case 5: //Artificial intelligence
- BitNodeMultipliers.ServerMaxMoney = 2;
- BitNodeMultipliers.ServerStartingSecurity = 2;
- BitNodeMultipliers.ServerStartingMoney = 0.5;
- BitNodeMultipliers.ScriptHackMoney = 0.15;
- BitNodeMultipliers.HacknetNodeMoney = 0.2;
- BitNodeMultipliers.CrimeMoney = 0.5;
- BitNodeMultipliers.InfiltrationRep = 1.5;
- BitNodeMultipliers.InfiltrationMoney = 1.5;
- BitNodeMultipliers.AugmentationMoneyCost = 2;
- BitNodeMultipliers.HackExpGain = 0.5;
- BitNodeMultipliers.CorporationValuation = 0.5;
- break;
- case 6: //Bladeburner
- BitNodeMultipliers.HackingLevelMultiplier = 0.5;
- BitNodeMultipliers.ServerMaxMoney = 0.5;
- BitNodeMultipliers.ServerStartingMoney = 0.5;
- BitNodeMultipliers.ServerStartingSecurity = 1.5;
- BitNodeMultipliers.ScriptHackMoney = 0.5;
- BitNodeMultipliers.CompanyWorkMoney = 0.5;
- BitNodeMultipliers.CrimeMoney = 0.5;
- BitNodeMultipliers.InfiltrationMoney = 0.5;
- BitNodeMultipliers.CorporationValuation = 0.2;
- BitNodeMultipliers.HacknetNodeMoney = 0.2;
- BitNodeMultipliers.FactionPassiveRepGain = 0;
- BitNodeMultipliers.HackExpGain = 0.25;
- break;
- case 8: //Ghost of Wall Street
- BitNodeMultipliers.ScriptHackMoney = 0;
- BitNodeMultipliers.ManualHackMoney = 0;
- BitNodeMultipliers.CompanyWorkMoney = 0;
- BitNodeMultipliers.CrimeMoney = 0;
- BitNodeMultipliers.HacknetNodeMoney = 0;
- BitNodeMultipliers.InfiltrationMoney = 0;
- BitNodeMultipliers.RepToDonateToFaction = 0;
- BitNodeMultipliers.CorporationValuation = 0;
- break;
- case 11: //The Big Crash
- BitNodeMultipliers.ServerMaxMoney = 0.1;
- BitNodeMultipliers.ServerStartingMoney = 0.1;
- BitNodeMultipliers.ServerGrowthRate = 0.5;
- BitNodeMultipliers.ServerWeakenRate = 2;
- BitNodeMultipliers.CrimeMoney = 3;
- BitNodeMultipliers.CompanyWorkMoney = 0.5;
- BitNodeMultipliers.HacknetNodeMoney = 0.1;
- BitNodeMultipliers.AugmentationMoneyCost = 2;
- BitNodeMultipliers.InfiltrationMoney = 2.5;
- BitNodeMultipliers.InfiltrationRep = 2.5;
- BitNodeMultipliers.CorporationValuation = 0.01;
- break;
- default:
- console.log("WARNING: Player.bitNodeN invalid");
- break;
- }
-}
-
-
-
-
-/***/ }),
-/* 16 */
-/*!****************************!*\
- !*** ./utils/IPAddress.js ***!
- \****************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRandomIp", function() { return createRandomIp; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ipExists", function() { return ipExists; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidIPAddress", function() { return isValidIPAddress; });
-/* harmony import */ var _src_Server_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/Server.js */ 10);
-
-/* Functions to deal with manipulating IP addresses*/
-
-//Generate a random IP address
-//Will not return an IP address that already exists in the AllServers array
-function createRandomIp() {
- var ip = createRandomByte(99) +'.' +
- createRandomByte(9) +'.' +
- createRandomByte(9) +'.' +
- createRandomByte(9);
-
- //If the Ip already exists, recurse to create a new one
- if (ipExists(ip)) {
- return createRandomIp();
- }
- return ip;
-}
-
-//Returns true if the IP already exists in one of the game's servers
-function ipExists(ip) {
- for (var property in _src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"]) {
- if (_src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"].hasOwnProperty(property)) {
- if (property == ip) {
- return true;
- }
- }
- }
- return false;
-}
-
-function createRandomByte(n=9) {
- return Math.round(Math.random()*n);
-}
-
-function isValidIPAddress(ipaddress) {
- if (/^(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))
- {
- return true;
- }
- return false;
-}
-
-
-
-
-/***/ }),
-/* 17 */
-/*!*********************************!*\
- !*** ./src/SpecialServerIps.js ***!
- \*********************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerNames", function() { return SpecialServerNames; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerIps", function() { return SpecialServerIps; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerIpsMap", function() { return SpecialServerIpsMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSpecialServerIps", function() { return loadSpecialServerIps; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeSpecialServerIps", function() { return prestigeSpecialServerIps; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSpecialServerIps", function() { return initSpecialServerIps; });
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-
-
-/* Holds IP of Special Servers */
-let SpecialServerNames = {
- FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
- CyberSecServer: "CyberSec Server",
- NiteSecServer: "NiteSec Server",
- TheBlackHandServer: "The Black Hand Server",
- BitRunnersServer: "BitRunners Server",
- TheDarkArmyServer: "The Dark Army Server",
- DaedalusServer: "Daedalus Server",
- WorldDaemon: "w0r1d_d43m0n",
-}
-function SpecialServerIpsMap() {}
-
-SpecialServerIpsMap.prototype.addIp = function(name, ip) {
- this[name] = ip;
-}
-
-SpecialServerIpsMap.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Generic_toJSON"])("SpecialServerIpsMap", this);
-}
-
-SpecialServerIpsMap.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Generic_fromJSON"])(SpecialServerIpsMap, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Reviver"].constructors.SpecialServerIpsMap = SpecialServerIpsMap;
-
-let SpecialServerIps = new SpecialServerIpsMap();
-
-function prestigeSpecialServerIps() {
- for (var member in SpecialServerIps) {
- delete SpecialServerIps[member];
- }
- SpecialServerIps = null;
- SpecialServerIps = new SpecialServerIpsMap();
-}
-
-function loadSpecialServerIps(saveString) {
- SpecialServerIps = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Reviver"]);
-}
-
-function initSpecialServerIps() {
- SpecialServerIps = new SpecialServerIpsMap();
-}
-
-
-
-
-/***/ }),
-/* 18 */
/*!*************************!*\
!*** ./src/Terminal.js ***!
\*************************/
@@ -12760,29 +11060,29 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; });
-/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30);
+/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 25);
/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14);
-/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 35);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 17);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 82);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 33);
-/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 71);
-/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25);
-/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 29);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 6);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 67);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 49);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 45);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 26);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
-/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 43);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 41);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 58);
/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 51);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 47);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 120);
/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__);
/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 119);
@@ -14817,10 +13117,354 @@ let Terminal = {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
/***/ }),
-/* 19 */
+/* 16 */
+/*!*********************************!*\
+ !*** ./src/SpecialServerIps.js ***!
+ \*********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerNames", function() { return SpecialServerNames; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerIps", function() { return SpecialServerIps; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpecialServerIpsMap", function() { return SpecialServerIpsMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSpecialServerIps", function() { return loadSpecialServerIps; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeSpecialServerIps", function() { return prestigeSpecialServerIps; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSpecialServerIps", function() { return initSpecialServerIps; });
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+
+
+/* Holds IP of Special Servers */
+let SpecialServerNames = {
+ FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
+ CyberSecServer: "CyberSec Server",
+ NiteSecServer: "NiteSec Server",
+ TheBlackHandServer: "The Black Hand Server",
+ BitRunnersServer: "BitRunners Server",
+ TheDarkArmyServer: "The Dark Army Server",
+ DaedalusServer: "Daedalus Server",
+ WorldDaemon: "w0r1d_d43m0n",
+}
+function SpecialServerIpsMap() {}
+
+SpecialServerIpsMap.prototype.addIp = function(name, ip) {
+ this[name] = ip;
+}
+
+SpecialServerIpsMap.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Generic_toJSON"])("SpecialServerIpsMap", this);
+}
+
+SpecialServerIpsMap.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Generic_fromJSON"])(SpecialServerIpsMap, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Reviver"].constructors.SpecialServerIpsMap = SpecialServerIpsMap;
+
+let SpecialServerIps = new SpecialServerIpsMap();
+
+function prestigeSpecialServerIps() {
+ for (var member in SpecialServerIps) {
+ delete SpecialServerIps[member];
+ }
+ SpecialServerIps = null;
+ SpecialServerIps = new SpecialServerIpsMap();
+}
+
+function loadSpecialServerIps(saveString) {
+ SpecialServerIps = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_0__["Reviver"]);
+}
+
+function initSpecialServerIps() {
+ SpecialServerIps = new SpecialServerIpsMap();
+}
+
+
+
+
+/***/ }),
+/* 17 */
+/*!******************************!*\
+ !*** ./src/CreateProgram.js ***!
+ \******************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Programs", function() { return Programs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayCreateProgramContent", function() { return displayCreateProgramContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNumAvailableCreateProgram", function() { return getNumAvailableCreateProgram; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initCreateProgramButtons", function() { return initCreateProgramButtons; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+/* Create programs */
+let Programs = {
+ NukeProgram: "NUKE.exe",
+ BruteSSHProgram: "BruteSSH.exe",
+ FTPCrackProgram: "FTPCrack.exe",
+ RelaySMTPProgram: "relaySMTP.exe",
+ HTTPWormProgram: "HTTPWorm.exe",
+ SQLInjectProgram: "SQLInject.exe",
+ DeepscanV1: "DeepscanV1.exe",
+ DeepscanV2: "DeepscanV2.exe",
+ ServerProfiler: "ServerProfiler.exe",
+ AutoLink: "AutoLink.exe",
+ Flight: "fl1ght.exe",
+ BitFlume: "b1t_flum3.exe"
+};
+
+var nukeALink, bruteSshALink, ftpCrackALink, relaySmtpALink, httpWormALink, sqlInjectALink,
+ deepscanv1ALink, deepscanv2ALink, servProfilerALink, autolinkALink, bitFlumeALink;
+function displayCreateProgramContent() {
+ nukeALink.style.display = "none";
+ bruteSshALink.style.display = "none";
+ ftpCrackALink.style.display = "none";
+ relaySmtpALink.style.display = "none";
+ httpWormALink.style.display = "none";
+ sqlInjectALink.style.display = "none";
+ deepscanv1ALink.style.display = "none";
+ deepscanv2ALink.style.display = "none";
+ servProfilerALink.style.display = "none";
+ autolinkALink.style.display = "none";
+ bitFlumeALink.style.display = "none";
+
+ //NUKE.exe (in case you delete it lol)
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.NukeProgram) == -1) {
+ nukeALink.style.display = "inline-block";
+ }
+ //BruteSSH
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.BruteSSHProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 50) {
+ bruteSshALink.style.display = "inline-block";
+ }
+ //FTPCrack
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.FTPCrackProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 100) {
+ ftpCrackALink.style.display = "inline-block";
+ }
+ //relaySMTP
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 250) {
+ relaySmtpALink.style.display = "inline-block";
+ }
+ //HTTPWorm
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.HTTPWormProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 500) {
+ httpWormALink.style.display = "inline-block";
+ }
+ //SQLInject
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.SQLInjectProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 750) {
+ sqlInjectALink.style.display = "inline-block";
+ }
+ //Deepscan V1 and V2
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV1) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ deepscanv1ALink.style.display = "inline-block";
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV2) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 400) {
+ deepscanv2ALink.style.display = "inline-block";
+ }
+ //Server profiler
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.ServerProfiler) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ servProfilerALink.style.display = "inline-block";
+ }
+ //Auto Link
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.AutoLink) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 25) {
+ autolinkALink.style.display = "inline-block";
+ }
+ //Bit Flume
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.BitFlume) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].sourceFiles.length > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 5) {
+ bitFlumeALink.style.display = "inline-block";
+ }
+}
+
+//Returns the number of programs that are currently available to be created
+function getNumAvailableCreateProgram() {
+ var count = 0;
+ //PortHack.exe (in case you delete it lol)
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.NukeProgram) == -1) {
+ ++count;
+ }
+ //BruteSSH
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.BruteSSHProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 50) {
+ ++count;
+ }
+ //FTPCrack
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.FTPCrackProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 100) {
+ ++count;
+ }
+ //relaySMTP
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 250) {
+ ++count;
+ }
+ //HTTPWorm
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.HTTPWormProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 500) {
+ ++count;
+ }
+ //SQLInject
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.SQLInjectProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 750) {
+ ++count;
+ }
+ //Deepscan V1 and V2
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV1) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ ++count;
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV2) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 400) {
+ ++count;
+ }
+ //Server profiler
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.ServerProfiler) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ ++count;
+ }
+ //Auto link
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.AutoLink) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 25) {
+ ++count;
+ }
+ //Bit Flume
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.BitFlume) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].sourceFiles.length > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 5) {
+ ++count;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable === false && count > 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable = true;
+ document.getElementById("create-program-tab").style.display = "list-item";
+ document.getElementById("hacking-menu-header").click();
+ document.getElementById("hacking-menu-header").click();
+ }
+ return count;
+}
+
+function initCreateProgramButtons() {
+ var createProgramList = document.getElementById("create-program-list");
+ nukeALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-nuke", innerText:Programs.NukeProgram,
+ tooltip:"This virus is used to gain root access to a machine if enough ports are opened.",
+ });
+ createProgramList.appendChild(nukeALink);
+
+ bruteSshALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-brutessh", innerText:Programs.BruteSSHProgram,
+ tooltip:"This program executes a brute force attack that opens SSH ports"
+ });
+ createProgramList.appendChild(bruteSshALink);
+
+ ftpCrackALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-ftpcrack", innerText:Programs.FTPCrackProgram,
+ tooltip:"This program cracks open FTP ports"
+ });
+ createProgramList.appendChild(ftpCrackALink);
+
+ relaySmtpALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-relaysmtp", innerText:Programs.RelaySMTPProgram,
+ tooltip:"This program opens SMTP ports by redirecting data"
+ }) ;
+ createProgramList.appendChild(relaySmtpALink);
+
+ httpWormALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-httpworm", innerText:Programs.HTTPWormProgram,
+ tooltip:"This virus opens up HTTP ports"
+ });
+ createProgramList.appendChild(httpWormALink);
+
+ sqlInjectALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-sqlinject", innerText:Programs.SQLInjectProgram,
+ tooltip:"This virus opens SQL ports"
+ });
+ createProgramList.appendChild(sqlInjectALink);
+
+ deepscanv1ALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-deepscanv1", innerText:Programs.DeepscanV1,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 5"
+ });
+ createProgramList.appendChild(deepscanv1ALink);
+
+ deepscanv2ALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-deepscanv2", innerText:Programs.DeepscanV2,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 10"
+ });
+ createProgramList.appendChild(deepscanv2ALink);
+
+ servProfilerALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-serverprofiler", innerText:Programs.ServerProfiler,
+ tooltip:"This program is used to display hacking and Netscript-related information about servers"
+ });
+ createProgramList.appendChild(servProfilerALink);
+
+ bitFlumeALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-bitflume", innerText:Programs.BitFlume,
+ tooltip:"This program creates a portal to the BitNode Nexus (allows you to restart and switch BitNodes)"
+ });
+ createProgramList.appendChild(bitFlumeALink);
+
+ autolinkALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-autolink", innerText:"AutoLink.exe",
+ tooltip:"This program allows you to directly connect to other servers through the 'scan-analyze' command"
+ });
+ createProgramList.appendChild(autolinkALink);
+
+ nukeALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
+ return false;
+ });
+ bruteSshALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
+ return false;
+ });
+ ftpCrackALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour, 100);
+ return false;
+ });
+ relaySmtpALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours, 250);
+ return false;
+ });
+ httpWormALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer4Hours, 500);
+ return false;
+ });
+ sqlInjectALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer8Hours, 750);
+ return false;
+ });
+ deepscanv1ALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
+ return false;
+ });
+ deepscanv2ALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours, 400);
+ return false;
+ });
+ servProfilerALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour, 75);
+ return false;
+ });
+ autolinkALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
+ return false;
+ });
+ bitFlumeALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.BitFlume, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes / 5, 5);
+ return false;
+ });
+}
+
+
+
+
+/***/ }),
+/* 18 */
/*!******************************!*\
!*** ./src/Augmentations.js ***!
\******************************/
@@ -14837,21 +13481,21 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "augmentationExists", function() { return augmentationExists; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Augmentation", function() { return Augmentation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayAugmentationsContent", function() { return displayAugmentationsContent; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 31);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 26);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Prestige.js */ 57);
-/* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SaveObject.js */ 47);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Script.js */ 26);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./SourceFile.js */ 44);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
+/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Prestige.js */ 53);
+/* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SaveObject.js */ 43);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./SourceFile.js */ 37);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
@@ -17460,2052 +16104,7 @@ function displaySourceFiles(listElement, sourceFiles) {
/***/ }),
-/* 20 */
-/*!***********************!*\
- !*** ./src/Crimes.js ***!
- \***********************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitShopliftCrime", function() { return commitShopliftCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitRobStoreCrime", function() { return commitRobStoreCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitMugCrime", function() { return commitMugCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitLarcenyCrime", function() { return commitLarcenyCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitDealDrugsCrime", function() { return commitDealDrugsCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitBondForgeryCrime", function() { return commitBondForgeryCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitTraffickArmsCrime", function() { return commitTraffickArmsCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitHomicideCrime", function() { return commitHomicideCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitGrandTheftAutoCrime", function() { return commitGrandTheftAutoCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitKidnapCrime", function() { return commitKidnapCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitAssassinationCrime", function() { return commitAssassinationCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitHeistCrime", function() { return commitHeistCrime; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeSuccess", function() { return determineCrimeSuccess; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceShoplift", function() { return determineCrimeChanceShoplift; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceRobStore", function() { return determineCrimeChanceRobStore; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceMug", function() { return determineCrimeChanceMug; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceLarceny", function() { return determineCrimeChanceLarceny; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceDealDrugs", function() { return determineCrimeChanceDealDrugs; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceBondForgery", function() { return determineCrimeChanceBondForgery; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceTraffickArms", function() { return determineCrimeChanceTraffickArms; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceHomicide", function() { return determineCrimeChanceHomicide; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceGrandTheftAuto", function() { return determineCrimeChanceGrandTheftAuto; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceKidnap", function() { return determineCrimeChanceKidnap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceAssassination", function() { return determineCrimeChanceAssassination; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceHeist", function() { return determineCrimeChanceHeist; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-
-
-
-
-/* Crimes.js */
-function commitShopliftCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift;
- var time = 2000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 0, 0, 2/div, 2/div, 0, 15000/div, time, singParams); //$7500/s, 1 exp/s
- return time;
-}
-
-function commitRobStoreCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore;
- var time = 60000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(30/div, 0, 0, 45/div, 45/div, 0, 400000/div, time, singParams); //$6666,6/2, 0.5exp/s, 0.75exp/s
- return time;
-}
-
-function commitMugCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug;
- var time = 4000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 3/div, 3/div, 3/div, 3/div, 0, 36000/div, time, singParams); //$9000/s, .66 exp/s
- return time;
-}
-
-function commitLarcenyCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny;
- var time = 90000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(45/div, 0, 0, 60/div, 60/div, 0, 800000/div, time, singParams) // $8888.88/s, .5 exp/s, .66 exp/s
- return time;
-}
-
-function commitDealDrugsCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs;
- var time = 10000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 0, 0, 5/div, 5/div, 10/div, 120000/div, time, singParams); //$12000/s, .5 exp/s, 1 exp/s
- return time;
-}
-
-function commitBondForgeryCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery;
- var time = 300000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(100/div, 0, 0, 150/div, 0, 15/div, 4500000/div, time, singParams); //$15000/s, 0.33 hack exp/s, .5 dex exp/s, .05 cha exp
- return time;
-}
-
-function commitTraffickArmsCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms;
- var time = 40000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 20/div, 20/div, 20/div, 20/div, 40/div, 600000/div, time, singParams); //$15000/s, .5 combat exp/s, 1 cha exp/s
- return time;
-}
-
-function commitHomicideCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide;
- var time = 3000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 2/div, 2/div, 2/div, 2/div, 0, 45000/div, time, singParams); //$15000/s, 0.66 combat exp/s
- return time;
-}
-
-function commitGrandTheftAutoCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto;
- var time = 80000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 20/div, 20/div, 20/div, 80/div, 40/div, 1600000/div, time, singParams); //$20000/s, .25 exp/s, 1 exp/s, .5 exp/s
- return time;
-}
-
-function commitKidnapCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap;
- var time = 120000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 80/div, 80/div, 80/div, 80/div, 80/div, 3600000/div, time, singParams); //$30000/s. .66 exp/s
- return time;
-}
-
-function commitAssassinationCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination;
- var time = 300000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 300/div, 300/div, 300/div, 300/div, 0, 12000000/div, time, singParams); //$40000/s, 1 exp/s
- return time;
-}
-
-function commitHeistCrime(div=1, singParams=null) {
- if (div <= 0) {div = 1;}
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist;
- var time = 600000;
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(450/div, 450/div, 450/div, 450/div, 450/div, 450/div, 120000000/div, time, singParams); //$200000/s, .75exp/s
- return time;
-}
-
-function determineCrimeSuccess(crime, moneyGained) {
- var chance = 0;
- switch (crime) {
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift:
- chance = determineCrimeChanceShoplift();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore:
- chance = determineCrimeChanceRobStore();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug:
- chance = determineCrimeChanceMug();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny:
- chance = determineCrimeChanceLarceny();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs:
- chance = determineCrimeChanceDealDrugs();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery:
- chance = determineCrimeChanceBondForgery();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms:
- chance = determineCrimeChanceTraffickArms();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide:
- chance = determineCrimeChanceHomicide();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto:
- chance = determineCrimeChanceGrandTheftAuto();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap:
- chance = determineCrimeChanceKidnap();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination:
- chance = determineCrimeChanceAssassination();
- break;
- case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist:
- chance = determineCrimeChanceHeist();
- break;
- default:
- console.log(crime);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
- return;
- }
-
- if (Math.random() <= chance) {
- //Success
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].gainMoney(moneyGained);
- return true;
- } else {
- //Failure
- return false;
- }
-}
-
-let intWgt = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeWeight;
-let maxLvl = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
-
-function determineCrimeChanceShoplift() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 20;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceRobStore() {
- var chance = (0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
- 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- 1 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 5;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceMug() {
- var chance = (1.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
- 1.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 5;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceLarceny() {
- var chance = (0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 3;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceDealDrugs() {
- var chance = (3*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
- 2*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceBondForgery() {
- var chance = (0.1*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
- 2.5*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- 2*intWgt*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceTraffickArms() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 2;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceHomicide() {
- var chance = (2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
- 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceGrandTheftAuto() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- 4 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 8;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceKidnap() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 5;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceAssassination() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 8;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-function determineCrimeChanceHeist() {
- var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
- _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
- intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 18;
- chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
- return Math.min(chance, 1);
-}
-
-
-
-
-/***/ }),
-/* 21 */
-/*!********************************!*\
- !*** ./src/NetscriptWorker.js ***!
- \********************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerScript", function() { return WorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "workerScripts", function() { return workerScripts; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPorts", function() { return NetscriptPorts; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptsLoop", function() { return runScriptsLoop; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killWorkerScript", function() { return killWorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addWorkerScript", function() { return addWorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateOnlineScriptTimes", function() { return updateOnlineScriptTimes; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeWorkerScripts", function() { return prestigeWorkerScripts; });
-/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 41);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 6);
-/* harmony import */ var _NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptJSEvaluator.js */ 63);
-/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptPort.js */ 46);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-function WorkerScript(runningScriptObj) {
- this.name = runningScriptObj.filename;
- this.running = false;
- this.serverIp = null;
- this.code = runningScriptObj.scriptRef.code;
- this.env = new _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__["Environment"](this);
- this.env.set("args", runningScriptObj.args.slice());
- this.output = "";
- this.ramUsage = 0;
- this.scriptRef = runningScriptObj;
- this.errorMessage = "";
- this.args = runningScriptObj.args.slice();
- this.delay = null;
- this.fnWorker = null; //Workerscript for a function call
- this.checkingRam = false;
- this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM
- this.disableLogs = {}; //Stores names of fns that should have logs disabled
-}
-
-//Returns the server on which the workerScript is running
-WorkerScript.prototype.getServer = function() {
- return _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][this.serverIp];
-}
-
-//Returns the Script object for the underlying script
-WorkerScript.prototype.getScript = function() {
- let server = this.getServer();
- for (var i = 0; i < server.scripts.length; ++i) {
- if (server.scripts[i].filename === this.name) {
- return server.scripts[i];
- }
- }
- console.log("ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong");
- return null;
-}
-
-//Array containing all scripts that are running across all servers, to easily run them all
-let workerScripts = [];
-
-var NetscriptPorts = [];
-for (var i = 0; i < _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NumNetscriptPorts; ++i) {
- NetscriptPorts.push(new _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__["NetscriptPort"]());
-}
-
-function prestigeWorkerScripts() {
- for (var i = 0; i < workerScripts.length; ++i) {
- Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
- workerScripts[i].env.stopFlag = true;
- }
- Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(5000); //Force UI to update
- workerScripts.length = 0;
-}
-
-// JS script promises need a little massaging to have the same guarantees as netscript
-// promises. This does said massaging and kicks the script off. It returns a promise
-// that resolves or rejects when the corresponding worker script is done.
-function startJsScript(workerScript) {
- workerScript.running = true;
-
- // The name of the currently running netscript function, to prevent concurrent
- // calls to hack, grow, etc.
- let runningFn = null;
-
- // We need to go through the environment and wrap each function in such a way that it
- // can be called at most once at a time. This will prevent situations where multiple
- // hack promises are outstanding, for example.
- function wrap(propName, f) {
- // This function unfortunately cannot be an async function, because we don't
- // know if the original one was, and there's no way to tell.
- return function (...args) {
- // Wrap every netscript function with a check for the stop flag.
- // This prevents cases where we never stop because we are only calling
- // netscript functions that don't check this.
- // This is not a problem for legacy Netscript because it also checks the
- // stop flag in the evaluator.
- if (workerScript.env.stopFlag) {throw workerScript;}
-
- if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep.
-
- const msg = "Concurrent calls to Netscript functions not allowed! " +
- "Did you forget to await hack(), grow(), or some other " +
- "promise-returning function? (Currently running: %s tried to run: %s)"
- if (runningFn) {
- workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, runningFn, propName), null)
- throw workerScript;
- }
- runningFn = propName;
- let result = f(...args);
- if (result && result.finally !== undefined) {
- return result.finally(function () {
- runningFn = null;
- });
- } else {
- runningFn = null;
- return result;
- }
- }
- };
-
- for (let prop in workerScript.env.vars) {
- if (typeof workerScript.env.vars[prop] !== "function") continue;
- workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
- }
-
- // Note: the environment that we pass to the JS script only needs to contain the functions visible
- // to that script, which env.vars does at this point.
- return Object(_NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__["executeJSScript"])(workerScript.getServer().scripts,
- workerScript).then(function (mainReturnValue) {
- if (mainReturnValue === undefined) return workerScript;
- return [mainReturnValue, workerScript];
- }).catch(e => {
- if (e instanceof Error) {
- workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(
- workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || ""));
- throw workerScript;
- } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(e)) {
- workerScript.errorMessage = e;
- throw workerScript;
- }
- throw e; // Don't know what to do with it, let's rethrow.
- });
-}
-
-//Loop through workerScripts and run every script that is not currently running
-function runScriptsLoop() {
- var scriptDeleted = false;
-
- //Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
- for (var i = workerScripts.length - 1; i >= 0; i--) {
- if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
- scriptDeleted = true;
- //Delete script from the runningScripts array on its host serverIp
- var ip = workerScripts[i].serverIp;
- var name = workerScripts[i].name;
-
- //Free RAM
- _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed -= workerScripts[i].ramUsage;
-
- //Delete script from Active Scripts
- Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
-
- for (var j = 0; j < _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.length; j++) {
- if (_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].filename == name &&
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].args, workerScripts[i].args)) {
- _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.splice(j, 1);
- break;
- }
- }
-
- //Delete script from workerScripts
- workerScripts.splice(i, 1);
- }
- }
- if (scriptDeleted) {Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])();} //Force Update
-
-
- //Run any scripts that haven't been started
- for (var i = 0; i < workerScripts.length; i++) {
- //If it isn't running, start the script
- if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
- let p = null; // p is the script's result promise.
- if (workerScripts[i].name.endsWith(".js") || workerScripts[i].name.endsWith(".ns")) {
- p = startJsScript(workerScripts[i]);
- } else {
- try {
- var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__["parse"])(workerScripts[i].code, {sourceType:"module"});
- //console.log(ast);
- } catch (e) {
- console.log("Error parsing script: " + workerScripts[i].name);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Syntax ERROR in " + workerScripts[i].name + ":
" + e);
- workerScripts[i].env.stopFlag = true;
- continue;
- }
- workerScripts[i].running = true;
- p = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["evaluate"])(ast, workerScripts[i]);
- }
-
- //Once the code finishes (either resolved or rejected, doesnt matter), set its
- //running status to false
- p.then(function(w) {
- console.log("Stopping script " + w.name + " because it finished running naturally");
- w.running = false;
- w.env.stopFlag = true;
- w.scriptRef.log("Script finished running");
- }).catch(function(w) {
- if (w instanceof Error) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else if (w.constructor === Array && w.length === 2 && w[0] === "RETURNSTATEMENT") {
- //Script ends with a return statement
- console.log("Script returning with value: " + w[1]);
- //TODO maybe do something with this in the future
- return;
- } else if (w instanceof WorkerScript) {
- if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w.errorMessage)) {
- var errorTextArray = w.errorMessage.split("|");
- if (errorTextArray.length != 4) {
- console.log("ERROR: Something wrong with Error text in evaluator...");
- console.log("Error text: " + errorText);
- return;
- }
- var serverIp = errorTextArray[1];
- var scriptName = errorTextArray[2];
- var errorMsg = errorTextArray[3];
-
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime error:
Server Ip: " + serverIp +
- "
Script name: " + scriptName +
- "
Args:" + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(w.args) + "
" + errorMsg);
- w.scriptRef.log("Script crashed with runtime error");
- } else {
- w.scriptRef.log("Script killed");
- }
- w.running = false;
- w.env.stopFlag = true;
-
- } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
- console.log(w);
- }
- });
- }
- }
-
- setTimeout(runScriptsLoop, 6000);
-}
-
-//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
-//all of its promises recursively, and when it does so it will no longer be running.
-//The runScriptsLoop() will then delete the script from worker scripts
-function killWorkerScript(runningScriptObj, serverIp) {
- for (var i = 0; i < workerScripts.length; i++) {
- if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
- workerScripts[i].env.stopFlag = true;
- Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(workerScripts[i]);
- //Recursively kill all functions
- var curr = workerScripts[i];
- while (curr.fnWorker) {
- curr.fnWorker.env.stopFlag = true;
- Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(curr.fnWorker);
- curr = curr.fnWorker;
- }
- return true;
- }
- }
- return false;
-}
-
-//Queues a script to be run
-function addWorkerScript(runningScriptObj, server) {
- var filename = runningScriptObj.filename;
-
- //Update server's ram usage
- var threads = 1;
- if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
- threads = runningScriptObj.threads;
- } else {
- runningScriptObj.threads = 1;
- }
- var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
- * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
- var ramAvailable = server.maxRam - server.ramUsed;
- if (ramUsage > ramAvailable) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
- "the game and the script's RAM usage increased (either because of an update to the game or " +
- "your changes to the script.)");
- return;
- }
- server.ramUsed += ramUsage;
-
- //Create the WorkerScript
- var s = new WorkerScript(runningScriptObj);
- s.serverIp = server.ip;
- s.ramUsage = ramUsage;
-
- //Add the WorkerScript to the Active Scripts list
- Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["addActiveScriptsItem"])(s);
-
- //Add the WorkerScript
- workerScripts.push(s);
- return;
-}
-
-//Updates the online running time stat of all running scripts
-function updateOnlineScriptTimes(numCycles = 1) {
- var time = (numCycles * _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
- for (var i = 0; i < workerScripts.length; ++i) {
- workerScripts[i].scriptRef.onlineRunningTime += time;
- }
-}
-
-
-
-
-/***/ }),
-/* 22 */
-/*!****************************!*\
- !*** ./src/StockMarket.js ***!
- \****************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockMarket", function() { return StockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockSymbols", function() { return StockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolToStockMap", function() { return SymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockSymbols", function() { return initStockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockMarket", function() { return initStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSymbolToStockMap", function() { return initSymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stockMarketCycle", function() { return stockMarketCycle; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyStock", function() { return buyStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellStock", function() { return sellStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shortStock", function() { return shortStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellShort", function() { return sellShort; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPrices", function() { return updateStockPrices; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayStockMarketContent", function() { return displayStockMarketContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockTicker", function() { return updateStockTicker; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPlayerPosition", function() { return updateStockPlayerPosition; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadStockMarket", function() { return loadStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setStockMarketContentCreated", function() { return setStockMarketContentCreated; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placeOrder", function() { return placeOrder; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOrder", function() { return cancelOrder; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Order", function() { return Order; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OrderTypes", function() { return OrderTypes; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionTypes", function() { return PositionTypes; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 31);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! numeral/min/numeral.min */ 13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-let StockPriceCap = 1e9; //Put a limit on how high a price can go
-
-function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
- this.symbol = symbol;
- this.name = name;
- this.price = initPrice;
-
- this.playerShares = 0;
- this.playerAvgPx = 0;
- this.playerShortShares = 0;
- this.playerAvgShortPx = 0;
- this.mv = mv;
- this.b = b;
- this.otlkMag = otlkMag;
-
- this.posTxtEl = null;
-}
-
-Stock.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Stock", this);
-}
-
-Stock.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Stock, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Stock = Stock;
-
-var OrderTypes = {
- LimitBuy: "Limit Buy Order",
- LimitSell: "Limit Sell Order",
- StopBuy: "Stop Buy Order",
- StopSell: "Stop Sell Order"
-}
-
-var PositionTypes = {
- Long: "L",
- Short: "S"
-}
-
-function placeOrder(stock, shares, price, type, position, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- var order = new Order(stock, shares, price, type, position);
- if (isNaN(shares) || isNaN(price)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- }
- return false;
- }
- if (StockMarket["Orders"] == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- }
- StockMarket["Orders"][stock.symbol].push(order);
- //Process to see if it should be executed immediately
- processOrders(order.stock, order.type, order.pos);
- updateStockOrderList(order.stock);
- return true;
-}
-
-//Returns true if successfully cancels an order, false otherwise
-function cancelOrder(params, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (StockMarket["Orders"] == null) {return false;}
- if (params.order && params.order instanceof Order) {
- var order = params.order;
- //An 'Order' object is passed in
- var stockOrders = StockMarket["Orders"][order.stock.symbol];
- for (var i = 0; i < stockOrders.length; ++i) {
- if (order == stockOrders[i]) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- return true;
- }
- }
- return false;
- } else if (params.stock && params.shares && params.price && params.type &&
- params.pos && params.stock instanceof Stock) {
- //Order properties are passed in. Need to look for the order
- var stockOrders = StockMarket["Orders"][params.stock.symbol];
- var orderTxt = params.stock.symbol + " - " + params.shares + " @ " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(params.price).format('$0.000a');
- for (var i = 0; i < stockOrders.length; ++i) {
- var order = stockOrders[i];
- if (params.shares === order.shares &&
- params.price === order.price &&
- params.type === order.type &&
- params.pos === order.pos) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- if (tixApi) {
- workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt);
- }
- return true;
- }
- }
- if (tixApi) {
- workerScript.scriptRef.log("Failed to cancel order: " + orderTxt);
- }
- return false;
- }
- return false;
-}
-
-function executeOrder(order) {
- var stock = order.stock;
- var orderBook = StockMarket["Orders"];
- var stockOrders = orderBook[stock.symbol];
- var res = true;
- console.log("Executing the following order:");
- console.log(order);
- switch (order.type) {
- case OrderTypes.LimitBuy:
- case OrderTypes.StopBuy:
- if (order.pos === PositionTypes.Long) {
- res = buyStock(order.stock, order.shares) && res;
- } else if (order.pos === PositionTypes.Short) {
- res = shortStock(order.stock, order.shares) && res;
- }
- break;
- case OrderTypes.LimitSell:
- case OrderTypes.StopSell:
- if (order.pos === PositionTypes.Long) {
- res = sellStock(order.stock, order.shares) && res;
- } else if (order.pos === PositionTypes.Short) {
- res = sellShort(order.stock, order.shares) && res;
- }
- break;
- }
- if (res) {
- //Remove order from order book
- for (var i = 0; i < stockOrders.length; ++i) {
- if (order == stockOrders[i]) {
- stockOrders.splice(i, 1);
- updateStockOrderList(order.stock);
- return;
- }
- }
- console.log("ERROR: Could not find the following Order in Order Book: ");
- console.log(order);
- } else {
- console.log("Order failed to execute");
- }
-}
-
-function Order(stock, shares, price, type, position) {
- this.stock = stock;
- this.shares = shares;
- this.price = price;
- this.type = type;
- this.pos = position;
-}
-
-Order.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Order", this);
-}
-
-Order.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Order, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Order = Order;
-
-let StockMarket = {} //Full name to stock object
-let StockSymbols = {} //Full name to symbol
-let SymbolToStockMap = {}; //Symbol to Stock object
-
-function loadStockMarket(saveString) {
- if (saveString === "") {
- StockMarket = {};
- } else {
- StockMarket = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
- }
-}
-
-function initStockSymbols() {
- //Stocks for companies at which you can work
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
- StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff] = "FNS";
-
- //Stocks for other companies
- StockSymbols["Sigma Cosmetics"] = "SGC";
- StockSymbols["Joes Guns"] = "JGN";
- StockSymbols["Catalyst Ventures"] = "CTYS";
- StockSymbols["Microdyne Technologies"] = "MDYN";
- StockSymbols["Titan Laboratories"] = "TITN";
-}
-
-function initStockMarket() {
- for (var stk in StockMarket) {
- if (StockMarket.hasOwnProperty(stk)) {
- delete StockMarket[stk];
- }
- }
-
- var ecorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
- var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[ecorp] = ecorpStk;
-
- var megacorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
- var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(25000, 33000));
- StockMarket[megacorp] = megacorpStk;
-
- var blade = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
- var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 22000));
- StockMarket[blade] = bladeStk;
-
- var clarke = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
- var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
- StockMarket[clarke] = clarkeStk;
-
- var omnitek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
- var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(35000, 40000));
- StockMarket[omnitek] = omnitekStk;
-
- var foursigma = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
- var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(60000, 70000));
- StockMarket[foursigma] = foursigmaStk;
-
- var kuaigong = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
- var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 24000));
- StockMarket[kuaigong] = kuaigongStk;
-
- var fulcrum = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
- var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(30000, 35000));
- StockMarket[fulcrum] = fulcrumStk;
-
- var storm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
- var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(21000, 24000));
- StockMarket[storm] = stormStk;
-
- var defcomm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
- var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
- StockMarket[defcomm] = defcommStk;
-
- var helios = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
- var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(12000, 16000));
- StockMarket[helios] = heliosStk;
-
- var vitalife = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
- var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 12000));
- StockMarket[vitalife] = vitalifeStk;
-
- var icarus = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
- var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(16000, 20000));
- StockMarket[icarus] = icarusStk;
-
- var universalenergy = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
- var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[universalenergy] = universalenergyStk;
-
- var aerocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
- var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
- StockMarket[aerocorp] = aerocorpStk;
-
- var omnia = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
- var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(9000, 12000));
- StockMarket[omnia] = omniaStk;
-
- var solaris = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
- var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[solaris] = solarisStk;
-
- var globalpharm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
- var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[globalpharm] = globalpharmStk;
-
- var nova = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
- var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
- StockMarket[nova] = novaStk;
-
- var watchdog = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
- var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[watchdog] = watchdogStk;
-
- var lexocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
- var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[lexocorp] = lexocorpStk;
-
- var rho = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
- var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
- StockMarket[rho] = rhoStk;
-
- var alpha = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
- var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
- StockMarket[alpha] = alphaStk;
-
- var syscore = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
- var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(4000, 7000))
- StockMarket[syscore] = syscoreStk;
-
- var computek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
- var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 5000));
- StockMarket[computek] = computekStk;
-
- var netlink = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
- var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 4000));
- StockMarket[netlink] = netlinkStk;
-
- var omega = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
- var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
- StockMarket[omega] = omegaStk;
-
- var fns = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
- var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(1000, 4000));
- StockMarket[fns] = fnsStk;
-
- var sigmacosm = "Sigma Cosmetics";
- var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 3000));
- StockMarket[sigmacosm] = sigmacosmStk;
-
- var joesguns = "Joes Guns";
- var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
- StockMarket[joesguns] = joesgunsStk;
-
- var catalyst = "Catalyst Ventures";
- var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
- StockMarket[catalyst] = catalystStk;
-
- var microdyne = "Microdyne Technologies";
- var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
- StockMarket[microdyne] = microdyneStk;
-
- var titanlabs = "Titan Laboratories";
- var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
- StockMarket[titanlabs] = titanlabsStk;
-
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
-}
-
-function initSymbolToStockMap() {
- for (var name in StockSymbols) {
- if (StockSymbols.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (stock == null) {
- console.log("ERROR finding stock");
- continue;
- }
- var symbol = StockSymbols[name];
- SymbolToStockMap[symbol] = stock;
- }
- }
-}
-
-function stockMarketCycle() {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- var thresh = 0.6;
- if (stock.b) {thresh = 0.4;}
- if (Math.random() < thresh) {
- stock.b = !stock.b;
- }
- }
- }
-}
-
-//Returns true if successful, false otherwise
-function buyStock(stock, shares) {
- if (stock == null || shares < 0 || isNaN(shares)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
- return false;
- }
- shares = Math.round(shares);
- if (shares == 0) {return false;}
-
- var totalPrice = stock.price * shares;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this. You need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2).toString() + ".");
- return false;
- }
-
- var origTotal = stock.playerShares * stock.playerAvgPx;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShares += shares;
- stock.playerAvgPx = newTotal / stock.playerShares;
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellStock(stock, shares) {
- if (shares == 0) {return false;}
- if (stock == null || shares < 0 || isNaN(shares)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell stock. This may be a bug, contact developer");
- return false;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShares) {shares = stock.playerShares;}
- if (shares === 0) {return false;}
- var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(gains);
- stock.playerShares -= shares;
- if (stock.playerShares == 0) {
- stock.playerAvgPx = 0;
- }
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
- "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(gains, 2));
- return true;
-}
-
-//Returns true if successful and false otherwise
-function shortStock(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (stock == null || isNaN(shares) || shares < 0) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to initiate a short position in a stock. This is probably " +
- "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
- }
- return false;
- }
- shares = Math.round(shares);
- if (shares === 0) {return false;}
-
- var totalPrice = stock.price * shares;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " +
- "money to purchase this short position. You need " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)'));
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + ".");
- }
-
- return false;
- }
-
- var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShortShares += shares;
- stock.playerAvgShortPx = newTotal / stock.playerShortShares;
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
- workerScript.scriptRef.log("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. Paid " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)') + " in commission fees.");
- }
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
- }
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellShort(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
- if (stock == null || isNaN(shares) || shares < 0) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell a short position in a stock. This is probably " +
- "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
- }
- return false;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}
- if (shares === 0) {return false;}
-
- var origCost = shares * stock.playerAvgShortPx;
- var profit = ((stock.playerAvgShortPx - stock.price) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
- if (isNaN(profit)) {profit = 0;}
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(origCost + profit);
- if (tixApi) {
- workerScript.scriptRef.onlineMoneyMade += profit;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].scriptProdSinceLastAug += profit;
- }
-
- stock.playerShortShares -= shares;
- if (stock.playerShortShares === 0) {
- stock.playerAvgShortPx = 0;
- }
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
- workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
- "a total of " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(origCost + profit).format('($0.000a)'));
- }
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold your short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
- "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(origCost + profit, 2));
- }
-
- return true;
-}
-
-function updateStockPrices() {
- var v = Math.random();
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- var av = (v * stock.mv) / 100;
- if (isNaN(av)) {av = .02;}
-
- var chc = 50;
- if (stock.b) {
- chc = (chc + stock.otlkMag)/100;
- if (isNaN(chc)) {chc = 0.5;}
- } else {
- chc = (chc - stock.otlkMag)/100;
- if (isNaN(chc)) {chc = 0.5;}
- }
- if (stock.price >= StockPriceCap) {
- chc = -1; //Limit on stock price
- stock.b = false;
- }
-
- var c = Math.random();
- if (c < chc) {
- stock.price *= (1 + av);
- processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);
- processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);
- processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);
- processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
- updateStockTicker(stock, true);
- }
- } else {
- stock.price /= (1 + av);
- processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);
- processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);
- processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);
- processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
- updateStockTicker(stock, false);
- }
- }
-
- var otlkMagChange = stock.otlkMag * av;
- if (stock.otlkMag <= 0.1) {
- otlkMagChange = 1;
- }
- if (c < 0.5) {
- stock.otlkMag += otlkMagChange;
- } else {
- stock.otlkMag -= otlkMagChange;
- }
- if (stock.otlkMag < 0) {
- stock.otlkMag *= -1;
- stock.b = !stock.b;
- }
-
- }
- }
-}
-
-//Checks and triggers any orders for the specified stock
-function processOrders(stock, orderType, posType) {
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- return; //Newly created, so no orders to process
- }
- var stockOrders = orderBook[stock.symbol];
- if (stockOrders == null || !(stockOrders.constructor === Array)) {
- console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()");
- stockOrders = [];
- return;
- }
- for (var i = 0; i < stockOrders.length; ++i) {
- var order = stockOrders[i];
- if (order.type === orderType && order.pos === posType) {
- switch(order.type) {
- case OrderTypes.LimitBuy:
- if (order.pos === PositionTypes.Long && stock.price <= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.LimitSell:
- if (order.pos === PositionTypes.Long && stock.price >= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.StopBuy:
- if (order.pos === PositionTypes.Long && stock.price >= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- case OrderTypes.StopSell:
- if (order.pos === PositionTypes.Long && stock.price <= order.price) {
- executeOrder/*66*/(order);
- } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
- executeOrder/*66*/(order);
- }
- break;
- default:
- console.log("Invalid order type: " + order.type);
- return;
- }
- }
- }
-}
-
-function setStockMarketContentCreated(b) {
- stockMarketContentCreated = b;
-}
-
-var stockMarketContentCreated = false;
-var stockMarketPortfolioMode = false;
-var COMM = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
-function displayStockMarketContent() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = false;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = false;}
-
- //Purchase WSE Account button
- var wseAccountButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-account");
- wseAccountButton.innerText = "Buy WSE Account - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost, 2).toString();
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost)) {
- wseAccountButton.setAttribute("class", "a-link-button");
- } else if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount){
- wseAccountButton.innerText = "WSE Account - Purchased";
- wseAccountButton.setAttribute("class", "a-link-button-bought");
- } else {
- wseAccountButton.setAttribute("class", "a-link-button-inactive");
- }
- wseAccountButton.addEventListener("click", function() {
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = true;
- initStockMarket();
- initSymbolToStockMap();
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost);
- displayStockMarketContent();
- return false;
- });
-
- //Purchase TIX API Access account
- var tixApiAccessButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-tix-api");
- tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost, 2).toString();
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost)) {
- tixApiAccessButton.setAttribute("class", "a-link-button");
- } else if(_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess) {
- tixApiAccessButton.innerText = "Trade Information eXchange (TIX) API Access - Purchased"
- tixApiAccessButton.setAttribute("class", "a-link-button-bought");
- } else {
- tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
- }
- tixApiAccessButton.addEventListener("click", function() {
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = true;
- _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost);
- displayStockMarketContent();
- return false;
- });
-
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
-
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- stockMarketContentCreated = false;
- while (stockList.firstChild) {
- stockList.removeChild(stockList.firstChild);
- }
- return;
- }
-
- //Create stock market content if you have an account
- if (!stockMarketContentCreated && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- console.log("Creating Stock Market UI");
- document.getElementById("stock-market-commission").innerHTML =
- "Commission Fees: Every transaction you make has a $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " commission fee.
" +
- "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
- "This means all your positions are lost, so make sure to sell your stocks before installing " +
- "Augmentations!";
-
- var investopediaButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-investopedia");
- investopediaButton.addEventListener("click", function() {
- var txt = "When making a transaction on the stock market, there are two " +
- "types of positions: Long and Short. A Long position is the typical " +
- "scenario where you buy a stock and earn a profit if the price of that " +
- "stock increases. Meanwhile, a Short position is the exact opposite. " +
- "In a Short position you purchase shares of a stock and earn a profit " +
- "if the price of that stock decreases. This is also called 'shorting' a stock.
" +
- "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.
" +
- "There are three different types of orders you can make to buy or sell " +
- "stocks on the exchange: Market Order, Limit Order, and Stop Order. " +
- "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " +
- "later on in the game.
" +
- "When you place a Market Order to buy or sell a stock, the order executes " +
- "immediately at whatever the current price of the stock is. For example " +
- "if you choose to short a stock with 5000 shares using a Market Order, " +
- "you immediately purchase those 5000 shares in a Short position at whatever " +
- "the current market price is for that stock.
" +
- "A Limit Order is an order that only executes under certain conditions. " +
- "A Limit Order is used to buy or sell a stock at a specified price or better. " +
- "For example, lets say you purchased a Long position of 100 shares of some stock " +
- "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " +
- "at $50 or better. The Limit Order will execute when the price of the stock reaches a " +
- "value of $50 or higher.
" +
- "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " +
- "at a specified price (before the price gets 'worse'). For example, lets say you purchased " +
- "a Short position of 100 shares of some stock at a price of $100 per share. " +
- "The current price of the stock is $80 (a profit of $20 per share). You can place a " +
- "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " +
- "This can be used to lock in your profits and limit any losses.
" +
- "Here is a summary of how each order works and when they execute:
" +
- "In a LONG Position:
" +
- "A Limit Order to buy will execute if the stock's price <= order's price
" +
- "A Limit Order to sell will execute if the stock's price >= order's price
" +
- "A Stop Order to buy will execute if the stock's price >= order's price
" +
- "A Stop Order to sell will execute if the stock's price <= order's price
" +
- "In a SHORT Position:
" +
- "A Limit Order to buy will execute if the stock's price >= order's price
" +
- "A Limit Order to sell will execute if the stock's price <= order's price
" +
- "A Stop Order to buy will execute if the stock's price <= order's price
" +
- "A Stop Order to sell will execute if the stock's price >= order's price.";
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])(txt);
- return false;
- });
-
- //Switch to Portfolio Mode Button
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
-
- //Expand/Collapse tickers buttons
- var expandBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-expand-tickers"),
- collapseBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-collapse-tickers"),
- stockList = document.getElementById("stock-market-list");
- if (expandBtn) {
- expandBtn.addEventListener("click", ()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (!tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
- if (collapseBtn) {
- collapseBtn.addEventListener("click",()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
-
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers(); //Clicking headers opens/closes panels
- stockMarketContentCreated = true;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- updateStockTicker(stock, null);
- updateStockOrderList(stock);
- }
- }
- }
-}
-
-//Displays only stocks you have position/order in
-function switchToPortfolioMode() {
- stockMarketPortfolioMode = true;
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
- "Displays all stocks on the WSE";
- modeBtn.addEventListener("click", switchToDisplayAllMode);
- }
- while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
-
- //Get Order book (create it if it hasn't been created)
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- }
-
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- var stockOrders = orderBook[stock.symbol];
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- stockOrders.length === 0) {continue;}
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers();
-}
-
-//Displays all stocks
-function switchToDisplayAllMode() {
- stockMarketPortfolioMode = false;
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
- var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
- while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof Stock)) {continue;} //orders property is an array
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers();
-}
-
-function createStockTicker(stock) {
- if (!(stock instanceof Stock)) {
- console.log("Invalid stock in createStockSticker()");
- return;
- }
- var tickerId = "stock-market-ticker-" + stock.symbol;
- var li = document.createElement("li"), hdr = document.createElement("button");
- hdr.classList.add("accordion-header");
- hdr.setAttribute("id", tickerId + "-hdr");
- hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price;
-
- //Div for entire panel
- var stockDiv = document.createElement("div");
- stockDiv.classList.add("accordion-panel");
- stockDiv.setAttribute("id", tickerId + "-panel");
-
- /* Create panel DOM */
- var qtyInput = document.createElement("input"),
- longShortSelect = document.createElement("select"),
- orderTypeSelect = document.createElement("select"),
- buyButton = document.createElement("span"),
- sellButton = document.createElement("span"),
- buyMaxButton = document.createElement("span"),
- sellAllButton = document.createElement("span"),
- positionTxt = document.createElement("p"),
- orderList = document.createElement("ul");
-
- qtyInput.classList.add("stock-market-input");
- qtyInput.placeholder = "Quantity (Shares)";
- qtyInput.setAttribute("id", tickerId + "-qty-input");
- qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " +
- " || (47Long Position: " +
- "Shares in the long position will increase " +
- "in value if the price of the corresponding stock increases
" +
- "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShares, 0) +
- "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgPx).format('$0.000a') +
- " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalCost).format('$0.000a') + ")" +
- "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(gains).format('$0.000a') +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(percentageGains*100, 2) + "%)
";
- if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 2)) {
- stock.posTxtEl.innerHTML +=
- "Short Position: " +
- "Shares in short position will increase " +
- "in value if the price of the corresponding stock decreases
" +
- "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShortShares, 0) +
- "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgShortPx).format('$0.000a') +
- " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortTotalCost).format('$0.000a') + ")" +
- "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortGains).format('$0.000a') +
- " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shortPercentageGains*100, 2) + "%)" +
- "Orders:
";
- }
-
-}
-
-function updateStockOrderList(stock) {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
- var tickerId = "stock-market-ticker-" + stock.symbol;
- var orderList = document.getElementById(tickerId + "-order-list");
- if (orderList == null) {
- if (!stockMarketPortfolioMode) {console.log("ERROR: Could not find order list for " + stock.symbol);}
- return;
- }
-
- var orderBook = StockMarket["Orders"];
- if (orderBook == null) {
- console.log("ERROR: Could not find order book in stock market");
- return;
- }
- var stockOrders = orderBook[stock.symbol];
- if (stockOrders == null) {
- console.log("ERROR: Could not find orders for: " + stock.symbol);
- return;
- }
-
- if (stockMarketPortfolioMode) {
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
- StockMarket["Orders"][stock.symbol].length === 0) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-panel");
- return;
- } else {
- //If the ticker hasn't been created, create it (handles updating)
- //If it has been created, continue normally
- if (document.getElementById(tickerId + "-hdr") == null) {
- createStockTicker(stock);
- setStockTickerClickHandlers();
- return;
- }
- }
- }
-
- //Remove everything from list
- while (orderList.firstChild) {
- orderList.removeChild(orderList.firstChild);
- }
-
- for (var i = 0; i < stockOrders.length; ++i) {
- (function() {
- var order = stockOrders[i];
- var li = document.createElement("li");
- li.style.padding = "4px";
- var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position");
- li.style.color = "white";
- li.innerText = order.type + " - " + posText + " - " +
- order.shares + " @ $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(order.price, 2);
-
- var cancelButton = document.createElement("span");
- cancelButton.classList.add("stock-market-order-cancel-btn");
- cancelButton.classList.add("a-link-button");
- cancelButton.innerHTML = "Cancel Order";
- cancelButton.addEventListener("click", function() {
- cancelOrder({order: order}, null);
- return false;
- });
- li.appendChild(cancelButton);
- orderList.appendChild(li);
- }());
-
- }
-}
-
-
-
-
-/***/ }),
-/* 23 */
+/* 19 */
/*!*************************!*\
!*** ./src/Settings.js ***!
\*************************/
@@ -19633,7 +16232,7 @@ function setSettingsLabels() {
/***/ }),
-/* 24 */
+/* 20 */
/*!************************************************!*\
!*** ./node_modules/decimal.js/decimal.es6.js ***!
\************************************************/
@@ -24426,7 +21025,7 @@ PI = new Decimal(pi);
/***/ }),
-/* 25 */
+/* 21 */
/*!************************************!*\
!*** ./src/InteractiveTutorial.js ***!
\************************************/
@@ -24442,7 +21041,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialIsRunning", function() { return iTutorialIsRunning; });
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
@@ -25110,7 +21709,647 @@ function iTutorialSetText(txt) {
/***/ }),
-/* 26 */
+/* 22 */
+/*!********************************!*\
+ !*** ./src/NetscriptWorker.js ***!
+ \********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerScript", function() { return WorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "workerScripts", function() { return workerScripts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPorts", function() { return NetscriptPorts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptsLoop", function() { return runScriptsLoop; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killWorkerScript", function() { return killWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addWorkerScript", function() { return addWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateOnlineScriptTimes", function() { return updateOnlineScriptTimes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeWorkerScripts", function() { return prestigeWorkerScripts; });
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 80);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptJSEvaluator.js */ 60);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptPort.js */ 65);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function WorkerScript(runningScriptObj) {
+ this.name = runningScriptObj.filename;
+ this.running = false;
+ this.serverIp = null;
+ this.code = runningScriptObj.scriptRef.code;
+ this.env = new _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__["Environment"](this);
+ this.env.set("args", runningScriptObj.args.slice());
+ this.output = "";
+ this.ramUsage = 0;
+ this.scriptRef = runningScriptObj;
+ this.errorMessage = "";
+ this.args = runningScriptObj.args.slice();
+ this.delay = null;
+ this.fnWorker = null; //Workerscript for a function call
+ this.checkingRam = false;
+ this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM. Used for static RAM evaluation
+ this.disableLogs = {}; //Stores names of fns that should have logs disabled
+
+ //Properties used for dynamic RAM evaluation
+ this.dynamicRamUsage = 1.4;
+ this.dynamicLoadedFns = {};
+}
+
+//Returns the server on which the workerScript is running
+WorkerScript.prototype.getServer = function() {
+ return _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][this.serverIp];
+}
+
+//Returns the Script object for the underlying script
+WorkerScript.prototype.getScript = function() {
+ let server = this.getServer();
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename === this.name) {
+ return server.scripts[i];
+ }
+ }
+ console.log("ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong");
+ return null;
+}
+
+//Array containing all scripts that are running across all servers, to easily run them all
+let workerScripts = [];
+
+var NetscriptPorts = [];
+for (var i = 0; i < _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NumNetscriptPorts; ++i) {
+ NetscriptPorts.push(new _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__["NetscriptPort"]());
+}
+
+function prestigeWorkerScripts() {
+ for (var i = 0; i < workerScripts.length; ++i) {
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+ workerScripts[i].env.stopFlag = true;
+ }
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(5000); //Force UI to update
+ workerScripts.length = 0;
+}
+
+// JS script promises need a little massaging to have the same guarantees as netscript
+// promises. This does said massaging and kicks the script off. It returns a promise
+// that resolves or rejects when the corresponding worker script is done.
+function startJsScript(workerScript) {
+ workerScript.running = true;
+
+ // The name of the currently running netscript function, to prevent concurrent
+ // calls to hack, grow, etc.
+ let runningFn = null;
+
+ // We need to go through the environment and wrap each function in such a way that it
+ // can be called at most once at a time. This will prevent situations where multiple
+ // hack promises are outstanding, for example.
+ function wrap(propName, f) {
+ // This function unfortunately cannot be an async function, because we don't
+ // know if the original one was, and there's no way to tell.
+ return function (...args) {
+ // Wrap every netscript function with a check for the stop flag.
+ // This prevents cases where we never stop because we are only calling
+ // netscript functions that don't check this.
+ // This is not a problem for legacy Netscript because it also checks the
+ // stop flag in the evaluator.
+ if (workerScript.env.stopFlag) {throw workerScript;}
+
+ if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep.
+
+ const msg = "Concurrent calls to Netscript functions not allowed! " +
+ "Did you forget to await hack(), grow(), or some other " +
+ "promise-returning function? (Currently running: %s tried to run: %s)"
+ if (runningFn) {
+ workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, runningFn, propName), null)
+ throw workerScript;
+ }
+ runningFn = propName;
+ let result = f(...args);
+ if (result && result.finally !== undefined) {
+ return result.finally(function () {
+ runningFn = null;
+ });
+ } else {
+ runningFn = null;
+ return result;
+ }
+ }
+ };
+
+ for (let prop in workerScript.env.vars) {
+ if (typeof workerScript.env.vars[prop] !== "function") continue;
+ workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
+ }
+
+ // Note: the environment that we pass to the JS script only needs to contain the functions visible
+ // to that script, which env.vars does at this point.
+ return Object(_NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__["executeJSScript"])(workerScript.getServer().scripts,
+ workerScript).then(function (mainReturnValue) {
+ if (mainReturnValue === undefined) return workerScript;
+ return [mainReturnValue, workerScript];
+ }).catch(e => {
+ if (e instanceof Error) {
+ workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(
+ workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || ""));
+ throw workerScript;
+ } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(e)) {
+ workerScript.errorMessage = e;
+ throw workerScript;
+ }
+ throw e; // Don't know what to do with it, let's rethrow.
+ });
+}
+
+//Loop through workerScripts and run every script that is not currently running
+function runScriptsLoop() {
+ var scriptDeleted = false;
+
+ //Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
+ for (var i = workerScripts.length - 1; i >= 0; i--) {
+ if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
+ scriptDeleted = true;
+ //Delete script from the runningScripts array on its host serverIp
+ var ip = workerScripts[i].serverIp;
+ var name = workerScripts[i].name;
+
+ //Free RAM
+ _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].ramUsed -= workerScripts[i].ramUsage;
+
+ //Delete script from Active Scripts
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+
+ for (var j = 0; j < _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.length; j++) {
+ if (_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].filename == name &&
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(_Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts[j].args, workerScripts[i].args)) {
+ _Server_js__WEBPACK_IMPORTED_MODULE_7__["AllServers"][ip].runningScripts.splice(j, 1);
+ break;
+ }
+ }
+
+ //Delete script from workerScripts
+ workerScripts.splice(i, 1);
+ }
+ }
+ if (scriptDeleted) {Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])();} //Force Update
+
+
+ //Run any scripts that haven't been started
+ for (var i = 0; i < workerScripts.length; i++) {
+ //If it isn't running, start the script
+ if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
+ let p = null; // p is the script's result promise.
+ if (workerScripts[i].name.endsWith(".js") || workerScripts[i].name.endsWith(".ns")) {
+ p = startJsScript(workerScripts[i]);
+ } else {
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__["parse"])(workerScripts[i].code, {sourceType:"module"});
+ //console.log(ast);
+ } catch (e) {
+ console.log("Error parsing script: " + workerScripts[i].name);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Syntax ERROR in " + workerScripts[i].name + ":
" + e);
+ workerScripts[i].env.stopFlag = true;
+ continue;
+ }
+ workerScripts[i].running = true;
+ p = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["evaluate"])(ast, workerScripts[i]);
+ }
+
+ //Once the code finishes (either resolved or rejected, doesnt matter), set its
+ //running status to false
+ p.then(function(w) {
+ console.log("Stopping script " + w.name + " because it finished running naturally");
+ w.running = false;
+ w.env.stopFlag = true;
+ w.scriptRef.log("Script finished running");
+ }).catch(function(w) {
+ if (w instanceof Error) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
+ console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString());
+ return;
+ } else if (w.constructor === Array && w.length === 2 && w[0] === "RETURNSTATEMENT") {
+ //Script ends with a return statement
+ console.log("Script returning with value: " + w[1]);
+ //TODO maybe do something with this in the future
+ return;
+ } else if (w instanceof WorkerScript) {
+ if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w.errorMessage)) {
+ var errorTextArray = w.errorMessage.split("|");
+ if (errorTextArray.length != 4) {
+ console.log("ERROR: Something wrong with Error text in evaluator...");
+ console.log("Error text: " + errorText);
+ return;
+ }
+ var serverIp = errorTextArray[1];
+ var scriptName = errorTextArray[2];
+ var errorMsg = errorTextArray[3];
+
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime error:
Server Ip: " + serverIp +
+ "
Script name: " + scriptName +
+ "
Args:" + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(w.args) + "
" + errorMsg);
+ w.scriptRef.log("Script crashed with runtime error");
+ } else {
+ w.scriptRef.log("Script killed");
+ }
+ w.running = false;
+ w.env.stopFlag = true;
+
+ } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
+ console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: " + w.toString());
+ return;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
+ console.log(w);
+ }
+ });
+ }
+ }
+
+ setTimeout(runScriptsLoop, 6000);
+}
+
+//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
+//all of its promises recursively, and when it does so it will no longer be running.
+//The runScriptsLoop() will then delete the script from worker scripts
+function killWorkerScript(runningScriptObj, serverIp) {
+ for (var i = 0; i < workerScripts.length; i++) {
+ if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
+ workerScripts[i].env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(workerScripts[i]);
+ //Recursively kill all functions
+ var curr = workerScripts[i];
+ while (curr.fnWorker) {
+ curr.fnWorker.env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(curr.fnWorker);
+ curr = curr.fnWorker;
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+//Queues a script to be run
+function addWorkerScript(runningScriptObj, server) {
+ var filename = runningScriptObj.filename;
+
+ //Update server's ram usage
+ var threads = 1;
+ if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
+ threads = runningScriptObj.threads;
+ } else {
+ runningScriptObj.threads = 1;
+ }
+ var ramUsage = runningScriptObj.scriptRef.ramUsage * threads
+ * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+ if (ramUsage > ramAvailable) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["printArray"])(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
+ "the game and the script's RAM usage increased (either because of an update to the game or " +
+ "your changes to the script.)");
+ return;
+ }
+ server.ramUsed += ramUsage;
+
+ //Create the WorkerScript
+ var s = new WorkerScript(runningScriptObj);
+ s.serverIp = server.ip;
+ s.ramUsage = ramUsage;
+
+ //Add the WorkerScript to the Active Scripts list
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["addActiveScriptsItem"])(s);
+
+ //Add the WorkerScript
+ workerScripts.push(s);
+ return;
+}
+
+//Updates the online running time stat of all running scripts
+function updateOnlineScriptTimes(numCycles = 1) {
+ var time = (numCycles * _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
+ for (var i = 0; i < workerScripts.length; ++i) {
+ workerScripts[i].scriptRef.onlineRunningTime += time;
+ }
+}
+
+
+
+
+/***/ }),
+/* 23 */
+/*!***********************!*\
+ !*** ./src/Crimes.js ***!
+ \***********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeSuccess", function() { return determineCrimeSuccess; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findCrime", function() { return findCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Crimes", function() { return Crimes; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+
+
+
+
+
+function Crime(name, type, time, money, difficulty, karma, params) {
+ this.name = name;
+ this.type = type;
+ this.time = time;
+ this.money = money;
+ this.difficulty = difficulty;
+ this.karma = karma;
+
+ this.hacking_success_weight = params.hacking_success_weight ? params.hacking_success_weight : 0;
+ this.strength_success_weight = params.strength_success_weight ? params.strength_success_weight : 0;
+ this.defense_success_weight = params.defense_success_weight ? params.defense_success_weight : 0;
+ this.dexterity_success_weight = params.dexterity_success_weight ? params.dexterity_success_weight : 0;
+ this.agility_success_weight = params.agility_success_weight ? params.agility_success_weight : 0;
+ this.charisma_success_weight = params.charisma_success_weight ? params.charisma_success_weight : 0;
+
+ this.hacking_exp = params.hacking_exp ? params.hacking_exp : 0;
+ this.strength_exp = params.strength_exp ? params.strength_exp : 0;
+ this.defense_exp = params.defense_exp ? params.defense_exp : 0;
+ this.dexterity_exp = params.dexterity_exp ? params.dexterity_exp : 0;
+ this.agility_exp = params.agility_exp ? params.agility_exp : 0;
+ this.charisma_exp = params.charisma_exp ? params.charisma_exp : 0;
+ this.intelligence_exp = params.intelligence_exp ? params.intelligence_exp : 0;
+
+ this.kills = params.kills ? params.kills : 0;
+}
+
+Crime.prototype.commit = function(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = this.type;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(
+ this.hacking_exp/div,
+ this.strength_exp/div,
+ this.defense_exp/div,
+ this.dexterity_exp/div,
+ this.agility_exp/div,
+ this.charisma_exp/div,
+ this.money/div, this.time, singParams);
+ return this.time;
+}
+
+Crime.prototype.successRate = function() {
+ var chance = (this.hacking_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill +
+ this.strength_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength +
+ this.defense_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense +
+ this.dexterity_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity +
+ this.agility_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility +
+ this.charisma_success_weight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma +
+ _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeWeight * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence);
+ chance /= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ chance /= this.difficulty;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+const Crimes = {
+ Shoplift: new Crime("Shoplift", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift, 2e3, 15e3, 1/20, 0.1, {
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ dexterity_exp: 2,
+ agility_exp: 2,
+ }),
+
+ RobStore: new Crime("Rob Store", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore, 60e3, 400e3, 1/5, 0.5, {
+ hacking_exp: 30,
+ dexterity_exp: 45,
+ agility_exp: 45,
+
+ hacking_success_weight: 0.5 ,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+
+ intelligence_exp: 0.25 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Mug: new Crime("Mug", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug, 4e3, 36e3, 1/5, 0.25, {
+ strength_exp: 3,
+ defense_exp: 3,
+ dexterity_exp: 3,
+ agility_exp: 3,
+
+ strength_success_weight: 1.5,
+ defense_success_weight: 0.5,
+ dexterity_success_weight: 1.5,
+ agility_success_weight: 0.5,
+ }),
+
+ Larceny: new Crime("Larceny", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny, 90e3, 800e3, 1/3, 1.5, {
+ hacking_exp: 45,
+ dexterity_exp: 60,
+ agility_exp: 60,
+
+ hacking_skill_success_weight: 0.5,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ intelligence_exp: 0.5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ DealDrugs: new Crime("Deal Drugs", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs, 10e3, 120e3, 1, 0.5, {
+ dexterity_exp: 5,
+ agility_exp: 5,
+ charisma_exp: 10,
+
+ charisma_success_weight: 3,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+ }),
+
+ BondForgery: new Crime("Bond Forgery", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery, 300e3, 4.5e6, 1/2, 0.1, {
+ hacking_exp: 100,
+ dexterity_exp: 150,
+ charisma_exp: 15,
+
+ hacking_skill_success_weight: 0.05,
+ dexterity_success_weight: 1.25,
+
+ intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ TraffickArms: new Crime("Traffick Arms", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms, 40e3, 600e3, 2, 1, {
+ strength_exp: 20,
+ defense_exp: 20,
+ dexterity_exp: 20,
+ agility_exp: 20,
+ charisma_exp: 40,
+
+ charisma_success_weight: 1,
+ strength_success_weight: 1,
+ defense_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+ }),
+
+ Homicide: new Crime("Homicide", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide, 3e3, 45e3, 1, 3, {
+ strength_exp: 2,
+ defense_exp: 2,
+ dexterity_exp: 2,
+ agility_exp: 2,
+
+ strength_success_weight: 2,
+ defense_success_weight: 2,
+ dexterity_success_weight: 0.5,
+ agility_success_weight: 0.5,
+
+ kills: 1,
+ }),
+
+ GrandTheftAuto: new Crime("Grand Theft Auto", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto, 80e3, 1.6e6, 8, 5, {
+ strength_exp: 20,
+ defense_exp: 20,
+ dexterity_exp: 20,
+ agility_exp: 80,
+ charisma_exp: 40,
+
+ hacking_skill_success_weight: 1,
+ strength_success_weight: 1,
+ dexterity_success_weight: 4,
+ agility_success_weight: 2,
+ charisma_success_weight: 2,
+
+ intelligence_exp: _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Kidnap: new Crime("Kidnap", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap, 120e3, 3.6e6, 5, 6, {
+ strength_exp: 80,
+ defense_exp: 80,
+ dexterity_exp: 80,
+ agility_exp: 80,
+ charisma_exp: 80,
+
+ charisma_success_weight: 1,
+ strength_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+
+ intelligence_exp: 2 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+
+ Assassination: new Crime("Assassination", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination, 300e3, 12e6, 8, 10, {
+ strength_exp: 300,
+ defense_exp: 300,
+ dexterity_exp: 300,
+ agility_exp: 300,
+
+ strength_success_weight: 1,
+ dexterity_success_weight: 2,
+ agility_success_weight: 1,
+
+ intelligence_exp: 5 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+
+ kills: 1,
+ }),
+
+ Heist: new Crime("Heist", _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist, 600e3, 120e6, 18, 15, {
+ hacking_exp: 450,
+ strength_exp: 450,
+ defense_exp: 450,
+ dexterity_exp: 450,
+ agility_exp: 450,
+ charisma_exp: 450,
+
+ hacking_skill_success_weight: 1,
+ strength_success_weight: 1,
+ defense_success_weight: 1,
+ dexterity_success_weight: 1,
+ agility_success_weight: 1,
+ charisma_success_weight: 1,
+
+ intelligence_exp: 10 * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeBaseExpGain,
+ }),
+};
+
+function determineCrimeSuccess(type, moneyGained) {
+ var chance = 0;
+ var found = false;
+ for(const i in Crimes) {
+ const crime = Crimes[i];
+ if(crime.type == type) {
+ chance = crime.successRate();
+ found = true;
+ break;
+ }
+ }
+ if(!found) {
+ console.log(crime);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
+ return;
+ }
+
+ if (Math.random() <= chance) {
+ //Success
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].gainMoney(moneyGained);
+ return true;
+ } else {
+ //Failure
+ return false;
+ }
+}
+
+function findCrime(roughName) {
+ if (roughName.includes("shoplift")) {
+ return Crimes.Shoplift;
+ } else if (roughName.includes("rob") && roughName.includes("store")) {
+ return Crimes.RobStore;
+ } else if (roughName.includes("mug")) {
+ return Crimes.Mug;
+ } else if (roughName.includes("larceny")) {
+ return Crimes.Larceny;
+ } else if (roughName.includes("drugs")) {
+ return Crimes.DealDrugs;
+ } else if (roughName.includes("bond") && roughName.includes("forge")) {
+ return Crimes.BondForgery;
+ } else if (roughName.includes("traffick") && roughName.includes("arms")) {
+ return Crimes.TraffickArms;
+ } else if (roughName.includes("homicide")) {
+ return Crimes.Homicide;
+ } else if (roughName.includes("grand") && roughName.includes("auto")) {
+ return Crimes.GrandTheftAuto;
+ } else if (roughName.includes("kidnap")) {
+ return Crimes.Kidnap;
+ } else if (roughName.includes("assassinate")) {
+ return Crimes.Assassination;
+ } else if (roughName.includes("heist")) {
+ return Crimes.Heist;
+ }
+ return null;
+}
+
+
+
+
+/***/ }),
+/* 24 */
/*!***********************!*\
!*** ./src/Script.js ***!
\***********************/
@@ -25128,20 +22367,20 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptFilename", function() { return isScriptFilename; });
/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 33);
-/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 6);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 31);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 26);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 18);
-/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile.js */ 43);
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 15);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile.js */ 58);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
var ace = __webpack_require__(/*! brace */ 196);
@@ -26108,3790 +23347,3589 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Reviver"].constructors.AllS
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
+
+/***/ }),
+/* 25 */
+/*!**********************!*\
+ !*** ./src/Alias.js ***!
+ \**********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Aliases", function() { return Aliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalAliases", function() { return GlobalAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "printAliases", function() { return printAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseAliasDeclaration", function() { return parseAliasDeclaration; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAlias", function() { return removeAlias; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; });
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 15);
+
+
+let Aliases = {};
+let GlobalAliases = {};
+
+function loadAliases(saveString) {
+ if (saveString === "") {
+ Aliases = {};
+ } else {
+ Aliases = JSON.parse(saveString);
+ }
+}
+
+function loadGlobalAliases(saveString) {
+ if (saveString === "") {
+ GlobalAliases = {};
+ } else {
+ GlobalAliases = JSON.parse(saveString);
+ }
+}
+
+//Print all aliases to terminal
+function printAliases() {
+ for (var name in Aliases) {
+ if (Aliases.hasOwnProperty(name)) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_0__["post"])("alias " + name + "=" + Aliases[name]);
+ }
+ }
+ for (var name in GlobalAliases) {
+ if (GlobalAliases.hasOwnProperty(name)) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_0__["post"])("global alias " + name + "=" + GlobalAliases[name]);
+ }
+ }
+}
+
+//True if successful, false otherwise
+function parseAliasDeclaration(dec,global=false) {
+ var re = /^([_|\w|!|%|,|@]+)="(.+)"$/;
+ var matches = dec.match(re);
+ if (matches == null || matches.length != 3) {return false;}
+ if (global){
+ addGlobalAlias(matches[1],matches[2]);
+ } else {
+ addAlias(matches[1], matches[2]);
+ }
+ return true;
+}
+
+function addAlias(name, value) {
+ if (name in GlobalAliases){
+ delete GlobalAliases[name];
+ }
+ Aliases[name] = value;
+}
+
+function addGlobalAlias(name, value) {
+ if (name in Aliases){
+ delete Aliases[name];
+ }
+ GlobalAliases[name] = value;
+}
+
+function getAlias(name) {
+ if (Aliases.hasOwnProperty(name)) {
+ return Aliases[name];
+ }
+ return null;
+}
+
+function getGlobalAlias(name) {
+ if (GlobalAliases.hasOwnProperty(name)) {
+ return GlobalAliases[name];
+ }
+ return null;
+}
+
+function removeAlias(name) {
+ if (Aliases.hasOwnProperty(name)) {
+ delete Aliases[name];
+ return true;
+ }
+ if (GlobalAliases.hasOwnProperty(name)) {
+ delete GlobalAliases[name];
+ return true;
+ }
+ return false;
+}
+
+//Returns the original string with any aliases substituted in
+//Aliases only applied to "whole words", one level deep
+function substituteAliases(origCommand) {
+ var commandArray = origCommand.split(" ");
+ if (commandArray.length>0){
+ var alias = getAlias(commandArray[0]);
+ if (alias != null) {
+ commandArray[0] = alias;
+ } else {
+ var alias = getGlobalAlias(commandArray[0]);
+ if (alias != null) {
+ commandArray[0] = alias;
+ }
+ }
+ for (var i = 0; i < commandArray.length; ++i) {
+ var alias = getGlobalAlias(commandArray[i]);
+ if (alias != null) {
+ commandArray[i] = alias;
+ }
+ }
+ }
+ return commandArray.join(" ");
+}
+
+
+
+
+/***/ }),
+/* 26 */
+/*!***********************************!*\
+ !*** ./src/NetscriptFunctions.js ***!
+ \***********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptFunctions", function() { return NetscriptFunctions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSingularitySFFlags", function() { return initSingularitySFFlags; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasSingularitySF", function() { return hasSingularitySF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBn11SF", function() { return hasBn11SF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasWallStreetSF", function() { return hasWallStreetSF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wallStreetSFLvl", function() { return wallStreetSFLvl; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasCorporationSF", function() { return hasCorporationSF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; });
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 12);
+/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 23);
+/* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Bladeburner.js */ 40);
+/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Company.js */ 8);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./CreateProgram.js */ 17);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./DarkWeb.js */ 82);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./HacknetNode.js */ 38);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Missions.js */ 39);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./StockMarket.js */ 29);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Terminal.js */ 15);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./TextFile.js */ 58);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 80);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./NetscriptPort.js */ 65);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! decimal.js */ 20);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../utils/IPAddress.js */ 13);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+var sprintf = __webpack_require__(/*! sprintf-js */ 114).sprintf,
+ vsprintf = __webpack_require__(/*! sprintf-js */ 114).vsprintf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var hasCorporationSF = false, //Source-File 3
+ hasSingularitySF = false, //Source-File 4
+ hasAISF = false, //Source-File 5
+ hasBladeburnerSF = false, //Source-File 6
+ hasBladeburner2079SF = false, //Source-File 7
+ hasWallStreetSF = false, //Source-File 8
+ hasBn11SF = false; //Source-File 11
+
+var singularitySFLvl=1, wallStreetSFLvl=1;
+
+var possibleLogs = {
+ ALL: true,
+ scan: true,
+ hack: true,
+ sleep: true,
+ disableLog: true,
+ enableLog: true,
+ grow: true,
+ weaken: true,
+ nuke: true,
+ brutessh: true,
+ ftpcrack: true,
+ relaysmtp: true,
+ httpworm: true,
+ sqlinject: true,
+ spawn: true,
+ kill: true,
+ killall: true,
+ scp: true,
+ getHackingLevel: true,
+ getServerMoneyAvailable: true,
+ getServerSecurityLevel: true,
+ getServerBaseSecurityLevel: true,
+ getServerMinSecurityLevel: true,
+ getServerRequiredHackingLevel: true,
+ getServerMaxMoney: true,
+ getServerGrowth: true,
+ getServerNumPortsRequired: true,
+ getServerRam: true,
+ buyStock: true,
+ sellStock: true,
+ purchaseServer: true,
+ deleteServer: true,
+ universityCourse: true,
+ gymWorkout: true,
+ travelToCity: true,
+ purchaseTor: true,
+ purchaseProgram: true,
+ stopAction: true,
+ upgradeHomeRam: true,
+ workForCompany: true,
+ applyToCompany: true,
+ joinFaction: true,
+ workForFaction: true,
+ createProgram: true,
+ commitCrime: true,
+ shortStock: true,
+ sellShort: true,
+}
+
+//Used to check and set flags for every Source File, despite the name of the function
+function initSingularitySFFlags() {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 3) {hasCorporationSF = true;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 4) {
+ hasSingularitySF = true;
+ singularitySFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].lvl;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 5) {hasAISF = true;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 6) {hasBladeburnerSF = true;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 7) {hasBladeburner2079SF = true;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 8) {
+ hasWallStreetSF = true;
+ wallStreetSFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].lvl;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 11) {hasBn11SF = true;}
+ }
+}
+
+function NetscriptFunctions(workerScript) {
+ var updateDynamicRam = function(fnName, ramCost) {
+ if (workerScript.dynamicLoadedFns[fnName]) {return;}
+ workerScript.dynamicLoadedFns[fnName] = true;
+ workerScript.dynamicRamUsage += ramCost;
+ if (workerScript.dynamicRamUsage > 1.01 * workerScript.ramUsage) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript,
+ "Dynamic RAM usage calculated to be greater than initial RAM usage. " +
+ "This is probably because you somehow circumvented the static RAM " +
+ "calculation.
Please don't do that :(");
+ }
+ };
+
+ var updateStaticRam = function(fnName, ramCost) {
+ if (workerScript.loadedFns[fnName]) {
+ return 0;
+ } else {
+ workerScript.loadedFns[fnName] = true;
+ return ramCost;
+ }
+ };
+
+ return {
+ Math : Math,
+ Date : Date,
+ Number : Number,
+ hacknetnodes : _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknetNodeWrappers,
+ sprintf : sprintf,
+ vsprintf: vsprintf,
+ scan : function(ip=workerScript.serverIp, hostnames=true){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("scan", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost);
+ }
+ updateDynamicRam("scan", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, 'Invalid IP or hostname passed into scan() command');
+ }
+ var out = [];
+ for (var i = 0; i < server.serversOnNetwork.length; i++) {
+ var entry;
+ if (hostnames) {
+ entry = server.getServerOnNetwork(i).hostname;
+ } else {
+ entry = server.getServerOnNetwork(i).ip;
+ }
+ if (entry == null) {
+ continue;
+ }
+ out.push(entry);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {
+ workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
+ }
+ return out;
+ },
+ hack : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("hack", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHackRamCost);
+ }
+ updateDynamicRam("hack", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHackRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
+ }
+
+ //Calculate the hacking time
+ var hackingTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingTime"])(server); //This is in seconds
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ if (server.requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill) {
+ workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
+ }
+
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
+ workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(hackingTime* 1000, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ var hackChance = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingChance"])(server);
+ var rand = Math.random();
+ var expGainedOnSuccess = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
+ var expGainedOnFailure = (expGainedOnSuccess / 4);
+ if (rand < hackChance) { //Success!
+ var moneyGained = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculatePercentMoneyHacked"])(server);
+ moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
+
+ //Over-the-top safety checks
+ if (moneyGained <= 0) {
+ moneyGained = 0;
+ expGainedOnSuccess = expGainedOnFailure;
+ }
+ if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
+ server.moneyAvailable -= moneyGained;
+ if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainMoney(moneyGained);
+ workerScript.scriptRef.onlineMoneyMade += moneyGained;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug += moneyGained;
+ workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGainedOnSuccess);
+ workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
+ workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
+ }
+ server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerFortifyAmount * threads);
+ return Promise.resolve(moneyGained);
+ } else {
+ //Player only gains 25% exp for failure?
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGainedOnFailure);
+ workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
+ workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
+ }
+ return Promise.resolve(0);
+ }
+ });
+ },
+ sleep : function(time){
+ if (workerScript.checkingRam) {return 0;}
+ if (time === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument");
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {
+ workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(time, workerScript).then(function() {
+ return Promise.resolve(true);
+ });
+ },
+ grow : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("grow", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGrowRamCost);
+ }
+ updateDynamicRam("grow", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGrowRamCost);
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip);
+ }
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ var growTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateGrowTime"])(server);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
+ workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(growTime/1000, 3) + " seconds (t=" + threads + ")");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(growTime, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
+ var growthPercentage = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["processSingleServerGrowth"])(server, 450 * threads);
+ workerScript.scriptRef.recordGrow(server.ip, threads);
+ var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
+ if (growthPercentage == 1) {
+ expGain = 0;
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
+ workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(growthPercentage*100 - 100, 6) + "%. Gained " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
+ }
+ workerScript.scriptRef.onlineExpGained += expGain;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGain);
+ return Promise.resolve(growthPercentage);
+ });
+ },
+ weaken : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("weaken", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptWeakenRamCost);
+ }
+ updateDynamicRam("weaken", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptWeakenRamCost);
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip);
+ }
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ var weakenTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateWeakenTime"])(server);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
+ workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(weakenTime, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ server.weaken(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerWeakenAmount * threads);
+ workerScript.scriptRef.recordWeaken(server.ip, threads);
+ var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
+ workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
+ ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
+ }
+ workerScript.scriptRef.onlineExpGained += expGain;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGain);
+ return Promise.resolve(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerWeakenAmount * threads);
+ });
+ },
+ print : function(args){
+ if (workerScript.checkingRam) {return 0;}
+ if (args === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument");
+ }
+ workerScript.scriptRef.log(args.toString());
+ },
+ tprint : function(args) {
+ if (workerScript.checkingRam) {return 0;}
+ if (args === undefined || args == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var x = args.toString();
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isHTML"])(x)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].takeDamage(1);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_28__["dialogBoxCreate"])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:
" +
+ "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!
" +
+ "(You lost 1 HP)");
+ return;
+ }
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_21__["post"])(workerScript.scriptRef.filename + ": " + args.toString());
+ },
+ clearLog : function() {
+ if (workerScript.checkingRam) {return 0;}
+ workerScript.scriptRef.clearLog();
+ },
+ disableLog : function(fn) {
+ if (workerScript.checkingRam) {return 0;}
+ if(possibleLogs[fn]===undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to disableLog: "+fn);
+ }
+ workerScript.disableLogs[fn] = true;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) {
+ workerScript.scriptRef.log("Disabled logging for " + fn);
+ }
+ },
+ enableLog : function(fn) {
+ if (workerScript.checkingRam) {return 0;}
+ if(possibleLogs[fn]===undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to enableLog: "+fn);
+ }
+ delete workerScript.disableLogs[fn];
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) {
+ workerScript.scriptRef.log("Enabled logging for " + fn);
+ }
+ },
+ nuke : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("nuke", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("nuke", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the NUKE.exe virus!");
+ }
+ if (server.openPortCount < server.numOpenPortsRequired) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Not enough ports opened to use NUKE.exe virus");
+ }
+ if (server.hasAdminRights) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
+ workerScript.scriptRef.log("Already have root access to " + server.hostname);
+ }
+ } else {
+ server.hasAdminRights = true;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
+ workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
+ }
+ }
+ return true;
+ },
+ brutessh : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("brutessh", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("brutessh", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram)) {
+ workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the BruteSSH.exe program!");
+ }
+ if (!server.sshPortOpen) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
+ workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
+ }
+ server.sshPortOpen = true;
+ ++server.openPortCount;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
+ workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
+ }
+ }
+ return true;
+ },
+ ftpcrack : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("ftpcrack", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("ftpcrack", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the FTPCrack.exe program!");
+ }
+ if (!server.ftpPortOpen) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
+ workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
+ }
+ server.ftpPortOpen = true;
+ ++server.openPortCount;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
+ workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
+ }
+ }
+ return true;
+ },
+ relaysmtp : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("relaysmtp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("relaysmtp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the relaySMTP.exe program!");
+ }
+ if (!server.smtpPortOpen) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
+ workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
+ }
+ server.smtpPortOpen = true;
+ ++server.openPortCount;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
+ workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
+ }
+ }
+ return true;
+ },
+ httpworm : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("httpworm", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("httpworm", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the HTTPWorm.exe program!");
+ }
+ if (!server.httpPortOpen) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
+ workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
+ }
+ server.httpPortOpen = true;
+ ++server.openPortCount;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
+ workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
+ }
+ }
+ return true;
+ },
+ sqlinject : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("sqlinject", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ }
+ updateDynamicRam("sqlinject", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the SQLInject.exe program!");
+ }
+ if (!server.sqlPortOpen) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
+ workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
+ }
+ server.sqlPortOpen = true;
+ ++server.openPortCount;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
+ workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
+ }
+ }
+ return true;
+ },
+ run : function(scriptname,threads = 1){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("run", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptRunRamCost);
+ }
+ updateDynamicRam("run", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptRunRamCost);
+ if (scriptname === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
+ }
+ if (isNaN(threads) || threads < 1) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0");
+ }
+ var argsForNewScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForNewScript.push(arguments[i]);
+ }
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["runScriptFromScript"])(scriptServer, scriptname, argsForNewScript, workerScript, threads);
+ },
+ exec : function(scriptname,ip,threads = 1) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("exec", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptExecRamCost);
+ }
+ updateDynamicRam("exec", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptExecRamCost);
+ if (scriptname === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
+ }
+ if (isNaN(threads) || threads < 1) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0");
+ }
+ var argsForNewScript = [];
+ for (var i = 3; i < arguments.length; ++i) {
+ argsForNewScript.push(arguments[i]);
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["runScriptFromScript"])(server, scriptname, argsForNewScript, workerScript, threads);
+ },
+ spawn : function(scriptname, threads) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("spawn", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSpawnRamCost);
+ }
+ updateDynamicRam("spawn", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSpawnRamCost);
+ if (scriptname == null || threads == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid scriptname or numThreads argument passed to spawn()");
+ }
+ setTimeout(()=>{
+ NetscriptFunctions(workerScript).run.apply(this, arguments);
+ }, 20000);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {
+ workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
+ }
+ NetscriptFunctions(workerScript).exit();
+ },
+ kill : function(filename,ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("kill", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ }
+ updateDynamicRam("kill", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ if (filename === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var argsForKillTarget = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForKillTarget.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(filename, argsForKillTarget, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget));
+ return false;
+ }
+ var res = Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(runningScriptObj, server.ip);
+ if (res) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
+ workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
+ }
+ return true;
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
+ workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget));
+ }
+ return false;
+ }
+ },
+ killall : function(ip=workerScript.serverIp){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("killall", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ }
+ updateDynamicRam("killall", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var scriptsRunning = (server.runningScripts.length > 0);
+ for (var i = server.runningScripts.length-1; i >= 0; --i) {
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(server.runningScripts[i], server.ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
+ workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
+ }
+ return scriptsRunning;
+ },
+ exit : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("exit", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ }
+ updateDynamicRam("exit", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev");
+ }
+ if (Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(workerScript.scriptRef, server.ip)) {
+ workerScript.scriptRef.log("Exiting...");
+ } else {
+ workerScript.scriptRef.log("Exit failed(). This is a bug please contact game developer");
+ }
+ },
+ scp : function(scriptname, ip1, ip2) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("scp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScpRamCost);
+ }
+ updateDynamicRam("scp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScpRamCost);
+ if (arguments.length !== 2 && arguments.length !== 3) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ if (scriptname && scriptname.constructor === Array) {
+ //Recursively call scp on all elements of array
+ var res = false;
+ scriptname.forEach(function(script) {
+ if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) {
+ res = true;
+ };
+ });
+ return res;
+ }
+ if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["isScriptFilename"])(scriptname) &&
+ !scriptname.endsWith("txt")) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
+ }
+
+ var destServer, currServ;
+
+ if (arguments.length === 3) { //scriptname, source, destination
+ if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip2);
+ if (destServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
+ }
+
+ currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip1);
+ if (currServ == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
+ }
+ } else if (arguments.length === 2) { //scriptname, destination
+ if (scriptname === undefined || ip1 === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip1);
+ if (destServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
+ }
+
+ currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (currServ == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
+ }
+ }
+
+ //Scp for lit files
+ if (scriptname.endsWith(".lit")) {
+ var found = false;
+ for (var i = 0; i < currServ.messages.length; ++i) {
+ if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) && currServ.messages[i] == scriptname) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
+ return false;
+ }
+
+ for (var i = 0; i < destServer.messages.length; ++i) {
+ if (destServer.messages[i] === scriptname) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
+ }
+ return true; //Already exists
+ }
+ }
+ destServer.messages.push(scriptname);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
+ }
+ return true;
+ }
+
+ //Scp for text files
+ if (scriptname.endsWith(".txt")) {
+ var found = false, txtFile;
+ for (var i = 0; i < currServ.textFiles.length; ++i) {
+ if (currServ.textFiles[i].fn === scriptname) {
+ found = true;
+ txtFile = currServ.textFiles[i];
+ break;
+ }
+ }
+
+ if (!found) {
+ workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
+ return false;
+ }
+
+ for (var i = 0; i < destServer.textFiles.length; ++i) {
+ if (destServer.textFiles[i].fn === scriptname) {
+ //Overwrite
+ destServer.textFiles[i].text = txtFile.text;
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
+ }
+ return true;
+ }
+ }
+ var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_22__["TextFile"](txtFile.fn, txtFile.text);
+ destServer.textFiles.push(newFile);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
+ }
+ return true;
+ }
+
+ //Scp for script files
+ var sourceScript = null;
+ for (var i = 0; i < currServ.scripts.length; ++i) {
+ if (scriptname == currServ.scripts[i].filename) {
+ sourceScript = currServ.scripts[i];
+ break;
+ }
+ }
+ if (sourceScript == null) {
+ workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
+ return false;
+ }
+
+ //Overwrite script if it already exists
+ for (var i = 0; i < destServer.scripts.length; ++i) {
+ if (scriptname == destServer.scripts[i].filename) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
+ workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
+ }
+ var oldScript = destServer.scripts[i];
+ oldScript.code = sourceScript.code;
+ oldScript.ramUsage = sourceScript.ramUsage;
+ return true;
+ }
+ }
+
+ //Create new script if it does not already exist
+ var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_16__["Script"]();
+ newScript.filename = scriptname;
+ newScript.code = sourceScript.code;
+ newScript.ramUsage = sourceScript.ramUsage;
+ newScript.server = destServer.ip;
+ destServer.scripts.push(newScript);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
+ workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
+ }
+ return true;
+ },
+ ls : function(ip, grep) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("ls", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost);
+ }
+ updateDynamicRam("ls", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost);
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip);
+ }
+
+ //Get the grep filter, if one exists
+ var filter = false;
+ if (arguments.length >= 2) {
+ filter = grep.toString();
+ }
+
+ var allFiles = [];
+ for (var i = 0; i < server.programs.length; i++) {
+ if (filter) {
+ if (server.programs[i].includes(filter)) {
+ allFiles.push(server.programs[i]);
+ }
+ } else {
+ allFiles.push(server.programs[i]);
+ }
+ }
+ for (var i = 0; i < server.scripts.length; i++) {
+ if (filter) {
+ if (server.scripts[i].filename.includes(filter)) {
+ allFiles.push(server.scripts[i].filename);
+ }
+ } else {
+ allFiles.push(server.scripts[i].filename);
+ }
+
+ }
+ for (var i = 0; i < server.messages.length; i++) {
+ if (filter) {
+ if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) {
+ if (server.messages[i].filename.includes(filter)) {
+ allFiles.push(server.messages[i].filename);
+ }
+ } else if (server.messages[i].includes(filter)) {
+ allFiles.push(server.messages[i]);
+ }
+ } else {
+ if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) {
+ allFiles.push(server.messages[i].filename);
+ } else {
+ allFiles.push(server.messages[i]);
+ }
+ }
+ }
+
+ for (var i = 0; i < server.textFiles.length; i++) {
+ if (filter) {
+ if (server.textFiles[i].fn.includes(filter)) {
+ allFiles.push(server.textFiles[i].fn);
+ }
+ } else {
+ allFiles.push(server.textFiles[i].fn);
+ }
+ }
+
+ //Sort the files alphabetically then print each
+ allFiles.sort();
+ return allFiles;
+ },
+ hasRootAccess : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("hasRootAccess", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHasRootAccessRamCost);
+ }
+ updateDynamicRam("hasRootAccess", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHasRootAccessRamCost);
+ if (ip===undefined){
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null){
+ workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return server.hasAdminRights;
+ },
+ getIp : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getIp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost);
+ }
+ updateDynamicRam("getIp", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost);
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+ return scriptServer.ip;
+ },
+ getHostname : function(){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getHostname", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost);
+ }
+ updateDynamicRam("getHostname", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost);
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+ return scriptServer.hostname;
+ },
+ getHackingLevel : function(){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getHackingLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackingLevelRamCost);
+ }
+ updateDynamicRam("getHackingLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackingLevelRamCost);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].updateSkillLevels();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
+ workerScript.scriptRef.log("getHackingLevel() returned " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill);
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill;
+ },
+ getHackingMultipliers : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getHackingMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ }
+ updateDynamicRam("getHackingMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ return {
+ chance: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_chance_mult,
+ speed: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_speed_mult,
+ money: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_money_mult,
+ growth: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_grow_mult,
+ };
+ },
+ getHacknetMultipliers : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getHacknetMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ }
+ updateDynamicRam("getHacknetMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ return {
+ production: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_money_mult,
+ purchaseCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_purchase_cost_mult,
+ ramCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_ram_cost_mult,
+ coreCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_core_cost_mult,
+ levelCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_level_cost_mult,
+ };
+ },
+ getBitNodeMultipliers: function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getBitNodeMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ }
+ updateDynamicRam("getBitNodeMultipliers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost);
+ if (!hasAISF) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run.");
+ }
+ let copy = Object.assign({}, _BitNode_js__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"]);
+ return copy;
+ },
+ getServerMoneyAvailable : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerMoneyAvailable", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerMoneyAvailable", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (server.hostname == "home") {
+ //Return player's money
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
+ workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.toNumber(), 2));
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.toNumber();
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
+ workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
+ }
+ return server.moneyAvailable;
+ },
+ getServerSecurityLevel : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
+ workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.hackDifficulty;
+ },
+ getServerBaseSecurityLevel : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerBaseSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerBaseSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
+ workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.baseDifficulty;
+ },
+ getServerMinSecurityLevel : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerMinSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerMinSecurityLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
+ workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.minDifficulty;
+ },
+ getServerRequiredHackingLevel : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerRequiredHackingLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerRequiredHackingLevel", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
+ workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
+ }
+ return server.requiredHackingSkill;
+ },
+ getServerMaxMoney : function(ip){
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerMaxMoney", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerMaxMoney", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
+ workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
+ }
+ return server.moneyMax;
+ },
+ getServerGrowth : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerGrowth", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerGrowth", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
+ workerScript.scriptRef.log("getServerGrowth() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
+ }
+ return server.serverGrowth;
+ },
+ getServerNumPortsRequired : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerNumPortsRequired", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerNumPortsRequired", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
+ workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
+ }
+ return server.numOpenPortsRequired;
+ },
+ getServerRam : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getServerRam", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("getServerRam", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
+ workerScript.scriptRef.log("getServerRam() returned [" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.ramUsed, 2) + "GB]");
+ }
+ return [server.maxRam, server.ramUsed];
+ },
+ serverExists : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("serverExists", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ }
+ updateDynamicRam("serverExists", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost);
+ return (Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip) !== null);
+ },
+ fileExists : function(filename,ip=workerScript.serverIp) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("fileExists", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptFileExistsRamCost);
+ }
+ updateDynamicRam("fileExists", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptFileExistsRamCost);
+ if (filename === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (filename == server.scripts[i].filename) {
+ return true;
+ }
+ }
+ for (var i = 0; i < server.programs.length; ++i) {
+ if (filename.toLowerCase() == server.programs[i].toLowerCase()) {
+ return true;
+ }
+ }
+ for (var i = 0; i < server.messages.length; ++i) {
+ if (!(server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) &&
+ filename.toLowerCase() === server.messages[i]) {
+ return true;
+ }
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(filename, server);
+ if (txtFile != null) {
+ return true;
+ }
+ return false;
+ },
+ isRunning : function(filename,ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("isRunning", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptIsRunningRamCost);
+ }
+ updateDynamicRam("isRunning", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptIsRunningRamCost);
+ if (filename === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var argsForTargetScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForTargetScript.push(arguments[i]);
+ }
+ return (Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(filename, argsForTargetScript, server) != null);
+ },
+ getNextHacknetNodeCost : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getNextHacknetNodeCost", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost);
+ }
+ updateDynamicRam("getNextHacknetNodeCost", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost);
+ return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__["getCostOfNextHacknetNode"])();
+ },
+
+ purchaseHacknetNode : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("purchaseHacknetNode", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost);
+ }
+ updateDynamicRam("purchaseHacknetNode", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost);
+ return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__["purchaseHacknet"])();
+ },
+ getStockPrice : function(symbol) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getStockPrice", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost);
+ }
+ updateDynamicRam("getStockPrice", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPrice()");
+ }
+ return parseFloat(stock.price.toFixed(3));
+ },
+ getStockPosition : function(symbol) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getStockPosition", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost);
+ }
+ updateDynamicRam("getStockPosition", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPosition()");
+ }
+ return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
+ },
+ buyStock : function(symbol, shares) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("buyStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("buyStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use buyStock()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into buyStock()");
+ }
+ if (shares < 0 || isNaN(shares)) {
+ workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()");
+ return 0;
+ }
+ shares = Math.round(shares);
+ if (shares === 0) {return 0;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission)) {
+ workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " +
+ symbol + ". Need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission, 2).toString());
+ return 0;
+ }
+
+ var origTotal = stock.playerShares * stock.playerAvgPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShares += shares;
+ stock.playerAvgPx = newTotal / stock.playerShares;
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].Page.StockMarket) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["updateStockPlayerPosition"])(stock);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
+ workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(stock.price, 2) + " per share");
+ }
+ return stock.price;
+ },
+ sellStock : function(symbol, shares) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("sellStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("sellStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellStock()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into sellStock()");
+ }
+ if (shares < 0 || isNaN(shares)) {
+ workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()");
+ return 0;
+ }
+ shares = Math.round(shares);
+ if (shares > stock.playerShares) {shares = stock.playerShares;}
+ if (shares === 0) {return 0;}
+ var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainMoney(gains);
+
+ //Calculate net profit and add to script stats
+ var netProfit = ((stock.price - stock.playerAvgPx) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission;
+ if (isNaN(netProfit)) {netProfit = 0;}
+ workerScript.scriptRef.onlineMoneyMade += netProfit;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug += netProfit;
+
+ stock.playerShares -= shares;
+ if (stock.playerShares == 0) {
+ stock.playerAvgPx = 0;
+ }
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].Page.StockMarket) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["updateStockPlayerPosition"])(stock);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
+ workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(stock.price, 2) + " per share. Gained " +
+ "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(gains, 2));
+ }
+ return stock.price;
+ },
+ shortStock(symbol, shares) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("shortStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("shortStock", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use shortStock()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()");
+ }
+ var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["shortStock"])(stock, shares, workerScript);
+ return res ? stock.price : 0;
+ },
+ sellShort(symbol, shares) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("sellShort", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("sellShort", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellShort()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()");
+ }
+ var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["sellShort"])(stock, shares, workerScript);
+ return res ? stock.price : 0;
+ },
+ placeOrder(symbol, shares, price, type, pos) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("placeOrder", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("placeOrder", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()");
+ }
+ var orderType, orderPos;
+ type = type.toLowerCase();
+ if (type.includes("limit") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitBuy;
+ } else if (type.includes("limit") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitSell;
+ } else if (type.includes("stop") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopBuy;
+ } else if (type.includes("stop") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopSell;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
+ }
+
+ pos = pos.toLowerCase();
+ if (pos.includes("l")) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Long;
+ } else if (pos.includes('s')) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Short;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
+ }
+
+ return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["placeOrder"])(stock, shares, price, orderType, orderPos, workerScript);
+ },
+ cancelOrder(symbol, shares, price, type, pos) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("cancelOrder", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ }
+ updateDynamicRam("cancelOrder", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost);
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()");
+ }
+ if (isNaN(shares) || isNaN(price)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric");
+ }
+ var orderType, orderPos;
+ type = type.toLowerCase();
+ if (type.includes("limit") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitBuy;
+ } else if (type.includes("limit") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitSell;
+ } else if (type.includes("stop") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopBuy;
+ } else if (type.includes("stop") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopSell;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
+ }
+
+ pos = pos.toLowerCase();
+ if (pos.includes("l")) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Long;
+ } else if (pos.includes('s')) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Short;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
+ }
+ var params = {
+ stock: stock,
+ shares: shares,
+ price: price,
+ type: orderType,
+ pos: orderPos
+ };
+ return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["cancelOrder"])(params, workerScript);
+ },
+ purchaseServer : function(hostname, ram) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("purchaseServer", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ }
+ updateDynamicRam("purchaseServer", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ var hostnameStr = String(hostname);
+ hostnameStr = hostnameStr.replace(/\s+/g, '');
+ if (hostnameStr == "") {
+ workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()");
+ return "";
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.length >= _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerLimit) {
+ workerScript.scriptRef.log("Error: You have reached the maximum limit of " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerLimit +
+ " servers. You cannot purchase any more.");
+ return "";
+ }
+
+ ram = Math.round(ram);
+ if (isNaN(ram) || !Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["powerOfTwo"])(ram)) {
+ workerScript.scriptRef.log("Error: purchaseServer() failed due to invalid ram argument. Must be numeric and a power of 2");
+ return "";
+ }
+
+ if (ram > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerMaxRam) {
+ workerScript.scriptRef.log("Error: purchasedServer() failed because specified RAM was too high. Maximum RAM on a purchased server is " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerMaxRam + "GB");
+ return "";
+ }
+
+ var cost = ram * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamServer;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(cost)) {
+ workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(cost, 2));
+ return "";
+ }
+ var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_17__["Server"]({
+ ip: Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__["createRandomIp"])(),
+ hostname: hostnameStr,
+ organizationName: "",
+ isConnectedTo: false,
+ adminRights: true,
+ purchasedByPlayer: true,
+ maxRam: ram,
+ });
+ Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["AddToAllServers"])(newServ);
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.push(newServ.ip);
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
+ homeComputer.serversOnNetwork.push(newServ.ip);
+ newServ.serversOnNetwork.push(homeComputer.ip);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(cost);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
+ workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(cost, 2));
+ }
+ return newServ.hostname;
+ },
+ deleteServer : function(hostname) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("deleteServer", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ }
+ updateDynamicRam("deleteServer", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ var hostnameStr = String(hostname);
+ hostnameStr = hostnameStr.replace(/\s\s+/g, '');
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["GetServerByHostname"])(hostnameStr);
+ if (server == null) {
+ workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed");
+ return false;
+ }
+
+ if (!server.purchasedByPlayer || server.hostname === "home") {
+ workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " +
+ "Cannot be deleted. deleteServer() failed");
+ return false;
+ }
+
+ var ip = server.ip;
+
+ //Can't delete server you're currently connected to
+ if (server.isConnectedTo) {
+ workerScript.scriptRef.log("Error: deleteServer() failed because you are currently connected to the server you are trying to delete");
+ return false;
+ }
+
+ //A server cannot delete itself
+ if (ip === workerScript.serverIp) {
+ workerScript.scriptRef.log("Error: Cannot call deleteServer() on self. deleteServer() failed");
+ return false;
+ }
+
+ //Delete all scripts running on server
+ if (server.runningScripts.length > 0) {
+ workerScript.scriptRef.log("Error: Cannot delete server " + server.hostname + " because it still has scripts running.");
+ return false;
+ }
+
+ //Delete from player's purchasedServers array
+ var found = false;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.length; ++i) {
+ if (ip == _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers[i]) {
+ found = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.splice(i, 1);
+ break;
+ }
+ }
+
+ if (!found) {
+ workerScript.scriptRef.log("Error: Could not identify server " + server.hostname +
+ "as a purchased server. This is likely a bug please contact game dev");
+ return false;
+ }
+
+ //Delete from all servers
+ delete _Server_js__WEBPACK_IMPORTED_MODULE_17__["AllServers"][ip];
+
+ //Delete from home computer
+ found = false;
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
+ for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
+ if (ip == homeComputer.serversOnNetwork[i]) {
+ homeComputer.serversOnNetwork.splice(i, 1);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {
+ workerScript.scriptRef.log("Deleted server " + hostnameStr);
+ }
+ return true;
+ }
+ }
+ //Wasn't found on home computer
+ workerScript.scriptRef.log("Error: Could not find server " + server.hostname +
+ "as a purchased server. This is likely a bug please contact game dev");
+ return false;
+ },
+ getPurchasedServers : function(hostname=true) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getPurchasedServers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ }
+ updateDynamicRam("getPurchasedServers", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost);
+ var res = [];
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.forEach(function(ip) {
+ if (hostname) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev");
+ }
+ res.push(server.hostname);
+ } else {
+ res.push(ip);
+ }
+ });
+ return res;
+ },
+ write : function(port, data="", mode="a") {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("write", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ }
+ updateDynamicRam("write", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ if (!isNaN(port)) { //Write to port
+ //Port 1-10
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to write to invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid.");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.write(data);
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Write to text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
+ if (txtFile == null) {
+ txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["createTextFile"])(fn, data, server);
+ return true;
+ }
+ if (mode === "w") {
+ txtFile.write(data);
+ } else {
+ txtFile.append(data);
+ }
+ return true;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for write: " + port);
+ }
+ },
+ read : function(port) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("read", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ }
+ updateDynamicRam("read", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ if (!isNaN(port)) { //Read from port
+ //Port 1-10
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to read from invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid.");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.read();
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Read from text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
+ if (txtFile !== null) {
+ return txtFile.text;
+ } else {
+ return "";
+ }
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for read(): " + port);
+ }
+ },
+ peek : function(port) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("peek", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ }
+ updateDynamicRam("peek", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ if (isNaN(port)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
+ }
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.peek();
+ },
+ clear : function(port) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("clear", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ }
+ updateDynamicRam("clear", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ if (!isNaN(port)) { //Clear port
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to clear invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.clear();
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Clear text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
+ if (txtFile != null) {
+ txtFile.write("");
+ }
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for clear(): " + port);
+ }
+ return 0;
+ },
+ getPortHandle : function(port) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getPortHandle", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost * 10);
+ }
+ updateDynamicRam("getPortHandle", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost * 10);
+ if (isNaN(port)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Invalid argument passed into getPortHandle(). Must be an integer between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
+ }
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: getPortHandle() called with invalid port number: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port;
+ },
+ rm : function(fn) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("rm", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ }
+ updateDynamicRam("rm", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost);
+ var s = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
+ if (s == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
+ }
+
+ if (fn.includes(".exe")) {
+ for (var i = 0; i < s.programs.length; ++i) {
+ if (s.programs[i] === fn) {
+ s.programs.splice(i, 1);
+ return true;
+ }
+ }
+ } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["isScriptFilename"])(fn)) {
+ for (var i = 0; i < s.scripts.length; ++i) {
+ if (s.scripts[i].filename === fn) {
+ //Check that the script isnt currently running
+ for (var j = 0; j < s.runningScripts.length; ++j) {
+ if (s.runningScripts[j].filename === fn) {
+ workerScript.scriptRef.log("Cannot delete a script that is currently running!");
+ return false;
+ }
+ }
+ s.scripts.splice(i, 1);
+ return true;
+ }
+ }
+ } else if (fn.endsWith(".lit")) {
+ for (var i = 0; i < s.messages.length; ++i) {
+ var f = s.messages[i];
+ if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(f) && f === fn) {
+ s.messages.splice(i, 1);
+ return true;
+ }
+ }
+ } else if (fn.endsWith(".txt")) {
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ if (s.textFiles[i].fn === fn) {
+ s.textFiles.splice(i, 1);
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+ scriptRunning : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("scriptRunning", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost);
+ }
+ updateDynamicRam("scriptRunning", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.runningScripts.length; ++i) {
+ if (server.runningScripts[i].filename == scriptname) {
+ return true;
+ }
+ }
+ return false;
+ },
+ scriptKill : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("scriptKill", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost);
+ }
+ updateDynamicRam("scriptKill", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var suc = false;
+ for (var i = 0; i < server.runningScripts.length; ++i) {
+ if (server.runningScripts[i].filename == scriptname) {
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(server.runningScripts[i], server.ip);
+ suc = true;
+ }
+ }
+ return suc;
+ },
+ getScriptName : function() {
+ if (workerScript.checkingRam) {return 0;}
+ return workerScript.name;
+ },
+ getScriptRam : function (scriptname, ip=workerScript.serverIp) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getScriptRam", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ }
+ updateDynamicRam("getScriptRam", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename == scriptname) {
+ return server.scripts[i].ramUsage;
+ }
+ }
+ return 0;
+ },
+ getHackTime : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getHackTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ }
+ updateDynamicRam("getHackTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingTime"])(server); //Returns seconds
+ },
+ getGrowTime : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getGrowTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ }
+ updateDynamicRam("getGrowTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateGrowTime"])(server) / 1000; //Returns seconds
+ },
+ getWeakenTime : function(ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getWeakenTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ }
+ updateDynamicRam("getWeakenTime", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateWeakenTime"])(server) / 1000; //Returns seconds
+ },
+ getScriptIncome : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getScriptIncome", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ }
+ updateDynamicRam("getScriptIncome", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ if (arguments.length === 0) {
+ //Get total script income
+ var res = [];
+ res.push(Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])());
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].playtimeSinceLastAug/1000));
+ return res;
+ } else {
+ //Get income for a particular script
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
+ }
+ var argsForScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForScript.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(scriptname, argsForScript, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForScript));
+ return -1;
+ }
+ return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;
+ }
+ },
+ getScriptExpGain : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getScriptExpGain", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ }
+ updateDynamicRam("getScriptExpGain", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost);
+ if (arguments.length === 0) {
+ var total = 0;
+ for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"].length; ++i) {
+ total += (_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"][i].scriptRef.onlineExpGained / _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"][i].scriptRef.onlineRunningTime);
+ }
+ return total;
+ } else {
+ //Get income for a particular script
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
+ }
+ var argsForScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForScript.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(scriptname, argsForScript, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForScript));
+ return -1;
+ }
+ return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
+ }
+ },
+ getTimeSinceLastAug : function() {
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getTimeSinceLastAug", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ }
+ updateDynamicRam("getTimeSinceLastAug", _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost);
+ return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].playtimeSinceLastAug;
+ },
+ prompt : function(txt) {
+ if (workerScript.checkingRam) {return 0;}
+ if (_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxOpen"]) {
+ workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
+ return false;
+ }
+ if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(txt)) {txt = String(txt);}
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Yes";
+ noBtn.innerHTML = "No";
+ return new Promise(function(resolve, reject) {
+ yesBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxClose"])();
+ resolve(true);
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxClose"])();
+ resolve(false);
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxCreate"])(txt);
+ });
+ },
+
+ /* Singularity Functions */
+ universityCourse : function(universityName, className) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("universityCourse", ramCost);
+ }
+ updateDynamicRam("universityCourse", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ var costMult, expMult;
+ switch(universityName.toLowerCase()) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSummitUniversity.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSummitUniversity;
+ costMult = 4;
+ expMult = 3;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12RothmanUniversity.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12RothmanUniversity;
+ costMult = 3;
+ expMult = 2;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenZBInstituteOfTechnology.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven) {
+ workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenZBInstituteOfTechnology;
+ costMult = 5;
+ expMult = 4;
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid university name: " + universityName + ". universityCourse() failed");
+ return false;
+ }
+
+ var task;
+ switch(className.toLowerCase()) {
+ case "Study Computer Science".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassStudyComputerScience;
+ break;
+ case "Data Structures".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassDataStructures;
+ break;
+ case "Networks".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassNetworks;
+ break;
+ case "Algorithms".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassAlgorithms;
+ break;
+ case "Management".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassManagement;
+ break;
+ case "Leadership".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassLeadership;
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, task);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
+ workerScript.scriptRef.log("Started " + task + " at " + universityName);
+ }
+ return true;
+ },
+
+ gymWorkout : function(gymName, stat) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("gymWorkout", ramCost);
+ }
+ updateDynamicRam("gymWorkout", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: gymWorkout() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+ var costMult, expMult;
+ switch(gymName.toLowerCase()) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumCrushFitnessGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumCrushFitnessGym;
+ costMult = 3;
+ expMult = 2;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSnapFitnessGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSnapFitnessGym;
+ costMult = 10;
+ expMult = 5;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12IronGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12IronGym;
+ costMult = 1;
+ expMult = 1;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12PowerhouseGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12PowerhouseGym;
+ costMult = 20;
+ expMult = 10;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenMilleniumFitnessGym:
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenMilleniumFitnessGym;
+ costMult = 7;
+ expMult = 4;
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed");
+ return false;
+ }
+
+ switch(stat.toLowerCase()) {
+ case "strength".toLowerCase():
+ case "str".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymStrength);
+ break;
+ case "defense".toLowerCase():
+ case "def".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymDefense);
+ break;
+ case "dexterity".toLowerCase():
+ case "dex".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymDexterity);
+ break;
+ case "agility".toLowerCase():
+ case "agi".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymAgility);
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed");
+ return false;
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
+ workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
+ }
+ return true;
+ },
+
+ travelToCity(cityname) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("travelToCity", ramCost);
+ }
+ updateDynamicRam("travelToCity", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ switch(cityname) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Chongqing:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyo:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Ishima:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven:
+ if(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TravelCost)) {
+ workerScript.scriptRef.log("ERROR: not enough money to travel with travelToCity().");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: not enough money to travel with travelToCity().");
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TravelCost);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city = cityname;
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {
+ workerScript.scriptRef.log("Traveled to " + cityname);
+ }
+ return true;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity().");
+ return false;
+ }
+ },
+
+ purchaseTor() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("purchaseTor", ramCost);
+ }
+ updateDynamicRam("purchaseTor", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"]["Darkweb Server"] != null) {
+ workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed");
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TorRouterCost)) {
+ workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TorRouterCost);
+
+ var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_17__["Server"]({
+ ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__["createRandomIp"])(), hostname:"darkweb", organizationName:"",
+ isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1
+ });
+ Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["AddToAllServers"])(darkweb);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip);
+
+ document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive");
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().serversOnNetwork.push(darkweb.ip);
+ darkweb.serversOnNetwork.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().ip);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
+ workerScript.scriptRef.log("You have purchased a Tor router!");
+ }
+ return true;
+ },
+ purchaseProgram(programName) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("purchaseProgram", ramCost);
+ }
+ updateDynamicRam("purchaseProgram", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"]["Darkweb Server"] == null) {
+ workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed.");
+ return false;
+ }
+
+ switch(programName.toLowerCase()) {
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].BruteSSHProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].FTPCrackProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].RelaySMTPProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].HTTPWormProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].SQLInjectProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].DeepScanV1Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].DeepScanV2Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid program passed into purchaseProgram().");
+ return false;
+ }
+ return true;
+ },
+ getStats : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getStats", ramCost);
+ }
+ updateDynamicRam("getStats", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return {};
+ }
+ }
+
+ return {
+ hacking: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill,
+ strength: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].strength,
+ defense: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].defense,
+ dexterity: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].dexterity,
+ agility: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].agility,
+ charisma: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].charisma,
+ intelligence: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].intelligence
+ }
+ },
+ getCharacterInformation : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getCharacterInformation", ramCost);
+ }
+ updateDynamicRam("getCharacterInformation", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCharacterInformation(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return {};
+ }
+ }
+
+ var companyPositionTitle = "";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["CompanyPosition"]) {
+ companyPositionTitle = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName;
+ }
+ return {
+ bitnode: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN,
+ company: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyName,
+ jobTitle: companyPositionTitle,
+ city: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city,
+ factions: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factions.slice(),
+ tor: _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"].hasOwnProperty("Darkweb Server"),
+ timeWorked: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].timeWorked,
+ workHackExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workHackExpGained,
+ workStrExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workStrExpGained,
+ workDefExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workDefExpGained,
+ workDexExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workDexExpGained,
+ workAgiExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workAgiExpGained,
+ workChaExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workChaExpGained,
+ workRepGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workRepGained,
+ workMoneyGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workMoneyGained,
+ };
+ },
+ isBusy : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("isBusy", ramCost);
+ }
+ updateDynamicRam("isBusy", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return;
+ }
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking;
+ },
+ stopAction : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("stopAction", ramCost);
+ }
+ updateDynamicRam("stopAction", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run stopAction(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ return true;
+ }
+ return false;
+ },
+ upgradeHomeRam : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("upgradeHomeRam", ramCost);
+ }
+ updateDynamicRam("upgradeHomeRam", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ //Calculate how many times ram has been upgraded (doubled)
+ var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().maxRam;
+ var numUpgrades = Math.log2(currentRam);
+
+ //Calculate cost
+ //Have cost increase by some percentage each time RAM has been upgraded
+ var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamHome;
+ var mult = Math.pow(1.55, numUpgrades);
+ cost = cost * mult;
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(cost)) {
+ workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
+ return false;
+ }
+
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
+ homeComputer.maxRam *= 2;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(cost);
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {
+ workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
+ }
+ return true;
+ },
+ getUpgradeHomeRamCost : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getUpgradeHomeRamCost", ramCost);
+ }
+ updateDynamicRam("getUpgradeHomeRamCost", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ //Calculate how many times ram has been upgraded (doubled)
+ var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().maxRam;
+ var numUpgrades = Math.log2(currentRam);
+
+ //Calculate cost
+ //Have cost increase by some percentage each time RAM has been upgraded
+ var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamHome;
+ var mult = Math.pow(1.55, numUpgrades);
+ return cost * mult;
+ },
+ workForCompany : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("workForCompany", ramCost);
+ }
+ updateDynamicRam("workForCompany", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: workForCompany() failed because you are in the middle of a mission.");
+ return;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition == "" || !(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["CompanyPosition"])) {
+ workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job");
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.isPartTimeJob()) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startWorkPartTime();
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startWork();
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
+ workerScript.scriptRef.log("Began working at " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName);
+ }
+ return true;
+ },
+ applyToCompany : function(companyName, field) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("applyToCompany", ramCost);
+ }
+ updateDynamicRam("applyToCompany", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Company_js__WEBPACK_IMPORTED_MODULE_5__["companyExists"])(companyName)) {
+ workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist.");
+ return false;
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = companyName;
+ var res;
+ switch (field.toLowerCase()) {
+ case "software":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSoftwareJob(true);
+ break;
+ case "software consultant":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSoftwareConsultantJob(true);
+ break;
+ case "it":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForItJob(true);
+ break;
+ case "security engineer":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSecurityEngineerJob(true);
+ break;
+ case "network engineer":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForNetworkEngineerJob(true);
+ break;
+ case "business":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForBusinessJob(true);
+ break;
+ case "business consultant":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForBusinessConsultantJob(true);
+ break;
+ case "security":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSecurityJob(true);
+ break;
+ case "agent":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForAgentJob(true);
+ break;
+ case "employee":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForEmployeeJob(true);
+ break;
+ case "part-time employee":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForPartTimeEmployeeJob(true);
+ break;
+ case "waiter":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForWaiterJob(true);
+ break;
+ case "part-time waiter":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForPartTimeWaiterJob(true);
+ break;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed");
+ return false;
+ }
+ //The Player object's applyForJob function can return string with special error messages
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(res)) {
+ workerScript.scriptRef.log(res);
+ return false;
+ }
+ if (res) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
+ workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName);
+ }
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
+ workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
+ }
+ }
+ return res;
+ },
+ getCompanyRep : function(companyName) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getCompanyRep", ramCost);
+ }
+ updateDynamicRam("getCompanyRep", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_5__["Companies"][companyName];
+ if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["Company"])) {
+ workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName);
+ return -1;
+ }
+ return company.playerReputation;
+ },
+ getCompanyFavor : function(companyName) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getCompanyFavor", ramCost);
+ }
+ updateDynamicRam("getCompanyFavor", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_5__["Companies"][companyName];
+ if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["Company"])) {
+ workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavor(): " + companyName);
+ return -1;
+ }
+ return company.favor;
+ },
+ checkFactionInvitations : function() {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("checkFactionInvitations", ramCost);
+ }
+ updateDynamicRam("checkFactionInvitations", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+ //Make a copy of Player.factionInvitations
+ return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.slice();
+ },
+ joinFaction : function(name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("joinFaction", ramCost);
+ }
+ updateDynamicRam("joinFaction", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist.");
+ return false;
+ }
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.includes(name)) {
+ workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
+ return false;
+ }
+
+ var index = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.indexOf(name);
+ if (index === -1) {
+ //Redundant and should never happen...
+ workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.splice(index, 1);
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name];
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["joinFaction"])(fac);
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
+ workerScript.scriptRef.log("Joined the " + name + " faction.");
+ }
+ return true;
+ },
+ workForFaction : function(name, type) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("workForFaction", ramCost);
+ }
+ updateDynamicRam("workForFaction", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: workForFaction() failed because you are in the middle of a mission.");
+ return;
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist.");
+ return false;
+ }
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factions.includes(name)) {
+ workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name);
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name];
+ //Arrays listing factions that allow each time of work
+ var hackAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp",
+ "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
+ "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
+ "Fulcrum Secret Technologies", "BitRunners", "The Black Hand",
+ "NiteSec", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
+ "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army",
+ "The Syndicate", "Silhouette", "Netburners", "Tian Di Hui", "CyberSec"];
+ var fdWkAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp",
+ "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
+ "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
+ "The Black Hand", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
+ "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army",
+ "The Syndicate", "Silhouette", "Tetrads", "Slum Snakes"];
+ var scWkAvailable = ["ECorp", "MegaCorp",
+ "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
+ "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
+ "Fulcrum Secret Technologies", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
+ "Ishima", "Volhaven", "Speakers for the Dead",
+ "The Syndicate", "Tetrads", "Slum Snakes", "Tian Di Hui"];
+
+ switch (type.toLowerCase()) {
+ case "hacking":
+ case "hacking contracts":
+ case "hackingcontracts":
+ if (!hackAvailable.includes(fac.name)) {
+ workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionHackWork(fac);
+ workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name);
+ return true;
+ case "field":
+ case "fieldwork":
+ case "field work":
+ if (!fdWkAvailable.includes(fac.name)) {
+ workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionFieldWork(fac);
+ workerScript.scriptRef.log("Started carrying out field missions for " + fac.name);
+ return true;
+ case "security":
+ case "securitywork":
+ case "security work":
+ if (!scWkAvailable.includes(fac.name)) {
+ workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionSecurityWork(fac);
+ workerScript.scriptRef.log("Started serving as security details for " + fac.name);
+ return true;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type);
+ }
+ return true;
+ },
+ getFactionRep : function(name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getFactionRep", ramCost);
+ }
+ updateDynamicRam("getFactionRep", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return -1;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist.");
+ return -1;
+ }
+
+ return _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name].playerReputation;
+ },
+ getFactionFavor : function(name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getFactionFavor", ramCost);
+ }
+ updateDynamicRam("getFactionFavor", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return -1;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavor() does not exist.");
+ return -1;
+ }
+
+ return _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name].favor;
+ },
+ createProgram : function(name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("createProgram", ramCost);
+ }
+ updateDynamicRam("createProgram", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ switch(name.toLowerCase()) {
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram.toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 50) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 100) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 100);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 250) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 250);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 500) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer4Hours, 500);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 750) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer8Hours, 750);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 75) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 400) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 400);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 75) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 75);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 25) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
+ break;
+ default:
+ workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
+ return false;
+ }
+ workerScript.scriptRef.log("Began creating program: " + name);
+ return true;
+ },
+ commitCrime : function(crimeRoughName) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("commitCrime", ramCost);
+ }
+ updateDynamicRam("commitCrime", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: commitCrime() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ //Set Location to slums
+ switch(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Chongqing:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].ChongqingSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12Slums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyo:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyoSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Ishima:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].IshimaSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven:
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenSlums;
+ break;
+ default:
+ console.log("Invalid Player.city value");
+ }
+
+ const crime = Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["findCrime"])(crimeRoughName.toLowerCase());
+ if(crime == null) { // couldn't find crime
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into commitCrime(): " + crime);
+ }
+ if(workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
+ workerScript.scriptRef.log("Attempting to commit crime: "+crime.name+"...");
+ }
+ return crime.commit(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ },
+ getCrimeChance : function(crimeRoughName) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getCrimeChance", ramCost);
+ }
+ updateDynamicRam("getCrimeChance", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return;
+ }
+ }
+
+ const crime = Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["findCrime"])(crimeRoughName.toLowerCase());
+ if(crime == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime);
+ }
+
+ return crime.successRate();
+ },
+ getOwnedAugmentations : function(purchased=false) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getOwnedAugmentations", ramCost);
+ }
+ updateDynamicRam("getOwnedAugmentations", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return [];
+ }
+ }
+ var res = [];
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations.length; ++i) {
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations[i].name);
+ }
+ if (purchased) {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length; ++i) {
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations[i].name);
+ }
+ }
+ return res;
+ },
+ getAugmentationsFromFaction : function(facname) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getAugmentationsFromFaction", ramCost);
+ }
+ updateDynamicRam("getAugmentationsFromFaction", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return [];
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(facname)) {
+ workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname);
+ return [];
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][facname];
+ var res = [];
+ for (var i = 0; i < fac.augmentations.length; ++i) {
+ res.push(fac.augmentations[i]);
+ }
+ return res;
+ },
+ getAugmentationCost : function(name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("getAugmentationCost", ramCost);
+ }
+ updateDynamicRam("getAugmentationCost", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["augmentationExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
+ return [-1, -1];
+ }
+
+ var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
+ return [aug.baseRepRequirement, aug.baseCost];
+ },
+ purchaseAugmentation : function(faction, name) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("purchaseAugmentation", ramCost);
+ }
+ updateDynamicRam("purchaseAugmentation", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][faction];
+ if (fac == null || !(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Faction"])) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid faction name: " + faction);
+ return false;
+ }
+
+ if (!fac.augmentations.includes(name)) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because the faction " + faction + " does not contain the " + name + " augmentation");
+ return false;
+ }
+
+ var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
+ if (aug == null || !(aug instanceof _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentation"])) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name);
+ return false;
+ }
+
+ var isNeuroflux = false;
+ if (aug.name === _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["AugmentationNames"].NeuroFluxGovernor) {
+ isNeuroflux = true;
+ }
+
+ if (!isNeuroflux) {
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations[j].name === aug.name) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
+ return false;
+ }
+ }
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations[j].name === aug.name) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
+ return false;
+ }
+ }
+ }
+
+ if (fac.playerReputation < aug.baseRepRequirement) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you do not have enough reputation with " + fac.name);
+ return false;
+ }
+
+ var res = Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["purchaseAugmentation"])(aug, fac, true);
+ workerScript.scriptRef.log(res);
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(res) && res.startsWith("You purchased")) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ return true;
+ } else {
+ return false;
+ }
+ },
+ installAugmentations : function(cbScript) {
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ if (workerScript.checkingRam) {
+ return updateStaticRam("installAugmentations", ramCost);
+ }
+ updateDynamicRam("installAugmentations", ramCost);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length === 0) {
+ workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed");
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["installAugmentations"])(cbScript);
+ return true;
+ },
+
+ //Bladeburner API
+ bladeburner : {
+ isContractName : function(name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ isOperationName : function(name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ isBlackOpName : function(name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ isGeneralActionName : function(name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ isSkillName : function(name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ startAction : function(type, name) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ stopAction : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getActionTime : function(type="", name="") {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getActionEstimatedSuccessChance : function(type="", name="") {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getActionCountRemaining : function(type="", name="") {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getRank : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getSkillPoints : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getSkillLevel : function(skillName="") {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ upgradeSkill : function(skillName) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getTeamSize : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ setTeamSize : function(type="", name="", size) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getCityEstimatedPopulation : function(cityName) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getCityEstimatedCommunities : function(cityName) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getCityChaos : function(cityName) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ switchCity : function(cityName) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ getStamina : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ },
+ joinFaction : function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
+
+ }
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
+ "at the Bladeburner division or because you do not have Source-File 7");
+ }
+ }
+ } //End return
+} //End NetscriptFunction()
+
+
+
/***/ }),
/* 27 */
-/*!****************************!*\
- !*** ./src/Bladeburner.js ***!
- \****************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bladeburner", function() { return Bladeburner; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Location.js */ 4);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./RedPill.js */ 45);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 18);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! numeral/min/numeral.min */ 13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
-
-var CyclesPerSecond = 5; //Game cycle is 200 ms
-
-var StaminaGainPerSecond = 0.0085;
-var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty
-var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain
-
-var DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time
-
-//The difficulty multiplier affects stamina loss and hp loss of an action. Its formula is:
-//difficulty ^ exponentialFactor + difficulty / linearFactor
-var DiffMultExponentialFactor = 0.28;
-var DiffMultLinearFactor = 670;
-
-var BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action
-
-var PopulationThreshold = 1e9; //Population at which success rates start being affected
-var ChaosThreshold = 50; //City chaos level after which it starts making tasks harder
-
-var BaseStatGain = 1; //Base stat gain per second
-var BaseIntGain = 0.001; //Base intelligence stat gain
-
-var ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value
-
-var RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank
-
-var ContractSuccessesPerLevel = 15; //How many successes you need to level up a contract
-var OperationSuccessesPerLevel = 10; //How many successes you need to level up an op
-
-var RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point
-
-var ContractBaseMoneyGain = 5e3; //Base Money Gained per contract
-
-//DOM related variables
-var ActiveActionCssClass = "bladeburner-active-action";
-
-//Console related stuff
-var consoleHistory = []; //Console command history
-var consoleHistoryIndex = 0;
-var consoleHelpText = {
- helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.
" +
- "automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks
" +
- "clear/cls Clear the console
" +
- "help [cmd] Display this help text, or help text for a specific command
" +
- "log [en/dis] [type] Enable or disable logging for events and actions
" +
- "skill [action] [name] Level or display info about your Bladeburner skills
" +
- "start [type] [name] Start a Bladeburner action/task
" +
- "stop Stops your current Bladeburner action/task
",
- automate:"automate [var] [val] [hi/low]
" +
- "A simple way to automate your Bladeburner actions. This console command can be used " +
- "to automatically start an action when your stamina rises above a certain threshold, and " +
- "automatically switch to another action when your stamina drops below another threshold.
" +
- "automate status - Check the current status of your automation and get a brief description of what it'll do
" +
- "automate en - Enable the automation feature
" +
- "automate dis - Disable the automation feature
" +
- "There are four properties that must be set for this automation to work properly. Here is how to set them:
" +
- "automate stamina 100 high
" +
- "automate contract Tracking high
" +
- "automate stamina 50 low
" +
- 'automate general "Field Analysis" low
' +
- "Using the four console commands above will set the automation to perform Tracking contracts " +
- "if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below " +
- "50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must " +
- "exactly match whatever the name is in the UI.",
- clear:"clear
Clears the console",
- cls:"cls
Clears the console",
- help:"help [command]
" +
- "Running 'help' with no arguments displays the general help text, which lists all console commands " +
- "and a brief description of what they do. A command can be specified to get more specific help text " +
- "about that particular command. For example:
" +
- "help automate
" +
- "will display specific information about using the automate console command",
- log:"log [en/dis] [type]
" +
- "Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged " +
- "in the console. There are also random events that are logged in the console as well. The five categories of " +
- "things that get logged are:
" +
- "[general, contracts, ops, blackops, events]
" +
- "The logging for these categories can be enabled or disabled like so:
" +
- "log dis contracts - Disables logging that occurs when contracts are completed
" +
- "log en contracts - Enables logging that occurs when contracts are completed
" +
- "log dis events - Disables logging for Bladeburner random events
" +
- "Logging can be universally enabled/disabled using the 'all' keyword:
" +
- "log dis all
" +
- "log en all",
- skill:"skill [action] [name]
" +
- "Level or display information about your skills.
" +
- "To display information about all of your skills and your multipliers, use:
" +
- "skill list
" +
- "To display information about a specific skill, specify the name of the skill afterwards. " +
- "Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If " +
- "the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
" +
- "skill list Reaper
" +
- 'skill list "Digital Observer"
' +
- "This console command can also be used to level up skills:
" +
- "skill level [skill name]",
- start:"start [type] [name]
" +
- "Start an action. An action is specified by its type and its name. The " +
- "name is case-sensitive. It must appear exactly as it does in the UI. If " +
- "the name of the action has whitespace, enclose it in double quotation marks. " +
- "Valid action types include:
" +
- "[general, contract, op, blackop]
" +
- "Examples:
" +
- 'start contract Tracking
' +
- 'start op "Undercover Operation"
',
- stop:"stop
" +
- "Stop your current action and go idle",
-}
-
-//Keypresses for Console
-$(document).keydown(function(event) {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
- //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
- // DomElems.consoleInput.focus();
- //}
-
- if (!(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner instanceof Bladeburner)) {return;}
-
- //NOTE: Keycodes imported from Terminal.js
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].ENTER) {
- event.preventDefault();
- var command = DomElems.consoleInput.value;
- if (command.length > 0) {
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.postToConsole("> " + command);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.resetConsoleInput();
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.executeConsoleCommands(command);
- }
- }
-
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].UPARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len === 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- if (i !== 0) {
- --consoleHistoryIndex;
- }
-
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);
- }
-
- if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].DOWNARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len == 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- //Latest command, put nothing
- if (i == len || i == len-1) {
- consoleHistoryIndex = len;
- DomElems.consoleInput.value = "";
- } else {
- ++consoleHistoryIndex;
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- }
- }
- }
-});
-
-function City(params={}) {
- this.name = params.name ? params.name : _Location_js__WEBPACK_IMPORTED_MODULE_3__["Locations"].Sector12;
-
- //Synthoid population and estimate
- this.pop = params.pop ? params.pop : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(800e6, 1.2*PopulationThreshold);
- this.popEst = this.pop * (Math.random() + 0.5);
-
- //Number of Synthoid communities population and estimate
- this.comms = params.comms ? params.comms : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 40);
- this.commsEst = this.comms + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-2, 2);
- if (this.commsEst < 0) {this.commsEst = 0;}
- this.chaos = 0;
-}
-
-City.prototype.improvePopulationEstimateByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passeed into City.improvePopulationEstimateByCount()");}
- if (this.popEst < this.pop) {
- this.popEst += n;
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst -= n;
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
-City.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {
- p = p*skillMult;
- if (isNaN(p)) {throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()");}
- if (this.popEst < this.pop) {
- ++this.popEst; //In case estimate is 0
- this.popEst *= (1 + (p/100));
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst *= (1 - (p/100));
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-City.prototype.improveCommunityEstimate = function(n=1) {
- if (isNaN(n)) {throw new Error("NaN passed into City.improveCommunityEstimate()");}
- if (this.commsEst < this.comms) {
- this.commsEst += n;
- if (this.commsEst > this.comms) {this.commsEst = this.comms;}
- } else if (this.commsEst > this.comms) {
- this.commsEst -= n;
- if (this.commsEst < this.comms) {this.commsEst = this.comms;}
- }
-}
-
-//@params options:
-// estChange(int): How much the estimate should change by
-// estOffset(int): Add offset to estimate (offset by percentage)
-City.prototype.changePopulationByCount = function(n, params={}) {
- if (isNaN(n)) {throw new Error("NaN passed into City.changePopulationByCount()");}
- this.pop += n;
- if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}
- if (params.estOffset) {
- this.popEst = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(this.popEst, params.estOffset);
- }
- this.popEst = Math.max(this.popEst, 0);
-}
-
-//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
-//@params options:
-// changeEstEqually(bool) - Change the population estimate by an equal amount
-// nonZero (bool) - Set to true to ensure that population always changes by at least 1
-City.prototype.changePopulationByPercentage = function(p, params={}) {
- if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
- if (p === 0) {return;}
- var change = Math.round(this.pop * (p/100));
-
- //Population always changes by at least 1
- if (params.nonZero && change === 0) {
- p > 0 ? change = 1 : change = -1;
- }
-
- this.pop += change;
- if (params.changeEstEqually) {
- this.popEst += change;
- if (this.popEst < 0) {this.popEst = 0;}
- }
- return change;
-}
-
-City.prototype.changeChaosByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passed into City.changeChaosByCount()");}
- if (n === 0) {return;}
- this.chaos += n;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
-City.prototype.changeChaosByPercentage = function(p) {
- if (isNaN(p)) {throw new Error("NaN passed into City.chaosChaosByPercentage()");}
- if (p === 0) {return;}
- var change = this.chaos * (p/100);
- this.chaos += change;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-City.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("City", this);
-}
-City.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(City, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.City = City;
-
-function Skill(params={name:"foo", desc:"foo"}) {
- if (params.name) {
- this.name = params.name;
- } else {
- throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor");
- }
- if (params.desc) {
- this.desc = params.desc;
- } else {
- throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor");
- }
- this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points
- this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level
-
- if (params.maxLvl) {this.maxLvl = params.maxLvl;}
-
- //These benefits are additive. So total multiplier will be level (handled externally) times the
- //effects below
- if (params.successChanceAll) {this.successChanceAll = params.successChanceAll;}
- if (params.successChanceStealth) {this.successChanceStealth = params.successChanceStealth;}
- if (params.successChanceKill) {this.successChanceKill = params.successChanceKill;}
- if (params.successChanceContract) {this.successChanceContract = params.successChanceContract;}
- if (params.successChanceOperation) {this.successChanceOperation = params.successChanceOperation;}
-
- //This multiplier affects everything that increases synthoid population/community estimate
- //e.g. Field analysis, Investigation Op, Undercover Op
- if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
-
- if (params.actionTime) {this.actionTime = params.actionTime;}
- if (params.effHack) {this.effHack = params.effHack;}
- if (params.effStr) {this.effStr = params.effStr;}
- if (params.effDef) {this.effDef = params.effDef;}
- if (params.effDex) {this.effDex = params.effDex;}
- if (params.effAgi) {this.effAgi = params.effAgi;}
- if (params.effCha) {this.effCha = params.effCha;}
-
- if (params.stamina) {this.stamina = params.stamina;}
-
- //Equipment
- if (params.weaponAbility) {this.weaponAbility = params.weaponAbility;}
- if (params.gunAbility) {this.gunAbility = params.gunAbility;}
-}
-var Skills = {};
-var SkillNames = {
- BladesIntuition: "Blade's Intuition",
- Reaper: "Reaper",
- Cloak: "Cloak",
- Marksman: "Marksman",
- WeaponProficiency: "Weapon Proficiency",
- Overclock: "Overclock",
- EvasiveSystem: "Evasive System",
- ShortCircuit: "Short-Circuit",
- DigitalObserver: "Digital Observer",
- Datamancer: "Datamancer",
- Tracer: "Tracer",
- CybersEdge: "Cyber's Edge"
-}
-
-//Base Class for Contracts, Operations, and BlackOps
-function Action(params={}) {
- this.name = params.name ? params.name : "";
- this.desc = params.desc ? params.desc : "";
-
- //Difficulty scales with level
- //Exact formula is not set in stone
- //Initial design: baseDifficulty * (difficultyFac ^ level)?
- //difficulty Fac is slightly greater than 1
- this.level = 1;
- this.maxLevel = 1;
- this.autoLevel = true;
- this.baseDifficulty = params.baseDifficulty ? Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(params.baseDifficulty, 10) : 100;
- this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;
-
- //Rank increase/decrease is affected by this exponent
- this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;
-
- this.successes = 0;
- this.failures = 0;
-
- //All of these scale with level/difficulty
- this.rankGain = params.rankGain ? params.rankGain : 0;
- if (params.rankLoss) {this.rankLoss = params.rankLoss;}
- if (params.hpLoss) {
- this.hpLoss = params.hpLoss;
- this.hpLost = 0;
- }
-
- //Action Category. Current categories are stealth and kill
- this.isStealth = params.isStealth ? true : false;
- this.isKill = params.isKill ? true : false;
-
- //Number of this contract remaining, and its growth rate
- //Growth rate is an integer and the count will increase by that integer every "cycle"
- this.count = params.count ? params.count : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1e3, 25e3);
- this.countGrowth = params.countGrowth ? params.countGrowth : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5);
-
- //Weighting of each stat in determining action success rate
- var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};
- this.weights = params.weights ? params.weights : defaultWeights;
-
- //Check to make sure weights are summed properly
- var sum = 0;
- for (var weight in this.weights) {
- if (this.weights.hasOwnProperty(weight)) {
- sum += this.weights[weight];
- }
- }
- if (sum - 1 >= 10 * Number.EPSILON) {
- throw new Error("Invalid weights when constructing Action " + this.name +
- ". The weights should sum up to 1. They sum up to :" + 1);
- }
-
- //Diminishing returns of stats (stat ^ decay where 0 <= decay <= 1)
- var defaultDecays = {hack:0.9,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.9,int:0.9};
- this.decays = params.decays ? params.decays : defaultDecays;
- for (var decay in this.decays) {
- if (this.decays.hasOwnProperty(decay)) {
- if (this.decays[decay] > 1) {
- throw new Error("Invalid decays when constructing " +
- "Action " + this.name + ". " +
- "Decay value cannot be greater than 1");
- }
- }
- }
-}
-
-Action.prototype.getDifficulty = function() {
- var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);
- if (isNaN(difficulty)) {throw new Error("Calculated NaN in Action.getDifficulty()");}
- return difficulty;
-}
-
-//@inst - Bladeburner Object
-//@params - options:
-// est (bool): Get success chance estimate instead of real success chance
-Action.prototype.getSuccessChance = function(inst, params={}) {
- if (inst == null) {throw new Error("Invalid Bladeburner instance passed into Action.getSuccessChance");}
- var difficulty = this.getDifficulty();
- var competence = 0;
- for (var stat in this.weights) {
- if (this.weights.hasOwnProperty(stat)) {
- var playerStatLvl = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].queryStatFromString(stat);
- var key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
- var effMultiplier = inst.skillMultipliers[key];
- if (effMultiplier == null) {
- console.log("ERROR: Failed to find Bladeburner Skill multiplier for: " + stat);
- effMultiplier = 1;
- }
- competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));
- }
- }
- competence *= inst.calculateStaminaPenalty();
-
- //For Operations, factor in team members
- if (this instanceof Operation || this instanceof BlackOperation) {
- if (this.teamCount && this.teamCount > 0) {
- this.teamCount = Math.min(this.teamCount, inst.teamSize);
- var teamMultiplier = Math.pow(this.teamCount, 0.05);
- competence *= teamMultiplier;
- }
- }
-
- //Lower city population results in lower chances
- if (!(this instanceof BlackOperation)) {
- var city = inst.getCurrentCity();
- if (params.est) {
- competence *= (city.popEst / PopulationThreshold);
- } else {
- competence *= (city.pop / PopulationThreshold);
- }
-
- //Too high of a chaos results in lower chances
- if (city.chaos > ChaosThreshold) {
- var diff = 1 + (city.chaos - ChaosThreshold);
- var mult = Math.pow(diff, 0.1);
- difficulty *= mult;
- }
-
- //For Raid Operations, no communities = fail
- if (this instanceof Operation && this.name === "Raid") {
- if (city.comms <= 0) {return 0;}
- }
- }
-
- //Factor skill multipliers into success chance
- competence *= inst.skillMultipliers.successChanceAll;
- if (this instanceof Operation || this instanceof BlackOperation) {
- competence *= inst.skillMultipliers.successChanceOperation;
- }
- if (this instanceof Contract) {
- competence *= inst.skillMultipliers.successChanceContract;
- }
- if (this.isStealth) {
- competence *= inst.skillMultipliers.successChanceStealth;
- }
- if (this.isKill) {
- competence *= inst.skillMultipliers.successChanceKill;
- }
-
- //Augmentation multiplier
- competence *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_success_chance_mult;
-
- if (isNaN(competence)) {throw new Error("Competence calculated as NaN in Action.getSuccessChance()");}
- return Math.min(1, competence / difficulty);
-}
-
-//Tests for success. Should be called when an action has completed
-// @inst - Bladeburner Object
-Action.prototype.attempt = function(inst) {
- return (Math.random() < this.getSuccessChance(inst));
-}
-
-Action.prototype.getActionTime = function(inst) {
- var difficulty = this.getDifficulty();
- var baseTime = difficulty / DifficultyToTimeFactor;
- var skillFac = inst.skillMultipliers.actionTime; //Always < 1
-
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * inst.skillMultipliers.effAgi;
- var effDexterity = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity * inst.skillMultipliers.effDex;
- var statFac = 0.5 * (Math.pow(effAgility, 0.03) + Math.pow(effDexterity, 0.03)); //Always > 1
-
- baseTime = Math.max(1, baseTime * skillFac / statFac);
-
- if (this instanceof Contract) {
- return Math.ceil(baseTime);
- } else if (this instanceof Operation) {
- return Math.ceil(baseTime);
- } else if (this instanceof BlackOperation) {
- return Math.ceil(baseTime * 1.5);
- } else {
- throw new Error("Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation");
- }
-}
-
-Action.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Action", this);
-}
-Action.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Action, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Action = Action;
-var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
-
-//Action Identifier
-var ActionTypes = Object.freeze({
- "Idle": 1,
- "Contract": 2,
- "Operation": 3,
- "BlackOp": 4,
- "BlackOperation": 4,
- "Training": 5,
- "Recruitment": 6,
- "FieldAnalysis": 7,
- "Field Analysis": 7
-});
-function ActionIdentifier(params={}) {
- if (params.name) {this.name = params.name;}
- if (params.type) {this.type = params.type;}
-}
-ActionIdentifier.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("ActionIdentifier", this);
-}
-ActionIdentifier.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(ActionIdentifier, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.ActionIdentifier = ActionIdentifier;
-
-//Contracts
-function Contract(params={}) {
- Action.call(this, params);
-}
-Contract.prototype = Object.create(Action.prototype);
-Contract.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Contract", this);
-}
-Contract.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Contract, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Contract = Contract;
-
-//Operations
-function Operation(params={}) {
- Action.call(this, params);
- this.reqdRank = params.reqdRank ? params.reqdRank : 100;
- this.teamCount = params.teamCount ? params.teamCount : 0; //# of team members to use
-}
-Operation.prototype = Object.create(Action.prototype);
-Operation.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Operation", this);
-}
-Operation.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Operation, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Operation = Operation;
-
-//Black Operations
-function BlackOperation(params={}) {
- Operation.call(this, params);
-
- //Black ops are one time missions
- this.count = 1;
- this.countGrowth = 0;
-}
-BlackOperation.prototype = Object.create(Action.prototype);
-BlackOperation.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("BlackOperation", this);
-}
-BlackOperation.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(BlackOperation, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.BlackOperation = BlackOperation;
-var BlackOperations = {};
-
-function Bladeburner(params={}) {
- this.numHosp = 0; //Number of hospitalizations
- this.moneyLost = 0; //Money lost due to hospitalizations
- this.rank = 0;
- this.maxRank = 0; //Used to determine skill points
-
- this.skillPoints = 0;
- this.totalSkillPoints = 0;
-
- this.teamSize = 0; //Number of team members
- this.teamLost = 0; //Number of team members lost
-
- this.storedCycles = 0;
-
- this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600); //5-10 minutes
-
- //These times are in seconds
- this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)
- this.actionTimeCurrent = 0;
-
- //ActionIdentifier Object
- var idleActionType = ActionTypes["Idle"];
- this.action = new ActionIdentifier({type:idleActionType});
-
- this.cities = {};
- for (var i = 0; i < CityNames.length; ++i) {
- this.cities[CityNames[i]] = new City({name:CityNames[i]});
- }
- this.city = _Location_js__WEBPACK_IMPORTED_MODULE_3__["Locations"].Sector12;
-
- //Map of SkillNames -> level
- this.skills = {};
- this.skillMultipliers = {};
- this.updateSkillMultipliers(); //Calls resetSkillMultipliers()
-
- //Max Stamina is based on stats and Bladeburner-specific bonuses
- this.staminaBonus = 0; //Gained from training
- this.maxStamina = 0;
- this.calculateMaxStamina();
- this.stamina = this.maxStamina;
-
- //Contracts and Operations objects. These objects have unique
- //properties because they are randomized in each instance and have stats like
- //successes/failures, so they need to be saved/loaded by the game.
- this.contracts = {};
- this.operations = {};
-
- //Object that contains name of all Black Operations that have been completed
- this.blackops = {};
-
- //Flags for whether these actions should be logged to console
- this.logging = {
- general:true,
- contracts:true,
- ops:true,
- blackops:true,
- events:true,
- }
-
- //Simple automation values
- this.automateEnabled = false;
- this.automateActionHigh = 0;
- this.automateThreshHigh = 0; //Stamina Threshold
- this.automateActionLow = 0;
- this.automateThreshLow = 0; //Stamina Threshold
-
- //Initialization
- initBladeburner();
- this.initializeDomElementRefs();
- if (params.new) {this.create();}
-}
-
-Bladeburner.prototype.create = function() {
- this.contracts["Tracking"] = new Contract({
- name:"Tracking",
- desc:"Identify and locate Synthoids. This contract involves reconnaissance " +
- "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
" +
- "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " +
- "whatever city you are currently in.",
- baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,
- rankGain:0.3, hpLoss:0.5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5),
- weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},
- isStealth:true
- });
- this.contracts["Bounty Hunter"] = new Contract({
- name:"Bounty Hunter",
- desc:"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
" +
- "Successfully completing a Bounty Hunter contract will lower the population in your " +
- "current city, and will also increase its chaos level.",
- baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,
- rankGain:0.9, hpLoss:1,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 3),
- weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
- this.contracts["Retirement"] = new Contract({
- name:"Retirement",
- desc:"Hunt down and retire (kill) rogue Synthoids.
" +
- "Successfully copmleting a Retirement contract will lower the population in your current " +
- "city, and will also increase its chaos level.",
- baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,
- rankGain:0.6, hpLoss:1,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1,4),
- weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
-
- this.operations["Investigation"] = new Operation({
- name:"Investigation",
- desc:"As a field agent, investigate and identify Synthoid " +
- "populations, movements, and operations.
Successful " +
- "Investigation ops will increase the accuracy of your " +
- "synthoid data.
" +
- "You will NOT lose HP from failed Investigation ops.",
- baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,
- rankGain:2, rankLoss:0.2,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 400), countGrowth:1,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},
- decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Undercover Operation"] = new Operation({
- name:"Undercover Operation",
- desc:"Conduct undercover operations to identify hidden " +
- "and underground Synthoid communities and organizations.
" +
- "Successful Undercover ops will increase the accuracy of your synthoid " +
- "data.",
- baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,
- rankGain:4, rankLoss:0.4, hpLoss:2,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 300), countGrowth:1,
- weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Sting Operation"] = new Operation({
- name:"Sting Operation",
- desc:"Conduct a sting operation to bait and capture particularly " +
- "notorious Synthoid criminals.",
- baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,
- rankGain:5, rankLoss:0.5, hpLoss:2.5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25,400), countGrowth:0.75,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Raid"] = new Operation({
- name:"Raid",
- desc:"Lead an assault on a known Synthoid community. Note that " +
- "there must be an existing Synthoid community in your current city " +
- "in order for this Operation to be successful",
- baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,
- rankGain:50,rankLoss:2.5,hpLoss:50,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 150), countGrowth:0.2,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isKill:true
- });
- this.operations["Stealth Retirement Operation"] = new Operation({
- name:"Stealth Retirement Operation",
- desc:"Lead a covert operation to retire Synthoids. The " +
- "objective is to complete the task without " +
- "drawing any attention. Stealth and discretion are key.",
- baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,
- rankGain:20, rankLoss:2, hpLoss:10,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 250), countGrowth:0.1,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isStealth:true, isKill:true
- });
- this.operations["Assassination"] = new Operation({
- name:"Assassination",
- desc:"Assassinate Synthoids that have been identified as " +
- "important, high-profile social and political leaders " +
- "in the Synthoid communities.",
- baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,
- rankGain:40, rankLoss:4, hpLoss:5,
- count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 200), countGrowth:0.1,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},
- isStealth:true, isKill:true
- });
-}
-
-Bladeburner.prototype.storeCycles = function(numCycles=1) {
- this.storedCycles += numCycles;
-}
-
-Bladeburner.prototype.process = function() {
- //If the Player starts doing some other actions, set action to idle and alert
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].isWorking) {
- if (this.action.type !== ActionTypes["Idle"]) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Your Bladeburner action was cancelled because you started " +
- "doing something else");
- }
- this.resetAction();
- }
-
- //A 'tick' for this mechanic is one second (= 5 game cycles)
- if (this.storedCycles >= CyclesPerSecond) {
- var seconds = Math.floor(this.storedCycles / CyclesPerSecond);
- seconds = Math.min(seconds, 5); //Max of 5 'ticks'
- this.storedCycles -= seconds * CyclesPerSecond;
-
- //Stamina
- this.calculateMaxStamina();
- this.stamina += (this.calculateStaminaGainPerSecond() * seconds);
- this.stamina = Math.min(this.maxStamina, this.stamina);
-
- //Count increase for contracts/operations
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- var contract = this.contracts[contractName];
- contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);
- }
- }
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- var op = this.operations[operationName];
- op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);
- }
- }
-
- //Chaos goes down very slowly
- for (var i = 0; i < CityNames.length; ++i) {
- var city = this.cities[CityNames[i]];
- if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
- city.chaos -= (0.0001 * seconds);
- city.chaos = Math.max(0, city.chaos);
- }
-
- //Random Events
- this.randomEventCounter -= seconds;
- if (this.randomEventCounter <= 0) {
- this.randomEvent();
- this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600);
- }
-
- this.processAction(seconds);
-
- //Automation
- if (this.automateEnabled) {
- if (this.stamina <= this.automateThreshLow) {
- if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {
- this.action = this.automateActionLow;
- this.startAction(this.action);
- }
- } else if (this.stamina >= this.automateThreshHigh) {
- if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {
- this.action = this.automateActionHigh;
- this.startAction(this.action);
- }
- }
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
- this.updateContent();
- }
- }
-}
-
-Bladeburner.prototype.calculateMaxStamina = function() {
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * this.skillMultipliers.effAgi;
- var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);
- maxStamina *= this.skillMultipliers.stamina;
- maxStamina *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_max_stamina_mult;
- if (isNaN(maxStamina)) {throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()");}
- this.maxStamina = maxStamina;
-}
-
-Bladeburner.prototype.calculateStaminaGainPerSecond = function() {
- var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * this.skillMultipliers.effAgi;
- var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;
- var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);
- return gain * (this.skillMultipliers.stamina * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_stamina_gain_mult);
-}
-
-Bladeburner.prototype.calculateStaminaPenalty = function() {
- return Math.min(1, this.stamina / (0.5 * this.maxStamina));
-}
-
-Bladeburner.prototype.changeRank = function(change) {
- if (isNaN(change)) {throw new Error("NaN passed into Bladeburner.changeRank()");}
- this.rank += change;
- if (this.rank < 0) {this.rank = 0;}
- this.maxRank = Math.max(this.rank, this.maxRank);
-
- var bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- if (bladeburnerFac.isMember) {
- bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].faction_rep_mult);
- }
- }
-
- //Gain skill points. You get 1 every 4 ranks
- var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;
- if (this.maxRank >= rankNeededForSp) {
- //Calculate how many skill points to gain
- var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);
- this.skillPoints += gainedSkillPoints;
- this.totalSkillPoints += gainedSkillPoints;
- }
-}
-
-Bladeburner.prototype.getCurrentCity = function() {
- var city = this.cities[this.city];
- if (!(city instanceof City)) {
- throw new Error("Bladeburner.getCurrentCity() did not properly return a City object");
- }
- return city;
-}
-
-Bladeburner.prototype.resetSkillMultipliers = function() {
- this.skillMultipliers = {
- successChanceAll:1,
- successChanceStealth:1,
- successChanceKill:1,
- successChanceContract:1,
- successChanceOperation:1,
- successChanceEstimate:1,
- actionTime:1,
- effHack:1,
- effStr:1,
- effDef:1,
- effDex:1,
- effAgi:1,
- effCha:1,
- effInt:1,
- stamina:1,
- weaponAbility:1,
- gunAbility:1,
- };
-}
-
-Bladeburner.prototype.updateSkillMultipliers = function() {
- this.resetSkillMultipliers();
- for (var skillName in this.skills) {
- if (this.skills.hasOwnProperty(skillName)) {
- var skill = Skills[skillName];
- if (skill == null) {
- throw new Error("Could not find Skill Object for: " + skillName);
- }
- var level = this.skills[skillName];
- if (level == null || level <= 0) {continue;} //Not upgraded
-
- var multiplierNames = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multiplierNames.length; ++i) {
- var multiplierName = multiplierNames[i];
- if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {
- var value = skill[multiplierName] * level;
- var multiplierValue = 1 + (value / 100);
- if (multiplierName === "actionTime") {
- multiplierValue = 1 - (value / 100);
- }
- this.skillMultipliers[multiplierName] *= multiplierValue;
- }
- }
- }
- }
-}
-
-Bladeburner.prototype.upgradeSkill = function(skill) {
- //This does NOT handle deduction of skill points
- var skillName = skill.name;
- if (this.skills[skillName]) {
- ++this.skills[skillName];
- } else {
- this.skills[skillName] = 1;
- }
- if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {
- throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]);
- }
- this.updateSkillMultipliers();
-}
-
-Bladeburner.prototype.getActionObject = function(actionId) {
- //Given an ActionIdentifier object, returns the corresponding
- //Contract, Operation, or BlackOperation object
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- return this.contracts[actionId.name];
- break;
- case ActionTypes["Operation"]:
- return this.operations[actionId.name];
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return BlackOperations[actionId.name];
- break;
- default:
- return null;
- console.log("WARNING: Bladeburner.getActionObject() called with an unexpected " +
- "ActionIdentifier type: " + actionId.type);
- }
-}
-
-//Sets the player to the "IDLE" action
-Bladeburner.prototype.resetAction = function() {
- this.action = new ActionIdentifier({type:ActionTypes.Idle});
-}
-
-Bladeburner.prototype.startAction = function(actionId) {
- this.action = actionId;
- this.actionTimeCurrent = 0;
- switch (actionId.type) {
- case ActionTypes["Idle"]:
- this.actionTimeToComplete = 0;
- break;
- case ActionTypes["Contract"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get Contract Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Operation"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error ("Failed to get Operation Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get BlackOperation object for: " + actionId.name);
- }
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.actionTimeToComplete = 30;
- break;
- case ActionTypes["Recruitment"]:
- var effCharisma = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma * this.skillMultipliers.effCha;
- var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;
- var time = Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));
- this.actionTimeToComplete = time;
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- this.actionTimeToComplete = 30;
- break;
- default:
- throw new Error("Invalid Action Type in Bladeburner.startAction(): " + actionId.type);
- break;
- }
-}
-
-Bladeburner.prototype.processAction = function(seconds) {
- if (this.action.type === ActionTypes["Idle"]) {return;}
- if (this.actionTimeToComplete <= 0) {
- console.log("action.type: " + this.action.type);
- throw new Error("Invalid actionTimeToComplete value: " + this.actionTimeToComplete);
- }
- if (!(this.action instanceof ActionIdentifier)) {
- throw new Error("Bladeburner.action is not an ActionIdentifier Object");
- }
-
- this.actionTimeCurrent += seconds;
- if (this.actionTimeCurrent >= this.actionTimeToComplete) {
- return this.completeAction();
- }
-}
-
-Bladeburner.prototype.completeAction = function() {
- switch (this.action.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- try {
- var isOperation = (this.action.type === ActionTypes["Operation"]);
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
- var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Process Contract/Operation success/failure
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- ++action.successes;
- --action.count;
-
- //Earn money for contracts
- var moneyGain = 0;
- if (!isOperation) {
- moneyGain = ContractBaseMoneyGain * rewardMultiplier;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainMoney(moneyGain);
- }
-
- if (isOperation) {
- action.maxLevel = Math.floor(action.successes / OperationSuccessesPerLevel) + 1;
- } else {
- action.maxLevel = Math.floor(action.successes / ContractSuccessesPerLevel) + 1;
- }
- if (action.rankGain) {
- var gain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankGain * rewardMultiplier, 10);
- this.changeRank(gain);
- if (isOperation && this.logging.ops) {
- this.log(action.name + " successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(gain, 3) + " rank");
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(gain, 3) + " rank and " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(moneyGain).format("$0.000a"));
- }
- }
- isOperation ? this.completeOperation(true) : this.completeContract(true);
- } else {
- this.gainActionStats(action, false);
- ++action.failures;
- var loss = 0, damage = 0;
- if (action.rankLoss) {
- loss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankLoss * rewardMultiplier, 10);
- this.changeRank(-1 * loss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(damage, 10));
- this.hpLost += damage;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].max_hp);
- }
- }
- var logLossText = "";
- if (loss > 0) {logLossText += "Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(loss, 3) + " rank.";}
- if (damage > 0) {logLossText += "Took " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(damage, 0) + " damage.";}
- if (isOperation && this.logging.ops) {
- this.log(action.name + " failed! " + logLossText);
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract failed! " + logLossText);
- }
- isOperation ? this.completeOperation(false) : this.completeContract(false);
- }
- if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel
- this.startAction(this.action); //Repeat action
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- var action = this.getActionObject(this.action);
- if (action == null || !(action instanceof BlackOperation)) {
- throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Team loss variables
- var teamCount = action.teamCount, teamLossMax;
-
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- action.count = 0;
- this.blackops[action.name] = true;
- var rankGain = 0;
- if (action.rankGain) {
- rankGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankGain, 10);
- this.changeRank(rankGain);
- }
- teamLossMax = Math.ceil(teamCount/2);
-
- //Operation Daedalus
- if (action.name === "Operation Daedalus") {
- this.resetAction();
- return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_5__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bitNodeN);
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
- this.createActionAndSkillsContent();
- }
-
- if (this.logging.blackops) {
- this.log(action.name + " successful! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(rankGain, 1) + " rank");
- }
- } else {
- this.gainActionStats(action, false);
- var rankLoss = 0, damage = 0;
- if (action.rankLoss) {
- rankLoss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankLoss, 10);
- this.changeRank(-1 * rankLoss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(damage, 10));
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].max_hp);
- }
- }
- teamLossMax = Math.floor(teamCount);
-
- if (this.logging.blackops) {
- this.log(action.name + " failed! Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(rankLoss, 1) + " rank and took" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(damage, 0) + " damage");
- }
- }
-
- this.resetAction(); //Stop regardless of success or fail
-
- //Calculate team lossses
- if (teamCount >= 1) {
- var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, teamLossMax);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.blackops) {
- this.log("You lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(losses, 0) + " team members during " + action.name);
- }
- }
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.stamina -= (0.5 * BaseStaminaLoss);
- var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult,
- defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult,
- dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult,
- agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult,
- staminaGain = 0.04 * this.skillMultipliers.stamina;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(strExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(defExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDexterityExp(dexExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainAgilityExp(agiExpGain);
- this.staminaBonus += (staminaGain);
- if (this.logging.general) {
- this.log("Training completed. Gained: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(strExpGain, 1) + " str exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(defExpGain, 1) + " def exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(dexExpGain, 1) + " dex exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(agiExpGain, 1) + " agi exp, " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(staminaGain, 3) + " max stamina");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- //Does not use stamina. Effectiveness depends on hacking, int, and cha
- var eff = 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_skill, 0.3) +
- 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].intelligence, 0.9) +
- 0.02 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma, 0.3);
- eff *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_analysis_mult;
- if (isNaN(eff) || eff < 0) {
- throw new Error("Field Analysis Effectiveness calculated to be NaN or negative");
- }
- var hackingExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_exp_mult,
- charismaExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma_exp_mult;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainHackingExp(hackingExpGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainIntelligenceExp(BaseIntGain);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(charismaExpGain);
- this.changeRank(0.1);
- console.log("DEBUG: Field Analysis effectiveness is " + (eff * this.skillMultipliers.successChanceEstimate));
- this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
- if (this.logging.general) {
- this.log("Field analysis completed. Gained 0.1 rank, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(hackingExpGain, 1) + " hacking exp, and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(charismaExpGain, 1) + " charisma exp");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["Recruitment"]:
- var successChance = Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma, 0.45) / (this.teamSize + 1);
- console.log("Bladeburner recruitment success chance: " + successChance);
- if (Math.random() < successChance) {
- var expGain = 2 * BaseStatGain * this.actionTimeToComplete;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(expGain);
- ++this.teamSize;
- if (this.logging.general) {
- this.log("Successfully recruited a team member! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- } else {
- var expGain = BaseStatGain * this.actionTimeToComplete;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(expGain);
- if (this.logging.general) {
- this.log("Failed to recruit a team member. Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- }
- this.startAction(this.action); //Repeat action
- break;
- default:
- break;
- }
-}
-
-Bladeburner.prototype.completeContract = function(success) {
- if (this.action.type !== ActionTypes.Contract) {
- throw new Error("completeContract() called even though current action is not a Contract");
- }
- var city = this.getCurrentCity();
- if (success) {
- switch (this.action.name) {
- case "Tracking":
- //Increase estimate accuracy by a relatively small amount
- city.improvePopulationEstimateByCount(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 1e3));
- break;
- case "Bounty Hunter":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.02);
- break;
- case "Retirement":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.04);
- break;
- default:
- throw new Error("Invalid Action name in completeContract: " + this.action.name);
- }
- }
-}
-
-Bladeburner.prototype.completeOperation = function(success) {
- if (this.action.type !== ActionTypes.Operation) {
- throw new Error("completeOperation() called even though current action is not an Operation");
- }
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
-
- //Calculate team losses
- var teamCount = action.teamCount, max;
- if (teamCount >= 1) {
- if (success) {
- max = Math.ceil(teamCount/2);
- } else {
- max = Math.floor(teamCount)
- }
- var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, max);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.ops && losses > 0) {
- this.log("Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(losses, 0) + " team members during this " + action.name);
- }
- }
-
- var city = this.getCurrentCity();
- if (this.logging.ops) {
- if (success) {
- this.log(action.name + " completed successfully! ")
- } else {
-
- }
- }
- switch (action.name) {
- case "Investigation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.1);
- }
- break;
- case "Undercover Operation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.15);
- }
- break;
- case "Sting Operation":
- if (success) {
- city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});
- }
- city.changeChaosByCount(0.1);
- break;
- case "Raid":
- if (success) {
- city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});
- --city.comms;
- --city.commsEst;
- } else {
- var change = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-3, -1);
- city.changePopulationByPercentage(change, {nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5));
- break;
- case "Stealth Retirement Operation":
- if (success) {
- city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-3, -1));
- break;
- case "Assassination":
- if (success) {
- city.changePopulationByCount(-1, {estChange:-1});
- }
- city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-5, 5));
- break;
- default:
- throw new Error("Invalid Action name in completeOperation: " + this.action.name);
- }
-}
-
-//Process stat gains from Contracts, Operations, and Black Operations
-//@action(Action obj) - Derived action class
-//@success(bool) - Whether action was successful
-Bladeburner.prototype.gainActionStats = function(action, success) {
- var difficulty = action.getDifficulty();
-
- //Gain multiplier based on difficulty. If this changes then the
- //same variable calculated in completeAction() needs to change too
- var difficultyMult = Math.pow(difficulty, 0.21);
-
- var time = this.actionTimeToComplete;
- var successMult = success ? 1 : 0.5;
-
- var unweightedGain = time * BaseStatGain * successMult * difficultyMult;
- var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainHackingExp(unweightedGain * action.weights.hack * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(unweightedGain * action.weights.str * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(unweightedGain * action.weights.def * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDexterityExp(unweightedGain * action.weights.dex * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainAgilityExp(unweightedGain * action.weights.agi * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(unweightedGain * action.weights.cha * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma_exp_mult);
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainIntelligenceExp(unweightedIntGain * action.weights.int);
-}
-
-Bladeburner.prototype.randomEvent = function() {
- var chance = Math.random();
-
- //Choose random source/destination city for events
- var sourceCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
- var sourceCity = this.cities[sourceCityName];
- if (!(sourceCity instanceof City)) {
- throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
- }
-
- var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
-
- if (!(sourceCity instanceof City) || !(destCity instanceof City)) {
- throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
- }
-
- if (chance <= 0.05) {
- //New Synthoid Community, 5%
- ++sourceCity.comms;
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else if (chance <= 0.1) {
- //Synthoid Community Migration, 5%
- if (sourceCity.comms <= 0) {
- //If no comms in source city, then instead trigger a new Synthoid community event
- ++sourceCity.comms;
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else {
- --sourceCity.comms;
- ++destCity.comms;
-
- //Change pop
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-
- if (this.logging.events) {
- this.log("Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city");
- }
- }
- } else if (chance <= 0.3) {
- //New Synthoids (non community), 20%
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(8, 24) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- } else if (chance <= 0.5) {
- //Synthoid migration (non community) 20%
- this.triggerMigration(sourceCityName);
- if (this.logging.events) {
- this.log("Intelligence indicates that a large number of Synthoids migrated from " + sourceCityName + " to some other city");
- }
- } else if (chance <= 0.7) {
- //Synthoid Riots (+chaos), 20%
- sourceCity.chaos += 1;
- sourceCity.chaos *= (1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(5, 10) / 100);
- if (this.logging.events) {
- this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
- }
- } else if (chance <= 0.9) {
- //Less Synthoids, 20%
- var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(5, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- }
- //20% chance of nothing happening
-}
-
-Bladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {
- if (chance == null || isNaN(chance)) {
- console.log("ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()");
- }
- if (chance > 1) {chance /= 100;}
- if (Math.random() < chance) {this.triggerMigration(sourceCityName);}
-}
-
-Bladeburner.prototype.triggerMigration = function(sourceCityName) {
- var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
- var sourceCity = this.cities[sourceCityName];
- if (destCity == null || sourceCity == null) {
- throw new Error("Failed to find City with name: " + destCityName);
- }
- var rand = Math.random(), percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(3, 15) / 100;
-
- if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration
- percentage *= Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(2, 4); //Migration increases population change
- --sourceCity.comms;
- ++destCity.comms;
- }
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-}
-
-var DomElems = {};
-
-Bladeburner.prototype.initializeDomElementRefs = function() {
- DomElems = {
- bladeburnerDiv: null,
-
- //Main Divs
- overviewConsoleParentDiv: null,
-
- overviewDiv: null, //Overview of stats that stays fixed on left
- actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)
- currentTab: null, //Contracts, Operations, Black Ops, Skills
-
- consoleDiv: null,
- consoleTable: null,
- consoleInputRow: null, //tr
- consoleInputCell: null, //td
- consoleInputHeader: null, //"> "
- consoleInput: null, //Actual input element
-
- //Overview Content
- overviewRank: null,
- overviewStamina: null,
- overviewStaminaHelpTip: null,
- overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city
- overviewEstPop: null,
- overviewEstPopHelpTip: null,
- overviewEstComms: null,
- overviewChaos: null,
- overviewSkillPoints: null,
- overviewAugSuccessMult: null,
- overviewAugMaxStaminaMult: null,
- overviewAugStaminaGainMult: null,
- overviewAugAnalysisMult: null,
-
- //Actions and Skills Content
- actionsAndSkillsDesc: null,
- actionsAndSkillsList: null, //ul element of all UI elements in this panel
- generalActions: {},
- contracts: {},
- operations: {},
- blackops: {},
- skills: {},
- };
-}
-
-Bladeburner.prototype.createContent = function() {
- DomElems.bladeburnerDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- id:"bladeburner-container", position:"fixed", class:"generic-menupage-container",
- });
-
- //Parent Div for Overview and Console
- DomElems.overviewConsoleParentDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- height:"60%", display:"block", position:"relative",
- });
-
- //Overview and Action/Skill pane
- DomElems.overviewDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- width:"30%", display:"inline-block", border:"1px solid white",
- });
-
- DomElems.actionAndSkillsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- height:"60%", width:"70%", display:"block",
- border:"1px solid white", margin:"6px", padding:"6px",
- });
-
- DomElems.currentTab = "general";
-
- this.createOverviewContent();
- this.createActionAndSkillsContent();
-
- //Console
- DomElems.consoleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-console-div",
- clickListener:()=>{
- if (DomElems.consoleInput instanceof Element) {
- DomElems.consoleInput.focus();
- }
- return false;
- }
- });
- DomElems.consoleTable = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("table", {class:"bladeburner-console-table"});
- DomElems.consoleInputRow = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("tr", {class:"bladeburner-console-input-row", id:"bladeubrner-console-input-row"});
- DomElems.consoleInputCell = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("td", {class:"bladeburner-console-input-cell"});
- DomElems.consoleInputHeader = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {innerText:"> "});
- DomElems.consoleInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
- type:"text", class:"bladeburner-console-input", tabIndex:1,
- onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}
- });
-
- DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);
- DomElems.consoleInputCell.appendChild(DomElems.consoleInput);
- DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);
- DomElems.consoleTable.appendChild(DomElems.consoleInputRow);
- DomElems.consoleDiv.appendChild(DomElems.consoleTable);
-
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);
-
- document.getElementById("entire-game-container").appendChild(DomElems.bladeburnerDiv);
-
- this.postToConsole("Bladeburner Console BETA");
- DomElems.consoleInput.focus();
-}
-
-Bladeburner.prototype.clearContent = function() {
- if (DomElems.bladeburnerDiv instanceof Element) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.bladeburnerDiv);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElement"])(DomElems.bladeburnerDiv);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems);
- this.initializeDomElementRefs();
-}
-
-Bladeburner.prototype.createOverviewContent = function() {
- if (DomElems.overviewDiv == null) {
- throw new Error("Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null");
- }
-
- DomElems.overviewRank = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Rank: ",
- display:"inline-block",
- tooltip:"Your rank within the Bladeburner division",
- });
-
- DomElems.overviewStamina = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"inline-block",
- });
-
- DomElems.overviewStaminaHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- innerText:"?", class:"help-tip",
- clickListener:()=>{
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Performing actions will use up your stamina.
" +
- "Your max stamina is determined primarily by your agility stat.
" +
- "Your stamina gain rate is determined by both your agility and your " +
- "max stamina. Higher max stamina leads to a higher gain rate.
" +
- "Once your " +
- "stamina falls below 50% of its max value, it begins to negatively " +
- "affect the success rate of your contracts/operations. This penalty " +
- "is shown in the overview panel. If the penalty is 15%, then this means " +
- "your success rate would be multipled by 85% (100 - 15).
" +
- "Your max stamina and stamina gain rate can also be increased by " +
- "training, or through skills and Augmentation upgrades.");
- }
- });
-
- DomElems.overviewGen1 = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- });
-
- DomElems.overviewEstPop = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Est. Synthoid Population: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner division's estimate of how many Synthoids exist " +
- "in your current city."
- });
-
- DomElems.overviewEstPopHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- innerText:"?", class:"help-tip",
- clickListener:()=>{
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("The success rate of your contracts/operations depends on " +
- "the population of Synthoids in your current city. " +
- "The success rate that is shown to you is only an estimate, " +
- "and it is based on your Synthoid population estimate.
" +
- "Therefore, it is important that this Synthoid population estimate " +
- "is accurate so that you have a better idea of your " +
- "success rate for contracts/operations. Certain " +
- "actions will increase the accuracy of your population " +
- "estimate.
" +
- "The Synthoid populations of cities can change due to your " +
- "actions or random events. If random events occur, they will " +
- "be logged in the Bladeburner Console.");
- }
- });
-
- DomElems.overviewEstComms = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Est. Synthoid Communities: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner divison's estimate of how many Synthoid " +
- "communities exist in your current city.",
- });
-
- DomElems.overviewChaos = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"City Chaos: ",
- display:"inline-block",
- tooltip:"The city's chaos level due to tensions and conflicts between humans and Synthoids. " +
- "Having too high of a chaos level can make contracts and operations harder."
- });
-
- DomElems.overviewSkillPoints = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
-
- DomElems.overviewAugSuccessMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
- DomElems.overviewAugMaxStaminaMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
- DomElems.overviewAugStaminaGainMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
- DomElems.overviewAugAnalysisMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
-
-
- DomElems.overviewDiv.appendChild(DomElems.overviewRank);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewStamina);
- DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);
- DomElems.overviewDiv.appendChild(DomElems.overviewGen1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewChaos);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 2);
- DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);
-
- //Travel to new city button
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerHTML:"Travel", class:"a-link-button", display:"inline-block",
- clickListener:()=>{
- var popupId = "bladeburner-travel-popup-cancel-btn";
- var popupArguments = [];
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Cancel Button
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId); return false;
- }
- }))
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", { //Info Text
- innerText:"Travel to a different city for your Bladeburner " +
- "activities. This does not cost any money. The city you are " +
- "in for your Bladeburner duties does not affect " +
- "your location in the game otherwise",
- }));
- for (var i = 0; i < CityNames.length; ++i) {
- (function(inst, i) {
- popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- //Reusing this css class...it adds a border and makes it
- //so that background color changes when you hover
- class:"cmpy-mgmt-find-employee-option",
- innerText:CityNames[i],
- clickListener:()=>{
- inst.city = CityNames[i];
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- inst.updateOverviewContent();
- return false;
- }
- }));
- })(this, i);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, popupArguments);
- }
- }));
-
- //Faction button
- var bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Faction", class:"a-link-button", display:"inline-block",
- tooltip:"Apply to the Bladeburner Faction, or go to the faction page if you are already a member",
- clickListener:()=>{
- if (bladeburnerFac.isMember) {
- _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(bladeburnersFactionName);
- } else {
- if (this.rank >= 25) {
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["joinFaction"])(bladeburnerFac);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Congratulations! You were accepted into the Bladeburners faction");
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.overviewDiv);
- this.createOverviewContent();
- } else {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("You need a rank of 25 to join the Bladeburners Faction!")
- }
- }
- return false;
- }
- }));
- }
-
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
- DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
-
- this.updateOverviewContent();
-}
-
-Bladeburner.prototype.createActionAndSkillsContent = function() {
- if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.actionAndSkillsDiv);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.generalActions);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.contracts);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.operations);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.blackops);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.skills);
-
- //Navigation buttons
- var currTab = DomElems.currentTab.toLowerCase();
- var buttons = ["General", "Contracts", "Operations", "BlackOps", "Skills"];
- for (var i = 0; i < buttons.length; ++i) {
- (function(buttons, i, inst, currTab) {
-
- DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:buttons[i],
- class:currTab === buttons[i].toLowerCase() ? "bladeburner-nav-button-inactive" : "bladeburner-nav-button",
- clickListener:()=>{
- DomElems.currentTab = buttons[i].toLowerCase();
- inst.createActionAndSkillsContent();
- return false;
- }
- }));
- }) (buttons, i, this, currTab);
- }
-
- //General info/description for each action
- DomElems.actionsAndSkillsDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block", margin:"4px", padding:"4px"
- });
-
- //List for actions/skills
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.actionsAndSkillsList);
- DomElems.actionsAndSkillsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("ul");
-
- switch(currTab) {
- case "general":
- this.createGeneralActionsContent();
- break;
- case "contracts":
- this.createContractsContent();
- break;
- case "operations":
- this.createOperationsContent();
- break;
- case "blackops":
- this.createBlackOpsContent();
- break;
- case "skills":
- this.createSkillsContent();
- break;
- default:
- throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
- }
- this.updateContent();
-
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);
-}
-
-Bladeburner.prototype.createGeneralActionsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createGeneralActionsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerText =
- "These are generic actions that will assist you in your Bladeburner " +
- "duties. They will not affect your Bladeburner rank in any way."
-
- for (var actionName in GeneralActions) {
- if (GeneralActions.hasOwnProperty(actionName)) {
- DomElems.generalActions[actionName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-action", name:actionName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);
- }
- }
-}
-
-Bladeburner.prototype.createContractsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createContractsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Complete contracts in order to increase your Bitburner rank and earn money. " +
- "Failing a contract will cause you to lose HP, which can lead to hospitalization.
" +
- "You can unlock higher-level contracts by successfully completing them. " +
- "Higher-level contracts are more difficult, but grant more rank, experience, and money.";
-
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- DomElems.contracts[contractName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-action", name:contractName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);
- }
- }
-}
-
-Bladeburner.prototype.createOperationsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createOperationsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Carry out operations for the Bladeburner division. " +
- "Failing an operation will reduce your Bladeburner rank. It will also " +
- "cause you to lose HP, which can lead to hospitalization. In general, " +
- "operations are harder and more punishing than contracts, " +
- "but are also more rewarding.
" +
- "Operations can affect the chaos level and Synthoid population of your " +
- "current city. The exact effects vary between different Operations.
" +
- "For operations, you can use a team. You must first recruit team members. " +
- "Having a larger team will improves your chances of success.
" +
- "You can unlock higher-level operations by successfully completing them. " +
- "Higher-level operations are more difficult, but grant more rank and experience.";
-
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- DomElems.operations[operationName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-action", name:operationName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);
- }
- }
-}
-
-Bladeburner.prototype.createBlackOpsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createBlackOpsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Black Operations (Black Ops) are special, one-time covert operations. " +
- "Each Black Op must be unlocked successively by completing " +
- "the one before it.
" +
- "Like normal operations, you may use a team for Black Ops. Failing " +
- "a black op will incur heavy HP and rank losses.";
-
- //Put Black Operations in sequence of required rank
- var blackops = [];
- for (var blackopName in BlackOperations) {
- if (BlackOperations.hasOwnProperty(blackopName)) {
- blackops.push(BlackOperations[blackopName]);
- }
- }
- blackops.sort(function(a, b) {
- return (a.reqdRank - b.reqdRank);
- });
-
- for (var i = 0; i < blackops.length; ++i) {
- DomElems.blackops[blackops[i].name] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-action", name:blackops[i].name
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);
- if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops
- }
-}
-
-Bladeburner.prototype.createSkillsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createSkillsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- //Display Current multipliers
- DomElems.actionsAndSkillsDesc.innerHTML =
- "You will gain one skill point every " + RanksPerSkillPoint + " ranks.
" +
- "Note that when upgrading a skill, the benefit for that skill is additive. " +
- "However, the effects of different skills with each other is multiplicative.
"
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- DomElems.actionsAndSkillsDesc.innerHTML += "Total Success Chance: x" + mult + "
";
- break;
- case "successChanceStealth":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stealth Success Chance: x" + mult + "
";
- break;
- case "successChanceKill":
- DomElems.actionsAndSkillsDesc.innerHTML += "Retirement Success Chance: x" + mult + "
";
- break;
- case "successChanceContract":
- DomElems.actionsAndSkillsDesc.innerHTML += "Contract Success Chance: x" + mult + "
";
- break;
- case "successChanceOperation":
- DomElems.actionsAndSkillsDesc.innerHTML += "Operation Success Chance: x" + mult + "
";
- break;
- case "successChanceEstimate":
- DomElems.actionsAndSkillsDesc.innerHTML += "Synthoid Data Estimate: x" + mult + "
";
- break;
- case "actionTime":
- DomElems.actionsAndSkillsDesc.innerHTML += "Action Time: x" + mult + "
";
- break;
- case "effHack":
- DomElems.actionsAndSkillsDesc.innerHTML += "Hacking Skill: x" + mult + "
";
- break;
- case "effStr":
- DomElems.actionsAndSkillsDesc.innerHTML += "Strength: x" + mult + "
";
- break;
- case "effDef":
- DomElems.actionsAndSkillsDesc.innerHTML += "Defense: x" + mult + "
";
- break;
- case "effDex":
- DomElems.actionsAndSkillsDesc.innerHTML += "Dexterity: x" + mult + "
";
- break;
- case "effAgi":
- DomElems.actionsAndSkillsDesc.innerHTML += "Agility: x" + mult + "
";
- break;
- case "effCha":
- DomElems.actionsAndSkillsDesc.innerHTML += "Charisma: x" + mult + "
";
- break;
- case "effInt":
- DomElems.actionsAndSkillsDesc.innerHTML += "Intelligence: x" + mult + "
";
- break;
- case "stamina":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stamina: x" + mult + "
";
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
-
- //Skill Points
- DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerHTML:"
Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skillPoints, 0) + ""
- }));
-
- //UI Element for each skill
- for (var skillName in Skills) {
- if (Skills.hasOwnProperty(skillName)) {
- DomElems.skills[skillName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
- class:"bladeburner-action", name:skillName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);
- }
- }
-}
-
-Bladeburner.prototype.updateContent = function() {
- this.updateOverviewContent();
- this.updateActionAndSkillsContent();
-}
-
-Bladeburner.prototype.updateOverviewContent = function() {
- if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {return;}
- DomElems.overviewRank.childNodes[0].nodeValue = "Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.rank, 2);
- DomElems.overviewStamina.innerText = "Stamina: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.stamina, 3) + " / " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.maxStamina, 3);
- DomElems.overviewGen1.innerHTML =
- "Stamina Penalty: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])((1-this.calculateStaminaPenalty())*100, 1) + "%
" +
- "Team Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.teamSize, 0) + "
" +
- "Team Members Lost: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.teamLost, 0) + "
" +
- "Num Times Hospitalized: " + this.numHosp + "
" +
- "Money Lost From Hospitalizations: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.moneyLost).format("$0.000a") + "
" +
- "Current City: " + this.city + "
";
-
- DomElems.overviewEstPop.childNodes[0].nodeValue = "Est. Synthoid Population: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.getCurrentCity().popEst).format("0.000a");
- DomElems.overviewEstComms.childNodes[0].nodeValue = "Est. Synthoid Communities: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.getCurrentCity().comms, 0);
- DomElems.overviewChaos.childNodes[0].nodeValue = "City Chaos: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.getCurrentCity().chaos);
- DomElems.overviewSkillPoints.innerText = "Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skillPoints, 0);
- DomElems.overviewAugSuccessMult.innerText = "Aug. Success Chance Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_success_chance_mult*100, 1) + "%";
- DomElems.overviewAugMaxStaminaMult.innerText = "Aug. Max Stamina Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_max_stamina_mult*100, 1) + "%";
- DomElems.overviewAugStaminaGainMult.innerText = "Aug. Stamina Gain Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_stamina_gain_mult*100, 1) + "%";
- DomElems.overviewAugAnalysisMult.innerText = "Aug. Field Analysis Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_analysis_mult*100, 1) + "%";
-}
-
-Bladeburner.prototype.updateActionAndSkillsContent = function() {
- if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
- switch(DomElems.currentTab.toLowerCase()) {
- case "general":
- var actionElems = Object.keys(DomElems.generalActions);
- for (var i = 0; i < actionElems.length; ++i) {
- var actionElem = DomElems.generalActions[actionElems[i]];
- var name = actionElem.name;
- var actionObj = GeneralActions[name];
- if (actionObj == null) {
- throw new Error("Could not find Object " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- if (this.action.type === ActionTypes[name]) {
- actionElem.classList.add(ActiveActionCssClass);
- } else {
- actionElem.classList.remove(ActiveActionCssClass);
- }
- this.updateGeneralActionsUIElement(actionElem, actionObj);
- }
- break;
- case "contracts":
- var contractElems = Object.keys(DomElems.contracts);
- for (var i = 0; i < contractElems.length; ++i) {
- var contractElem = DomElems.contracts[contractElems[i]];
- var name = contractElem.name;
- if (this.action.type === ActionTypes["Contract"] && name === this.action.name) {
- contractElem.classList.add(ActiveActionCssClass);
- } else {
- contractElem.classList.remove(ActiveActionCssClass);
- }
- var contract = this.contracts[name];
- if (contract == null) {
- throw new Error("Could not find Contract " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateContractsUIElement(contractElem, contract);
- }
- break;
- case "operations":
- var operationElems = Object.keys(DomElems.operations);
- for (var i = 0; i < operationElems.length; ++i) {
- var operationElem = DomElems.operations[operationElems[i]];
- var name = operationElem.name;
- if (this.action.type === ActionTypes["Operation"] && name === this.action.name) {
- operationElem.classList.add(ActiveActionCssClass);
- } else {
- operationElem.classList.remove(ActiveActionCssClass);
- }
- var operation = this.operations[name];
- if (operation == null) {
- throw new Error("Could not find Operation " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateOperationsUIElement(operationElem, operation);
- }
- break;
- case "blackops":
- var blackopsElems = Object.keys(DomElems.blackops);
- for (var i = 0; i < blackopsElems.length; ++i) {
- var blackopElem = DomElems.blackops[blackopsElems[i]];
- var name = blackopElem.name;
- if (this.action.type === ActionTypes["BlackOperation"] && name === this.action.name) {
- blackopElem.classList.add(ActiveActionCssClass);
- } else {
- blackopElem.classList.remove(ActiveActionCssClass);
- }
- var blackop = BlackOperations[name];
- if (blackop == null) {
- throw new Error("Could not find BlackOperation " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateBlackOpsUIElement(blackopElem, blackop);
- }
- break;
- case "skills":
- var skillElems = Object.keys(DomElems.skills);
- for (var i = 0; i < skillElems.length; ++i) {
- var skillElem = DomElems.skills[skillElems[i]];
- var name = skillElem.name;
- var skill = Skills[name];
- if (skill == null) {
- throw new Error("Could not find Skill " + name + " in Bladeburner.updateActionAndSkillsContent()");
- }
- this.updateSkillsUIElement(skillElem, skill);
- }
- break;
- default:
- throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
- }
-}
-
-Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block",
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
- }));
- } else {
- //Start button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes[action.name];
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- }
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", { //Info
- innerHTML:action.desc, display:"inline-block"
- }));
-
-
-}
-
-Bladeburner.prototype.updateContractsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block"
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
- }));
- } else { //Start button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- padding:"3px", margin:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes.Contract;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- }
-
- //Level and buttons to change level
- var maxLevel = (action.level >= action.maxLevel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
- display:"inline-block",
- innerText:"Level: " + action.level + " / " + action.maxLevel
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
- display:"inline",
- clickListener:()=>{
- ++action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateContractsUIElement(el, action);
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
- display:"inline",
- clickListener:()=>{
- --action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateContractsUIElement(el, action);
- return false;
- }
- }));
-
- var actionTime = action.getActionTime(this);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", { //Info
- display:"inline-block",
- innerHTML:action.desc + "\n\n" +
- "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required (s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 0) + "\n" +
- "Contracts remaining: " + Math.floor(action.count) + "\n" +
- "Successes: " + action.successes + "\n" +
- "Failures: " + action.failures,
- }));
-
- //Autolevel Checkbox
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
- var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("label", {
- for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
- tooltip:"Automatically increase contract level when possible"
- }));
- var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
- type:"checkbox", id:autolevelCheckboxId, margin:"4px",
- checked:action.autoLevel,
- changeListener:()=>{
- action.autoLevel = autolevelCheckbox.checked;
- }
- });
- el.appendChild(autolevelCheckbox);
-}
-
-Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block"
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
- }));
- } else { //Start button and set Team Size button
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Start", class: "a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- this.action.type = ActionTypes.Operation;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- var popupId = "bladeburner-operation-set-team-size-popup";
- var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Enter the amount of team members you would like to take on these " +
- "operations. If you do not have the specified number of team members, " +
- "then as many as possible will be used. Note that team members may " +
- "be lost during operations."
-
- });
- var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
- type:"number", placeholder: "Team Members"
- });
- var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Confirm", class:"a-link-button",
- clickListener:()=>{
- var num = Math.round(parseFloat(input.value));
- if (isNaN(num)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
- } else {
- action.teamCount = num;
- this.updateOperationsUIElement(el, action);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- return false;
- }
- });
- var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- return false;
- }
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
- }
- }));
- }
-
- //Level and buttons to change level
- var maxLevel = (action.level >= action.maxLevel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
- display:"inline-block",
- innerText:"Level: " + action.level + " / " + action.maxLevel
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
- display:"inline",
- clickListener:()=>{
- ++action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateOperationsUIElement(el, action);
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
- padding:"2px", margin:"2px",
- tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
- display:"inline",
- clickListener:()=>{
- --action.level;
- if (isActive) {this.startAction(this.action);} //Restart Action
- this.updateOperationsUIElement(el, action);
- return false;
- }
- }));
-
- //General Info
- var difficulty = action.getDifficulty();
- var actionTime = action.getActionTime(this);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
- display:"inline-block",
- innerHTML:action.desc + "\n\n" +
- "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 1) + "\n" +
- "Operations remaining: " + Math.floor(action.count) + "\n" +
- "Successes: " + action.successes + "\n" +
- "Failures: " + action.failures,
- }));
-
- //Autolevel Checkbox
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
- var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("label", {
- for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
- tooltip:"Automatically increase operation level when possible"
- }));
- var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
- type:"checkbox", id:autolevelCheckboxId, margin:"4px",
- checked:action.autoLevel,
- changeListener:()=>{
- action.autoLevel = autolevelCheckbox.checked;
- }
- });
- el.appendChild(autolevelCheckbox);
-}
-
-Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
- var isActive = el.classList.contains(ActiveActionCssClass);
- var isCompleted = (this.blackops[action.name] != null);
- var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
- var difficulty = action.getDifficulty();
- var actionTime = action.getActionTime(this);
- var hasReqdRank = this.rank >= action.reqdRank;
-
- //UI for Completed Black Op
- if (isCompleted) {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", {
- innerText:action.name + " (COMPLETED)", display:"block",
- }));
- return;
- }
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
- innerText:isActive ? action.name + " (IN PROGRESS - " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
- : action.name,
- display:"inline-block",
- }));
-
- if (isActive) { //Progress bar if its active
- var progress = this.actionTimeCurrent / this.actionTimeToComplete;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
- }));
- } else {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Start button
- innerText:"Start", margin:"3px", padding:"3px",
- class:hasReqdRank ? "a-link-button" : "a-link-button-inactive",
- clickListener:()=>{
- this.action.type = ActionTypes.BlackOperation;
- this.action.name = action.name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- return false;
- }
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Set Team Size Button
- innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- var popupId = "bladeburner-operation-set-team-size-popup";
- var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- innerText:"Enter the amount of team members you would like to take on this " +
- "BlackOp. If you do not have the specified number of team members, " +
- "then as many as possible will be used. Note that team members may " +
- "be lost during operations."
-
- });
- var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
- type:"number", placeholder: "Team Members"
- });
- var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Confirm", class:"a-link-button",
- clickListener:()=>{
- var num = Math.round(parseFloat(input.value));
- if (isNaN(num)) {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
- } else {
- action.teamCount = num;
- this.updateBlackOpsUIElement(el, action);
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- return false;
- }
- });
- var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- return false;
- }
- });
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
- }
- }));
- }
-
- //Info
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"inline-block",
- innerHTML:"
" + action.desc + "
",
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block", color:hasReqdRank ? "white" : "red",
- innerHTML:"Required Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.reqdRank, 0) + "
"
- }));
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"inline-block",
- innerHTML:"Estimated Success Chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
- "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 1),
- }))
-}
-
-Bladeburner.prototype.updateSkillsUIElement = function(el, skill) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
- var skillName = skill.name;
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var pointCost = skill.baseCost + (currentLevel * skill.costInc);
-
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
- innerText:skill.name + " (Lvl " + currentLevel + ")", display:"inline-block"
- }));
-
- var canLevel = this.skillPoints >= pointCost;
- var maxLvl = skill.maxLvl ? currentLevel >= skill.maxLvl : false;
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Level up button
- innerText:"Level", display:"inline-block",
- class: canLevel && !maxLvl ? "a-link-button" : "a-link-button-inactive",
- margin:"3px", padding:"3px",
- clickListener:()=>{
- this.skillPoints -= pointCost;
- this.upgradeSkill(skill);
- this.createActionAndSkillsContent();
- return false;
- }
- }));
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
- if (maxLvl) {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- color:"red", display:"block",
- innerText:"MAX LEVEL"
- }));
- } else {
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
- display:"block",
- innerText:"Skill Points required: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(pointCost, 0),
- }));
- }
- el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", { //Info/Description
- innerHTML:skill.desc, display:"inline-block",
- }));
-}
-
-//Bladeburner Console Window
-Bladeburner.prototype.postToConsole = function(input) {
- if (input == null || DomElems.consoleDiv == null) {return;}
- $("#bladeubrner-console-input-row").before(' ');
- if (DomElems.consoleTable.childNodes.length > 200) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
- this.updateConsoleScroll();
-}
-
-Bladeburner.prototype.updateConsoleScroll = function() {
- DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;
-}
-
-Bladeburner.prototype.resetConsoleInput = function() {
- DomElems.consoleInput.value = "";
-}
-
-Bladeburner.prototype.clearConsole = function() {
- while (DomElems.consoleTable.childNodes.length > 1) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
-}
-
-Bladeburner.prototype.log = function(input) {
- //Adds a timestamp and then just calls postToConsole
- var d = new Date();
- var timestamp = d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes();
- this.postToConsole("[" + timestamp + "] " + input);
-}
-
-//Handles a potential series of commands (comm1; comm2; comm3;)
-Bladeburner.prototype.executeConsoleCommands = function(commands) {
- try {
- //Console History
- if (consoleHistory[consoleHistory.length-1] != commands) {
- consoleHistory.push(commands);
- if (consoleHistory.length > 50) {
- consoleHistory.splice(0, 1);
- }
- }
- consoleHistoryIndex = consoleHistory.length;
-
- var arrayOfCommands = commands.split(";");
- for (var i = 0; i < arrayOfCommands.length; ++i) {
- this.executeConsoleCommand(arrayOfCommands[i]);
- }
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
- }
-}
-
-//A single command
-Bladeburner.prototype.executeConsoleCommand = function(command) {
- command = command.trim();
- command = command.replace(/\s\s+/g, ' '); //Replace all whitespace w/ a single space
-
- var args = this.parseCommandArguments(command);
- if (args.length <= 0) {return;} //Log an error?
-
- switch(args[0].toLowerCase()) {
- case "automate":
- this.executeAutomateConsoleCommand(args);
- break;
- case "clear":
- case "cls":
- this.clearConsole();
- break;
- case "help":
- this.executeHelpConsoleCommand(args);
- break;
- case "log":
- this.executeLogConsoleCommand(args);
- break;
- case "skill":
- this.executeSkillConsoleCommand(args);
- break;
- case "start":
- this.executeStartConsoleCommand(args);
- break;
- case "stop":
- this.resetAction();
- break;
- default:
- this.postToConsole("Invalid console command");
- break;
- }
-}
-
-Bladeburner.prototype.parseCommandArguments = function(command) {
- //Returns an array with command and its arguments in each index.
- //e.g. skill "blade's intuition" foo returns [skill, blade's intuition, foo]
- //The input to this fn will be trimmed and will have all whitespace replaced w/ a single space
- var args = [];
- var start = 0, i = 0;
- while (i < command.length) {
- var c = command.charAt(i);
- if (c === '"') {
- var endQuote = command.indexOf('"', i+1);
- if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === " ")) {
- args.push(command.substr(i+1, (endQuote - i - 1)));
- if (endQuote === command.length-1) {
- start = i = endQuote+1;
- } else {
- start = i = endQuote+2; //Skip the space
- }
- continue;
- }
- } else if (c === " ") {
- args.push(command.substr(start, i-start));
- start = i+1;
- }
- ++i;
- }
- if (start !== i) {args.push(command.substr(start, i-start));}
- console.log("Bladeburner.parseCommandArguments returned: " + args);
- return args;
-}
-
-Bladeburner.prototype.executeAutomateConsoleCommand = function(args) {
- if (args.length !== 2 && args.length !== 4) {
- this.postToConsole("Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info");
- return;
- }
-
- //Enable/Disable
- if (args.length === 2) {
- var flag = args[1];
- if (flag.toLowerCase() === "status") {
- this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
- if (this.automateEnabled) {
- this.postToConsole("When your stamina drops to " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.automateThreshLow, 0) +
- ", you will automatically switch to " + this.automateActionLow.name +
- ". When your stamina recovers to " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.automateThreshHigh, 0) + ", you will automatically " +
- "switch to " + this.automateActionHigh.name + ".");
- }
-
- } else if (flag.toLowerCase().includes("en")) {
- if (!(this.automateActionLow instanceof ActionIdentifier) ||
- !(this.automateActionHigh instanceof ActionIdentifier)) {
- return this.log("Failed to enable automation. Actions were not set");
- }
- this.automateEnabled = true;
- this.log("Bladeburner automation enabled");
- } else if (flag.toLowerCase().includes("d")) {
- this.automateEnabled = false;
- this.log("Bladeburner automation disabled");
- } else {
- this.log("Invalid argument for 'automate' console command: " + args[1]);
- }
- return;
- }
-
- //Set variables
- if (args.length === 4) {
- var variable = args[1], val = args[2];
-
- var highLow = false; //True for high, false for low
- if (args[3].toLowerCase().includes("hi")) {highLow = true;}
-
- switch (variable) {
- case "general":
- case "gen":
- if (GeneralActions[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes[val], name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid action name specified: " + val);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Contract, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid contract name specified: " + val);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Operation, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid Operation name specified: " + val);
- }
- break;
- case "stamina":
- if (isNaN(val)) {
- this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val);
- } else {
- if (highLow) {
- this.automateThreshHigh = Number(val);
- } else {
- this.automateThreshLow = Number(val);
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val);
- }
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-Bladeburner.prototype.executeHelpConsoleCommand = function(args) {
- if (args.length === 1) {
- this.postToConsole(consoleHelpText.helpList);
- } else {
- for (var i = 1; i < args.length; ++i) {
- var commandText = consoleHelpText[args[i]];
- if (commandText != null) {
- this.postToConsole(commandText);
- this.postToConsole("' + input + '
");
- }
- }
- }
-}
-
-Bladeburner.prototype.executeLogConsoleCommand = function(args) {
- if (args.length < 3) {
- this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]");
- this.postToConsole("Use 'help log' for more details and examples");
- return;
- }
-
- var flag = true;
- if (args[1].toLowerCase().includes("d")) {flag = false;} //d for disable
-
- switch (args[2].toLowerCase()) {
- case "general":
- case "gen":
- this.logging.general = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions");
- break;
- case "contract":
- case "contracts":
- this.logging.contracts = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts");
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- this.logging.ops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations");
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- this.logging.blackops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps");
- break;
- case "event":
- case "events":
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for events");
- break;
- case "all":
- this.logging.general = flag;
- this.logging.contracts = flag;
- this.logging.ops = flag;
- this.logging.blackops = flag;
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything");
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[2]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]");
- break;
- }
-}
-
-Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
- switch (args.length) {
- case 1:
- //Display Skill Help Command
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- case 2:
- if (args[1].toLowerCase() === "list") {
- //List all skills and their level
- this.postToConsole("Skills: ");
- var skillNames = Object.keys(Skills);
- for(var i = 0; i < skillNames.length; ++i) {
- var skill = Skills[skillNames[i]];
- var level = 0;
- if (this.skills[skill.name] != null) {level = this.skills[skill.name];}
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(level, 0));
- }
- this.postToConsole(" ");
- this.postToConsole("Effects: ");
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- this.postToConsole("Total Success Chance: x" + mult);
- break;
- case "successChanceStealth":
- this.postToConsole("Stealth Success Chance: x" + mult);
- break;
- case "successChanceKill":
- this.postToConsole("Retirement Success Chance: x" + mult);
- break;
- case "successChanceContract":
- this.postToConsole("Contract Success Chance: x" + mult);
- break;
- case "successChanceOperation":
- this.postToConsole("Operation Success Chance: x" + mult);
- break;
- case "successChanceEstimate":
- this.postToConsole("Synthoid Data Estimate: x" + mult);
- break;
- case "actionTime":
- this.postToConsole("Action Time: x" + mult);
- break;
- case "effHack":
- this.postToConsole("Hacking Skill: x" + mult);
- break;
- case "effStr":
- this.postToConsole("Strength: x" + mult);
- break;
- case "effDef":
- this.postToConsole("Defense: x" + mult);
- break;
- case "effDex":
- this.postToConsole("Dexterity: x" + mult);
- break;
- case "effAgi":
- this.postToConsole("Agility: x" + mult);
- break;
- case "effCha":
- this.postToConsole("Charisma: x" + mult);
- break;
- case "effInt":
- this.postToConsole("Intelligence: x" + mult);
- break;
- case "stamina":
- this.postToConsole("Stamina: x" + mult);
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- case 3:
- var skillName = args[2];
- var skill = Skills[skillName];
- if (skill == null || !(skill instanceof Skill)) {
- return this.postToConsole("Invalid skill name (Note that this is case-sensitive): " + skillName);
- }
- if (args[1].toLowerCase() === "list") {
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skills[skill.name]), 0);
- } else if (args[1].toLowerCase() === "level") {
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var pointCost = skill.baseCost + (currentLevel * skill.costInc);
- if (this.skillPoints >= pointCost) {
- this.skillPoints -= pointCost;
- this.upgradeSkill(skill);
- this.log(skill.name + " upgraded to Level " + this.skills[skillName]);
- this.createActionAndSkillsContent();
- } else {
- this.postToConsole("You do not have enough Skill Points to upgrade this. You need " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(pointCost, 0));
- }
-
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- default:
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- }
-}
-
-Bladeburner.prototype.executeStartConsoleCommand = function(args) {
- if (args.length !== 3) {
- this.postToConsole("Invalid usage of 'start' console command: start [type] [name]");
- this.postToConsole("Use 'help start' for more info");
- return;
- }
- var name = args[2];
- switch (args[1].toLowerCase()) {
- case "general":
- case "gen":
- if (GeneralActions[name] != null) {
- this.action.type = ActionTypes[name];
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid action name specified: " + args[2]);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[name] != null) {
- this.action.type = ActionTypes.Contract;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid contract name specified: " + args[2]);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[name] != null) {
- this.action.type = ActionTypes.Operation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid Operation name specified: " + args[2]);
- }
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- if (BlackOperations[name] != null) {
- this.action.type = ActionTypes.BlackOperation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid BlackOp name specified: " + args[2]);
- }
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[1]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]");
- break;
- }
-}
-
-
-Bladeburner.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Bladeburner", this);
-}
-Bladeburner.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Bladeburner, value.data);
-}
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Bladeburner = Bladeburner;
-
-//This initialized Bladeburner-related data that is NOT saved/loaded
-// eg: Skill Objects, BLack Operations
-//Any data that is saved/loaded should go in Bladeburner object
-// eg: contracts, operations
-function initBladeburner() {
- //Skills
- Skills[SkillNames.BladesIntuition] = new Skill({
- name:SkillNames.BladesIntuition,
- desc:"Each level of this skill increases your success chance " +
- "for all contracts and operations by 3%",
- baseCost:5, costInc:2,
- successChanceAll:3
- });
- Skills[SkillNames.Reaper] = new Skill({
- name:SkillNames.Reaper,
- desc:"Each level of this skill increases your " +
- "effective combat stats for Bladeburner actions by 3%",
- baseCost:3, costInc:2,
- effStr:3, effDef:3, effDex:3, effAgi:3
- });
- Skills[SkillNames.Cloak] = new Skill({
- name:SkillNames.Cloak,
- desc:"Each level of this skill increases your " +
- "success chance in stealth-related contracts and operations by 5.5%",
- baseCost:3, costInc:1,
- successChanceStealth:5.5
- });
-
- //TODO Marksman
- //TODO Weapon Proficiency
-
- Skills[SkillNames.Overclock] = new Skill({
- name:SkillNames.Overclock,
- desc:"Each level of this skill decreases the time it takes " +
- "to attempt a contract or operation by 1% (Max Level: 95)",
- baseCost:5, costInc:1, maxLvl:95,
- actionTime:1
- });
- Skills[SkillNames.EvasiveSystem] = new Skill({
- name:SkillNames.EvasiveSystem,
- desc:"Each level of this skill increases your effective " +
- "dexterity and agility for Bladeburner actions by 5%",
- baseCost:2, costInc: 1,
- effDex:5, effAgi:5
- });
- Skills[SkillNames.ShortCircuit] = new Skill({
- name:SkillNames.ShortCircuit,
- desc:"Each level of this skill increases your success chance " +
- "in contracts and operations that involve retirement by 5.5%",
- baseCost:3, costInc:2,
- successChanceKill:5.5
- });
- Skills[SkillNames.DigitalObserver] = new Skill({
- name:SkillNames.DigitalObserver,
- desc:"Each level of this skill increases your success chance in " +
- "all operations by 4%",
- baseCost:5, costInc:2,
- successChanceOperation:4
- });
- Skills[SkillNames.Datamancer] = new Skill({
- name:SkillNames.Datamancer,
- desc:"Each level of this skill increases your effectiveness in " +
- "synthoid population analysis and investigation by 5%. " +
- "This affects all actions that can potentially increase " +
- "the accuracy of your synthoid population/community estimates.",
- baseCost:3,costInc:1,
- successChanceEstimate:5
- });
- Skills[SkillNames.Tracer] = new Skill({
- name:SkillNames.Tracer,
- desc:"Each level of this skill increases your success chance in " +
- "all contracts by 4%",
- baseCost:3, costInc:2,
- successChanceContract:4
- });
- Skills[SkillNames.CybersEdge] = new Skill({
- name:SkillNames.CybersEdge,
- desc:"Each level of this skill increases your max " +
- "stamina by 2%",
- baseCost:1, costInc:3,
- stamina:2
- });
-
- //General Actions
- var actionName = "Training";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Improve your abilities at the Bladeburner unit's specialized training " +
- "center. Doing this gives experience for all combat stats and also " +
- "increases your max stamina."
- });
-
- var actionName = "Field Analysis";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Mine and analyze Synthoid-related data. This improve the " +
- "Bladeburner's unit intelligence on Synthoid locations and " +
- "activities. Completing this action will improve the accuracy " +
- "of your Synthoid population estimated in the current city.
" +
- "Does NOT require stamina."
- });
-
- var actionName = "Recruitment";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Attempt to recruit members for your Bladeburner team. These members " +
- "can help you conduct operations.
" +
- "Does NOT require stamina."
- });
-
- //Black Operations
- BlackOperations["Operation Typhoon"] = new BlackOperation({
- name:"Operation Typhoon",
- desc:"Obadiah Zenyatta is the leader of a RedWater PMC. It has long " +
- "been known among the intelligence community that Zenyatta, along " +
- "with the rest of the PMC, is a Synthoid.
" +
- "The goal of Operation Typhoon is to find and eliminate " +
- "Zenyatta and RedWater by any means necessary. After the task " +
- "is completed, the actions must be covered up from the general public.",
- baseDifficulty:2000, reqdRank:2.5e3,
- rankGain:25, rankLoss:10, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Zero"] = new BlackOperation({
- name:"Operation Zero",
- desc:"AeroCorp is one of the world's largest defense contractors. " +
- "It's leader, Steve Watataki, is thought to be a supporter of " +
- "Synthoid rights. He must be removed.
" +
- "The goal of Operation Zero is to covertly infiltrate AeroCorp and " +
- "uncover any incriminating evidence or " +
- "information against Watataki that will cause him to be removed " +
- "from his position at AeroCorp. Incriminating evidence can be " +
- "fabricated as a last resort. Be warned that AeroCorp has some of " +
- "the most advanced security measures in the world.",
- baseDifficulty:2500, reqdRank:5e3,
- rankGain:30, rankLoss:15, hpLoss:50,
- weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation X"] = new BlackOperation({
- name:"Operation X",
- desc:"We have recently discovered an underground publication " +
- "group called Samizdat. Even though most of their publications " +
- "are nonsensical conspiracy theories, the average human is " +
- "gullible enough to believe them. Many of their works discuss " +
- "Synthoids and pose a threat to society. The publications are spreading " +
- "rapidly in China and other Eastern countries.
" +
- "Samizdat has done a good job of keeping hidden and anonymous. " +
- "However, we've just received intelligence that their base of " +
- "operations is in Ishima's underground sewer systems. Your task is to " +
- "investigate the sewer systems, and eliminate Samizdat. They must " +
- "never publish anything again.",
- baseDifficulty:3000, reqdRank:7.5e3,
- rankGain:30, rankLoss:15, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Titan"] = new BlackOperation({
- name:"Operation Titan",
- desc:"Several months ago Titan Laboratories' Bioengineering department " +
- "was infiltrated by Synthoids. As far as we know, Titan Laboratories' " +
- "management has no knowledge about this. We don't know what the " +
- "Synthoids are up to, but the research that they could " +
- "be conducting using Titan Laboraties' vast resources is potentially " +
- "very dangerous.
" +
- "Your goal is to enter and destroy the Bioengineering department's " +
- "facility in Aevum. The task is not just to retire the Synthoids there, but " +
- "also to destroy any information or research at the facility that " +
- "is relevant to the Synthoids and their goals.",
- baseDifficulty:4000, reqdRank:10e3,
- rankGain:40, rankLoss:20, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ares"] = new BlackOperation({
- name:"Operation Ares",
- desc:"One of our undercover agents, Agent Carter, has informed us of a " +
- "massive weapons deal going down in Dubai between rogue Russian " +
- "militants and a radical Synthoid community. These weapons are next-gen " +
- "plasma and energy weapons. It is critical for the safety of humanity " +
- "that this deal does not happen.
" +
- "Your task is to intercept the deal. Leave no survivors.",
- baseDifficulty:5000, reqdRank:12.5e3,
- rankGain:40, rankLoss:20, hpLoss:200,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Archangel"] = new BlackOperation({
- name:"Operation Archangel",
- desc:"Our analysts have discovered that the popular Red Rabbit brothel in " +
- "Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence " +
- "suggests that the profit from this brothel is used to fund a large " +
- "black market arms trafficking operation.
" +
- "The goal of this operation is to take out the leaders that are running " +
- "the Red Rabbit brothel. Try to limit the number of other casualties, " +
- "but do what you must to complete the mission.",
- baseDifficulty:7500, reqdRank:15e3,
- rankGain:50, rankLoss:20, hpLoss:25,
- weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Juggernaut"] = new BlackOperation({
- name:"Operation Juggernaut",
- desc:"The CIA has just encountered a new security threat. A new " +
- "criminal group, lead by a shadowy operative who calls himself " +
- "Juggernaut, has been smuggling drugs and weapons (including " +
- "suspected bioweapons) into Sector-12. We also have reason " +
- "to believe the tried to break into one of Universal Energy's " +
- "facilities in order to cause a city-wide blackout. The CIA " +
- "suspects that Juggernaut is a heavily-augmented Synthoid, and " +
- "have thus enlisted our help.
" +
- "Your mission is to eradicate Juggernaut and his followers.",
- baseDifficulty:10e3, reqdRank:20e3,
- rankGain:75, rankLoss:40, hpLoss:300,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Red Dragon"] = new BlackOperation({
- name:"Operation Red Dragon",
- desc:"The Tetrads criminal organization is suspected of " +
- "reverse-engineering the MK-VI Synthoid design. We believe " +
- "they altered and possibly improved the design and began " +
- "manufacturing their own Synthoid models in order to bolster " +
- "their criminal activities.
" +
- "Your task is to infiltrate and destroy the Tetrads' base of operations " +
- "in Los Angeles. Intelligence tells us that their base houses " +
- "one of their Synthoid manufacturing units.",
- baseDifficulty:12.5e3, reqdRank:25e3,
- rankGain:100, rankLoss:50, hpLoss:500,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation K"] = new BlackOperation({
- name:"Operation K",
- desc:"CODE RED SITUATION. Our intelligence tells us that VitaLife " +
- "has discovered a new android cloning technology. This technology " +
- "is supposedly capable of cloning Synthoid, not only physically " +
- "but also their advanced AI modules. We do not believe that " +
- "VitaLife is trying to use this technology illegally or " +
- "maliciously, but if any Synthoids were able to infiltrate the " +
- "corporation and take advantage of this technology then the " +
- "results would be catastrophic.
" +
- "We do not have the power or jurisdiction to shutdown this down " +
- "through legal or political means, so we must resort to a covert " +
- "operation. Your goal is to destroy this technology and eliminate" +
- "anyone who was involved in its creation.",
- baseDifficulty:15e3, reqdRank:30e3,
- rankGain:120, rankLoss:60, hpLoss:1000,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Deckard"] = new BlackOperation({
- name:"Operation Deckard",
- desc:"Despite your success in eliminating VitaLife's new android-replicating " +
- "technology in Operation K, we've discovered that a small group of " +
- "MK-VI Synthoids were able to make off with the schematics and design " +
- "of the technology before the Operation. It is almost a certainty that " +
- "these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising." +
- "The goal of Operation Deckard is to hunt down these Synthoids and retire " +
- "them. I don't need to tell you how critical this mission is.",
- baseDifficulty:20e3, reqdRank:40e3,
- rankGain:150, rankLoss:75, hpLoss:200,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Tyrell"] = new BlackOperation({
- name:"Operation Tyrell",
- desc:"A week ago Blade Industries reported a small break-in at one " +
- "of their Aevum Augmentation storage facitilities. We figured out " +
- "that The Dark Army was behind the heist, and didn't think any more " +
- "of it. However, we've just discovered that several known MK-VI Synthoids " +
- "were part of that break-in group.
" +
- "We cannot have Synthoids upgrading their already-enhanced abilities " +
- "with Augmentations. Your task is to hunt down the associated Dark Army " +
- "members and eliminate them.",
- baseDifficulty:25e3, reqdRank:50e3,
- rankGain:200, rankLoss:100, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Wallace"] = new BlackOperation({
- name:"Operation Wallace",
- desc:"Based on information gathered from Operation Tyrell, we've discovered " +
- "that The Dark Army was well aware that there were Synthoids amongst " +
- "their ranks. Even worse, we believe that The Dark Army is working " +
- "together with other criminal organizations such as The Syndicate and " +
- "that they are planning some sort of large-scale takeover of multiple major " +
- "cities, most notably Aevum. We suspect that Synthoids have infiltrated " +
- "the ranks of these criminal factions and are trying to stage another " +
- "Synthoid uprising.
" +
- "The best way to deal with this is to prevent it before it even happens. " +
- "The goal of Operation Wallace is to destroy the Dark Army and " +
- "Syndicate factions in Aevum immediately. Leave no survivors.",
- baseDifficulty:30e3, reqdRank:75e3,
- rankGain:500, rankLoss:150, hpLoss:1500,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Shoulder of Orion"] = new BlackOperation({
- name:"Operation Shoulder of Orion",
- desc:"China's Solaris Space Systems is secretly launching the first " +
- "manned spacecraft in over a decade using Synthoids. We believe " +
- "China is trying to establish the first off-world colonies.
" +
- "The mission is to prevent this launch without instigating an " +
- "international conflict. When you accept this mission you will be " +
- "officially disavowed by the NSA and the national government until after you " +
- "successfully return. In the event of failure, all of the operation's " +
- "team members must not let themselves be captured alive.",
- baseDifficulty:35e3, reqdRank:100e3,
- rankGain:1e3, rankLoss:500, hpLoss:1500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Hyron"] = new BlackOperation({
- name:"Operation Hyron",
- desc:"Our intelligence tells us that Fulcrum Technologies is developing " +
- "a quantum supercomputer using human brains as core " +
- "processors. This supercomputer " +
- "is rumored to be able to store vast amounts of data and " +
- "perform computations unmatched by any other supercomputer on the " +
- "planet. But more importantly, the use of organic human brains " +
- "means that the supercomputer may be able to reason abstractly " +
- "and become self-aware.
" +
- "I do not need to remind you why sentient-level AIs pose a serious " +
- "thread to all of mankind.
" +
- "The research for this project is being conducted at one of Fulcrum " +
- "Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. " +
- "Infiltrate the compound, delete and destroy the work, and then find and kill the " +
- "project lead.",
- baseDifficulty:40e3, reqdRank:125e3,
- rankGain:2e3, rankLoss:1e3, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Morpheus"] = new BlackOperation({
- name:"Operation Morpheus",
- desc:"DreamSense Technologies is an advertising company that uses " +
- "special technology to transmit their ads into the peoples " +
- "dreams and subconcious. They do this using broadcast transmitter " +
- "towers. Based on information from our agents and informants in " +
- "Chonqging, we have reason to believe that one of the broadcast " +
- "towers there has been compromised by Synthoids and is being used " +
- "to spread pro-Synthoid propaganda.
" +
- "The mission is to destroy this broadcast tower. Speed and " +
- "stealth are of the upmost important for this.",
- baseDifficulty:45e3, reqdRank:150e3,
- rankGain:5e3, rankLoss:1e3, hpLoss:100,
- weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Ion Storm"] = new BlackOperation({
- name:"Operation Ion Storm",
- desc:"Our analysts have uncovered a gathering of MK-VI Synthoids " +
- "that have taken up residence in the Sector-12 Slums. We " +
- "don't know if they are rogue Synthoids from the Uprising, " +
- "but we do know that they have been stockpiling " +
- "weapons, money, and other resources. This makes them dangerous.
" +
- "This is a full-scale assault operation to find and retire all of these " +
- "Synthoids in the Sector-12 Slums.",
- baseDifficulty:50e3, reqdRank:175e3,
- rankGain:5e3, rankLoss:1e3, hpLoss:5000,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Annihilus"] = new BlackOperation({
- name:"Operation Annihilus",
- desc:"Our superiors have ordered us to eradicate everything and everyone " +
- "in an underground facility located in Aevum. They tell us " +
- "that the facility houses many dangerous Synthoids and " +
- "belongs to a terrorist organization called " +
- "'The Covenant'. We have no prior intelligence about this " +
- "organization, so you are going in blind.",
- baseDifficulty:55e3, reqdRank:200e3,
- rankGain:5e3, rankLoss:1e3, hpLoss:10e3,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ultron"] = new BlackOperation({
- name:"Operation Ultron",
- desc:"OmniTek Incorporated, the original designer and manufacturer of Synthoids, " +
- "has notified us of a malfunction in their AI design. This malfunction, " +
- "when triggered, causes MK-VI Synthoids to become radicalized and seek out " +
- "the destruction of humanity. They say that this bug affects all MK-VI Synthoids, " +
- "not just the rogue ones from the Uprising.
" +
- "OmniTek has also told us they they believe someone has triggered this " +
- "malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids " +
- "are now amassing in Volhaven to form a terrorist group called Ultron.
" +
- "Intelligence suggests Ultron is heavily armed and that their members are " +
- "augmented. We believe Ultron is making moves to take control of " +
- "and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
" +
- "Your task is to find and destroy Ultron.",
- baseDifficulty:60e3, reqdRank:250e3,
- rankGain:10e3, rankLoss:2e3, hpLoss:10e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Centurion"] = new BlackOperation({
- name:"Operation Centurion",
- desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
- "Throughout all of humanity's history, we have relied on " +
- "technology to survive, conquer, and progress. Its advancement became our primary goal. " +
- "And at the peak of human civilization technology turned into " +
- "power. Global, absolute power.
" +
- "It seems that the universe is not without a sense of irony.
" +
- "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
- baseDifficulty:70e3, reqdRank:300e3,
- rankGain:15e3, rankLoss:5e3, hpLoss:10e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
- BlackOperations["Operation Vindictus"] = new BlackOperation({
- name:"Operation Vindictus",
- desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
- "The bits are all around us. The daemons that hold the Node " +
- "together can manifest themselves in many different ways.
" +
- "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
- baseDifficulty:75e3, reqdRank:350e3,
- rankGain:20e3, rankLoss:20e3, hpLoss:20e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
- BlackOperations["Operation Daedalus"] = new BlackOperation({
- name:"Operation Daedalus",
- desc:"Yesterday we obeyed kings and bent our neck to emperors. " +
- "Today we kneel only to truth.",
- baseDifficulty:80e3, reqdRank:400e3,
- rankGain:40e3, rankLoss:10e3, hpLoss:100e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- });
-}
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
-
-/***/ }),
-/* 28 */
-/*!****************************!*\
- !*** ./src/FactionInfo.js ***!
- \****************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactionInfo", function() { return FactionInfo; });
-//Contains the "information" property for all the Factions, which is just a description
-//of each faction
-let FactionInfo = {
- //Endgame
- IlluminatiInfo: "Humanity never changes. No matter how civilized society becomes, it will eventually fall back " +
- "into chaos. And from this chaos, we are the Invisible hand that guides them to order. ",
-
- DaedalusInfo: "Yesterday we obeyed kings and bent our necks to emperors. Today we kneel only to truth.",
-
- CovenantInfo: "Surrender yourself. Give up your empty individuality to become part of something great, something eternal. " +
- "Become a slave. Submit your mind, body, and soul. Only then can you set yourself free.
" +
- "Only then can you discover immortality.",
-
- //Megacorporations, each forms its own faction
- ECorpInfo: "ECorp's mission is simple: to connect the world of today with the technology of tomorrow. " +
- "With our wide range of Internet-related software and commercial hardware, ECorp makes the world's " +
- "information universally accessible.",
-
- MegaCorpInfo: "MegaCorp does things that others don't. We imagine. We create. We invent. We build things that " +
- "others have never even dreamed of. Our work fills the world's needs for food, water, power, and " +
- "transporation on an unprecendented scale, in ways that no other company can.
" +
- "In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.",
-
- BachmanAndAssociatesInfo: "Where Law and Business meet - thats where we are.
" +
- "Legal Insight - Business Instinct - Experience Innovation",
-
- BladeIndustriesInfo: "Augmentation is salvation",
-
- NWOInfo: "The human being does not truly desire freedom. It wants " +
- "to be observed, understood, and judged. It wants to be given purpose and " +
- "direction in its life. That is why humans created God. " +
- "And that is why humans created civilization - " +
- "not because of willingness, " +
- "but because of a need to be incorporated into higher orders of structure and meaning.",
-
- ClarkeIncorporatedInfo: "Unlocking the power of the genome",
-
- OmniTekIncorporatedInfo: "Simply put, our mission is to design and build robots that make a difference",
-
- FourSigmaInfo: "The scientific method is the best way to approach investing. Big strategies backed up with big data. Driven by " +
- "deep learning and innovative ideas. And improved by iteration. That's Four Sigma.",
-
- KuaiGongInternationalInfo: "Dream big. Work hard. Make history.",
-
- //Other Corporations
- FulcrumSecretTechnologiesInfo: "The human organism has an innate desire to worship. " +
- "That is why they created gods. If there were no gods, " +
- "it would be necessary to create them. And now we can.",
-
- //Hacker groups
- BitRunnersInfo: "Our entire lives are controlled by bits. All of our actions, our thoughts, our personal information. "+
- "It's all transformed into bits, stored in bits, communicated through bits. It’s impossible for any person " +
- "to move, to live, to operate at any level without the use of bits. " +
- "And when a person moves, lives, and operates, they leave behind their bits, mere traces of seemingly " +
- "meaningless fragments of information. But these bits can be reconstructed. Transformed. Used.
" +
- "Those who run the bits, run the world",
-
-
- BlackHandInfo: "The world, so afraid of strong government, now has no government. Only power - Digital power. Financial power. " +
- "Technological power. " +
- "And those at the top rule with an invisible hand. They built a society where the rich get richer, " +
- "and everyone else suffers.
" +
- "So much pain. So many lives. Their darkness must end.",
-
- NiteSecInfo:
-" __..__
" +
-" _.nITESECNIt.
" +
-" .-'NITESECNITESEc.
" +
-" .' NITESECNITESECn
" +
-" / NITESECNITESEC;
" +
-" : :NITESECNITESEC;
" +
-" ; $ NITESECNITESECN
" +
-" : _, ,N'ITESECNITESEC
" +
-" : .+^^`, : `NITESECNIT
" +
-" ) /), `-,-=,NITESECNI
" +
-" / ^ ,-;|NITESECN;
" +
-" / _.' '-';NITESECN
" +
-" ( , ,-''`^NITE'
" +
-" )` :`. .'
" +
-" )-- ; `- /
" +
-" \' _.-' :
" +
-" ( _.-' \. \
" +
-" \------. \ \
" +
-" \. \ \
" +
-" \ _.nIt
" +
-" \ _.nITESECNi
" +
-" nITESECNIT^' \
" +
-" NITE^' ___ \
" +
-" / .gP''''Tp. \
" +
-" : d' . `b \
" +
-" ; d' o `b ;
" +
-" / d; `b|
" +
-" /, $; @ `:
" +
-" /' $$ ;
" +
-" .' $$b o |
" +
-" .' d$$$; :
" +
-" / .d$$$$; , ;
" +
-" d .dNITESEC $ |
" +
-" :bp.__.gNITESEC$$ :$ ;
" +
-" NITESECNITESECNIT $$b :
",
-
- //City factions, essentially governments
- ChongqingInfo: "Serve the people",
- Sector12Info: "The City of the Future",
- HongKongInfo: "Asia's World City",
- AevumInfo: "The Silicon City",
- IshimaInfo: "The East Asian Order of the Future",
- VolhavenInfo: "Benefit, Honour, and Glory",
-
- //Criminal Organizations/Gangs
- SpeakersForTheDeadInfo: "It is better to reign in hell than to serve in heaven.",
-
- DarkArmyInfo: "The World doesn't care about right or wrong. It's all about power.",
-
- TheSyndicateInfo: "Honor holds you back",
-
- SilhouetteInfo: "Corporations have filled the void of power left behind by the collapse of Western government. The issue is they've become so big " +
- "that you don't know who they're working for. And if you're employed at one of these corporations, you don't even know who you're working " +
- "for.\n\n" +
- "That's terror. Terror, fear, and corruption. All born into the system, all propagated by the system.",
-
- TetradsInfo: "Following the Mandate of Heaven and Carrying out the Way",
-
- SlumSnakesInfo: "Slum Snakes rule!",
-
- //Earlygame factions - factions the player will prestige with early on that don't
- //belong in other categories
- NetburnersInfo: "~~//*>H4CK|\|3T 8URN3R5**>?>\\~~",
-
- TianDiHuiInfo: "Obey Heaven and Work Righteousness",
-
- CyberSecInfo: "The Internet is the first thing that humanity has built that humanity doesn’t understand, " +
- "the largest experiment in anarchy that we have ever had. And as the world becomes increasingly " +
- "dominated by the internet, society approaches the brink of total chaos. " +
- "We serve only to protect society, to protect humanity, to protect the world from its imminent collapse.",
-
- //Special Factions
- BladeburnersInfo: "It's too bad they won't live. But then again, who does?
" +
- "Note that for this faction, reputation can only be gained through Bladeburner actions. Completing " +
- "Bladeburner contracts/operations will increase your reputation.",
-}
-
-
-
-
-/***/ }),
-/* 29 */
/*!************************!*\
!*** ./src/Message.js ***!
\************************/
@@ -29906,15 +26944,15 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadMessages", function() { return loadMessages; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initMessages", function() { return initMessages; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Message", function() { return Message; });
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CreateProgram.js */ 14);
-/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 34);
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CreateProgram.js */ 17);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 39);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RedPill.js */ 45);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RedPill.js */ 41);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
@@ -30109,3991 +27147,7 @@ function initMessages() {
/***/ }),
-/* 30 */
-/*!**********************!*\
- !*** ./src/Alias.js ***!
- \**********************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Aliases", function() { return Aliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalAliases", function() { return GlobalAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "printAliases", function() { return printAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseAliasDeclaration", function() { return parseAliasDeclaration; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAlias", function() { return removeAlias; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; });
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 18);
-
-
-let Aliases = {};
-let GlobalAliases = {};
-
-function loadAliases(saveString) {
- if (saveString === "") {
- Aliases = {};
- } else {
- Aliases = JSON.parse(saveString);
- }
-}
-
-function loadGlobalAliases(saveString) {
- if (saveString === "") {
- GlobalAliases = {};
- } else {
- GlobalAliases = JSON.parse(saveString);
- }
-}
-
-//Print all aliases to terminal
-function printAliases() {
- for (var name in Aliases) {
- if (Aliases.hasOwnProperty(name)) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_0__["post"])("alias " + name + "=" + Aliases[name]);
- }
- }
- for (var name in GlobalAliases) {
- if (GlobalAliases.hasOwnProperty(name)) {
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_0__["post"])("global alias " + name + "=" + GlobalAliases[name]);
- }
- }
-}
-
-//True if successful, false otherwise
-function parseAliasDeclaration(dec,global=false) {
- var re = /^([_|\w|!|%|,|@]+)="(.+)"$/;
- var matches = dec.match(re);
- if (matches == null || matches.length != 3) {return false;}
- if (global){
- addGlobalAlias(matches[1],matches[2]);
- } else {
- addAlias(matches[1], matches[2]);
- }
- return true;
-}
-
-function addAlias(name, value) {
- if (name in GlobalAliases){
- delete GlobalAliases[name];
- }
- Aliases[name] = value;
-}
-
-function addGlobalAlias(name, value) {
- if (name in Aliases){
- delete Aliases[name];
- }
- GlobalAliases[name] = value;
-}
-
-function getAlias(name) {
- if (Aliases.hasOwnProperty(name)) {
- return Aliases[name];
- }
- return null;
-}
-
-function getGlobalAlias(name) {
- if (GlobalAliases.hasOwnProperty(name)) {
- return GlobalAliases[name];
- }
- return null;
-}
-
-function removeAlias(name) {
- if (Aliases.hasOwnProperty(name)) {
- delete Aliases[name];
- return true;
- }
- if (GlobalAliases.hasOwnProperty(name)) {
- delete GlobalAliases[name];
- return true;
- }
- return false;
-}
-
-//Returns the original string with any aliases substituted in
-//Aliases only applied to "whole words", one level deep
-function substituteAliases(origCommand) {
- var commandArray = origCommand.split(" ");
- if (commandArray.length>0){
- var alias = getAlias(commandArray[0]);
- if (alias != null) {
- commandArray[0] = alias;
- } else {
- var alias = getGlobalAlias(commandArray[0]);
- if (alias != null) {
- commandArray[0] = alias;
- }
- }
- for (var i = 0; i < commandArray.length; ++i) {
- var alias = getGlobalAlias(commandArray[i]);
- if (alias != null) {
- commandArray[i] = alias;
- }
- }
- }
- return commandArray.join(" ");
-}
-
-
-
-
-/***/ }),
-/* 31 */
-/*!***********************************!*\
- !*** ./src/NetscriptFunctions.js ***!
- \***********************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptFunctions", function() { return NetscriptFunctions; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSingularitySFFlags", function() { return initSingularitySFFlags; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasSingularitySF", function() { return hasSingularitySF; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBn11SF", function() { return hasBn11SF; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasWallStreetSF", function() { return hasWallStreetSF; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wallStreetSFLvl", function() { return wallStreetSFLvl; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasCorporationSF", function() { return hasCorporationSF; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; });
-/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 41);
-/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 19);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 15);
-/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 20);
-/* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Bladeburner.js */ 27);
-/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Company.js */ 9);
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./CreateProgram.js */ 14);
-/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./DarkWeb.js */ 35);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./HacknetNode.js */ 40);
-/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Location.js */ 4);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Message.js */ 29);
-/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Missions.js */ 34);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Script.js */ 26);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
-/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./StockMarket.js */ 22);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Terminal.js */ 18);
-/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./TextFile.js */ 43);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 6);
-/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69);
-/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./NetscriptPort.js */ 46);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! decimal.js */ 24);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
-var sprintf = __webpack_require__(/*! sprintf-js */ 68).sprintf,
- vsprintf = __webpack_require__(/*! sprintf-js */ 68).vsprintf
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-var hasCorporationSF = false, //Source-File 3
- hasSingularitySF = false, //Source-File 4
- hasAISF = false, //Source-File 5
- hasBladeburnerSF = false, //Source-File 6
- hasBladeburner2079SF = false, //Source-File 7
- hasWallStreetSF = false, //Source-File 8
- hasBn11SF = false; //Source-File 11
-
-var singularitySFLvl=1, wallStreetSFLvl=1;
-
-var possibleLogs = {
- ALL: true,
- scan: true,
- hack: true,
- sleep: true,
- disableLog: true,
- enableLog: true,
- grow: true,
- weaken: true,
- nuke: true,
- brutessh: true,
- ftpcrack: true,
- relaysmtp: true,
- httpworm: true,
- sqlinject: true,
- spawn: true,
- kill: true,
- killall: true,
- scp: true,
- getHackingLevel: true,
- getServerMoneyAvailable: true,
- getServerSecurityLevel: true,
- getServerBaseSecurityLevel: true,
- getServerMinSecurityLevel: true,
- getServerRequiredHackingLevel: true,
- getServerMaxMoney: true,
- getServerGrowth: true,
- getServerNumPortsRequired: true,
- getServerRam: true,
- buyStock: true,
- sellStock: true,
- purchaseServer: true,
- deleteServer: true,
- universityCourse: true,
- gymWorkout: true,
- travelToCity: true,
- purchaseTor: true,
- purchaseProgram: true,
- stopAction: true,
- upgradeHomeRam: true,
- workForCompany: true,
- applyToCompany: true,
- joinFaction: true,
- workForFaction: true,
- createProgram: true,
- commitCrime: true,
- shortStock: true,
- sellShort: true,
-}
-
-//Used to check and set flags for every Source File, despite the name of the function
-function initSingularitySFFlags() {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 3) {hasCorporationSF = true;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 4) {
- hasSingularitySF = true;
- singularitySFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].lvl;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 5) {hasAISF = true;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 6) {hasBladeburnerSF = true;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 7) {hasBladeburner2079SF = true;}
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 8) {
- hasWallStreetSF = true;
- wallStreetSFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].lvl;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].sourceFiles[i].n === 11) {hasBn11SF = true;}
- }
-}
-
-function NetscriptFunctions(workerScript) {
- return {
- Math : Math,
- Date : Date,
- Number : Number,
- hacknetnodes : _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknetNodeWrappers,
- sprintf : sprintf,
- vsprintf: vsprintf,
- scan : function(ip=workerScript.serverIp, hostnames=true){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.scan) {
- return 0;
- } else {
- workerScript.loadedFns.scan = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, 'Invalid IP or hostname passed into scan() command');
- }
- var out = [];
- for (var i = 0; i < server.serversOnNetwork.length; i++) {
- var entry;
- if (hostnames) {
- entry = server.getServerOnNetwork(i).hostname;
- } else {
- entry = server.getServerOnNetwork(i).ip;
- }
- if (entry == null) {
- continue;
- }
- out.push(entry);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {
- workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
- }
- return out;
- },
- hack : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.hack) {
- return 0;
- } else {
- workerScript.loadedFns.hack = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHackRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument");
- }
- var threads = workerScript.scriptRef.threads;
- if (isNaN(threads) || threads < 1) {threads = 1;}
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
- }
-
- //Calculate the hacking time
- var hackingTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingTime"])(server); //This is in seconds
-
- //No root access or skill level too low
- if (server.hasAdminRights == false) {
- workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access");
- }
-
- if (server.requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill) {
- workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
- }
-
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(hackingTime* 1000, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- var hackChance = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingChance"])(server);
- var rand = Math.random();
- var expGainedOnSuccess = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
- var expGainedOnFailure = (expGainedOnSuccess / 4);
- if (rand < hackChance) { //Success!
- var moneyGained = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculatePercentMoneyHacked"])(server);
- moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
-
- //Over-the-top safety checks
- if (moneyGained <= 0) {
- moneyGained = 0;
- expGainedOnSuccess = expGainedOnFailure;
- }
- if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
- server.moneyAvailable -= moneyGained;
- if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainMoney(moneyGained);
- workerScript.scriptRef.onlineMoneyMade += moneyGained;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug += moneyGained;
- workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGainedOnSuccess);
- workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
- }
- server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerFortifyAmount * threads);
- return Promise.resolve(moneyGained);
- } else {
- //Player only gains 25% exp for failure?
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGainedOnFailure);
- workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
- }
- return Promise.resolve(0);
- }
- });
- },
- sleep : function(time){
- if (workerScript.checkingRam) {return 0;}
- if (time === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument");
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {
- workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(time, workerScript).then(function() {
- return Promise.resolve(true);
- });
- },
- grow : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.grow) {
- return 0;
- } else {
- workerScript.loadedFns.grow = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGrowRamCost;
- }
- }
- var threads = workerScript.scriptRef.threads;
- if (isNaN(threads) || threads < 1) {threads = 1;}
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip);
- }
-
- //No root access or skill level too low
- if (server.hasAdminRights == false) {
- workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
- }
-
- var growTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateGrowTime"])(server);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
- workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(growTime/1000, 3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(growTime, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
- var growthPercentage = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["processSingleServerGrowth"])(server, 450 * threads);
- workerScript.scriptRef.recordGrow(server.ip, threads);
- var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
- if (growthPercentage == 1) {
- expGain = 0;
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
- workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(growthPercentage*100 - 100, 6) + "%. Gained " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
- }
- workerScript.scriptRef.onlineExpGained += expGain;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGain);
- return Promise.resolve(growthPercentage);
- });
- },
- weaken : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.weaken) {
- return 0;
- } else {
- workerScript.loadedFns.weaken = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptWeakenRamCost;
- }
- }
- var threads = workerScript.scriptRef.threads;
- if (isNaN(threads) || threads < 1) {threads = 1;}
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip);
- }
-
- //No root access or skill level too low
- if (server.hasAdminRights == false) {
- workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
- }
-
- var weakenTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateWeakenTime"])(server);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
- workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["netscriptDelay"])(weakenTime, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- server.weaken(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerWeakenAmount * threads);
- workerScript.scriptRef.recordWeaken(server.ip, threads);
- var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateExpGain"])(server) * threads;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
- workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
- ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
- }
- workerScript.scriptRef.onlineExpGained += expGain;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainHackingExp(expGain);
- return Promise.resolve(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ServerWeakenAmount * threads);
- });
- },
- print : function(args){
- if (workerScript.checkingRam) {return 0;}
- if (args === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument");
- }
- workerScript.scriptRef.log(args.toString());
- },
- tprint : function(args) {
- if (workerScript.checkingRam) {return 0;}
- if (args === undefined || args == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
- }
- var x = args.toString();
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isHTML"])(x)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].takeDamage(1);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_28__["dialogBoxCreate"])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:
" +
- "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!
" +
- "(You lost 1 HP)");
- return;
- }
- Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_21__["post"])(workerScript.scriptRef.filename + ": " + args.toString());
- },
- clearLog : function() {
- if (workerScript.checkingRam) {return 0;}
- workerScript.scriptRef.clearLog();
- },
- disableLog : function(fn) {
- if (workerScript.checkingRam) {return 0;}
- if(possibleLogs[fn]===undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to disableLog: "+fn);
- }
- workerScript.disableLogs[fn] = true;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) {
- workerScript.scriptRef.log("Disabled logging for " + fn);
- }
- },
- enableLog : function(fn) {
- if (workerScript.checkingRam) {return 0;}
- if(possibleLogs[fn]===undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to enableLog: "+fn);
- }
- delete workerScript.disableLogs[fn];
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) {
- workerScript.scriptRef.log("Enabled logging for " + fn);
- }
- },
- nuke : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.nuke) {
- return 0;
- } else {
- workerScript.loadedFns.nuke = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the NUKE.exe virus!");
- }
- if (server.openPortCount < server.numOpenPortsRequired) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Not enough ports opened to use NUKE.exe virus");
- }
- if (server.hasAdminRights) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
- workerScript.scriptRef.log("Already have root access to " + server.hostname);
- }
- } else {
- server.hasAdminRights = true;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
- workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
- }
- }
- return true;
- },
- brutessh : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.brutessh) {
- return 0;
- } else {
- workerScript.loadedFns.brutessh = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram)) {
- workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the BruteSSH.exe program!");
- }
- if (!server.sshPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
- workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
- }
- server.sshPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
- workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
- }
- }
- return true;
- },
- ftpcrack : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.ftpcrack) {
- return 0;
- } else {
- workerScript.loadedFns.ftpcrack = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the FTPCrack.exe program!");
- }
- if (!server.ftpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
- workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
- }
- server.ftpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
- workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
- }
- }
- return true;
- },
- relaysmtp : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.relaysmtp) {
- return 0;
- } else {
- workerScript.loadedFns.relaysmtp = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the relaySMTP.exe program!");
- }
- if (!server.smtpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
- workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
- }
- server.smtpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
- workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
- }
- }
- return true;
- },
- httpworm : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.httpworm) {
- return 0;
- } else {
- workerScript.loadedFns.httpworm = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the HTTPWorm.exe program!");
- }
- if (!server.httpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
- workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
- }
- server.httpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
- workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
- }
- }
- return true;
- },
- sqlinject : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.sqlinject) {
- return 0;
- } else {
- workerScript.loadedFns.sqlinject = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPortProgramRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You do not have the SQLInject.exe program!");
- }
- if (!server.sqlPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
- workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
- }
- server.sqlPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
- workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
- }
- }
- return true;
- },
- run : function(scriptname,threads = 1){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.run) {
- return 0;
- } else {
- workerScript.loadedFns.run = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptRunRamCost;
- }
- }
- if (scriptname === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
- }
- if (isNaN(threads) || threads < 1) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0");
- }
- var argsForNewScript = [];
- for (var i = 2; i < arguments.length; ++i) {
- argsForNewScript.push(arguments[i]);
- }
- var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
-
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["runScriptFromScript"])(scriptServer, scriptname, argsForNewScript, workerScript, threads);
- },
- exec : function(scriptname,ip,threads = 1) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.exec) {
- return 0;
- } else {
- workerScript.loadedFns.exec = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptExecRamCost;
- }
- }
- if (scriptname === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
- }
- if (isNaN(threads) || threads < 1) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0");
- }
- var argsForNewScript = [];
- for (var i = 3; i < arguments.length; ++i) {
- argsForNewScript.push(arguments[i]);
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip);
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["runScriptFromScript"])(server, scriptname, argsForNewScript, workerScript, threads);
- },
- spawn : function(scriptname, threads) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.spawn) {
- return 0;
- } else {
- workerScript.loadedFns.spawn = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSpawnRamCost;
- }
- }
- if (scriptname == null || threads == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid scriptname or numThreads argument passed to spawn()");
- }
- setTimeout(()=>{
- NetscriptFunctions(workerScript).run.apply(this, arguments);
- }, 20000);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {
- workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
- }
- NetscriptFunctions(workerScript).exit();
- },
- kill : function(filename,ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.kill) {
- return 0;
- } else {
- workerScript.loadedFns.kill = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost;
- }
- }
-
- if (filename === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip);
- }
- var argsForKillTarget = [];
- for (var i = 2; i < arguments.length; ++i) {
- argsForKillTarget.push(arguments[i]);
- }
- var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(filename, argsForKillTarget, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget));
- return false;
- }
- var res = Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(runningScriptObj, server.ip);
- if (res) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
- workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
- }
- return true;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
- workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForKillTarget));
- }
- return false;
- }
- },
- killall : function(ip=workerScript.serverIp){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.killall) {
- return 0;
- } else {
- workerScript.loadedFns.killall = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost;
- }
- }
-
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
- }
- var scriptsRunning = (server.runningScripts.length > 0);
- for (var i = server.runningScripts.length-1; i >= 0; --i) {
- Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(server.runningScripts[i], server.ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
- workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
- }
- return scriptsRunning;
- },
- exit : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.exit) {
- return 0;
- } else {
- workerScript.loadedFns.exit = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptKillRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev");
- }
- if (Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(workerScript.scriptRef, server.ip)) {
- workerScript.scriptRef.log("Exiting...");
- } else {
- workerScript.scriptRef.log("Exit failed(). This is a bug please contact game developer");
- }
- },
- scp : function(scriptname, ip1, ip2) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.scp) {
- return 0;
- } else {
- workerScript.loadedFns.scp = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScpRamCost;
- }
- }
- if (arguments.length !== 2 && arguments.length !== 3) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
- if (scriptname && scriptname.constructor === Array) {
- //Recursively call scp on all elements of array
- var res = false;
- scriptname.forEach(function(script) {
- if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) {
- res = true;
- };
- });
- return res;
- }
- if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["isScriptFilename"])(scriptname) &&
- !scriptname.endsWith("txt")) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
- }
-
- var destServer, currServ;
-
- if (arguments.length === 3) { //scriptname, source, destination
- if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
- destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip2);
- if (destServer == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
- }
-
- currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip1);
- if (currServ == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
- }
- } else if (arguments.length === 2) { //scriptname, destination
- if (scriptname === undefined || ip1 === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
- destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip1);
- if (destServer == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
- }
-
- currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (currServ == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
- }
- }
-
- //Scp for lit files
- if (scriptname.endsWith(".lit")) {
- var found = false;
- for (var i = 0; i < currServ.messages.length; ++i) {
- if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) && currServ.messages[i] == scriptname) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
- return false;
- }
-
- for (var i = 0; i < destServer.messages.length; ++i) {
- if (destServer.messages[i] === scriptname) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true; //Already exists
- }
- }
- destServer.messages.push(scriptname);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- }
-
- //Scp for text files
- if (scriptname.endsWith(".txt")) {
- var found = false, txtFile;
- for (var i = 0; i < currServ.textFiles.length; ++i) {
- if (currServ.textFiles[i].fn === scriptname) {
- found = true;
- txtFile = currServ.textFiles[i];
- break;
- }
- }
-
- if (!found) {
- workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
- return false;
- }
-
- for (var i = 0; i < destServer.textFiles.length; ++i) {
- if (destServer.textFiles[i].fn === scriptname) {
- //Overwrite
- destServer.textFiles[i].text = txtFile.text;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- }
- }
- var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_22__["TextFile"](txtFile.fn, txtFile.text);
- destServer.textFiles.push(newFile);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- }
-
- //Scp for script files
- var sourceScript = null;
- for (var i = 0; i < currServ.scripts.length; ++i) {
- if (scriptname == currServ.scripts[i].filename) {
- sourceScript = currServ.scripts[i];
- break;
- }
- }
- if (sourceScript == null) {
- workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
- return false;
- }
-
- //Overwrite script if it already exists
- for (var i = 0; i < destServer.scripts.length; ++i) {
- if (scriptname == destServer.scripts[i].filename) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten.");
- workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname);
- }
- var oldScript = destServer.scripts[i];
- oldScript.code = sourceScript.code;
- oldScript.ramUsage = sourceScript.ramUsage;
- return true;
- }
- }
-
- //Create new script if it does not already exist
- var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_16__["Script"]();
- newScript.filename = scriptname;
- newScript.code = sourceScript.code;
- newScript.ramUsage = sourceScript.ramUsage;
- newScript.server = destServer.ip;
- destServer.scripts.push(newScript);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- },
- ls : function(ip, grep) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.ls) {
- return 0;
- } else {
- workerScript.loadedFns.ls = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptScanRamCost;
- }
- }
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip);
- }
-
- //Get the grep filter, if one exists
- var filter = false;
- if (arguments.length >= 2) {
- filter = grep.toString();
- }
-
- var allFiles = [];
- for (var i = 0; i < server.programs.length; i++) {
- if (filter) {
- if (server.programs[i].includes(filter)) {
- allFiles.push(server.programs[i]);
- }
- } else {
- allFiles.push(server.programs[i]);
- }
- }
- for (var i = 0; i < server.scripts.length; i++) {
- if (filter) {
- if (server.scripts[i].filename.includes(filter)) {
- allFiles.push(server.scripts[i].filename);
- }
- } else {
- allFiles.push(server.scripts[i].filename);
- }
-
- }
- for (var i = 0; i < server.messages.length; i++) {
- if (filter) {
- if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) {
- if (server.messages[i].filename.includes(filter)) {
- allFiles.push(server.messages[i].filename);
- }
- } else if (server.messages[i].includes(filter)) {
- allFiles.push(server.messages[i]);
- }
- } else {
- if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) {
- allFiles.push(server.messages[i].filename);
- } else {
- allFiles.push(server.messages[i]);
- }
- }
- }
-
- for (var i = 0; i < server.textFiles.length; i++) {
- if (filter) {
- if (server.textFiles[i].fn.includes(filter)) {
- allFiles.push(server.textFiles[i].fn);
- }
- } else {
- allFiles.push(server.textFiles[i].fn);
- }
- }
-
- //Sort the files alphabetically then print each
- allFiles.sort();
- return allFiles;
- },
- hasRootAccess : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.hasRootAccess) {
- return 0;
- } else {
- workerScript.loadedFns.hasRootAccess = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptHasRootAccessRamCost;
- }
- }
- if (ip===undefined){
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null){
- workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
- }
- return server.hasAdminRights;
- },
- getIp : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getIp) {
- return 0;
- } else {
- workerScript.loadedFns.getIp = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost;
- }
- }
- var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
- return scriptServer.ip;
- },
- getHostname : function(){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getHostname) {
- return 0;
- } else {
- workerScript.loadedFns.getHostname = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHostnameRamCost;
- }
- }
- var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
- return scriptServer.hostname;
- },
- getHackingLevel : function(){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getHackingLevel) {
- return 0;
- } else {
- workerScript.loadedFns.getHackingLevel = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackingLevelRamCost;
- }
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].updateSkillLevels();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
- workerScript.scriptRef.log("getHackingLevel() returned " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill);
- }
- return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill;
- },
- getHackingMultipliers : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getHackingMultipliers) {
- return 0;
- } else {
- workerScript.loadedFns.getHackingMultipliers = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost;
- }
- }
- return {
- chance: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_chance_mult,
- speed: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_speed_mult,
- money: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_money_mult,
- growth: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_grow_mult,
- };
- },
- getHacknetMultipliers : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getHacknetMultipliers) {
- return 0;
- } else {
- workerScript.loadedFns.getHacknetMultipliers = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost;
- }
- }
- return {
- production: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_money_mult,
- purchaseCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_purchase_cost_mult,
- ramCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_ram_cost_mult,
- coreCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_core_cost_mult,
- levelCost: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacknet_node_level_cost_mult,
- };
- },
- getBitNodeMultipliers: function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getBitNodeMultipliers) {
- return 0;
- } else {
- workerScript.loadedFns.getBitNodeMultipliers = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetMultipliersRamCost;
- }
- }
- if (!hasAISF) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run.");
- }
- let copy = Object.assign({}, _BitNode_js__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"]);
- return copy;
- },
- getServerMoneyAvailable : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerMoneyAvailable) {
- return 0;
- } else {
- workerScript.loadedFns.getServerMoneyAvailable = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (server.hostname == "home") {
- //Return player's money
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.toNumber(), 2));
- }
- return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.toNumber();
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
- }
- return server.moneyAvailable;
- },
- getServerSecurityLevel : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerSecurityLevel) {
- return 0;
- } else {
- workerScript.loadedFns.getServerSecurityLevel = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
- workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
- }
- return server.hackDifficulty;
- },
- getServerBaseSecurityLevel : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerBaseSecurityLevel) {
- return 0;
- } else {
- workerScript.loadedFns.getServerBaseSecurityLevel = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
- workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
- }
- return server.baseDifficulty;
- },
- getServerMinSecurityLevel : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerMinSecurityLevel) {
- return 0;
- } else {
- workerScript.loadedFns.getServerMinSecurityLevel = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
- workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
- }
- return server.minDifficulty;
- },
- getServerRequiredHackingLevel : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerRequiredHackingLevel) {
- return 0;
- } else {
- workerScript.loadedFns.getServerRequiredHackingLevel = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
- workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
- }
- return server.requiredHackingSkill;
- },
- getServerMaxMoney : function(ip){
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerMaxMoney) {
- return 0;
- } else {
- workerScript.loadedFns.getServerMaxMoney = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
- workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
- }
- return server.moneyMax;
- },
- getServerGrowth : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerGrowth) {
- return 0;
- } else {
- workerScript.loadedFns.getServerGrowth = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
- workerScript.scriptRef.log("getServerGrowth() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
- }
- return server.serverGrowth;
- },
- getServerNumPortsRequired : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerNumPortsRequired) {
- return 0;
- } else {
- workerScript.loadedFns.getServerNumPortsRequired = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
- workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
- }
- return server.numOpenPortsRequired;
- },
- getServerRam : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getServerRam) {
- return 0;
- } else {
- workerScript.loadedFns.getServerRam = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
- workerScript.scriptRef.log("getServerRam() returned [" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(server.ramUsed, 2) + "GB]");
- }
- return [server.maxRam, server.ramUsed];
- },
- serverExists : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.serverExists) {
- return 0;
- } else {
- workerScript.loadedFns.serverExists = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetServerRamCost;
- }
- }
- return (Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip) !== null);
- },
- fileExists : function(filename,ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.fileExists) {
- return 0;
- } else {
- workerScript.loadedFns.fileExists = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptFileExistsRamCost;
- }
- }
- if (filename === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip);
- }
- for (var i = 0; i < server.scripts.length; ++i) {
- if (filename == server.scripts[i].filename) {
- return true;
- }
- }
- for (var i = 0; i < server.programs.length; ++i) {
- if (filename.toLowerCase() == server.programs[i].toLowerCase()) {
- return true;
- }
- }
- for (var i = 0; i < server.messages.length; ++i) {
- if (!(server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) &&
- filename.toLowerCase() === server.messages[i]) {
- return true;
- }
- }
- var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(filename, server);
- if (txtFile != null) {
- return true;
- }
- return false;
- },
- isRunning : function(filename,ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.isRunning) {
- return 0;
- } else {
- workerScript.loadedFns.isRunning = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptIsRunningRamCost;
- }
- }
- if (filename === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip);
- }
- var argsForTargetScript = [];
- for (var i = 2; i < arguments.length; ++i) {
- argsForTargetScript.push(arguments[i]);
- }
- return (Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(filename, argsForTargetScript, server) != null);
- },
- getNextHacknetNodeCost : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getNextHacknetNodeCost) {
- return 0;
- } else {
- workerScript.loadedFns.getNextHacknetNodeCost = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost;
- }
- }
- return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__["getCostOfNextHacknetNode"])();
- },
-
- purchaseHacknetNode : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.purchaseHacknetNode) {
- return 0;
- } else {
- workerScript.loadedFns.purchaseHacknetNode = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseHacknetRamCost;
- }
- }
- return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_11__["purchaseHacknet"])();
- },
- getStockPrice : function(symbol) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getStockPrice) {
- return 0;
- } else {
- workerScript.loadedFns.getStockPrice = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()");
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPrice()");
- }
- return parseFloat(stock.price.toFixed(3));
- },
- getStockPosition : function(symbol) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getStockPosition) {
- return 0;
- } else {
- workerScript.loadedFns.getStockPosition = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()");
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPosition()");
- }
- return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
- },
- buyStock : function(symbol, shares) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.buyStock) {
- return 0;
- } else {
- workerScript.loadedFns.buyStock = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use buyStock()");
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into buyStock()");
- }
- if (shares < 0 || isNaN(shares)) {
- workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()");
- return 0;
- }
- shares = Math.round(shares);
- if (shares === 0) {return 0;}
-
- var totalPrice = stock.price * shares;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission)) {
- workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " +
- symbol + ". Need $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission, 2).toString());
- return 0;
- }
-
- var origTotal = stock.playerShares * stock.playerAvgPx;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShares += shares;
- stock.playerAvgPx = newTotal / stock.playerShares;
- if (_engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].Page.StockMarket) {
- Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["updateStockPlayerPosition"])(stock);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
- workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(stock.price, 2) + " per share");
- }
- return stock.price;
- },
- sellStock : function(symbol, shares) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.sellStock) {
- return 0;
- } else {
- workerScript.loadedFns.sellStock = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellStock()");
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into sellStock()");
- }
- if (shares < 0 || isNaN(shares)) {
- workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()");
- return 0;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShares) {shares = stock.playerShares;}
- if (shares === 0) {return 0;}
- var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainMoney(gains);
-
- //Calculate net profit and add to script stats
- var netProfit = ((stock.price - stock.playerAvgPx) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].StockMarketCommission;
- if (isNaN(netProfit)) {netProfit = 0;}
- workerScript.scriptRef.onlineMoneyMade += netProfit;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug += netProfit;
-
- stock.playerShares -= shares;
- if (stock.playerShares == 0) {
- stock.playerAvgPx = 0;
- }
- if (_engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_9__["Engine"].Page.StockMarket) {
- Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["updateStockPlayerPosition"])(stock);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
- workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(stock.price, 2) + " per share. Gained " +
- "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(gains, 2));
- }
- return stock.price;
- },
- shortStock(symbol, shares) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.shortStock) {
- return 0;
- } else {
- workerScript.loadedFns.shortStock = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use shortStock()");
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
- }
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()");
- }
- var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["shortStock"])(stock, shares, workerScript);
- return res ? stock.price : 0;
- },
- sellShort(symbol, shares) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.sellShort) {
- return 0;
- } else {
- workerScript.loadedFns.sellShort = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellShort()");
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
- }
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()");
- }
- var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["sellShort"])(stock, shares, workerScript);
- return res ? stock.price : 0;
- },
- placeOrder(symbol, shares, price, type, pos) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.placeOrder) {
- return 0;
- } else {
- workerScript.loadedFns.placeOrder = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()");
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
- }
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()");
- }
- var orderType, orderPos;
- type = type.toLowerCase();
- if (type.includes("limit") && type.includes("buy")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitBuy;
- } else if (type.includes("limit") && type.includes("sell")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitSell;
- } else if (type.includes("stop") && type.includes("buy")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopBuy;
- } else if (type.includes("stop") && type.includes("sell")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopSell;
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
- }
-
- pos = pos.toLowerCase();
- if (pos.includes("l")) {
- orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Long;
- } else if (pos.includes('s')) {
- orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Short;
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
- }
-
- return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["placeOrder"])(stock, shares, price, orderType, orderPos, workerScript);
- },
- cancelOrder(symbol, shares, price, type, pos) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.cancelOrder) {
- return 0;
- } else {
- workerScript.loadedFns.cancelOrder = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptBuySellStockRamCost;
- }
- }
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()");
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
- }
- }
- var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["SymbolToStockMap"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()");
- }
- if (isNaN(shares) || isNaN(price)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric");
- }
- var orderType, orderPos;
- type = type.toLowerCase();
- if (type.includes("limit") && type.includes("buy")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitBuy;
- } else if (type.includes("limit") && type.includes("sell")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].LimitSell;
- } else if (type.includes("stop") && type.includes("buy")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopBuy;
- } else if (type.includes("stop") && type.includes("sell")) {
- orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["OrderTypes"].StopSell;
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
- }
-
- pos = pos.toLowerCase();
- if (pos.includes("l")) {
- orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Long;
- } else if (pos.includes('s')) {
- orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["PositionTypes"].Short;
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
- }
- var params = {
- stock: stock,
- shares: shares,
- price: price,
- type: orderType,
- pos: orderPos
- };
- return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_20__["cancelOrder"])(params, workerScript);
- },
- purchaseServer : function(hostname, ram) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.purchaseServer) {
- return 0;
- } else {
- workerScript.loadedFns.purchaseServer = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost;
- }
- }
- var hostnameStr = String(hostname);
- hostnameStr = hostnameStr.replace(/\s+/g, '');
- if (hostnameStr == "") {
- workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()");
- return "";
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.length >= _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerLimit) {
- workerScript.scriptRef.log("Error: You have reached the maximum limit of " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerLimit +
- " servers. You cannot purchase any more.");
- return "";
- }
-
- ram = Math.round(ram);
- if (isNaN(ram) || !Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["powerOfTwo"])(ram)) {
- workerScript.scriptRef.log("Error: purchaseServer() failed due to invalid ram argument. Must be numeric and a power of 2");
- return "";
- }
-
- if (ram > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerMaxRam) {
- workerScript.scriptRef.log("Error: purchasedServer() failed because specified RAM was too high. Maximum RAM on a purchased server is " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].PurchasedServerMaxRam + "GB");
- return "";
- }
-
- var cost = ram * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamServer;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(cost)) {
- workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(cost, 2));
- return "";
- }
- var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_17__["Server"]({
- ip: Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__["createRandomIp"])(),
- hostname: hostnameStr,
- organizationName: "",
- isConnectedTo: false,
- adminRights: true,
- purchasedByPlayer: true,
- maxRam: ram,
- });
- Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["AddToAllServers"])(newServ);
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.push(newServ.ip);
- var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
- homeComputer.serversOnNetwork.push(newServ.ip);
- newServ.serversOnNetwork.push(homeComputer.ip);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(cost);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
- workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["formatNumber"])(cost, 2));
- }
- return newServ.hostname;
- },
- deleteServer : function(hostname) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.deleteServer) {
- return 0;
- } else {
- workerScript.loadedFns.deleteServer = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost;
- }
- }
- var hostnameStr = String(hostname);
- hostnameStr = hostnameStr.replace(/\s\s+/g, '');
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["GetServerByHostname"])(hostnameStr);
- if (server == null) {
- workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed");
- return false;
- }
-
- if (!server.purchasedByPlayer || server.hostname === "home") {
- workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " +
- "Cannot be deleted. deleteServer() failed");
- return false;
- }
-
- var ip = server.ip;
-
- //Can't delete server you're currently connected to
- if (server.isConnectedTo) {
- workerScript.scriptRef.log("Error: deleteServer() failed because you are currently connected to the server you are trying to delete");
- return false;
- }
-
- //A server cannot delete itself
- if (ip === workerScript.serverIp) {
- workerScript.scriptRef.log("Error: Cannot call deleteServer() on self. deleteServer() failed");
- return false;
- }
-
- //Delete all scripts running on server
- if (server.runningScripts.length > 0) {
- workerScript.scriptRef.log("Error: Cannot delete server " + server.hostname + " because it still has scripts running.");
- return false;
- }
-
- //Delete from player's purchasedServers array
- var found = false;
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.length; ++i) {
- if (ip == _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers[i]) {
- found = true;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.splice(i, 1);
- break;
- }
- }
-
- if (!found) {
- workerScript.scriptRef.log("Error: Could not identify server " + server.hostname +
- "as a purchased server. This is likely a bug please contact game dev");
- return false;
- }
-
- //Delete from all servers
- delete _Server_js__WEBPACK_IMPORTED_MODULE_17__["AllServers"][ip];
-
- //Delete from home computer
- found = false;
- var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
- for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
- if (ip == homeComputer.serversOnNetwork[i]) {
- homeComputer.serversOnNetwork.splice(i, 1);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {
- workerScript.scriptRef.log("Deleted server " + hostnameStr);
- }
- return true;
- }
- }
- //Wasn't found on home computer
- workerScript.scriptRef.log("Error: Could not find server " + server.hostname +
- "as a purchased server. This is likely a bug please contact game dev");
- return false;
- },
- getPurchasedServers : function(hostname=true) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getPurchasedServers) {
- return 0;
- } else {
- workerScript.loadedFns.getPurchasedServers = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptPurchaseServerRamCost;
- }
- }
- var res = [];
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].purchasedServers.forEach(function(ip) {
- if (hostname) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev");
- }
- res.push(server.hostname);
- } else {
- res.push(ip);
- }
- });
- return res;
- },
- write : function(port, data="", mode="a") {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.write) {
- return 0;
- } else {
- workerScript.loadedFns.write = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost;
- }
- }
- if (!isNaN(port)) { //Write to port
- //Port 1-10
- port = Math.round(port);
- if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to write to invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid.");
- }
- var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
- if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.write(data);
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Write to text file
- var fn = port;
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");
- }
- var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
- if (txtFile == null) {
- txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["createTextFile"])(fn, data, server);
- return true;
- }
- if (mode === "w") {
- txtFile.write(data);
- } else {
- txtFile.append(data);
- }
- return true;
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for write: " + port);
- }
- },
- read : function(port) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.read) {
- return 0;
- } else {
- workerScript.loadedFns.read = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost;
- }
- }
- if (!isNaN(port)) { //Read from port
- //Port 1-10
- port = Math.round(port);
- if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to read from invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid.");
- }
- var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
- if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.read();
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Read from text file
- var fn = port;
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev");
- }
- var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
- if (txtFile !== null) {
- return txtFile.text;
- } else {
- return "";
- }
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for read(): " + port);
- }
- },
- peek : function(port) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.peek) {
- return 0;
- } else {
- workerScript.loadedFns.peek = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost;
- }
- }
- if (isNaN(port)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
- }
- port = Math.round(port);
- if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
- }
- var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
- if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.peek();
- },
- clear : function(port) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.clear) {
- return 0;
- } else {
- workerScript.loadedFns.clear = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost;
- }
- }
- if (!isNaN(port)) { //Clear port
- port = Math.round(port);
- if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to clear invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid");
- }
- var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
- if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.clear();
- } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(port)) { //Clear text file
- var fn = port;
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
- }
- var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_22__["getTextFile"])(fn, server);
- if (txtFile != null) {
- txtFile.write("");
- }
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for clear(): " + port);
- }
- return 0;
- },
- getPortHandle : function(port) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getPortHandle) {
- return 0;
- } else {
- workerScript.loadedFns.getPortHandle = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost * 10;
- }
- }
- if (isNaN(port)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Invalid argument passed into getPortHandle(). Must be an integer between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts);
- }
- port = Math.round(port);
- if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: getPortHandle() called with invalid port number: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].NumNetscriptPorts + " are valid");
- }
- var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["NetscriptPorts"][port-1];
- if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_26__["NetscriptPort"])) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port;
- },
- rm : function(fn) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.rm) {
- return 0;
- } else {
- workerScript.loadedFns.rm = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptReadWriteRamCost;
- }
- }
- var s = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(workerScript.serverIp);
- if (s == null) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
- }
-
- if (fn.includes(".exe")) {
- for (var i = 0; i < s.programs.length; ++i) {
- if (s.programs[i] === fn) {
- s.programs.splice(i, 1);
- return true;
- }
- }
- } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["isScriptFilename"])(fn)) {
- for (var i = 0; i < s.scripts.length; ++i) {
- if (s.scripts[i].filename === fn) {
- //Check that the script isnt currently running
- for (var j = 0; j < s.runningScripts.length; ++j) {
- if (s.runningScripts[j].filename === fn) {
- workerScript.scriptRef.log("Cannot delete a script that is currently running!");
- return false;
- }
- }
- s.scripts.splice(i, 1);
- return true;
- }
- }
- } else if (fn.endsWith(".lit")) {
- for (var i = 0; i < s.messages.length; ++i) {
- var f = s.messages[i];
- if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_13__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(f) && f === fn) {
- s.messages.splice(i, 1);
- return true;
- }
- }
- } else if (fn.endsWith(".txt")) {
- for (var i = 0; i < s.textFiles.length; ++i) {
- if (s.textFiles[i].fn === fn) {
- s.textFiles.splice(i, 1);
- return true;
- }
- }
- }
- return false;
- },
- scriptRunning : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.scriptRunning) {
- return 0;
- } else {
- workerScript.loadedFns.scriptRunning = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
- }
- for (var i = 0; i < server.runningScripts.length; ++i) {
- if (server.runningScripts[i].filename == scriptname) {
- return true;
- }
- }
- return false;
- },
- scriptKill : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.scriptKill) {
- return 0;
- } else {
- workerScript.loadedFns.scriptKill = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptArbScriptRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip);
- }
- var suc = false;
- for (var i = 0; i < server.runningScripts.length; ++i) {
- if (server.runningScripts[i].filename == scriptname) {
- Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["killWorkerScript"])(server.runningScripts[i], server.ip);
- suc = true;
- }
- }
- return suc;
- },
- getScriptName : function() {
- if (workerScript.checkingRam) {return 0;}
- return workerScript.name;
- },
- getScriptRam : function (scriptname, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getScriptRam) {
- return 0;
- } else {
- workerScript.loadedFns.getScriptRam = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
- }
- for (var i = 0; i < server.scripts.length; ++i) {
- if (server.scripts[i].filename == scriptname) {
- return server.scripts[i].ramUsage;
- }
- }
- return 0;
- },
- getHackTime : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getHackTime) {
- return 0;
- } else {
- workerScript.loadedFns.getHackTime = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateHackingTime"])(server); //Returns seconds
- },
- getGrowTime : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getGrowTime) {
- return 0;
- } else {
- workerScript.loadedFns.getGrowTime = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateGrowTime"])(server) / 1000; //Returns seconds
- },
- getWeakenTime : function(ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getWeakenTime) {
- return 0;
- } else {
- workerScript.loadedFns.getWeakenTime = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost;
- }
- }
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["scriptCalculateWeakenTime"])(server) / 1000; //Returns seconds
- },
- getScriptIncome : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getScriptIncome) {
- return 0;
- } else {
- workerScript.loadedFns.getScriptIncome = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost;
- }
- }
- if (arguments.length === 0) {
- //Get total script income
- var res = [];
- res.push(Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])());
- res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].playtimeSinceLastAug/1000));
- return res;
- } else {
- //Get income for a particular script
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
- }
- var argsForScript = [];
- for (var i = 2; i < arguments.length; ++i) {
- argsForScript.push(arguments[i]);
- }
- var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(scriptname, argsForScript, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForScript));
- return -1;
- }
- return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;
- }
- },
- getScriptExpGain : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getScriptExpGain) {
- return 0;
- } else {
- workerScript.loadedFns.getScriptExpGain = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetScriptRamCost;
- }
- }
- if (arguments.length === 0) {
- var total = 0;
- for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"].length; ++i) {
- total += (_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"][i].scriptRef.onlineExpGained / _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_23__["workerScripts"][i].scriptRef.onlineRunningTime);
- }
- return total;
- } else {
- //Get income for a particular script
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["getServer"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
- }
- var argsForScript = [];
- for (var i = 2; i < arguments.length; ++i) {
- argsForScript.push(arguments[i]);
- }
- var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_16__["findRunningScript"])(scriptname, argsForScript, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_29__["printArray"])(argsForScript));
- return -1;
- }
- return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
- }
- },
- getTimeSinceLastAug : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getTimeSinceLastAug) {
- return 0;
- } else {
- workerScript.loadedFns.getTimeSinceLastAug = true;
- return _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptGetHackTimeRamCost;
- }
- }
- return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].playtimeSinceLastAug;
- },
- prompt : function(txt) {
- if (workerScript.checkingRam) {return 0;}
- if (_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxOpen"]) {
- workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
- return false;
- }
- if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(txt)) {txt = String(txt);}
- var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Yes";
- noBtn.innerHTML = "No";
- return new Promise(function(resolve, reject) {
- yesBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxClose"])();
- resolve(true);
- });
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxClose"])();
- resolve(false);
- });
- Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_32__["yesNoBoxCreate"])(txt);
- });
- },
-
- /* Singularity Functions */
- universityCourse : function(universityName, className) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.universityCourse) {
- return 0;
- } else {
- workerScript.loadedFns.universityCourse = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- var costMult, expMult;
- switch(universityName.toLowerCase()) {
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSummitUniversity.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSummitUniversity;
- costMult = 4;
- expMult = 3;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12RothmanUniversity.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12RothmanUniversity;
- costMult = 3;
- expMult = 2;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenZBInstituteOfTechnology.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven) {
- workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenZBInstituteOfTechnology;
- costMult = 5;
- expMult = 4;
- break;
- default:
- workerScript.scriptRef.log("Invalid university name: " + universityName + ". universityCourse() failed");
- return false;
- }
-
- var task;
- switch(className.toLowerCase()) {
- case "Study Computer Science".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassStudyComputerScience;
- break;
- case "Data Structures".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassDataStructures;
- break;
- case "Networks".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassNetworks;
- break;
- case "Algorithms".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassAlgorithms;
- break;
- case "Management".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassManagement;
- break;
- case "Leadership".toLowerCase():
- task = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassLeadership;
- break;
- default:
- workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, task);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
- workerScript.scriptRef.log("Started " + task + " at " + universityName);
- }
- return true;
- },
-
- gymWorkout : function(gymName, stat) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.gymWorkout) {
- return 0;
- } else {
- workerScript.loadedFns.gymWorkout = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: gymWorkout() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
- workerScript.scriptRef.log(txt);
- }
- }
- var costMult, expMult;
- switch(gymName.toLowerCase()) {
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumCrushFitnessGym.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumCrushFitnessGym;
- costMult = 3;
- expMult = 2;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSnapFitnessGym.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSnapFitnessGym;
- costMult = 10;
- expMult = 5;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12IronGym.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12IronGym;
- costMult = 1;
- expMult = 1;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12PowerhouseGym.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12PowerhouseGym;
- costMult = 20;
- expMult = 10;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenMilleniumFitnessGym:
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenMilleniumFitnessGym;
- costMult = 7;
- expMult = 4;
- break;
- default:
- workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed");
- return false;
- }
-
- switch(stat.toLowerCase()) {
- case "strength".toLowerCase():
- case "str".toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymStrength);
- break;
- case "defense".toLowerCase():
- case "def".toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymDefense);
- break;
- case "dexterity".toLowerCase():
- case "dex".toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymDexterity);
- break;
- case "agility".toLowerCase():
- case "agi".toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ClassGymAgility);
- break;
- default:
- workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed");
- return false;
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
- workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
- }
- return true;
- },
-
- travelToCity(cityname) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.travelToCity) {
- return 0;
- } else {
- workerScript.loadedFns.travelToCity = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- switch(cityname) {
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum:
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Chongqing:
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12:
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyo:
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Ishima:
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(200000);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city = cityname;
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {
- workerScript.scriptRef.log("Traveled to " + cityname);
- }
- return true;
- default:
- workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity().");
- return false;
- }
- },
-
- purchaseTor() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.purchaseTor) {
- return 0;
- } else {
- workerScript.loadedFns.purchaseTor = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"]["Darkweb Server"] != null) {
- workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed");
- return false;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TorRouterCost)) {
- workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].TorRouterCost);
-
- var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_17__["Server"]({
- ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_30__["createRandomIp"])(), hostname:"darkweb", organizationName:"",
- isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1
- });
- Object(_Server_js__WEBPACK_IMPORTED_MODULE_17__["AddToAllServers"])(darkweb);
- _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip);
-
- document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive");
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().serversOnNetwork.push(darkweb.ip);
- darkweb.serversOnNetwork.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().ip);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
- workerScript.scriptRef.log("You have purchased a Tor router!");
- }
- return true;
- },
- purchaseProgram(programName) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.purchaseProgram) {
- return 0;
- } else {
- workerScript.loadedFns.purchaseProgram = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"]["Darkweb Server"] == null) {
- workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed.");
- return false;
- }
-
- switch(programName.toLowerCase()) {
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].BruteSSHProgram);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].FTPCrackProgram);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].RelaySMTPProgram);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].HTTPWormProgram);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].SQLInjectProgram);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].DeepScanV1Program);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2.toLowerCase():
- var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_8__["DarkWebItems"].DeepScanV2Program);
- if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.gt(price)) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(price);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
- }
- } else {
- workerScript.scriptRef.log("Not enough money to purchase " + programName);
- return false;
- }
- return true;
- default:
- workerScript.scriptRef.log("ERROR: Invalid program passed into purchaseProgram().");
- return false;
- }
- return true;
- },
- getStats : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getStats) {
- return 0;
- } else {
- workerScript.loadedFns.getStats = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return {};
- }
- }
-
- return {
- hacking: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill,
- strength: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].strength,
- defense: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].defense,
- dexterity: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].dexterity,
- agility: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].agility,
- charisma: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].charisma,
- intelligence: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].intelligence
- }
- },
- getCharacterInformation : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getCharacterInformation) {
- return 0;
- } else {
- workerScript.loadedFns.getCharacterInformation = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCharacterInformation(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return {};
- }
- }
-
- var companyPositionTitle = "";
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["CompanyPosition"]) {
- companyPositionTitle = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName;
- }
- return {
- bitnode: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN,
- company: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyName,
- jobTitle: companyPositionTitle,
- city: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city,
- factions: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factions.slice(),
- tor: _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_19__["SpecialServerIps"].hasOwnProperty("Darkweb Server"),
- timeWorked: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].timeWorked,
- workHackExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workHackExpGained,
- workStrExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workStrExpGained,
- workDefExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workDefExpGained,
- workDexExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workDexExpGained,
- workAgiExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workAgiExpGained,
- workChaExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workChaExpGained,
- workRepGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workRepGained,
- workMoneyGain: _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].workMoneyGained,
- };
- },
- isBusy : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.isBusy) {
- return 0;
- } else {
- workerScript.loadedFns.isBusy = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return;
- }
- }
- return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking;
- },
- stopAction : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.stopAction) {
- return 0;
- } else {
- workerScript.loadedFns.stopAction = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run stopAction(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
- workerScript.scriptRef.log(txt);
- }
- return true;
- }
- return false;
- },
- upgradeHomeRam : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.upgradeHomeRam) {
- return 0;
- } else {
- workerScript.loadedFns.upgradeHomeRam = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- //Calculate how many times ram has been upgraded (doubled)
- var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().maxRam;
- var numUpgrades = Math.log2(currentRam);
-
- //Calculate cost
- //Have cost increase by some percentage each time RAM has been upgraded
- var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamHome;
- var mult = Math.pow(1.55, numUpgrades);
- cost = cost * mult;
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].money.lt(cost)) {
- workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
- return false;
- }
-
- var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer();
- homeComputer.maxRam *= 2;
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].loseMoney(cost);
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {
- workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
- }
- return true;
- },
- getUpgradeHomeRamCost : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getUpgradeHomeRamCost) {
- return 0;
- } else {
- workerScript.loadedFns.getUpgradeHomeRamCost = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- //Calculate how many times ram has been upgraded (doubled)
- var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].getHomeComputer().maxRam;
- var numUpgrades = Math.log2(currentRam);
-
- //Calculate cost
- //Have cost increase by some percentage each time RAM has been upgraded
- var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].BaseCostFor1GBOfRamHome;
- var mult = Math.pow(1.55, numUpgrades);
- return cost * mult;
- },
- workForCompany : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.workForCompany) {
- return 0;
- } else {
- workerScript.loadedFns.workForCompany = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: workForCompany() failed because you are in the middle of a mission.");
- return;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition == "" || !(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["CompanyPosition"])) {
- workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job");
- return false;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.isPartTimeJob()) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startWorkPartTime();
- } else {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startWork();
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
- workerScript.scriptRef.log("Began working at " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName);
- }
- return true;
- },
- applyToCompany : function(companyName, field) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.applyToCompany) {
- return 0;
- } else {
- workerScript.loadedFns.applyToCompany = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (!Object(_Company_js__WEBPACK_IMPORTED_MODULE_5__["companyExists"])(companyName)) {
- workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist.");
- return false;
- }
-
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = companyName;
- var res;
- switch (field.toLowerCase()) {
- case "software":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSoftwareJob(true);
- break;
- case "software consultant":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSoftwareConsultantJob(true);
- break;
- case "it":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForItJob(true);
- break;
- case "security engineer":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSecurityEngineerJob(true);
- break;
- case "network engineer":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForNetworkEngineerJob(true);
- break;
- case "business":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForBusinessJob(true);
- break;
- case "business consultant":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForBusinessConsultantJob(true);
- break;
- case "security":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForSecurityJob(true);
- break;
- case "agent":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForAgentJob(true);
- break;
- case "employee":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForEmployeeJob(true);
- break;
- case "part-time employee":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForPartTimeEmployeeJob(true);
- break;
- case "waiter":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForWaiterJob(true);
- break;
- case "part-time waiter":
- res = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].applyForPartTimeWaiterJob(true);
- break;
- default:
- workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed");
- return false;
- }
- //The Player object's applyForJob function can return string with special error messages
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(res)) {
- workerScript.scriptRef.log(res);
- return false;
- }
- if (res) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
- workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].companyPosition.positionName);
- }
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
- workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
- }
- }
- return res;
- },
- getCompanyRep : function(companyName) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getCompanyRep) {
- return 0;
- } else {
- workerScript.loadedFns.getCompanyRep = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- var company = _Company_js__WEBPACK_IMPORTED_MODULE_5__["Companies"][companyName];
- if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["Company"])) {
- workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName);
- return -1;
- }
- return company.playerReputation;
- },
- getCompanyFavor : function(companyName) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getCompanyFavor) {
- return 0;
- } else {
- workerScript.loadedFns.getCompanyFavor = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- var company = _Company_js__WEBPACK_IMPORTED_MODULE_5__["Companies"][companyName];
- if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_5__["Company"])) {
- workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavor(): " + companyName);
- return -1;
- }
- return company.favor;
- },
- checkFactionInvitations : function() {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.checkFactionInvitations) {
- return 0;
- } else {
- workerScript.loadedFns.checkFactionInvitations = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
- //Make a copy of Player.factionInvitations
- return _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.slice();
- },
- joinFaction : function(name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.joinFaction) {
- return 0;
- } else {
- workerScript.loadedFns.joinFaction = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist.");
- return false;
- }
-
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.includes(name)) {
- workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
- return false;
- }
-
- var index = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.indexOf(name);
- if (index === -1) {
- //Redundant and should never happen...
- workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factionInvitations.splice(index, 1);
- var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name];
- Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["joinFaction"])(fac);
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
- workerScript.scriptRef.log("Joined the " + name + " faction.");
- }
- return true;
- },
- workForFaction : function(name, type) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.workForFaction) {
- return 0;
- } else {
- workerScript.loadedFns.workForFaction = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: workForFaction() failed because you are in the middle of a mission.");
- return;
- }
-
- if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist.");
- return false;
- }
-
- if (!_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].factions.includes(name)) {
- workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name);
- return false;
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name];
- //Arrays listing factions that allow each time of work
- var hackAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp",
- "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
- "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
- "Fulcrum Secret Technologies", "BitRunners", "The Black Hand",
- "NiteSec", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
- "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army",
- "The Syndicate", "Silhouette", "Netburners", "Tian Di Hui", "CyberSec"];
- var fdWkAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp",
- "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
- "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
- "The Black Hand", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
- "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army",
- "The Syndicate", "Silhouette", "Tetrads", "Slum Snakes"];
- var scWkAvailable = ["ECorp", "MegaCorp",
- "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated",
- "OmniTek Incorporated", "Four Sigma", "KuaiGong International",
- "Fulcrum Secret Technologies", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
- "Ishima", "Volhaven", "Speakers for the Dead",
- "The Syndicate", "Tetrads", "Slum Snakes", "Tian Di Hui"];
-
- switch (type.toLowerCase()) {
- case "hacking":
- case "hacking contracts":
- case "hackingcontracts":
- if (!hackAvailable.includes(fac.name)) {
- workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionHackWork(fac);
- workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name);
- return true;
- case "field":
- case "fieldwork":
- case "field work":
- if (!fdWkAvailable.includes(fac.name)) {
- workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionFieldWork(fac);
- workerScript.scriptRef.log("Started carrying out field missions for " + fac.name);
- return true;
- case "security":
- case "securitywork":
- case "security work":
- if (!scWkAvailable.includes(fac.name)) {
- workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startFactionSecurityWork(fac);
- workerScript.scriptRef.log("Started serving as security details for " + fac.name);
- return true;
- default:
- workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type);
- }
- return true;
- },
- getFactionRep : function(name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getFactionRep) {
- return 0;
- } else {
- workerScript.loadedFns.getFactionRep = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist.");
- return -1;
- }
-
- return _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name].playerReputation;
- },
- getFactionFavor : function(name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getFactionFavor) {
- return 0;
- } else {
- workerScript.loadedFns.getFactionFavor = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavor() does not exist.");
- return -1;
- }
-
- return _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][name].favor;
- },
- createProgram : function(name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.createProgram) {
- return 0;
- } else {
- workerScript.loadedFns.createProgram = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- switch(name.toLowerCase()) {
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram.toLowerCase():
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 50) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 100) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 100);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 250) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 250);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 500) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer4Hours, 500);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 750) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer8Hours, 750);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 75) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 400) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPer2Hours, 400);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 75) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerHalfHour, 75);
- break;
- case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink.toLowerCase():
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].hacking_skill < 25) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_7__["Programs"].AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
- break;
- default:
- workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
- return false;
- }
- workerScript.scriptRef.log("Began creating program: " + name);
- return true;
- },
- commitCrime : function(crime) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.commitCrime) {
- return 0;
- } else {
- workerScript.loadedFns.commitCrime = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return;
- }
- }
- if (_Missions_js__WEBPACK_IMPORTED_MODULE_14__["inMission"]) {
- workerScript.scriptRef.log("ERROR: commitCrime() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].isWorking) {
- var txt = _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- //Set Location to slums
- switch(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].city) {
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Aevum:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].AevumSlums;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Chongqing:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].ChongqingSlums;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Sector12Slums;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyo:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].NewTokyoSlums;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Ishima:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].IshimaSlums;
- break;
- case _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].Volhaven:
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_12__["Locations"].VolhavenSlums;
- break;
- default:
- console.log("Invalid Player.city value");
- }
-
- crime = crime.toLowerCase();
- let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null
- if (crime.includes("shoplift")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitShopliftCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("rob") && crime.includes("store")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitRobStoreCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("mug")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitMugCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("larceny")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitLarcenyCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("drugs")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitDealDrugsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("bond") && crime.includes("forge")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitBondForgeryCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("traffick") && crime.includes("arms")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitTraffickArmsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("homicide")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHomicideCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("grand") && crime.includes("auto")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitGrandTheftAutoCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("kidnap")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitKidnapCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else if (crime.includes("assassinate")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitAssassinationCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript})
- } else if (crime.includes("heist")) {
- if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to pull off a heist...");}
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHeistCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into commitCrime(): " + crime);
- }
- },
- getCrimeChance : function(crime) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getCrimeChance) {
- return 0;
- } else {
- workerScript.loadedFns.getCrimeChance = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return;
- }
- }
-
- crime = crime.toLowerCase();
- if (crime.includes("shoplift")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceShoplift"])();
- } else if (crime.includes("rob") && crime.includes("store")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceRobStore"])();
- } else if (crime.includes("mug")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceMug"])();
- } else if (crime.includes("larceny")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceLarceny"])();
- } else if (crime.includes("drugs")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceDealDrugs"])();
- } else if (crime.includes("bond") && crime.includes("forge")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceBondForgery"])();
- } else if (crime.includes("traffick") && crime.includes("arms")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceTraffickArms"])();
- } else if (crime.includes("homicide")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceHomicide"])();
- } else if (crime.includes("grand") && crime.includes("auto")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceGrandTheftAuto"])();
- } else if (crime.includes("kidnap")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceKidnap"])();
- } else if (crime.includes("assassinate")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceAssassination"])();
- } else if (crime.includes("heist")) {
- return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceHeist"])();
- } else {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime);
- }
- },
- getOwnedAugmentations : function(purchased=false) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getOwnedAugmentations) {
- return 0;
- } else {
- workerScript.loadedFns.getOwnedAugmentations = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return [];
- }
- }
- var res = [];
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations.length; ++i) {
- res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations[i].name);
- }
- if (purchased) {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length; ++i) {
- res.push(_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations[i].name);
- }
- }
- return res;
- },
- getAugmentationsFromFaction : function(facname) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getAugmentationsFromFaction) {
- return 0;
- } else {
- workerScript.loadedFns.getAugmentationsFromFaction = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return [];
- }
- }
-
- if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["factionExists"])(facname)) {
- workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname);
- return [];
- }
-
- var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][facname];
- var res = [];
- for (var i = 0; i < fac.augmentations.length; ++i) {
- res.push(fac.augmentations[i]);
- }
- return res;
- },
- getAugmentationCost : function(name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.getAugmentationCost) {
- return 0;
- } else {
- workerScript.loadedFns.getAugmentationCost = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- if (!Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["augmentationExists"])(name)) {
- workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
- return [-1, -1];
- }
-
- var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
- return [aug.baseRepRequirement, aug.baseCost];
- },
- purchaseAugmentation : function(faction, name) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.purchaseAugmentation) {
- return 0;
- } else {
- workerScript.loadedFns.purchaseAugmentation = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Factions"][faction];
- if (fac == null || !(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_10__["Faction"])) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid faction name: " + faction);
- return false;
- }
-
- if (!fac.augmentations.includes(name)) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because the faction " + faction + " does not contain the " + name + " augmentation");
- return false;
- }
-
- var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
- if (aug == null || !(aug instanceof _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentation"])) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name);
- return false;
- }
-
- var isNeuroflux = false;
- if (aug.name === _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["AugmentationNames"].NeuroFluxGovernor) {
- isNeuroflux = true;
- }
-
- if (!isNeuroflux) {
- for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length; ++j) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations[j].name === aug.name) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
- return false;
- }
- }
- for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations.length; ++j) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].augmentations[j].name === aug.name) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
- return false;
- }
- }
- }
-
- if (fac.playerReputation < aug.baseRepRequirement) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you do not have enough reputation with " + fac.name);
- return false;
- }
-
- var res = Object(_Faction_js__WEBPACK_IMPORTED_MODULE_10__["purchaseAugmentation"])(aug, fac, true);
- workerScript.scriptRef.log(res);
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_31__["isString"])(res) && res.startsWith("You purchased")) {
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- return true;
- } else {
- return false;
- }
- },
- installAugmentations : function(cbScript) {
- if (workerScript.checkingRam) {
- if (workerScript.loadedFns.installAugmentations) {
- return 0;
- } else {
- workerScript.loadedFns.installAugmentations = true;
- var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN !== 4) {ramCost *= 8;}
- return ramCost;
- }
- }
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].queuedAugmentations.length === 0) {
- workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed");
- return false;
- }
- _Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_6__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed");
- Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["installAugmentations"])(cbScript);
- return true;
- },
-
- //Bladeburner API
- bladeburner : {
- isContractName : function(name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- isOperationName : function(name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- isBlackOpName : function(name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- isGeneralActionName : function(name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- isSkillName : function(name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- startAction : function(type, name) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- stopAction : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionTime : function(type="", name="") {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionEstimatedSuccessChance : function(type="", name="") {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionCountRemaining : function(type="", name="") {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getRank : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillPoints : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillLevel : function(skillName="") {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- upgradeSkill : function(skillName) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getTeamSize : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- setTeamSize : function(type="", name="", size) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityEstimatedPopulation : function(cityName) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityEstimatedCommunities : function(cityName) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityChaos : function(cityName) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- switchCity : function(cityName) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getStamina : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- joinFaction : function() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_4__["Bladeburner"] && (_Player_js__WEBPACK_IMPORTED_MODULE_15__["Player"].bitNodeN === 7 || hasBladeburner2079SF)) {
-
- }
- throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_24__["makeRuntimeRejectMsg"])(workerScript, "isContractName() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- }
- }
- } //End return
-} //End NetscriptFunction()
-
-
-
-
-/***/ }),
-/* 32 */
+/* 28 */
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/utils.js ***!
\*****************************************/
@@ -34102,11 +27156,11 @@ function NetscriptFunctions(workerScript) {
"use strict";
-var support = __webpack_require__(/*! ./support */ 50);
-var base64 = __webpack_require__(/*! ./base64 */ 105);
-var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ 65);
-var setImmediate = __webpack_require__(/*! core-js/library/fn/set-immediate */ 167);
-var external = __webpack_require__(/*! ./external */ 58);
+var support = __webpack_require__(/*! ./support */ 46);
+var base64 = __webpack_require__(/*! ./base64 */ 104);
+var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ 62);
+var setImmediate = __webpack_require__(/*! core-js/library/fn/set-immediate */ 166);
+var external = __webpack_require__(/*! ./external */ 54);
/**
@@ -34579,7 +27633,1393 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt
/***/ }),
-/* 33 */
+/* 29 */
+/*!****************************!*\
+ !*** ./src/StockMarket.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockMarket", function() { return StockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockSymbols", function() { return StockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolToStockMap", function() { return SymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockSymbols", function() { return initStockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockMarket", function() { return initStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSymbolToStockMap", function() { return initSymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stockMarketCycle", function() { return stockMarketCycle; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyStock", function() { return buyStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellStock", function() { return sellStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shortStock", function() { return shortStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellShort", function() { return sellShort; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPrices", function() { return updateStockPrices; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayStockMarketContent", function() { return displayStockMarketContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockTicker", function() { return updateStockTicker; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPlayerPosition", function() { return updateStockPlayerPosition; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadStockMarket", function() { return loadStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setStockMarketContentCreated", function() { return setStockMarketContentCreated; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placeOrder", function() { return placeOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOrder", function() { return cancelOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Order", function() { return Order; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OrderTypes", function() { return OrderTypes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionTypes", function() { return PositionTypes; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 26);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+let StockPriceCap = 1e9; //Put a limit on how high a price can go
+
+function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
+ this.symbol = symbol;
+ this.name = name;
+ this.price = initPrice;
+
+ this.playerShares = 0;
+ this.playerAvgPx = 0;
+ this.playerShortShares = 0;
+ this.playerAvgShortPx = 0;
+ this.mv = mv;
+ this.b = b;
+ this.otlkMag = otlkMag;
+
+ this.posTxtEl = null;
+}
+
+Stock.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Stock", this);
+}
+
+Stock.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Stock, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Stock = Stock;
+
+var OrderTypes = {
+ LimitBuy: "Limit Buy Order",
+ LimitSell: "Limit Sell Order",
+ StopBuy: "Stop Buy Order",
+ StopSell: "Stop Sell Order"
+}
+
+var PositionTypes = {
+ Long: "L",
+ Short: "S"
+}
+
+function placeOrder(stock, shares, price, type, position, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ var order = new Order(stock, shares, price, type, position);
+ if (isNaN(shares) || isNaN(price)) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
+ }
+ return false;
+ }
+ if (StockMarket["Orders"] == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ }
+ StockMarket["Orders"][stock.symbol].push(order);
+ //Process to see if it should be executed immediately
+ processOrders(order.stock, order.type, order.pos);
+ updateStockOrderList(order.stock);
+ return true;
+}
+
+//Returns true if successfully cancels an order, false otherwise
+function cancelOrder(params, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (StockMarket["Orders"] == null) {return false;}
+ if (params.order && params.order instanceof Order) {
+ var order = params.order;
+ //An 'Order' object is passed in
+ var stockOrders = StockMarket["Orders"][order.stock.symbol];
+ for (var i = 0; i < stockOrders.length; ++i) {
+ if (order == stockOrders[i]) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ return true;
+ }
+ }
+ return false;
+ } else if (params.stock && params.shares && params.price && params.type &&
+ params.pos && params.stock instanceof Stock) {
+ //Order properties are passed in. Need to look for the order
+ var stockOrders = StockMarket["Orders"][params.stock.symbol];
+ var orderTxt = params.stock.symbol + " - " + params.shares + " @ " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(params.price).format('$0.000a');
+ for (var i = 0; i < stockOrders.length; ++i) {
+ var order = stockOrders[i];
+ if (params.shares === order.shares &&
+ params.price === order.price &&
+ params.type === order.type &&
+ params.pos === order.pos) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ if (tixApi) {
+ workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt);
+ }
+ return true;
+ }
+ }
+ if (tixApi) {
+ workerScript.scriptRef.log("Failed to cancel order: " + orderTxt);
+ }
+ return false;
+ }
+ return false;
+}
+
+function executeOrder(order) {
+ var stock = order.stock;
+ var orderBook = StockMarket["Orders"];
+ var stockOrders = orderBook[stock.symbol];
+ var res = true;
+ console.log("Executing the following order:");
+ console.log(order);
+ switch (order.type) {
+ case OrderTypes.LimitBuy:
+ case OrderTypes.StopBuy:
+ if (order.pos === PositionTypes.Long) {
+ res = buyStock(order.stock, order.shares) && res;
+ } else if (order.pos === PositionTypes.Short) {
+ res = shortStock(order.stock, order.shares) && res;
+ }
+ break;
+ case OrderTypes.LimitSell:
+ case OrderTypes.StopSell:
+ if (order.pos === PositionTypes.Long) {
+ res = sellStock(order.stock, order.shares) && res;
+ } else if (order.pos === PositionTypes.Short) {
+ res = sellShort(order.stock, order.shares) && res;
+ }
+ break;
+ }
+ if (res) {
+ //Remove order from order book
+ for (var i = 0; i < stockOrders.length; ++i) {
+ if (order == stockOrders[i]) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ return;
+ }
+ }
+ console.log("ERROR: Could not find the following Order in Order Book: ");
+ console.log(order);
+ } else {
+ console.log("Order failed to execute");
+ }
+}
+
+function Order(stock, shares, price, type, position) {
+ this.stock = stock;
+ this.shares = shares;
+ this.price = price;
+ this.type = type;
+ this.pos = position;
+}
+
+Order.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Order", this);
+}
+
+Order.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Order, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Order = Order;
+
+let StockMarket = {} //Full name to stock object
+let StockSymbols = {} //Full name to symbol
+let SymbolToStockMap = {}; //Symbol to Stock object
+
+function loadStockMarket(saveString) {
+ if (saveString === "") {
+ StockMarket = {};
+ } else {
+ StockMarket = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
+ }
+}
+
+function initStockSymbols() {
+ //Stocks for companies at which you can work
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff] = "FNS";
+
+ //Stocks for other companies
+ StockSymbols["Sigma Cosmetics"] = "SGC";
+ StockSymbols["Joes Guns"] = "JGN";
+ StockSymbols["Catalyst Ventures"] = "CTYS";
+ StockSymbols["Microdyne Technologies"] = "MDYN";
+ StockSymbols["Titan Laboratories"] = "TITN";
+}
+
+function initStockMarket() {
+ for (var stk in StockMarket) {
+ if (StockMarket.hasOwnProperty(stk)) {
+ delete StockMarket[stk];
+ }
+ }
+
+ var ecorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
+ var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[ecorp] = ecorpStk;
+
+ var megacorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
+ var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(25000, 33000));
+ StockMarket[megacorp] = megacorpStk;
+
+ var blade = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
+ var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 22000));
+ StockMarket[blade] = bladeStk;
+
+ var clarke = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
+ var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[clarke] = clarkeStk;
+
+ var omnitek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
+ var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(35000, 40000));
+ StockMarket[omnitek] = omnitekStk;
+
+ var foursigma = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
+ var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(60000, 70000));
+ StockMarket[foursigma] = foursigmaStk;
+
+ var kuaigong = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
+ var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 24000));
+ StockMarket[kuaigong] = kuaigongStk;
+
+ var fulcrum = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
+ var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(30000, 35000));
+ StockMarket[fulcrum] = fulcrumStk;
+
+ var storm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
+ var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(21000, 24000));
+ StockMarket[storm] = stormStk;
+
+ var defcomm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
+ var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[defcomm] = defcommStk;
+
+ var helios = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
+ var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(12000, 16000));
+ StockMarket[helios] = heliosStk;
+
+ var vitalife = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
+ var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 12000));
+ StockMarket[vitalife] = vitalifeStk;
+
+ var icarus = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
+ var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(16000, 20000));
+ StockMarket[icarus] = icarusStk;
+
+ var universalenergy = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
+ var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[universalenergy] = universalenergyStk;
+
+ var aerocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
+ var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[aerocorp] = aerocorpStk;
+
+ var omnia = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
+ var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(9000, 12000));
+ StockMarket[omnia] = omniaStk;
+
+ var solaris = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
+ var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[solaris] = solarisStk;
+
+ var globalpharm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
+ var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[globalpharm] = globalpharmStk;
+
+ var nova = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
+ var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[nova] = novaStk;
+
+ var watchdog = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
+ var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[watchdog] = watchdogStk;
+
+ var lexocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
+ var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[lexocorp] = lexocorpStk;
+
+ var rho = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
+ var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[rho] = rhoStk;
+
+ var alpha = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
+ var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[alpha] = alphaStk;
+
+ var syscore = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
+ var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(4000, 7000))
+ StockMarket[syscore] = syscoreStk;
+
+ var computek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
+ var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 5000));
+ StockMarket[computek] = computekStk;
+
+ var netlink = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
+ var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 4000));
+ StockMarket[netlink] = netlinkStk;
+
+ var omega = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
+ var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[omega] = omegaStk;
+
+ var fns = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
+ var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(1000, 4000));
+ StockMarket[fns] = fnsStk;
+
+ var sigmacosm = "Sigma Cosmetics";
+ var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 3000));
+ StockMarket[sigmacosm] = sigmacosmStk;
+
+ var joesguns = "Joes Guns";
+ var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[joesguns] = joesgunsStk;
+
+ var catalyst = "Catalyst Ventures";
+ var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[catalyst] = catalystStk;
+
+ var microdyne = "Microdyne Technologies";
+ var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[microdyne] = microdyneStk;
+
+ var titanlabs = "Titan Laboratories";
+ var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[titanlabs] = titanlabsStk;
+
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+}
+
+function initSymbolToStockMap() {
+ for (var name in StockSymbols) {
+ if (StockSymbols.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (stock == null) {
+ console.log("ERROR finding stock");
+ continue;
+ }
+ var symbol = StockSymbols[name];
+ SymbolToStockMap[symbol] = stock;
+ }
+ }
+}
+
+function stockMarketCycle() {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ var thresh = 0.6;
+ if (stock.b) {thresh = 0.4;}
+ if (Math.random() < thresh) {
+ stock.b = !stock.b;
+ }
+ }
+ }
+}
+
+//Returns true if successful, false otherwise
+function buyStock(stock, shares) {
+ if (stock == null || shares < 0 || isNaN(shares)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares == 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this. You need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2).toString() + ".");
+ return false;
+ }
+
+ var origTotal = stock.playerShares * stock.playerAvgPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShares += shares;
+ stock.playerAvgPx = newTotal / stock.playerShares;
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function sellStock(stock, shares) {
+ if (shares == 0) {return false;}
+ if (stock == null || shares < 0 || isNaN(shares)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell stock. This may be a bug, contact developer");
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares > stock.playerShares) {shares = stock.playerShares;}
+ if (shares === 0) {return false;}
+ var gains = stock.price * shares - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(gains);
+ stock.playerShares -= shares;
+ if (stock.playerShares == 0) {
+ stock.playerAvgPx = 0;
+ }
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(gains, 2));
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function shortStock(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to initiate a short position in a stock. This is probably " +
+ "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
+ }
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares === 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " +
+ "money to purchase this short position. You need " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)'));
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + ".");
+ }
+
+ return false;
+ }
+
+ var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShortShares += shares;
+ stock.playerAvgShortPx = newTotal / stock.playerShortShares;
+ updateStockPlayerPosition(stock);
+ if (tixApi) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
+ workerScript.scriptRef.log("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. Paid " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)') + " in commission fees.");
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
+ }
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function sellShort(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to sell a short position in a stock. This is probably " +
+ "due to an invalid quantity. Otherwise, this may be a bug, so contact developer");
+ }
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}
+ if (shares === 0) {return false;}
+
+ var origCost = shares * stock.playerAvgShortPx;
+ var profit = ((stock.playerAvgShortPx - stock.price) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ if (isNaN(profit)) {profit = 0;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(origCost + profit);
+ if (tixApi) {
+ workerScript.scriptRef.onlineMoneyMade += profit;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].scriptProdSinceLastAug += profit;
+ }
+
+ stock.playerShortShares -= shares;
+ if (stock.playerShortShares === 0) {
+ stock.playerAvgShortPx = 0;
+ }
+ updateStockPlayerPosition(stock);
+ if (tixApi) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
+ workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
+ "a total of " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(origCost + profit).format('($0.000a)'));
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold your short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(origCost + profit, 2));
+ }
+
+ return true;
+}
+
+function updateStockPrices() {
+ var v = Math.random();
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ var av = (v * stock.mv) / 100;
+ if (isNaN(av)) {av = .02;}
+
+ var chc = 50;
+ if (stock.b) {
+ chc = (chc + stock.otlkMag)/100;
+ if (isNaN(chc)) {chc = 0.5;}
+ } else {
+ chc = (chc - stock.otlkMag)/100;
+ if (isNaN(chc)) {chc = 0.5;}
+ }
+ if (stock.price >= StockPriceCap) {
+ chc = -1; //Limit on stock price
+ stock.b = false;
+ }
+
+ var c = Math.random();
+ if (c < chc) {
+ stock.price *= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
+ updateStockTicker(stock, true);
+ }
+ } else {
+ stock.price /= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
+ updateStockTicker(stock, false);
+ }
+ }
+
+ var otlkMagChange = stock.otlkMag * av;
+ if (stock.otlkMag <= 0.1) {
+ otlkMagChange = 1;
+ }
+ if (c < 0.5) {
+ stock.otlkMag += otlkMagChange;
+ } else {
+ stock.otlkMag -= otlkMagChange;
+ }
+ if (stock.otlkMag < 0) {
+ stock.otlkMag *= -1;
+ stock.b = !stock.b;
+ }
+
+ }
+ }
+}
+
+//Checks and triggers any orders for the specified stock
+function processOrders(stock, orderType, posType) {
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ return; //Newly created, so no orders to process
+ }
+ var stockOrders = orderBook[stock.symbol];
+ if (stockOrders == null || !(stockOrders.constructor === Array)) {
+ console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()");
+ stockOrders = [];
+ return;
+ }
+ for (var i = 0; i < stockOrders.length; ++i) {
+ var order = stockOrders[i];
+ if (order.type === orderType && order.pos === posType) {
+ switch(order.type) {
+ case OrderTypes.LimitBuy:
+ if (order.pos === PositionTypes.Long && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.LimitSell:
+ if (order.pos === PositionTypes.Long && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.StopBuy:
+ if (order.pos === PositionTypes.Long && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ case OrderTypes.StopSell:
+ if (order.pos === PositionTypes.Long && stock.price <= order.price) {
+ executeOrder/*66*/(order);
+ } else if (order.pos === PositionTypes.Short && stock.price >= order.price) {
+ executeOrder/*66*/(order);
+ }
+ break;
+ default:
+ console.log("Invalid order type: " + order.type);
+ return;
+ }
+ }
+ }
+}
+
+function setStockMarketContentCreated(b) {
+ stockMarketContentCreated = b;
+}
+
+var stockMarketContentCreated = false;
+var stockMarketPortfolioMode = false;
+var COMM = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+function displayStockMarketContent() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = false;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = false;}
+
+ //Purchase WSE Account button
+ var wseAccountButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-account");
+ wseAccountButton.innerText = "Buy WSE Account - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost)) {
+ wseAccountButton.setAttribute("class", "a-link-button");
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount){
+ wseAccountButton.innerText = "WSE Account - Purchased";
+ wseAccountButton.setAttribute("class", "a-link-button-bought");
+ } else {
+ wseAccountButton.setAttribute("class", "a-link-button-inactive");
+ }
+ wseAccountButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = true;
+ initStockMarket();
+ initSymbolToStockMap();
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ //Purchase TIX API Access account
+ var tixApiAccessButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-tix-api");
+ tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost)) {
+ tixApiAccessButton.setAttribute("class", "a-link-button");
+ } else if(_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess) {
+ tixApiAccessButton.innerText = "Trade Information eXchange (TIX) API Access - Purchased"
+ tixApiAccessButton.setAttribute("class", "a-link-button-bought");
+ } else {
+ tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
+ }
+ tixApiAccessButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ stockMarketContentCreated = false;
+ while (stockList.firstChild) {
+ stockList.removeChild(stockList.firstChild);
+ }
+ return;
+ }
+
+ //Create stock market content if you have an account
+ if (!stockMarketContentCreated && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ console.log("Creating Stock Market UI");
+ document.getElementById("stock-market-commission").innerHTML =
+ "Commission Fees: Every transaction you make has a $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " commission fee.
" +
+ "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
+ "This means all your positions are lost, so make sure to sell your stocks before installing " +
+ "Augmentations!";
+
+ var investopediaButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-investopedia");
+ investopediaButton.addEventListener("click", function() {
+ var txt = "When making a transaction on the stock market, there are two " +
+ "types of positions: Long and Short. A Long position is the typical " +
+ "scenario where you buy a stock and earn a profit if the price of that " +
+ "stock increases. Meanwhile, a Short position is the exact opposite. " +
+ "In a Short position you purchase shares of a stock and earn a profit " +
+ "if the price of that stock decreases. This is also called 'shorting' a stock.
" +
+ "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.
" +
+ "There are three different types of orders you can make to buy or sell " +
+ "stocks on the exchange: Market Order, Limit Order, and Stop Order. " +
+ "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " +
+ "later on in the game.
" +
+ "When you place a Market Order to buy or sell a stock, the order executes " +
+ "immediately at whatever the current price of the stock is. For example " +
+ "if you choose to short a stock with 5000 shares using a Market Order, " +
+ "you immediately purchase those 5000 shares in a Short position at whatever " +
+ "the current market price is for that stock.
" +
+ "A Limit Order is an order that only executes under certain conditions. " +
+ "A Limit Order is used to buy or sell a stock at a specified price or better. " +
+ "For example, lets say you purchased a Long position of 100 shares of some stock " +
+ "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " +
+ "at $50 or better. The Limit Order will execute when the price of the stock reaches a " +
+ "value of $50 or higher.
" +
+ "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " +
+ "at a specified price (before the price gets 'worse'). For example, lets say you purchased " +
+ "a Short position of 100 shares of some stock at a price of $100 per share. " +
+ "The current price of the stock is $80 (a profit of $20 per share). You can place a " +
+ "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " +
+ "This can be used to lock in your profits and limit any losses.
" +
+ "Here is a summary of how each order works and when they execute:
" +
+ "In a LONG Position:
" +
+ "A Limit Order to buy will execute if the stock's price <= order's price
" +
+ "A Limit Order to sell will execute if the stock's price >= order's price
" +
+ "A Stop Order to buy will execute if the stock's price >= order's price
" +
+ "A Stop Order to sell will execute if the stock's price <= order's price
" +
+ "In a SHORT Position:
" +
+ "A Limit Order to buy will execute if the stock's price >= order's price
" +
+ "A Limit Order to sell will execute if the stock's price <= order's price
" +
+ "A Stop Order to buy will execute if the stock's price <= order's price
" +
+ "A Stop Order to sell will execute if the stock's price >= order's price.";
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])(txt);
+ return false;
+ });
+
+ //Switch to Portfolio Mode Button
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
+ "Displays only the stocks for which you have shares or orders";
+ modeBtn.addEventListener("click", switchToPortfolioMode);
+ }
+
+ //Expand/Collapse tickers buttons
+ var expandBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-expand-tickers"),
+ collapseBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-collapse-tickers"),
+ stockList = document.getElementById("stock-market-list");
+ if (expandBtn) {
+ expandBtn.addEventListener("click", ()=>{
+ var tickerHdrs = stockList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < tickerHdrs.length; ++i) {
+ if (!tickerHdrs[i].classList.contains("active")) {
+ tickerHdrs[i].click();
+ }
+ }
+ });
+ }
+ if (collapseBtn) {
+ collapseBtn.addEventListener("click",()=>{
+ var tickerHdrs = stockList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < tickerHdrs.length; ++i) {
+ if (tickerHdrs[i].classList.contains("active")) {
+ tickerHdrs[i].click();
+ }
+ }
+ });
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers(); //Clicking headers opens/closes panels
+ stockMarketContentCreated = true;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ updateStockTicker(stock, null);
+ updateStockOrderList(stock);
+ }
+ }
+ }
+}
+
+//Displays only stocks you have position/order in
+function switchToPortfolioMode() {
+ stockMarketPortfolioMode = true;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
+ "Displays all stocks on the WSE";
+ modeBtn.addEventListener("click", switchToDisplayAllMode);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+
+ //Get Order book (create it if it hasn't been created)
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ var stockOrders = orderBook[stock.symbol];
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ stockOrders.length === 0) {continue;}
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+//Displays all stocks
+function switchToDisplayAllMode() {
+ stockMarketPortfolioMode = false;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
+ "Displays only the stocks for which you have shares or orders";
+ modeBtn.addEventListener("click", switchToPortfolioMode);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+function createStockTicker(stock) {
+ if (!(stock instanceof Stock)) {
+ console.log("Invalid stock in createStockSticker()");
+ return;
+ }
+ var tickerId = "stock-market-ticker-" + stock.symbol;
+ var li = document.createElement("li"), hdr = document.createElement("button");
+ hdr.classList.add("accordion-header");
+ hdr.setAttribute("id", tickerId + "-hdr");
+ hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price;
+
+ //Div for entire panel
+ var stockDiv = document.createElement("div");
+ stockDiv.classList.add("accordion-panel");
+ stockDiv.setAttribute("id", tickerId + "-panel");
+
+ /* Create panel DOM */
+ var qtyInput = document.createElement("input"),
+ longShortSelect = document.createElement("select"),
+ orderTypeSelect = document.createElement("select"),
+ buyButton = document.createElement("span"),
+ sellButton = document.createElement("span"),
+ buyMaxButton = document.createElement("span"),
+ sellAllButton = document.createElement("span"),
+ positionTxt = document.createElement("p"),
+ orderList = document.createElement("ul");
+
+ qtyInput.classList.add("stock-market-input");
+ qtyInput.placeholder = "Quantity (Shares)";
+ qtyInput.setAttribute("id", tickerId + "-qty-input");
+ qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " +
+ " || (47Long Position: " +
+ "Shares in the long position will increase " +
+ "in value if the price of the corresponding stock increases
" +
+ "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShares, 0) +
+ "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgPx).format('$0.000a') +
+ " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(totalCost).format('$0.000a') + ")" +
+ "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(gains).format('$0.000a') +
+ " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(percentageGains*100, 2) + "%)
";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 2)) {
+ stock.posTxtEl.innerHTML +=
+ "Short Position: " +
+ "Shares in short position will increase " +
+ "in value if the price of the corresponding stock decreases
" +
+ "
Shares: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.playerShortShares, 0) +
+ "
Average Price: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(stock.playerAvgShortPx).format('$0.000a') +
+ " (Total Cost: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortTotalCost).format('$0.000a') + ")" +
+ "
Profit: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_9___default()(shortGains).format('$0.000a') +
+ " (" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shortPercentageGains*100, 2) + "%)" +
+ "Orders:
";
+ }
+
+}
+
+function updateStockOrderList(stock) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
+ var tickerId = "stock-market-ticker-" + stock.symbol;
+ var orderList = document.getElementById(tickerId + "-order-list");
+ if (orderList == null) {
+ if (!stockMarketPortfolioMode) {console.log("ERROR: Could not find order list for " + stock.symbol);}
+ return;
+ }
+
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ console.log("ERROR: Could not find order book in stock market");
+ return;
+ }
+ var stockOrders = orderBook[stock.symbol];
+ if (stockOrders == null) {
+ console.log("ERROR: Could not find orders for: " + stock.symbol);
+ return;
+ }
+
+ if (stockMarketPortfolioMode) {
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
+ StockMarket["Orders"][stock.symbol].length === 0) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-panel");
+ return;
+ } else {
+ //If the ticker hasn't been created, create it (handles updating)
+ //If it has been created, continue normally
+ if (document.getElementById(tickerId + "-hdr") == null) {
+ createStockTicker(stock);
+ setStockTickerClickHandlers();
+ return;
+ }
+ }
+ }
+
+ //Remove everything from list
+ while (orderList.firstChild) {
+ orderList.removeChild(orderList.firstChild);
+ }
+
+ for (var i = 0; i < stockOrders.length; ++i) {
+ (function() {
+ var order = stockOrders[i];
+ var li = document.createElement("li");
+ li.style.padding = "4px";
+ var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position");
+ li.style.color = "white";
+ li.innerText = order.type + " - " + posText + " - " +
+ order.shares + " @ $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(order.price, 2);
+
+ var cancelButton = document.createElement("span");
+ cancelButton.classList.add("stock-market-order-cancel-btn");
+ cancelButton.classList.add("a-link-button");
+ cancelButton.innerHTML = "Cancel Order";
+ cancelButton.addEventListener("click", function() {
+ cancelOrder({order: order}, null);
+ return false;
+ });
+ li.appendChild(cancelButton);
+ orderList.appendChild(li);
+ }());
+
+ }
+}
+
+
+
+
+/***/ }),
+/* 30 */
/*!**********************!*\
!*** ./src/Fconf.js ***!
\**********************/
@@ -34591,7 +29031,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; });
-/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__);
@@ -34723,27 +29163,40 @@ function loadFconf(saveString) {
/***/ }),
-/* 34 */
-/*!*************************!*\
- !*** ./src/Missions.js ***!
- \*************************/
+/* 31 */
+/*!***********************************!*\
+ !*** ./src/NetscriptEvaluator.js ***!
+ \***********************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HackingMission", function() { return HackingMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inMission", function() { return inMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setInMission", function() { return setInMission; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currMission", function() { return currMission; });
-/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! jsplumb */ 197);
-/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(jsplumb__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeRuntimeRejectMsg", function() { return makeRuntimeRejectMsg; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "netscriptDelay", function() { return netscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptFromScript", function() { return runScriptFromScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingChance", function() { return scriptCalculateHackingChance; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingTime", function() { return scriptCalculateHackingTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateExpGain", function() { return scriptCalculateExpGain; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculatePercentMoneyHacked", function() { return scriptCalculatePercentMoneyHacked; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateGrowTime", function() { return scriptCalculateGrowTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateWeakenTime", function() { return scriptCalculateWeakenTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluate", function() { return evaluate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptErrorMessage", function() { return isScriptErrorMessage; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killNetscriptDelay", function() { return killNetscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluateImport", function() { return evaluateImport; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 80);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 32);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/IPAddress.js */ 13);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
@@ -34753,1755 +29206,927 @@ __webpack_require__.r(__webpack_exports__);
-let inMission = false; //Flag to denote whether a mission is running
-let currMission = null;
-function setInMission(bool, mission) {
- inMission = bool;
- if (bool) {
- currMission = mission;
- } else {
- currMission = null;
- }
-}
-//Keyboard shortcuts
-$(document).keydown(function(e) {
- if (inMission && currMission && currMission.selectedNode.length != 0) {
- switch (e.keyCode) {
- case 65: //a for Attack
- currMission.actionButtons[0].click();
- break;
- case 83: //s for Scan
- currMission.actionButtons[1].click();
- break;
- case 87: //w for Weaken
- currMission.actionButtons[2].click();
- break;
- case 70: //f for Fortify
- currMission.actionButtons[3].click();
- break;
- case 82: //r for Overflow
- currMission.actionButtons[4].click();
- break;
- case 68: //d for Detach connection
- currMission.actionButtons[5].click();
- break;
- default:
- break;
- }
- }
+
+
+
+
+var Promise = __webpack_require__(/*! bluebird */ 181);
+
+Promise.config({
+ warnings: false,
+ longStackTraces: false,
+ cancellation: true,
+ monitoring: false
});
-
-let NodeTypes = {
- Core: "CPU Core Node", //All actions available
- Firewall: "Firewall Node", //No actions available
- Database: "Database Node", //No actions available
- Spam: "Spam Node", //No actions Available
- Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow
- Shield: "Shield Node" //Can Fortify
-}
-
-let NodeActions = {
- Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def
- Scan: "Scanning", //-Def for target, affected by attack and hacking level
- Weaken: "Weakening", //-Attack for target, affected by attack and hacking level
- Fortify: "Fortifying", //+Defense for Node, affected by hacking level
- Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level
-}
-
-function Node(type, stats) {
- this.type = type;
- this.atk = stats.atk ? stats.atk : 0;
- this.def = stats.def ? stats.def : 0;
- this.hp = stats.hp ? stats.hp : 0;
- this.maxhp = this.hp;
- this.plyrCtrl = false;
- this.enmyCtrl = false;
- this.pos = [0, 0]; //x, y
- this.el = null; //Holds the Node's DOM element
- this.action = null;
- this.targetedCount = 0; //Count of how many connections this node is the target of
-
- //Holds the JsPlumb Connection object for this Node,
- //where this Node is the Source (since each Node
- //can only have 1 outgoing Connection)
- this.conn = null;
-}
-
-Node.prototype.setPosition = function(x, y) {
- this.pos = [x, y];
-}
-
-Node.prototype.setControlledByPlayer = function() {
- this.plyrCtrl = true;
- this.enmyCtrl = false;
- if (this.el) {
- this.el.classList.remove("hack-mission-enemy-node");
- this.el.classList.add("hack-mission-player-node");
- }
-}
-
-Node.prototype.setControlledByEnemy = function() {
- this.plyrCtrl = false;
- this.enmyCtrl = true;
- if (this.el) {
- this.el.classList.remove("hack-mission-player-node");
- this.el.classList.add("hack-mission-enemy-node");
- }
-}
-
-//Sets this node to be the active node
-Node.prototype.select = function(actionButtons) {
- if (this.enmyCtrl) {return;}
- this.el.classList.add("hack-mission-player-node-active");
-
- //Make all buttons inactive
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button");
- actionButtons[i].classList.add("a-link-button-inactive");
- }
-
- switch(this.type) {
- case NodeTypes.Core:
- //All buttons active
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button-inactive");
- actionButtons[i].classList.add("a-link-button");
- }
- break;
- case NodeTypes.Transfer:
- actionButtons[1].classList.remove("a-link-button-inactive");
- actionButtons[1].classList.add("a-link-button");
- actionButtons[2].classList.remove("a-link-button-inactive");
- actionButtons[2].classList.add("a-link-button");
- actionButtons[3].classList.remove("a-link-button-inactive");
- actionButtons[3].classList.add("a-link-button");
- actionButtons[4].classList.remove("a-link-button-inactive");
- actionButtons[4].classList.add("a-link-button");
- actionButtons[5].classList.remove("a-link-button-inactive");
- actionButtons[5].classList.add("a-link-button");
- break;
- case NodeTypes.Shield:
- case NodeTypes.Firewall:
- actionButtons[3].classList.remove("a-link-button-inactive");
- actionButtons[3].classList.add("a-link-button");
- break;
- default:
- break;
- }
-}
-
-Node.prototype.deselect = function(actionButtons) {
- this.el.classList.remove("hack-mission-player-node-active");
- for (var i = 0; i < actionButtons.length; ++i) {
- actionButtons[i].classList.remove("a-link-button");
- actionButtons[i].classList.add("a-link-button-inactive");
- }
-}
-
-
-Node.prototype.untarget = function() {
- if (this.targetedCount === 0) {
- console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count");
- return;
- }
- --this.targetedCount;
-}
-
-//Hacking mission instance
-//Takes in the reputation of the Faction for which the mission is
-//being conducted
-function HackingMission(rep, fac) {
- this.faction = fac;
-
- this.started = false;
- this.time = 180000; //5 minutes to start, milliseconds
-
- this.playerCores = [];
- this.playerNodes = []; //Non-core nodes
- this.playerAtk = 0;
- this.playerDef = 0;
-
- this.enemyCores = [];
- this.enemyDatabases = [];
- this.enemyNodes = []; //Non-core nodes
- this.enemyAtk = 0;
- this.enemyDef = 0;
-
- this.miscNodes = [];
-
- this.selectedNode = []; //Which of the player's nodes are currently selected
-
- this.actionButtons = []; //DOM buttons for actions
-
- this.availablePositions = [];
- for (var r = 0; r < 8; ++r) {
- for (var c = 0; c < 8; ++c) {
- this.availablePositions.push([r, c]);
+/* Evaluator
+ * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser
+ *
+ * Returns a promise
+ */
+function evaluate(exp, workerScript) {
+ return Promise.delay(_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].CodeInstructionRunTime).then(function() {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ if (exp == null) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error: NULL expression", exp));
}
- }
-
- this.map = [];
- for (var i = 0; i < 8; ++i) {
- this.map.push([null, null, null, null, null, null, null, null]);
- }
-
- this.jsplumbinstance = null;
-
- this.difficulty = rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToDiffConversion + 1;
- console.log("difficulty: " + this.difficulty);
- this.reward = 250 + (rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToRewardConversion);
-}
-
-HackingMission.prototype.init = function() {
- //Create Header DOM
- this.createPageDom();
-
- //Create player starting nodes
- var home = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer()
- for (var i = 0; i < home.cpuCores; ++i) {
- var stats = {
- atk: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 7.5) + 30,
- def: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 20),
- hp: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 4),
- };
- this.playerCores.push(new Node(NodeTypes.Core, stats));
- this.playerCores[i].setControlledByPlayer();
- this.setNodePosition(this.playerCores[i], i, 0);
- this.removeAvailablePosition(i, 0);
- }
-
- //Randomly generate enemy nodes (CPU and Firewall) based on difficulty
- var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4)));
- var numFirewalls = Math.min(20,
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1));
- var numDatabases = Math.min(10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(1, Math.round(this.difficulty / 3) + 1));
- var totalNodes = numNodes + numFirewalls + numDatabases;
- var xlimit = 7 - Math.floor(totalNodes / 8);
- var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.8 + (this.difficulty / 5), 10);
- for (var i = 0; i < numNodes; ++i) {
- var stats = {
- atk: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(80, 86),
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(5, 10),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 230)
- }
- this.enemyCores.push(new Node(NodeTypes.Core, stats));
- this.enemyCores[i].setControlledByEnemy();
- this.setNodeRandomPosition(this.enemyCores[i], xlimit);
- }
- for (var i = 0; i < numFirewalls; ++i) {
- var stats = {
- atk: 0,
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(10, 20),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(275, 300)
- }
- this.enemyNodes.push(new Node(NodeTypes.Firewall, stats));
- this.enemyNodes[i].setControlledByEnemy();
- this.setNodeRandomPosition(this.enemyNodes[i], xlimit);
- }
- for (var i = 0; i < numDatabases; ++i) {
- var stats = {
- atk: 0,
- def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 55),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 275)
- }
- var node = new Node(NodeTypes.Database, stats);
- node.setControlledByEnemy();
- this.setNodeRandomPosition(node, xlimit);
- this.enemyDatabases.push(node);
- }
- this.calculateDefenses();
- this.calculateAttacks();
- this.createMap();
-}
-
-HackingMission.prototype.createPageDom = function() {
- var container = document.getElementById("mission-container");
-
- var favorMult = 1 + (this.faction.favor / 100);
- var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
- var headerText = document.createElement("p");
- headerText.innerHTML = "You are about to start a hacking mission! You will gain " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " faction reputation with " + this.faction.name +
- " if you win. For more information " +
- "about how hacking missions work, click one of the guide links " +
- "below (one opens up an in-game guide and the other opens up " +
- "the guide from the wiki). Click the 'Start' button to begin.";
- headerText.style.display = "block";
- headerText.classList.add("hack-mission-header-element");
- headerText.style.width = "80%";
-
- var inGameGuideBtn = document.createElement("a");
- inGameGuideBtn.innerText = "How to Play";
- inGameGuideBtn.classList.add("a-link-button");
- inGameGuideBtn.style.display = "inline-block";
- inGameGuideBtn.classList.add("hack-mission-header-element");
- inGameGuideBtn.addEventListener("click", function() {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionHowToPlay);
- return false;
- });
-
- var wikiGuideBtn = document.createElement("a");
- wikiGuideBtn.innerText = "Wiki Guide";
- wikiGuideBtn.classList.add("a-link-button");
- wikiGuideBtn.style.display = "inline-block";
- wikiGuideBtn.classList.add("hack-mission-header-element");
- wikiGuideBtn.target = "_blank";
- //TODO Add link to wiki page wikiGuideBtn.href =
-
-
- //Start button will get replaced with forfeit when game is started
- var startBtn = document.createElement("a");
- startBtn.innerHTML = "Start";
- startBtn.setAttribute("id", "hack-mission-start-btn");
- startBtn.classList.add("a-link-button");
- startBtn.classList.add("hack-mission-header-element");
- startBtn.style.display = "inline-block";
- startBtn.addEventListener("click", ()=>{
- this.start();
- return false;
- });
-
- var forfeitMission = document.createElement("a");
- forfeitMission.innerHTML = "Forfeit Mission (Exit)";
- forfeitMission.classList.add("a-link-button");
- forfeitMission.classList.add("hack-mission-header-element");
- forfeitMission.style.display = "inline-block";
- forfeitMission.addEventListener("click", ()=> {
- this.finishMission(false);
- return false;
- });
-
- var timer = document.createElement("p");
- timer.setAttribute("id", "hacking-mission-timer");
- timer.style.display = "inline-block";
- timer.style.margin = "6px";
-
- //Create Action Buttons (Attack/Scan/Weaken/ etc...)
- var actionsContainer = document.createElement("span");
- actionsContainer.style.display = "block";
- actionsContainer.classList.add("hack-mission-action-buttons-container");
- for (var i = 0; i < 6; ++i) {
- this.actionButtons.push(document.createElement("a"));
- this.actionButtons[i].style.display = "inline-block";
- this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start
- this.actionButtons[i].classList.add("tooltip"); //Disabled at start
- this.actionButtons[i].classList.add("hack-mission-header-element");
- actionsContainer.appendChild(this.actionButtons[i]);
- }
- this.actionButtons[0].innerText = "Attack(a)";
- var atkTooltip = document.createElement("span");
- atkTooltip.classList.add("tooltiptexthigh");
- atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[0].appendChild(atkTooltip);
- this.actionButtons[1].innerText = "Scan(s)";
- var scanTooltip = document.createElement("span");
- scanTooltip.classList.add("tooltiptexthigh");
- scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[1].appendChild(scanTooltip);
- this.actionButtons[2].innerText = "Weaken(w)";
- var WeakenTooltip = document.createElement("span");
- WeakenTooltip.classList.add("tooltiptexthigh");
- WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " +
- "this node's Attack level, your hacking level, and the opponent's defense level.";
- this.actionButtons[2].appendChild(WeakenTooltip);
- this.actionButtons[3].innerText = "Fortify(f)";
- var fortifyTooltip = document.createElement("span");
- fortifyTooltip.classList.add("tooltiptexthigh");
- fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " +
- "your hacking level";
- this.actionButtons[3].appendChild(fortifyTooltip);
- this.actionButtons[4].innerText = "Overflow(r)";
- var overflowTooltip = document.createElement("span");
- overflowTooltip.classList.add("tooltiptexthigh");
- overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " +
- "of this depends on your hacking level.";
- this.actionButtons[4].appendChild(overflowTooltip);
- this.actionButtons[5].innerText = "Drop Connection(d)";
- var dropconnTooltip = document.createElement("span");
- dropconnTooltip.classList.add("tooltiptexthigh");
- dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " +
- "also be done by simply clicking the white connection line.";
- this.actionButtons[5].appendChild(dropconnTooltip);
-
- //Player/enemy defense displays will be in action container
- var playerStats = document.createElement("p");
- var enemyStats = document.createElement("p");
- playerStats.style.display = "inline-block";
- enemyStats.style.display = "inline-block";
- playerStats.style.color = "#00ccff";
- enemyStats.style.color = "red";
- playerStats.style.margin = "4px";
- enemyStats.style.margin = "4px";
- playerStats.setAttribute("id", "hacking-mission-player-stats");
- enemyStats.setAttribute("id", "hacking-mission-enemy-stats");
- actionsContainer.appendChild(playerStats);
- actionsContainer.appendChild(enemyStats);
-
- //Set Action Button event listeners
- this.actionButtons[0].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- if (this.selectedNode[0].type !== NodeTypes.Core) {return;}
- this.setActionButtonsActive(this.selectedNode[0].type);
- this.setActionButton(NodeActions.Attack, false); //Set attack button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Attack;
- });
- });
-
- this.actionButtons[1].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Scan, false); //Set scan button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Scan;
- });
- });
-
- this.actionButtons[2].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Weaken;
- });
- });
-
- this.actionButtons[3].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- this.setActionButtonsActive(this.selectedNode[0].type);
- this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Fortify;
- });
- });
-
- this.actionButtons[4].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- var nodeType = this.selectedNode[0].type;
- if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
- this.setActionButtonsActive(nodeType);
- this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive
- this.selectedNode.forEach(function(node){
- node.action = NodeActions.Overflow;
- });
- });
-
- this.actionButtons[5].addEventListener("click", ()=>{
- if (!(this.selectedNode.length > 0)) {
- console.log("ERR: Pressing Action button without selected node");
- return;
- }
- this.selectedNode.forEach(function(node){
- if (node.conn) {
- var endpoints = node.conn.endpoints;
- endpoints[0].detachFrom(endpoints[1]);
- }
- node.action = NodeActions.Fortify;
- });
- // if (this.selectedNode.conn) {
- // var endpoints = this.selectedNode.conn.endpoints;
- // endpoints[0].detachFrom(endpoints[1]);
- // }
- })
-
- var timeDisplay = document.createElement("p");
-
- container.appendChild(headerText);
- container.appendChild(inGameGuideBtn);
- container.appendChild(wikiGuideBtn);
- container.appendChild(startBtn);
- container.appendChild(forfeitMission);
- container.appendChild(timer);
- container.appendChild(actionsContainer);
- container.appendChild(timeDisplay);
-}
-
-HackingMission.prototype.setActionButtonsInactive = function() {
- for (var i = 0; i < this.actionButtons.length; ++i) {
- this.actionButtons[i].classList.remove("a-link-button");
- this.actionButtons[i].classList.add("a-link-button-inactive");
- }
-}
-
-HackingMission.prototype.setActionButtonsActive = function(nodeType=null) {
- for (var i = 0; i < this.actionButtons.length; ++i) {
- this.actionButtons[i].classList.add("a-link-button");
- this.actionButtons[i].classList.remove("a-link-button-inactive");
- }
-
- //For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled
- //0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn
- if (nodeType) {
- switch (nodeType) {
- case NodeTypes.Firewall:
- case NodeTypes.Shield:
- this.actionButtons[0].classList.remove("a-link-button");
- this.actionButtons[0].classList.add("a-link-button-inactive");
- this.actionButtons[1].classList.remove("a-link-button");
- this.actionButtons[1].classList.add("a-link-button-inactive");
- this.actionButtons[2].classList.remove("a-link-button");
- this.actionButtons[2].classList.add("a-link-button-inactive");
- this.actionButtons[4].classList.remove("a-link-button");
- this.actionButtons[4].classList.add("a-link-button-inactive");
- this.actionButtons[5].classList.remove("a-link-button");
- this.actionButtons[5].classList.add("a-link-button-inactive");
- break;
- case NodeTypes.Transfer:
- this.actionButtons[0].classList.remove("a-link-button");
- this.actionButtons[0].classList.add("a-link-button-inactive");
- break;
- default:
- break;
- }
- }
-}
-
-//True for active, false for inactive
-HackingMission.prototype.setActionButton = function(i, active=true) {
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(i)) {
- switch (i) {
- case NodeActions.Attack:
- i = 0;
- break;
- case NodeActions.Scan:
- i = 1;
- break;
- case NodeActions.Weaken:
- i = 2;
- break;
- case NodeActions.Fortify:
- i = 3;
- break;
- case NodeActions.Overflow:
- default:
- i = 4;
- break;
- }
- }
- if (active) {
- this.actionButtons[i].classList.remove("a-link-button-inactive");
- this.actionButtons[i].classList.add("a-link-button");
- } else {
- this.actionButtons[i].classList.remove("a-link-button");
- this.actionButtons[i].classList.add("a-link-button-inactive");
- }
-
-}
-
-HackingMission.prototype.calculateAttacks = function() {
- var total = 0;
- for (var i = 0; i < this.playerCores.length; ++i) {
- total += this.playerCores[i].atk;
- }
- for (var i = 0; i < this.playerNodes.length; ++i) {
- total += this.playerNodes[i].atk;
- }
- this.playerAtk = total;
- document.getElementById("hacking-mission-player-stats").innerHTML =
- "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
- "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
- total = 0;
- for (var i = 0; i < this.enemyCores.length; ++i) {
- total += this.enemyCores[i].atk;
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- total += this.enemyDatabases[i].atk;
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- total += this.enemyNodes[i].atk;
- }
- this.enemyAtk = total;
- document.getElementById("hacking-mission-enemy-stats").innerHTML =
- "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
- "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
-}
-
-HackingMission.prototype.calculateDefenses = function() {
- var total = 0;
- for (var i = 0; i < this.playerCores.length; ++i) {
- total += this.playerCores[i].def;
- }
- for (var i = 0; i < this.playerNodes.length; ++i) {
- total += this.playerNodes[i].def;
- }
- this.playerDef = total;
- document.getElementById("hacking-mission-player-stats").innerHTML =
- "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
- "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
- total = 0;
- for (var i = 0; i < this.enemyCores.length; ++i) {
- total += this.enemyCores[i].def;
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- total += this.enemyDatabases[i].def;
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- total += this.enemyNodes[i].def;
- }
- this.enemyDef = total;
- document.getElementById("hacking-mission-enemy-stats").innerHTML =
- "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
- "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
-}
-
-HackingMission.prototype.removeAvailablePosition = function(x, y) {
- for (var i = 0; i < this.availablePositions.length; ++i) {
- if (this.availablePositions[i][0] === x &&
- this.availablePositions[i][1] === y) {
- this.availablePositions.splice(i, 1);
- return;
- }
- }
- console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y);
-}
-
-HackingMission.prototype.setNodePosition = function(nodeObj, x, y) {
- if (!(nodeObj instanceof Node)) {
- console.log("WARNING: Non-Node object passed into setNodePOsition");
- return;
- }
- if (isNaN(x) || isNaN(y)) {
- console.log("ERR: Invalid values passed as x and y for setNodePosition");
- console.log(x);
- console.log(y);
- return;
- }
- nodeObj.pos = [x, y];
- this.map[x][y] = nodeObj;
-}
-
-HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {
- var i = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.availablePositions.length - 1);
- if (this.availablePositions[i][1] < xlimit) {
- //Recurse if not within limit
- return this.setNodeRandomPosition(nodeObj, xlimit);
- }
- var pos = this.availablePositions.splice(i, 1);
- pos = pos[0];
- this.setNodePosition(nodeObj, pos[0], pos[1]);
-}
-
-HackingMission.prototype.createMap = function() {
- //Use a grid
- var map = document.createElement("div");
- map.classList.add("hack-mission-grid");
- map.setAttribute("id", "hacking-mission-map");
- document.getElementById("mission-container").appendChild(map);
-
- //Create random Nodes for every space in the map that
- //hasn't been filled yet. The stats of each Node will be based on
- //the player/enemy attack
- var averageAttack = (this.playerAtk + this.enemyAtk) / 2;
- for (var x = 0; x < 8; ++x) {
- for (var y = 0; y < 8; ++y) {
- if (!(this.map[x][y] instanceof Node)) {
- var node, type = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, 2);
- var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.85 + (this.difficulty / 2), 15);
- switch (type) {
- case 0: //Spam
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(200, 225)
- }
- node = new Node(NodeTypes.Spam, stats);
- break;
- case 1: //Transfer
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(250, 275)
- }
- node = new Node(NodeTypes.Transfer, stats);
- break;
- case 2: //Shield
- default:
- var stats = {
- atk: 0,
- def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 70),
- hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(300, 320)
- }
- node = new Node(NodeTypes.Shield, stats);
- break;
- }
- this.setNodePosition(node, x, y);
- this.removeAvailablePosition(x, y);
- this.miscNodes.push(node);
- }
- }
- }
-
- //Create DOM elements in order
- for (var r = 0; r < 8; ++r) {
- for (var c = 0; c < 8; ++c) {
- this.createNodeDomElement(this.map[r][c]);
- }
- }
-
- //Configure all Player CPUS
- for (var i = 0; i < this.playerCores.length; ++i) {
- console.log("Configuring Player Node: " + this.playerCores[i].el.id);
- this.configurePlayerNodeElement(this.playerCores[i].el);
- }
-}
-
-HackingMission.prototype.createNodeDomElement = function(nodeObj) {
- var nodeDiv = document.createElement("a"), txtEl = document.createElement('p');
- nodeObj.el = nodeDiv;
-
- //Set the node element's id based on its coordinates
- var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
- nodeDiv.setAttribute("id", id);
- txtEl.setAttribute("id", id + "-txt");
-
- //Set node classes for owner
- nodeDiv.classList.add("hack-mission-node");
- if (nodeObj.plyrCtrl) {
- nodeDiv.classList.add("hack-mission-player-node");
- } else if (nodeObj.enmyCtrl) {
- nodeDiv.classList.add("hack-mission-enemy-node");
- }
-
- //Set node classes based on type
- var txt;
- switch (nodeObj.type) {
- case NodeTypes.Core:
- txt = "CPU Core
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-cpu-node");
- break;
- case NodeTypes.Firewall:
- txt = "Firewall
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-firewall-node");
- break;
- case NodeTypes.Database:
- txt = "Database
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-database-node");
- break;
- case NodeTypes.Spam:
- txt = "Spam
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-spam-node");
- break;
- case NodeTypes.Transfer:
- txt = "Transfer
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-transfer-node");
- break;
- case NodeTypes.Shield:
- default:
- txt = "Shield
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- nodeDiv.classList.add("hack-mission-shield-node");
- break;
- }
-
- txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
- "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
- txtEl.innerHTML = txt;
-
- nodeDiv.appendChild(txtEl);
- document.getElementById("hacking-mission-map").appendChild(nodeDiv);
-}
-
-HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
- if (nodeObj.el == null) {
- console.log("ERR: Calling updateNodeDomElement on a Node without an element");
- return;
- }
-
- var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
- var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt");
-
- //Set node classes based on type
- var txt;
- switch (nodeObj.type) {
- case NodeTypes.Core:
- txt = "CPU Core
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Firewall:
- txt = "Firewall
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Database:
- txt = "Database
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Spam:
- txt = "Spam
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Transfer:
- txt = "Transfer
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- case NodeTypes.Shield:
- default:
- txt = "Shield
" + "HP: " +
- Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
- break;
- }
-
- txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
- "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
- if (nodeObj.action) {
- txt += "
" + nodeObj.action;
- }
- txtEl.innerHTML = txt;
-}
-
-//Gets a Node DOM element's corresponding Node object using its
-//element id. Function accepts either the DOM element object or the ID as
-//an argument
-HackingMission.prototype.getNodeFromElement = function(el) {
- var id;
- if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(el)) {
- id = el;
- } else {
- id = el.id;
- }
- id = id.replace("hacking-mission-node-", "");
- var res = id.split('-');
- if (res.length != 2) {
- console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates");
- return null;
- }
- var x = res[0], y = res[1];
- if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {
- console.log("ERROR: Unexpected values for x and y: " + x + ", " + y);
- return null;
- }
- return this.map[x][y];
-}
-
-function selectNode(hackMissionInst, el) {
- var nodeObj = hackMissionInst.getNodeFromElement(el);
- if (nodeObj == null) {console.log("Error getting Node object");}
- if (!nodeObj.plyrCtrl) {return;}
-
- clearAllSelectedNodes(hackMissionInst);
- nodeObj.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(nodeObj);
-}
-
-function multiselectNode(hackMissionInst, el) {
- var nodeObj = hackMissionInst.getNodeFromElement(el);
- if (nodeObj == null) {console.log("ERROR: Getting Node Object in multiselectNode()");}
- if (!nodeObj.plyrCtrl) {return;}
-
- clearAllSelectedNodes(hackMissionInst);
- var type = nodeObj.type;
- if (type === NodeTypes.Core) {
- hackMissionInst.playerCores.forEach(function(node) {
- node.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(node);
- });
- } else {
- hackMissionInst.playerNodes.forEach(function(node) {
- if (node.type === type) {
- node.select(hackMissionInst.actionButtons);
- hackMissionInst.selectedNode.push(node);
- }
- });
- }
-}
-
-function clearAllSelectedNodes(hackMissionInst) {
- if (hackMissionInst.selectedNode.length > 0) {
- hackMissionInst.selectedNode.forEach(function(node){
- node.deselect(hackMissionInst.actionButtons);
- });
- hackMissionInst.selectedNode.length = 0;
- }
-}
-
-//Configures a DOM element representing a player-owned node to
-//be selectable and actionable
-//Note: Does NOT change its css class. This is handled by Node.setControlledBy...
-HackingMission.prototype.configurePlayerNodeElement = function(el) {
- var nodeObj = this.getNodeFromElement(el);
- if (nodeObj == null) {console.log("Error getting Node object");}
-
- //Add event listener
- var self = this;
- function selectNodeWrapper() {
- selectNode(self, el);
- }
- el.addEventListener("click", selectNodeWrapper);
-
- function multiselectNodeWrapper() {
- multiselectNode(self, el);
- }
- el.addEventListener("dblclick", multiselectNodeWrapper);
-
-
- if (el.firstChild) {
- el.firstChild.addEventListener("click", selectNodeWrapper);
- }
-}
-
-//Configures a DOM element representing an enemy-node by removing
-//any event listeners
-HackingMission.prototype.configureEnemyNodeElement = function(el) {
- //Deselect node if it was the selected node
- var nodeObj = this.getNodeFromElement(el);
- for (var i = 0; i < this.selectedNode.length; ++i) {
- if (this.selectedNode[i] == nodeObj) {
- nodeObj.deselect(this.actionButtons);
- this.selectedNode.splice(i, 1);
- break;
- }
- }
-}
-
-//Returns bool indicating whether a node is reachable by player
-//by checking if any of the adjacent nodes are owned by the player
-HackingMission.prototype.nodeReachable = function(node) {
- var x = node.pos[0], y = node.pos[1];
- if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;}
- if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}
- if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}
- if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}
- return false;
-}
-
-HackingMission.prototype.nodeReachableByEnemy = function(node) {
- if (node == null) {return false;}
- var x = node.pos[0], y = node.pos[1];
- if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
- if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
- if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}
- if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}
- return false;
-}
-
-HackingMission.prototype.start = function() {
- this.started = true;
- this.initJsPlumb();
- var startBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("hack-mission-start-btn");
- startBtn.classList.remove("a-link-button");
- startBtn.classList.add("a-link-button-inactive");
-}
-
-HackingMission.prototype.initJsPlumb = function() {
- var instance = jsPlumb.getInstance({
- DragOptions:{cursor:"pointer", zIndex:2000},
- PaintStyle: {
- gradient: { stops: [
- [ 0, "#FFFFFF" ],
- [ 1, "#FFFFFF" ]
- ] },
- stroke: "#FFFFFF",
- strokeWidth: 8
- },
- });
-
- this.jsplumbinstance = instance;
-
- //All player cores are sources
- for (var i = 0; i < this.playerCores.length; ++i) {
- instance.makeSource(this.playerCores[i].el, {
- deleteEndpointsOnEmpty:true,
- maxConnections:1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
-
- //Everything else is a target
- for (var i = 0; i < this.enemyCores.length; ++i) {
- instance.makeTarget(this.enemyCores[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
- for (var i = 0; i < this.enemyDatabases.length; ++i) {
- instance.makeTarget(this.enemyDatabases[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:["Flowchart"]
- });
- }
- for (var i = 0; i < this.enemyNodes.length; ++i) {
- instance.makeTarget(this.enemyNodes[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
- for (var i = 0; i < this.miscNodes.length; ++i) {
- instance.makeTarget(this.miscNodes[i].el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- }
-
- //Clicking a connection drops it
- instance.bind("click", function(conn, originalEvent) {
- var endpoints = conn.endpoints;
- endpoints[0].detachFrom(endpoints[1]);
- });
-
- //Connection events
- instance.bind("connection", (info)=>{
- var targetNode = this.getNodeFromElement(info.target);
-
- //Do not detach for enemy nodes
- var thisNode = this.getNodeFromElement(info.source);
- if (thisNode.enmyCtrl) {return;}
-
- //If the node is not reachable, drop the connection
- if (!this.nodeReachable(targetNode)) {
- info.sourceEndpoint.detachFrom(info.targetEndpoint);
- return;
- }
-
- var sourceNode = this.getNodeFromElement(info.source);
- sourceNode.conn = info.connection;
- var targetNode = this.getNodeFromElement(info.target);
- ++targetNode.targetedCount;
- });
-
- //Detach Connection events
- instance.bind("connectionDetached", (info, originalEvent)=>{
- var sourceNode = this.getNodeFromElement(info.source);
- sourceNode.conn = null;
- var targetNode = this.getNodeFromElement(info.target);
- targetNode.untarget();
- });
-
-}
-
-//Drops all connections where the specified node is the source
-HackingMission.prototype.dropAllConnectionsFromNode = function(node) {
- var allConns = this.jsplumbinstance.getAllConnections();
- for (var i = allConns.length-1; i >= 0; --i) {
- if (allConns[i].source == node.el) {
- allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
- }
- }
-}
-
-//Drops all connections where the specified node is the target
-HackingMission.prototype.dropAllConnectionsToNode = function(node) {
- var allConns = this.jsplumbinstance.getAllConnections();
- for (var i = allConns.length-1; i >= 0; --i) {
- if (allConns[i].target == node.el) {
- allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
- }
- }
- node.beingTargeted = false;
-}
-
-var storedCycles = 0;
-HackingMission.prototype.process = function(numCycles=1) {
- if (!this.started) {return;}
- storedCycles += numCycles;
- if (storedCycles < 2) {return;} //Only process every 3 cycles minimum
-
- var res = false;
- //Process actions of all player nodes
- this.playerCores.forEach((node)=>{
- res |= this.processNode(node, storedCycles);
- });
-
- this.playerNodes.forEach((node)=>{
- if (node.type === NodeTypes.Transfer ||
- node.type === NodeTypes.Shield ||
- node.type === NodeTypes.Firewall) {
- res |= this.processNode(node, storedCycles);
- }
- });
-
- //Process actions of all enemy nodes
- this.enemyCores.forEach((node)=>{
- this.enemyAISelectAction(node);
- res |= this.processNode(node, storedCycles);
- });
-
- this.enemyNodes.forEach((node)=>{
- if (node.type === NodeTypes.Transfer ||
- node.type === NodeTypes.Shield ||
- node.type === NodeTypes.Firewall) {
- this.enemyAISelectAction(node);
- res |= this.processNode(node, storedCycles);
- }
- });
-
- //The hp of enemy databases increases slowly
- this.enemyDatabases.forEach((node)=>{
- node.maxhp += (0.1 * storedCycles);
- node.hp += (0.1 * storedCycles);
- });
-
- if (res) {
- this.calculateAttacks();
- this.calculateDefenses();
- }
-
- //Win if all enemy databases are conquered
- if (this.enemyDatabases.length === 0) {
- this.finishMission(true);
- return;
- }
-
- //Lose if all your cores are gone
- if (this.playerCores.length === 0) {
- this.finishMission(false);
- return;
- }
-
- //Defense/hp of misc nodes increases slowly over time
- this.miscNodes.forEach((node)=>{
- node.def += (0.1 * storedCycles);
- node.maxhp += (0.05 * storedCycles);
- node.hp += (0.1 * storedCycles);
- if (node.hp > node.maxhp) {node.hp = node.maxhp;}
- this.updateNodeDomElement(node);
- });
-
- //Update timer and check if player lost
- this.time -= (storedCycles * _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"]._idleSpeed);
- if (this.time <= 0) {
- this.finishMission(false);
- return;
- }
- this.updateTimer();
-
- storedCycles = 0;
-}
-
-//Returns a bool representing whether defenses need to be re-calculated
-HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
- if (nodeObj.action == null) {
- return;
- }
-
- var targetNode = null, def, atk;
- if (nodeObj.conn) {
- if (nodeObj.conn.target != null) {
- targetNode = this.getNodeFromElement(nodeObj.conn.target);
- } else {
- targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
- }
-
- if (targetNode == null) {
- //Player is in the middle of dragging the connection,
- //so the target node is null. Do nothing here
- } else if (targetNode.plyrCtrl) {
- def = this.playerDef;
- atk = this.enemyAtk;
- } else if (targetNode.enmyCtrl) {
- def = this.enemyDef;
- atk = this.playerAtk;
- } else { //Misc Node
- def = targetNode.def;
- nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;
- }
- }
-
- //Calculations are per second, so divide everything by 5
- var calcStats = false, plyr = nodeObj.plyrCtrl;
- var enmyHacking = this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionDifficultyToHacking;
- switch(nodeObj.action) {
- case NodeActions.Attack:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var dmg = this.calculateAttackDamage(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.hp -= (dmg/5 * numCycles);
- break;
- case NodeActions.Scan:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var eff = this.calculateScanEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.def -= (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Weaken:
- if (targetNode == null) {break;}
- if (nodeObj.conn == null) {break;}
- var eff = this.calculateWeakenEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
- targetNode.atk -= (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Fortify:
- var eff = this.calculateFortifyEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
- nodeObj.def += (eff/5 * numCycles);
- calcStats = true;
- break;
- case NodeActions.Overflow:
- var eff = this.calculateOverflowEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
- if (nodeObj.def < eff) {break;}
- nodeObj.def -= (eff/5 * numCycles);
- nodeObj.atk += (eff/5 * numCycles);
- calcStats = true;
- break;
- default:
- console.log("ERR: Invalid Node Action: " + nodeObj.action);
- break;
- }
-
- //Stats can't go below 0
- if (nodeObj.atk < 0) {nodeObj.atk = 0;}
- if (nodeObj.def < 0) {nodeObj.def = 0;}
- if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}
- if (targetNode && targetNode.def < 0) {targetNode.def = 0;}
-
- //Conquering a node
- if (targetNode && targetNode.hp <= 0) {
- var conqueredByPlayer = nodeObj.plyrCtrl;
- targetNode.hp = targetNode.maxhp;
- targetNode.action = null;
- targetNode.conn = null;
- if (this.selectedNode == targetNode) {
- targetNode.deselect(this.actionButtons);
- }
-
- //The conquered node has its stats reduced
- targetNode.atk /= 2;
- targetNode.def /= 3.5;
-
- //Flag for whether the target node was a misc node
- var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;
-
- //Remove all connections from Node
- this.dropAllConnectionsToNode(targetNode);
- this.dropAllConnectionsFromNode(targetNode);
-
- //Changes the css class and turn the node into a JsPlumb Source/Target
- if (conqueredByPlayer) {
- targetNode.setControlledByPlayer();
- this.jsplumbinstance.unmakeTarget(targetNode.el);
- this.jsplumbinstance.makeSource(targetNode.el, {
- deleteEndpointsOnEmpty:true,
- maxConnections:1,
- anchor:"Continuous",
- connector:"Flowchart"
- });
- } else {
- targetNode.setControlledByEnemy();
- nodeObj.conn = null; //Clear connection
- this.jsplumbinstance.unmakeSource(targetNode.el);
- this.jsplumbinstance.makeTarget(targetNode.el, {
- maxConnections:-1,
- anchor:"Continuous",
- connector:["Flowchart"]
- });
- }
-
- calcStats = true;
-
- //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays
- function swapNodes(orig, dest, targetNode) {
- for (var i = 0; i < orig.length; ++i) {
- if (orig[i] == targetNode) {
- var node = orig.splice(i, 1);
- node = node[0];
- dest.push(node);
- break;
- }
- }
- }
-
- switch(targetNode.type) {
- case NodeTypes.Core:
- if (conqueredByPlayer) {
- swapNodes(this.enemyCores, this.playerCores, targetNode);
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(this.playerCores, this.enemyCores, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Firewall:
- if (conqueredByPlayer) {
- swapNodes(this.enemyNodes, this.playerNodes, targetNode);
- } else {
- swapNodes(this.playerNodes, this.enemyNodes, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Database:
- if (conqueredByPlayer) {
- swapNodes(this.enemyDatabases, this.playerNodes, targetNode);
- } else {
- swapNodes(this.playerNodes, this.enemyDatabases, targetNode);
- }
- break;
- case NodeTypes.Spam:
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- //Conquering spam node increases time limit
- this.time += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionSpamTimeIncrease;
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- }
-
- break;
- case NodeTypes.Transfer:
- //Conquering a Transfer node increases the attack of all cores by some percentages
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- this.playerCores.forEach(function(node) {
- node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
- });
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- this.enemyCores.forEach(function(node) {
- node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
- });
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- case NodeTypes.Shield:
- if (conqueredByPlayer) {
- swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
- this.configurePlayerNodeElement(targetNode.el);
- } else {
- swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
- this.configureEnemyNodeElement(targetNode.el);
- }
- break;
- }
-
- //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount
- if (isMiscNode) { //&& conqueredByPlayer) {
- this.miscNodes.forEach((node)=>{
- if (node.targetedCount === 0) {
- node.def *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionMiscDefenseIncrease;
- }
- });
- }
- }
-
- //Update node DOMs
- this.updateNodeDomElement(nodeObj);
- if (targetNode) {this.updateNodeDomElement(targetNode);}
- return calcStats;
-}
-
-//Enemy "AI" for CPU Core and Transfer Nodes
-HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
- if (nodeObj == null) {return;}
- switch(nodeObj.type) {
- case NodeTypes.Core:
- //Select a single RANDOM target from miscNodes and player's Nodes
- //If it is reachable, it will target it. If not, no target will
- //be selected for now, and the next time process() gets called this will repeat
- if (nodeObj.conn == null) {
- if (this.miscNodes.length === 0) {
- //Randomly pick a player node and attack it if its reachable
- var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerNodes.length-1);
- var node;
- if (this.playerNodes.length === 0) {
- node = null;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ switch (exp.type) {
+ case "BlockStatement":
+ case "Program":
+ var evaluateProgPromise = evaluateProg(exp, workerScript, 0); //TODO: make every block/program use individual enviroment
+ return evaluateProgPromise.then(function(w) {
+ return Promise.resolve(workerScript);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ return Promise.reject(e);
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ workerScript.errorMessage = e;
+ return Promise.reject(workerScript);
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ return Promise.reject(e);
} else {
- node = this.playerNodes[rand];
+ return Promise.reject(workerScript);
}
- if (this.nodeReachableByEnemy(node)) {
- //Create connection
- nodeObj.conn = this.jsplumbinstance.connect({
- source:nodeObj.el,
- target:node.el
- });
- ++node.targetedCount;
- } else {
- //Randomly pick a player core and attack it if its reachable
- rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerCores.length-1);
- if (this.playerCores.length === 0) {
- return; //No Misc Nodes, no player Nodes, no Player cores. Player lost
- } else {
- node = this.playerCores[rand];
- }
+ });
+ break;
+ case "Literal":
+ return Promise.resolve(exp.value);
+ break;
+ case "Identifier":
+ //Javascript constructor() method can be used as an exploit to run arbitrary code
+ if (exp.name == "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
- if (this.nodeReachableByEnemy(node)) {
- //Create connection
- nodeObj.conn = this.jsplumbinstance.connect({
- source:nodeObj.el,
- target:node.el
+ if (!(exp.name in env.vars)){
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.name + " not defined", exp));
+ }
+ return Promise.resolve(env.get(exp.name))
+ break;
+ case "ExpressionStatement":
+ return evaluate(exp.expression, workerScript);
+ break;
+ case "ArrayExpression":
+ var argPromises = exp.elements.map(function(arg) {
+ return evaluate(arg, workerScript);
+ });
+ return Promise.all(argPromises).then(function(array) {
+ return Promise.resolve(array)
+ });
+ break;
+ case "CallExpression":
+ return evaluate(exp.callee, workerScript).then(function(func) {
+ return Promise.map(exp.arguments, function(arg) {
+ return evaluate(arg, workerScript);
+ }).then(function(args) {
+ if (func instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) { //Player-defined function
+ //Create new Environment for the function
+ //Should be automatically garbage collected...
+ var funcEnv = env.extend();
+
+ //Define function arguments in this new environment
+ for (var i = 0; i < func.params.length; ++i) {
+ var arg;
+ if (i >= args.length) {
+ arg = null;
+ } else {
+ arg = args[i];
+ }
+ funcEnv.def(func.params[i].name, arg);
+ }
+
+ //Create a new WorkerScript for this function evaluation
+ var funcWorkerScript = new _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"](workerScript.scriptRef);
+ funcWorkerScript.serverIp = workerScript.serverIp;
+ funcWorkerScript.env = funcEnv;
+ workerScript.fnWorker = funcWorkerScript;
+
+ return evaluate(func.body, funcWorkerScript).then(function(res) {
+ //If the function finished successfuly, that means there
+ //was no return statement since a return statement rejects. So resolve to null
+ workerScript.fnWorker = null;
+ return Promise.resolve(null);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ //Return statement from function
+ return Promise.resolve(e[1]);
+ workerScript.fnWorker = null;
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e));
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ //Parse out the err message from the WorkerScript and re-reject
+ var errorMsg = e.errorMessage;
+ var errorTextArray = errorMsg.split("|");
+ if (errorTextArray.length === 4) {
+ errorMsg = errorTextArray[3];
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, errorMsg));
+ } else {
+ if (env.stopFlag) {
+ return Promise.reject(workerScript);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error in one of your functions. Could not identify which function"));
+ }
+ }
+ } else if (e instanceof Error) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e.toString()));
+ }
});
- ++node.targetedCount;
+ } else if (exp.callee.type === "MemberExpression"){
+ return evaluate(exp.callee.object, workerScript).then(function(object) {
+ try {
+ if (func === "NETSCRIPTFOREACH") {
+ return evaluateForeach(object, args, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ }
+ var res = func.apply(object,args);
+ return Promise.resolve(res);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
+ });
+ } else {
+ try {
+ var out = func.apply(null,args);
+ if (out instanceof Promise){
+ return out.then(function(res) {
+ return Promise.resolve(res)
+ }).catch(function(e) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.resolve(out);
+ }
+ } catch (e) {
+ if (isScriptErrorMessage(e)) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
+ }
+ }
+ });
+ });
+ break;
+ case "MemberExpression":
+ return evaluate(exp.object, workerScript).then(function(object) {
+ if (exp.computed){
+ return evaluate(exp.property, workerScript).then(function(index) {
+ if (index >= object.length) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays", exp));
+ }
+ return Promise.resolve(object[index]);
+ }).catch(function(e) {
+ if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] || isScriptErrorMessage(e)) {
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression", exp));
+ }
+ });
+ } else {
+ if (exp.property.name === "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
+ if (object != null && object instanceof Array && exp.property.name === "forEach") {
+ return "NETSCRIPTFOREACH";
+ }
+ try {
+ return Promise.resolve(object[exp.property.name])
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to get property: " + e.toString(), exp));
+ }
+ }
+ });
+ break;
+ case "LogicalExpression":
+ case "BinaryExpression":
+ return evalBinary(exp, workerScript);
+ break;
+ case "UnaryExpression":
+ return evalUnary(exp, workerScript);
+ break;
+ case "AssignmentExpression":
+ return evalAssignment(exp, workerScript);
+ break;
+ case "UpdateExpression":
+ if (exp.argument.type==="Identifier"){
+ if (exp.argument.name in env.vars){
+ if (exp.operator === "++" || exp.operator === "--") {
+ switch (exp.operator) {
+ case "++":
+ env.set(exp.argument.name,env.get(exp.argument.name)+1);
+ break;
+ case "--":
+ env.set(exp.argument.name,env.get(exp.argument.name)-1);
+ break;
+ default: break;
+ }
+ return Promise.resolve(env.get(exp.argument.name));
+ }
+ //Not sure what prefix UpdateExpressions there would be besides ++/--
+ if (exp.prefix){
+ return Promise.resolve(env.get(exp.argument.name))
+ }
+ switch (exp.operator){
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". You are trying to use code that is currently unsupported", exp));
+ }
+ return Promise.resolve(env.get(exp.argument.name))
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.argument.name + " not defined", exp));
+ }
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier", exp));
+ }
+ break;
+ case "EmptyStatement":
+ return Promise.resolve(false);
+ break;
+ case "ReturnStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(["RETURNSTATEMENT", res]);
+ });
+ break;
+ case "BreakStatement":
+ return Promise.reject("BREAKSTATEMENT");
+ break;
+ case "ContinueStatement":
+ return Promise.reject("CONTINUESTATEMENT");
+ break;
+ case "IfStatement":
+ return evaluateIf(exp, workerScript);
+ break;
+ case "SwitchStatement":
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Switch statements are not yet implemented in Netscript", exp));
+ break;
+ case "WhileStatement":
+ return evaluateWhile(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("whileLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "ForStatement":
+ return evaluate(exp.init, workerScript).then(function(expInit) {
+ return evaluateFor(exp, workerScript);
+ }).then(function(forLoopRes) {
+ return Promise.resolve("forLoopDone");
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("forLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "FunctionDeclaration":
+ if (exp.id && exp.id.name) {
+ env.set(exp.id.name, exp);
+ return Promise.resolve(true);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration", exp));
+ }
+ break;
+ case "ImportDeclaration":
+ return evaluateImport(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ break;
+ case "ThrowStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, res));
+ });
+ break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". This is currently unsupported in Netscript", exp));
+ break;
+ } //End switch
+ }).catch(function(e) {
+ return Promise.reject(e);
+ }); // End Promise
+}
+
+function evalBinary(exp, workerScript){
+ return evaluate(exp.left, workerScript).then(function(expLeft) {
+ //Short circuiting
+ if (expLeft == true && exp.operator === "||") {
+ return Promise.resolve(true);
+ }
+ if (expLeft == false && exp.operator === "&&") {
+ return Promise.resolve(false);
+ }
+ return evaluate(exp.right, workerScript).then(function(expRight) {
+ switch (exp.operator){
+ case "===":
+ case "==":
+ return Promise.resolve(expLeft===expRight);
+ break;
+ case "!==":
+ case "!=":
+ return Promise.resolve(expLeft!==expRight);
+ break;
+ case "<":
+ return Promise.resolve(expLeft
" +
- "Total production from all Hacknet Nodes: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction, 2) + " / second";
-
- //Update information in each owned hacknet node
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- updateHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
-}
-
-//Creates a single Hacknet Node DOM element
-function createHacknetNodeDomElement(nodeObj) {
- var nodeName = nodeObj.name;
-
- var listItem = document.createElement("li");
- listItem.setAttribute("class", "hacknet-node");
-
- var span = document.createElement("span");
- span.style.display = "inline";
-
- var buttonDiv = document.createElement("div");
- buttonDiv.setAttribute("class", "hacknet-node-button-div");
-
- //Text
- var txt = document.createElement("p");
- //txt.setAttribute("id", "hacknet-node-text-" + nodeName);
- txt.id = "hacknet-node-text-" + nodeName;
-
- //Upgrade buttons
- var upgradeLevelButton = document.createElement("a");
- var upgradeRamButton = document.createElement("a");
- var upgradeCoreButton = document.createElement("a");
-
- //upgradeLevelButton.setAttribute("id", "hacknet-node-upgrade-level-" + nodeName);
- upgradeLevelButton.id = "hacknet-node-upgrade-level-" + nodeName;
- upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
- upgradeLevelButton.addEventListener("click", function() {
- var numUpgrades = hacknetNodePurchaseMultiplier;
- if (hacknetNodePurchaseMultiplier == 0) {
- numUpgrades = getMaxNumberLevelUpgrades(nodeObj);
- }
- nodeObj.purchaseLevelUpgrade(numUpgrades);
- updateHacknetNodesContent();
- return false;
- });
- //upgradeRamButton.setAttribute("id", "hacknet-node-upgrade-ram-" + nodeName);
- upgradeRamButton.id = "hacknet-node-upgrade-ram-" + nodeName;
- upgradeRamButton.setAttribute("class", "a-link-button-inactive");
- upgradeRamButton.addEventListener("click", function() {
- nodeObj.purchaseRamUpgrade();
- updateHacknetNodesContent();
- return false;
- });
- //upgradeCoreButton.setAttribute("id", "hacknet-node-upgrade-core-" + nodeName);
- upgradeCoreButton.id = "hacknet-node-upgrade-core-" + nodeName;
- upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
- upgradeCoreButton.addEventListener("click", function() {
- nodeObj.purchaseCoreUpgrade();
- updateHacknetNodesContent();
- return false;
- });
-
- //Put all the components together in the li element
- span.appendChild(txt);
- buttonDiv.appendChild(upgradeLevelButton);
- buttonDiv.appendChild(upgradeRamButton);
- buttonDiv.appendChild(upgradeCoreButton);
- span.appendChild(buttonDiv);
- listItem.appendChild(span);
-
- document.getElementById("hacknet-nodes-list").appendChild(listItem);
-
- //Set the text and stuff inside the DOM element
- updateHacknetNodeDomElement(nodeObj);
-}
-
-//Updates information on a single hacknet node DOM element
-function updateHacknetNodeDomElement(nodeObj) {
- var nodeName = nodeObj.name;
- var txt = document.getElementById("hacknet-node-text-" + nodeName);
- if (txt == null) {throw new Error("Cannot find text element");}
- txt.innerHTML = "Node name: " + nodeName + "
" +
- "Production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(nodeObj.totalMoneyGenerated, 2) +
- " ($" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(nodeObj.moneyGainRatePerSecond, 2) + " / second)
" +
- "Level: " + nodeObj.level + "
" +
- "RAM: " + nodeObj.ram + "GB
" +
- "Cores: " + nodeObj.cores;
-
- //Upgrade level
- var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName);
- if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");}
- if (nodeObj.level >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel) {
- upgradeLevelButton.innerHTML = "MAX LEVEL";
- upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
- } else {
- var multiplier = 0;
- if (hacknetNodePurchaseMultiplier == 0) {
- //Max
- multiplier = getMaxNumberLevelUpgrades(nodeObj);
- } else {
- var levelsToMax = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - nodeObj.level;
- multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier);
- }
-
- var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier);
- upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier +
- " - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeLevelCost, 2);
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeLevelCost)) {
- upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
- } else {
- upgradeLevelButton.setAttribute("class", "a-link-button");
- }
- }
-
- //Upgrade RAM
- var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName);
- if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");}
- if (nodeObj.ram >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxRam) {
- upgradeRamButton.innerHTML = "MAX RAM";
- upgradeRamButton.setAttribute("class", "a-link-button-inactive");
- } else {
- var upgradeRamCost = nodeObj.calculateRamUpgradeCost();
- upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeRamCost, 2);
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeRamCost)) {
- upgradeRamButton.setAttribute("class", "a-link-button-inactive");
- } else {
- upgradeRamButton.setAttribute("class", "a-link-button");
- }
- }
-
- //Upgrade Cores
- var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName);
- if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");}
- if (nodeObj.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {
- upgradeCoreButton.innerHTML = "MAX CORES";
- upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
- } else {
- var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost();
- upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeCoreCost, 2);
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeCoreCost)) {
- upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
- } else {
- upgradeCoreButton.setAttribute("class", "a-link-button");
- }
- }
-}
-
-function createPlayerHacknetNodeWrappers() {
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] = new HacknetNodeWrapper(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
-}
-
-function updatePlayerHacknetNodeWrappers() {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length !== _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length) {
- return createPlayerHacknetNodeWrappers();
- }
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length; ++i) {
- if (!(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] instanceof HacknetNodeWrapper)) {return createPlayerHacknetNodeWrappers();}
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].level = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].level;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].ram = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].ram;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].cores = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].cores;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].totalMoneyGenerated = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].totalMoneyGenerated;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].onlineTimeSeconds = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].onlineTimeSeconds;
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].moneyGainRatePerSecond = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
- }
-}
-
-function processAllHacknetNodeEarnings(numCycles) {
- var total = 0;
- updatePlayerHacknetNodeWrappers();
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- total += processSingleHacknetNodeEarnings(numCycles, _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
- }
- return total;
-}
-
-function processSingleHacknetNodeEarnings(numCycles, nodeObj) {
- var cyclesPerSecond = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed;
- var earningPerCycle = nodeObj.moneyGainRatePerSecond / cyclesPerSecond;
- if (isNaN(earningPerCycle)) {
- console.log("ERROR: Hacknet Node Calculated earnings is NaN");
- earningPerCycle = 0;
- }
- var totalEarnings = numCycles * earningPerCycle;
- nodeObj.totalMoneyGenerated += totalEarnings;
- nodeObj.onlineTimeSeconds += (numCycles * (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed / 1000));
- _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainMoney(totalEarnings);
- return totalEarnings;
-}
-
-function getHacknetNode(name) {
- for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
- if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].name == name) {
- return _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i];
- }
- }
- return null;
-}
-
-
-
-
-/***/ }),
-/* 41 */
-/*!********************************!*\
- !*** ./src/ActiveScriptsUI.js ***!
- \********************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; });
-/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
-/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/LogBox.js */ 51);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! numeral/min/numeral.min */ 13);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-
-
-
-
-
-
-
-
-
-
-/* {
- * serverName: {
- * header: Server Header Element
- * panel: Server Panel List (ul) element
- * scripts: {
- * script id: Ref to Script information
- * }
- * }
- * ...
- */
-let ActiveScriptsUI = {};
-let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
-
-function createActiveScriptsServerPanel(server) {
- let hostname = server.hostname;
-
- var activeScriptsList = document.getElementById("active-scripts-list");
-
- let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname});
- let li = res[0];
- var hdr = res[1];
- let panel = res[2];
-
- if (ActiveScriptsUI[hostname] != null) {
- console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
- return;
- }
-
- var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul");
- panel.appendChild(panelScriptList);
- activeScriptsList.appendChild(li);
-
- ActiveScriptsUI[hostname] = {
- header: hdr,
- panel: panel,
- panelList: panelScriptList,
- scripts: {}, //Holds references to li elements for each active script
- scriptHdrs: {}, //Holds references to header elements for each active script
- scriptStats: {} //Holds references to the p elements containing text for each active script
- };
-
- return li;
-}
-
-//Deletes the info for a particular server (Dropdown header + Panel with all info)
-//in the Active Scripts page if it exists
-function deleteActiveScriptsServerPanel(server) {
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null) {
- console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
- return;
- }
-
- //Make sure it's empty
- if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) {
- console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting");
- return;
- }
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel);
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header);
- delete ActiveScriptsUI[hostname];
-}
-
-function addActiveScriptsItem(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()");
- return;
- }
- let hostname = server.hostname;
-
- ActiveScriptsTasks.push(function(workerscript, hostname) {
- if (ActiveScriptsUI[hostname] == null) {
- createActiveScriptsServerPanel(server);
- }
-
- //Create the unique identifier (key) for this script
- var itemNameArray = ["active", "scripts", hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:workerscript.name});
- let li = res[0];
- let hdr = res[1];
- let panel = res[2];
-
- hdr.classList.remove("accordion-header");
- hdr.classList.add("active-scripts-script-header");
- panel.classList.remove("accordion-panel");
- panel.classList.add("active-scripts-script-panel");
-
- //Handle the constant elements on the panel that don't change after creation
- //Threads, args, kill/log button
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
- innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" +
- "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args)
- }));
- var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
- innerText:"Loading...", fontSize:"14px",
- });
- panel.appendChild(panelText);
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br"));
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
- innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px",
- clickListener:()=>{
- Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef);
- return false;
- }
- }));
- panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
- innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px",
- clickListener:()=>{
- Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server);
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete...");
- return false;
- }
- }));
-
- //Append element to list
- ActiveScriptsUI[hostname]["panelList"].appendChild(li);
- ActiveScriptsUI[hostname].scripts[itemName] = li;
- ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr;
- ActiveScriptsUI[hostname].scriptStats[itemName] = panelText;
- }.bind(null, workerscript, hostname));
-}
-
-function deleteActiveScriptsItem(workerscript) {
- ActiveScriptsTasks.push(function(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " +
- "you tried to delete a large number of scripts and also deleted servers at the " +
- "same time. It's not a big deal, just save and refresh the game.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null) {
- console.log("ERROR: Trying to delete Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
- return;
- }
-
- var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- let li = ActiveScriptsUI[hostname].scripts[itemName];
- if (li == null) {
- console.log("ERROR: Cannot find Active Script UI element for workerscript: ");
- console.log(workerscript);
- return;
- }
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(li);
- delete ActiveScriptsUI[hostname].scripts[itemName];
- delete ActiveScriptsUI[hostname].scriptHdrs[itemName];
- delete ActiveScriptsUI[hostname].scriptStats[itemName];
- if (Object.keys(ActiveScriptsUI[hostname].scripts).length === 0) {
- deleteActiveScriptsServerPanel(server);
- }
- }.bind(null, workerscript));
-}
-
-//Update the ActiveScriptsItems array
-function updateActiveScriptsItems(maxTasks=100) {
- //Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
- //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once...
- let numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
- for (let i = 0; i < numTasks; ++i) {
- let task = ActiveScriptsTasks.shift();
- try {
- task();
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
- console.log(task);
- }
- }
-
- if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;}
- var total = 0;
- for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) {
- try {
- total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]);
- } catch(e) {
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
- }
- }
- document.getElementById("active-scripts-total-prod").innerHTML =
- "Total online production of Active Scripts: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" +
- "Total online production since last Aug installation: " +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" +
- numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)";
- return total;
-}
-
-//Updates the content of the given item in the Active Scripts list
-function updateActiveScriptsItemContent(workerscript) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null) {
- return; //Hasn't been created yet. We'll skip it
- }
-
- var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
- for (var i = 0; i < workerscript.args.length; ++i) {
- itemNameArray.push(String(workerscript.args[i]));
- }
- var itemName = itemNameArray.join("-");
-
- if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) {
- return; //Hasn't been fully added yet. We'll skip it
- }
- var item = ActiveScriptsUI[hostname].scriptStats[itemName];
-
- //Update the text if necessary. This fn returns the online $/s production
- return updateActiveScriptsText(workerscript, item, itemName);
-}
-
-function updateActiveScriptsText(workerscript, item, itemName) {
- var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
- if (server == null) {
- console.log("ERROR: Invalid server IP for workerscript.");
- return;
- }
- let hostname = server.hostname;
- if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == null) {
- console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
- return;
- }
-
- var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
-
- //Only update if the item is visible
- if (ActiveScriptsUI[hostname].header.classList.contains("active") === false) {return onlineMps;}
- if (ActiveScriptsUI[hostname].scriptHdrs[itemName].classList.contains("active") === false) {return onlineMps;}
-
- Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item);
-
- //Online
- var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2);
- var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " ");
-
- var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second";
- var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime;
- var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " ");
-
- //Offline
- var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2);
- var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " ");
-
- var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
- var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second";
- var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime;
- var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " ");
-
- item.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" +
- onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" +
- offlineMpsText + "
" + offlineEpsText + "
";
- return onlineMps;
-}
-
-
-
-
-/***/ }),
-/* 42 */
+/* 36 */
/*!**********************************!*\
!*** ./src/CompanyManagement.js ***!
\**********************************/
@@ -53174,20 +45909,20 @@ function updateActiveScriptsText(workerscript, item, itemName) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Corporation", function() { return Corporation; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Literature.js */ 53);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Literature.js */ 49);
/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Location.js */ 4);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! decimal.js */ 24);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! decimal.js */ 20);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! numeral/min/numeral.min */ 13);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__);
/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
@@ -58103,113 +50838,7 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Corpo
/***/ }),
-/* 43 */
-/*!*************************!*\
- !*** ./src/TextFile.js ***!
- \*************************/
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFile", function() { return TextFile; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTextFile", function() { return getTextFile; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createTextFile", function() { return createTextFile; });
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
-
-
-
-
-function TextFile(fn="", txt="") {
- this.fn = fn.endsWith(".txt") ? fn : fn + ".txt";
- this.fn = this.fn.replace(/\s+/g, '');
- this.text = String(txt);
-}
-
-TextFile.prototype.append = function(txt) {
- this.text += String(txt);
-}
-
-TextFile.prototype.write = function(txt) {
- this.text = String(txt);
-}
-
-TextFile.prototype.read = function() {
- return this.txt;
-}
-
-TextFile.prototype.show = function() {
- Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_1__["dialogBoxCreate"])(this.fn + "
" + this.text, true);
-}
-
-TextFile.prototype.download = function() {
- var filename = this.fn;
- var file = new Blob([this.text], {type: 'text/plain'});
- if (window.navigator.msSaveOrOpenBlob) {// IE10+
- window.navigator.msSaveOrOpenBlob(file, filename);
- } else { // Others
- var a = document.createElement("a"),
- url = URL.createObjectURL(file);
- a.href = url;
- a.download = this.fn;
- document.body.appendChild(a);
- a.click();
- setTimeout(function() {
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- }, 0);
- }
-}
-
-TextFile.prototype.toJSON = function() {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Generic_toJSON"])("TextFile", this);
-}
-
-TextFile.fromJSON = function(value) {
- return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Generic_fromJSON"])(TextFile, value.data);
-}
-
-_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Reviver"].constructors.TextFile = TextFile;
-
-function getTextFile(fn, server) {
- if (!fn.endsWith(".txt")) {fn += ".txt";}
- for (var i = 0; i < server.textFiles.length; ++i) {
- if (server.textFiles[i].fn === fn) {
- return server.textFiles[i];
- }
- }
- return null;
-}
-
-//Returns the TextFile object that was just created
-function createTextFile(fn, txt, server) {
- if (getTextFile(fn, server) !== null) {
- console.log("ERROR: createTextFile failed because the specified " +
- "server already has a text file with the same fn");
- return;
- }
- var file = new TextFile(fn, txt);
- server.textFiles.push(file);
- return file;
-}
-
-function deleteTextFile(fn, server) {
- if (!fn.endsWith(".txt")) {fn += ".txt";}
- for (var i = 0; i < server.textFiles.length; ++i) {
- if (server.textFiles[i].fn === fn) {
- server.textFiles.splice(i, 1);
- return true;
- }
- }
- return false;
-}
-
-
-
-
-/***/ }),
-/* 44 */
+/* 37 */
/*!***************************!*\
!*** ./src/SourceFile.js ***!
\***************************/
@@ -58222,7 +50851,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applySourceFile", function() { return applySourceFile; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSourceFiles", function() { return initSourceFiles; });
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 12);
@@ -58418,7 +51047,5788 @@ function applySourceFile(srcFile) {
/***/ }),
-/* 45 */
+/* 38 */
+/*!****************************!*\
+ !*** ./src/HacknetNode.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hacknetNodesInit", function() { return hacknetNodesInit; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HacknetNode", function() { return HacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseHacknet", function() { return purchaseHacknet; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateTotalHacknetProduction", function() { return updateTotalHacknetProduction; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCostOfNextHacknetNode", function() { return getCostOfNextHacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesMultiplierButtons", function() { return updateHacknetNodesMultiplierButtons; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getMaxNumberLevelUpgrades", function() { return getMaxNumberLevelUpgrades; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayHacknetNodesContent", function() { return displayHacknetNodesContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateHacknetNodesContent", function() { return updateHacknetNodesContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processAllHacknetNodeEarnings", function() { return processAllHacknetNodeEarnings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getHacknetNode", function() { return getHacknetNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPlayerHacknetNodeWrappers", function() { return createPlayerHacknetNodeWrappers; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 21);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+
+
+
+
+
+
+
+
+
+
+/* HacknetNode.js */
+function hacknetNodesInit() {
+ var mult1x = document.getElementById("hacknet-nodes-1x-multiplier");
+ mult1x.addEventListener("click", function() {
+ hacknetNodePurchaseMultiplier = 1;
+ updateHacknetNodesMultiplierButtons();
+ updateHacknetNodesContent();
+ return false;
+ });
+ var mult5x = document.getElementById("hacknet-nodes-5x-multiplier");
+ mult5x.addEventListener("click", function() {
+ hacknetNodePurchaseMultiplier = 5;
+ updateHacknetNodesMultiplierButtons();
+ updateHacknetNodesContent();
+ return false;
+ });
+ var mult10x = document.getElementById("hacknet-nodes-10x-multiplier");
+ mult10x.addEventListener("click", function() {
+ hacknetNodePurchaseMultiplier = 10;
+ updateHacknetNodesMultiplierButtons();
+ updateHacknetNodesContent();
+ return false;
+ });
+ var multMax = document.getElementById("hacknet-nodes-max-multiplier");
+ multMax.addEventListener("click", function() {
+ hacknetNodePurchaseMultiplier = 0;
+ updateHacknetNodesMultiplierButtons();
+ updateHacknetNodesContent();
+ return false;
+ });
+}
+document.addEventListener("DOMContentLoaded", hacknetNodesInit, false);
+
+function HacknetNode(name) {
+ this.level = 1;
+ this.ram = 1; //GB
+ this.cores = 1;
+
+ this.name = name;
+
+ this.totalMoneyGenerated = 0;
+ this.onlineTimeSeconds = 0;
+
+ this.moneyGainRatePerSecond = 0;
+}
+
+
+HacknetNode.prototype.updateMoneyGainRate = function() {
+ //How much extra $/s is gained per level
+ var gainPerLevel = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMoneyGainPerLevel;
+
+ this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
+ Math.pow(1.035, this.ram-1) *
+ ((this.cores + 5) / 6) *
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_money_mult *
+ _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].HacknetNodeMoney;
+ if (isNaN(this.moneyGainRatePerSecond)) {
+ this.moneyGainRatePerSecond = 0;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_5__["dialogBoxCreate"])("Error in calculating Hacknet Node production. Please report to game developer");
+ }
+
+ updateTotalHacknetProduction();
+}
+
+HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) {
+ levels = Math.round(levels);
+ if (isNaN(levels) || levels < 1) {return 0;}
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeLevelMult;
+ var totalMultiplier = 0; //Summed
+ var currLevel = this.level;
+ for (var i = 0; i < levels; ++i) {
+ totalMultiplier += Math.pow(mult, currLevel);
+ ++currLevel;
+ }
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode / 2 * totalMultiplier * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_level_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getLevelUpgradeCost = function(levels=1) {
+ return this.calculateLevelUpgradeCost(levels);
+}
+
+HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
+ levels = Math.round(levels);
+ var cost = this.calculateLevelUpgradeCost(levels);
+ if (isNaN(cost) || levels < 0) {return false;}
+ if (this.level + levels > _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel) {
+ var diff = Math.max(0, _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - this.level);
+ return this.purchaseLevelUpgrade(diff);
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {return false;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ this.level += levels;
+ this.updateMoneyGainRate();
+ return true;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeLevel = function(levels=1) {
+ let res = this.purchaseLevelUpgrade(levels);
+ createPlayerHacknetNodeWrappers();
+ return res;
+}
+
+HacknetNode.prototype.calculateRamUpgradeCost = function() {
+ var numUpgrades = Math.log2(this.ram);
+
+ //Calculate cost
+ //Base cost of RAM is 50k per 1GB, increased by some multiplier for each time RAM is upgraded
+ var baseCost = this.ram * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostFor1GBOfRamHacknetNode;
+ var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeRamMult, numUpgrades);
+ return baseCost * mult * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_ram_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getRamUpgradeCost = function() {
+ return this.calculateRamUpgradeCost();
+}
+
+HacknetNode.prototype.purchaseRamUpgrade = function() {
+ var cost = this.calculateRamUpgradeCost();
+ if (isNaN(cost)) {return false;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {return false;}
+ if (this.ram >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxRam) {return false;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ this.ram *= 2; //Ram is always doubled
+ this.updateMoneyGainRate();
+ return true;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeRam = function() {
+ let res = this.purchaseRamUpgrade();
+ createPlayerHacknetNodeWrappers();
+ return res;
+}
+
+HacknetNode.prototype.calculateCoreUpgradeCost = function() {
+ var coreBaseCost = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNodeCore;
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeUpgradeCoreMult;
+ return coreBaseCost * Math.pow(mult, this.cores-1) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_core_cost_mult;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.getCoreUpgradeCost = function() {
+ let res = this.calculateCoreUpgradeCost();
+ createPlayerHacknetNodeWrappers();
+ return res;
+}
+
+HacknetNode.prototype.purchaseCoreUpgrade = function() {
+ var cost = this.calculateCoreUpgradeCost();
+ if (isNaN(cost)) {return false;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {return false;}
+ if (this.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {return false;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ ++this.cores;
+ this.updateMoneyGainRate();
+ return true;
+}
+
+//Wrapper function for Netscript
+HacknetNode.prototype.upgradeCore = function() {
+ return this.purchaseCoreUpgrade();
+}
+
+/* Saving and loading HackNets */
+HacknetNode.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_toJSON"])("HacknetNode", this);
+}
+
+HacknetNode.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Generic_fromJSON"])(HacknetNode, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_7__["Reviver"].constructors.HacknetNode = HacknetNode;
+
+var HacknetNodeWrapper = function(hacknetNodeObj) {
+ var _node = hacknetNodeObj;
+ return {
+ name : _node.name,
+ level : _node.level,
+ ram : _node.ram,
+ cores : _node.cores,
+ totalMoneyGenerated : _node.totalMoneyGenerated,
+ onlineTimeSeconds : _node.onlineTimeSeconds,
+ moneyGainRatePerSecond : _node.moneyGainRatePerSecond,
+ upgradeLevel : function(n) {
+ return _node.upgradeLevel(n);
+ },
+ upgradeRam : function() {
+ return _node.upgradeRam();
+ },
+ upgradeCore : function() {
+ return _node.upgradeCore();
+ },
+ getLevelUpgradeCost : function(n) {
+ return _node.getLevelUpgradeCost(n);
+ },
+ getRamUpgradeCost : function() {
+ return _node.getRamUpgradeCost();
+ },
+ getCoreUpgradeCost : function() {
+ return _node.getCoreUpgradeCost();
+ }
+ }
+}
+
+function purchaseHacknet() {
+ /* INTERACTIVE TUTORIAL */
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialIsRunning"]) {
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["currITutorialStep"] == _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialSteps"].HacknetNodesIntroduction) {
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialNextStep"])();
+ } else {
+ return;
+ }
+ }
+
+ /* END INTERACTIVE TUTORIAL */
+
+ var cost = getCostOfNextHacknetNode();
+ if (isNaN(cost)) {throw new Error("Cost is NaN"); return;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ //dialogBoxCreate("You cannot afford to purchase a Hacknet Node!");
+ return false;
+ }
+
+ //Auto generate a name for the node for now...TODO
+ var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
+ var name = "hacknet-node-" + numOwned;
+ var node = new HacknetNode(name);
+ node.updateMoneyGainRate();
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].loseMoney(cost);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.push(node);
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Page.HacknetNodes) {
+ displayHacknetNodesContent();
+ }
+ createPlayerHacknetNodeWrappers();
+ updateTotalHacknetProduction();
+ return numOwned;
+}
+
+//Calculates the total production from all HacknetNodes
+function updateTotalHacknetProduction() {
+ var total = 0;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ total += _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction = total;
+}
+
+function getCostOfNextHacknetNode() {
+ //Cost increases exponentially based on how many you own
+ var numOwned = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
+ var mult = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodePurchaseNextMult;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].BaseCostForHacknetNode * Math.pow(mult, numOwned) * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknet_node_purchase_cost_mult;
+}
+
+var hacknetNodePurchaseMultiplier = 1;
+function updateHacknetNodesMultiplierButtons() {
+ var mult1x = document.getElementById("hacknet-nodes-1x-multiplier");
+ var mult5x = document.getElementById("hacknet-nodes-5x-multiplier");
+ var mult10x = document.getElementById("hacknet-nodes-10x-multiplier");
+ var multMax = document.getElementById("hacknet-nodes-max-multiplier");
+ mult1x.setAttribute("class", "a-link-button");
+ mult5x.setAttribute("class", "a-link-button");
+ mult10x.setAttribute("class", "a-link-button");
+ multMax.setAttribute("class", "a-link-button");
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length == 0) {
+ mult1x.setAttribute("class", "a-link-button-inactive");
+ mult5x.setAttribute("class", "a-link-button-inactive");
+ mult10x.setAttribute("class", "a-link-button-inactive");
+ multMax.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 1) {
+ mult1x.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 5) {
+ mult5x.setAttribute("class", "a-link-button-inactive");
+ } else if (hacknetNodePurchaseMultiplier == 10) {
+ mult10x.setAttribute("class", "a-link-button-inactive");
+ } else {
+ multMax.setAttribute("class", "a-link-button-inactive");
+ }
+}
+
+//Calculate the maximum number of times the Player can afford to upgrade
+//a Hacknet Node's level"
+function getMaxNumberLevelUpgrades(nodeObj) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(1))) {return 0;}
+ var min = 1;
+ var max = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel-1;
+ var levelsToMax = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - nodeObj.level;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(levelsToMax))) {
+ return levelsToMax;
+ }
+
+ while (min <= max) {
+ var curr = (min + max) / 2 | 0;
+ if (curr != _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr)) &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr+1))) {
+ return Math.min(levelsToMax, curr);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(nodeObj.calculateLevelUpgradeCost(curr))) {
+ max = curr - 1;
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.gt(nodeObj.calculateLevelUpgradeCost(curr))) {
+ min = curr + 1;
+ } else {
+ return Math.min(levelsToMax, curr);
+ }
+ }
+}
+
+//Creates Hacknet Node DOM elements when the page is opened
+function displayHacknetNodesContent() {
+ //Update Hacknet Nodes button
+ var newPurchaseButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["clearEventListeners"])("hacknet-nodes-purchase-button");
+
+ newPurchaseButton.addEventListener("click", function() {
+ purchaseHacknet();
+ return false;
+ });
+
+ //Handle Purchase multiplier buttons
+ updateHacknetNodesMultiplierButtons();
+
+ //Remove all old hacknet Node DOM elements
+ var hacknetNodesList = document.getElementById("hacknet-nodes-list");
+ while (hacknetNodesList.firstChild) {
+ hacknetNodesList.removeChild(hacknetNodesList.firstChild);
+ }
+
+ //Then re-create them
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ createHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+ updateHacknetNodesContent();
+}
+
+//Update information on all Hacknet Node DOM elements
+function updateHacknetNodesContent() {
+ //Set purchase button to inactive if not enough money, and update its price display
+ var cost = getCostOfNextHacknetNode();
+ var purchaseButton = document.getElementById("hacknet-nodes-purchase-button");
+ purchaseButton.innerHTML = "Purchase Hacknet Node - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(cost, 2);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(cost)) {
+ purchaseButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ purchaseButton.setAttribute("class", "a-link-button");
+ }
+
+ //Update player's money
+ var moneyElem = document.getElementById("hacknet-nodes-money");
+ moneyElem.innerHTML = "Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.toNumber(), 2) + "
" +
+ "Total production from all Hacknet Nodes: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].totalHacknetNodeProduction, 2) + " / second";
+
+ //Update information in each owned hacknet node
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ updateHacknetNodeDomElement(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+}
+
+//Creates a single Hacknet Node DOM element
+function createHacknetNodeDomElement(nodeObj) {
+ var nodeName = nodeObj.name;
+
+ var listItem = document.createElement("li");
+ listItem.setAttribute("class", "hacknet-node");
+
+ var span = document.createElement("span");
+ span.style.display = "inline";
+
+ var buttonDiv = document.createElement("div");
+ buttonDiv.setAttribute("class", "hacknet-node-button-div");
+
+ //Text
+ var txt = document.createElement("p");
+ //txt.setAttribute("id", "hacknet-node-text-" + nodeName);
+ txt.id = "hacknet-node-text-" + nodeName;
+
+ //Upgrade buttons
+ var upgradeLevelButton = document.createElement("a");
+ var upgradeRamButton = document.createElement("a");
+ var upgradeCoreButton = document.createElement("a");
+
+ //upgradeLevelButton.setAttribute("id", "hacknet-node-upgrade-level-" + nodeName);
+ upgradeLevelButton.id = "hacknet-node-upgrade-level-" + nodeName;
+ upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
+ upgradeLevelButton.addEventListener("click", function() {
+ var numUpgrades = hacknetNodePurchaseMultiplier;
+ if (hacknetNodePurchaseMultiplier == 0) {
+ numUpgrades = getMaxNumberLevelUpgrades(nodeObj);
+ }
+ nodeObj.purchaseLevelUpgrade(numUpgrades);
+ updateHacknetNodesContent();
+ return false;
+ });
+ //upgradeRamButton.setAttribute("id", "hacknet-node-upgrade-ram-" + nodeName);
+ upgradeRamButton.id = "hacknet-node-upgrade-ram-" + nodeName;
+ upgradeRamButton.setAttribute("class", "a-link-button-inactive");
+ upgradeRamButton.addEventListener("click", function() {
+ nodeObj.purchaseRamUpgrade();
+ updateHacknetNodesContent();
+ return false;
+ });
+ //upgradeCoreButton.setAttribute("id", "hacknet-node-upgrade-core-" + nodeName);
+ upgradeCoreButton.id = "hacknet-node-upgrade-core-" + nodeName;
+ upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
+ upgradeCoreButton.addEventListener("click", function() {
+ nodeObj.purchaseCoreUpgrade();
+ updateHacknetNodesContent();
+ return false;
+ });
+
+ //Put all the components together in the li element
+ span.appendChild(txt);
+ buttonDiv.appendChild(upgradeLevelButton);
+ buttonDiv.appendChild(upgradeRamButton);
+ buttonDiv.appendChild(upgradeCoreButton);
+ span.appendChild(buttonDiv);
+ listItem.appendChild(span);
+
+ document.getElementById("hacknet-nodes-list").appendChild(listItem);
+
+ //Set the text and stuff inside the DOM element
+ updateHacknetNodeDomElement(nodeObj);
+}
+
+//Updates information on a single hacknet node DOM element
+function updateHacknetNodeDomElement(nodeObj) {
+ var nodeName = nodeObj.name;
+ var txt = document.getElementById("hacknet-node-text-" + nodeName);
+ if (txt == null) {throw new Error("Cannot find text element");}
+ txt.innerHTML = "Node name: " + nodeName + "
" +
+ "Production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(nodeObj.totalMoneyGenerated, 2) +
+ " ($" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(nodeObj.moneyGainRatePerSecond, 2) + " / second)
" +
+ "Level: " + nodeObj.level + "
" +
+ "RAM: " + nodeObj.ram + "GB
" +
+ "Cores: " + nodeObj.cores;
+
+ //Upgrade level
+ var upgradeLevelButton = document.getElementById("hacknet-node-upgrade-level-" + nodeName);
+ if (upgradeLevelButton == null) {throw new Error("Cannot find upgrade level button element");}
+ if (nodeObj.level >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel) {
+ upgradeLevelButton.innerHTML = "MAX LEVEL";
+ upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ var multiplier = 0;
+ if (hacknetNodePurchaseMultiplier == 0) {
+ //Max
+ multiplier = getMaxNumberLevelUpgrades(nodeObj);
+ } else {
+ var levelsToMax = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxLevel - nodeObj.level;
+ multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier);
+ }
+
+ var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier);
+ upgradeLevelButton.innerHTML = "Upgrade Hacknet Node Level x" + multiplier +
+ " - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeLevelCost, 2);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeLevelCost)) {
+ upgradeLevelButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ upgradeLevelButton.setAttribute("class", "a-link-button");
+ }
+ }
+
+ //Upgrade RAM
+ var upgradeRamButton = document.getElementById("hacknet-node-upgrade-ram-" + nodeName);
+ if (upgradeRamButton == null) {throw new Error("Cannot find upgrade ram button element");}
+ if (nodeObj.ram >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxRam) {
+ upgradeRamButton.innerHTML = "MAX RAM";
+ upgradeRamButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ var upgradeRamCost = nodeObj.calculateRamUpgradeCost();
+ upgradeRamButton.innerHTML = "Upgrade Hacknet Node RAM - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeRamCost, 2);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeRamCost)) {
+ upgradeRamButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ upgradeRamButton.setAttribute("class", "a-link-button");
+ }
+ }
+
+ //Upgrade Cores
+ var upgradeCoreButton = document.getElementById("hacknet-node-upgrade-core-" + nodeName);
+ if (upgradeCoreButton == null) {throw new Error("Cannot find upgrade cores button element");}
+ if (nodeObj.cores >= _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].HacknetNodeMaxCores) {
+ upgradeCoreButton.innerHTML = "MAX CORES";
+ upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ var upgradeCoreCost = nodeObj.calculateCoreUpgradeCost();
+ upgradeCoreButton.innerHTML = "Purchase additional CPU Core - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(upgradeCoreCost, 2);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].money.lt(upgradeCoreCost)) {
+ upgradeCoreButton.setAttribute("class", "a-link-button-inactive");
+ } else {
+ upgradeCoreButton.setAttribute("class", "a-link-button");
+ }
+ }
+}
+
+function createPlayerHacknetNodeWrappers() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] = new HacknetNodeWrapper(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+}
+
+function updatePlayerHacknetNodeWrappers() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length !== _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length) {
+ return createPlayerHacknetNodeWrappers();
+ }
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers.length; ++i) {
+ if (!(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i] instanceof HacknetNodeWrapper)) {return createPlayerHacknetNodeWrappers();}
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].level = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].level;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].ram = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].ram;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].cores = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].cores;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].totalMoneyGenerated = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].totalMoneyGenerated;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].onlineTimeSeconds = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].onlineTimeSeconds;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodeWrappers[i].moneyGainRatePerSecond = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].moneyGainRatePerSecond;
+ }
+}
+
+function processAllHacknetNodeEarnings(numCycles) {
+ var total = 0;
+ updatePlayerHacknetNodeWrappers();
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ total += processSingleHacknetNodeEarnings(numCycles, _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i]);
+ }
+ return total;
+}
+
+function processSingleHacknetNodeEarnings(numCycles, nodeObj) {
+ var cyclesPerSecond = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed;
+ var earningPerCycle = nodeObj.moneyGainRatePerSecond / cyclesPerSecond;
+ if (isNaN(earningPerCycle)) {
+ console.log("ERROR: Hacknet Node Calculated earnings is NaN");
+ earningPerCycle = 0;
+ }
+ var totalEarnings = numCycles * earningPerCycle;
+ nodeObj.totalMoneyGenerated += totalEarnings;
+ nodeObj.onlineTimeSeconds += (numCycles * (_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed / 1000));
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainMoney(totalEarnings);
+ return totalEarnings;
+}
+
+function getHacknetNode(name) {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i].name == name) {
+ return _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacknetNodes[i];
+ }
+ }
+ return null;
+}
+
+
+
+
+/***/ }),
+/* 39 */
+/*!*************************!*\
+ !*** ./src/Missions.js ***!
+ \*************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HackingMission", function() { return HackingMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inMission", function() { return inMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setInMission", function() { return setInMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currMission", function() { return currMission; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! jsplumb */ 197);
+/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(jsplumb__WEBPACK_IMPORTED_MODULE_7__);
+
+
+
+
+
+
+
+
+
+let inMission = false; //Flag to denote whether a mission is running
+let currMission = null;
+function setInMission(bool, mission) {
+ inMission = bool;
+ if (bool) {
+ currMission = mission;
+ } else {
+ currMission = null;
+ }
+}
+
+//Keyboard shortcuts
+$(document).keydown(function(e) {
+ if (inMission && currMission && currMission.selectedNode.length != 0) {
+ switch (e.keyCode) {
+ case 65: //a for Attack
+ currMission.actionButtons[0].click();
+ break;
+ case 83: //s for Scan
+ currMission.actionButtons[1].click();
+ break;
+ case 87: //w for Weaken
+ currMission.actionButtons[2].click();
+ break;
+ case 70: //f for Fortify
+ currMission.actionButtons[3].click();
+ break;
+ case 82: //r for Overflow
+ currMission.actionButtons[4].click();
+ break;
+ case 68: //d for Detach connection
+ currMission.actionButtons[5].click();
+ break;
+ default:
+ break;
+ }
+ }
+});
+
+let NodeTypes = {
+ Core: "CPU Core Node", //All actions available
+ Firewall: "Firewall Node", //No actions available
+ Database: "Database Node", //No actions available
+ Spam: "Spam Node", //No actions Available
+ Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow
+ Shield: "Shield Node" //Can Fortify
+}
+
+let NodeActions = {
+ Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def
+ Scan: "Scanning", //-Def for target, affected by attack and hacking level
+ Weaken: "Weakening", //-Attack for target, affected by attack and hacking level
+ Fortify: "Fortifying", //+Defense for Node, affected by hacking level
+ Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level
+}
+
+function Node(type, stats) {
+ this.type = type;
+ this.atk = stats.atk ? stats.atk : 0;
+ this.def = stats.def ? stats.def : 0;
+ this.hp = stats.hp ? stats.hp : 0;
+ this.maxhp = this.hp;
+ this.plyrCtrl = false;
+ this.enmyCtrl = false;
+ this.pos = [0, 0]; //x, y
+ this.el = null; //Holds the Node's DOM element
+ this.action = null;
+ this.targetedCount = 0; //Count of how many connections this node is the target of
+
+ //Holds the JsPlumb Connection object for this Node,
+ //where this Node is the Source (since each Node
+ //can only have 1 outgoing Connection)
+ this.conn = null;
+}
+
+Node.prototype.setPosition = function(x, y) {
+ this.pos = [x, y];
+}
+
+Node.prototype.setControlledByPlayer = function() {
+ this.plyrCtrl = true;
+ this.enmyCtrl = false;
+ if (this.el) {
+ this.el.classList.remove("hack-mission-enemy-node");
+ this.el.classList.add("hack-mission-player-node");
+ }
+}
+
+Node.prototype.setControlledByEnemy = function() {
+ this.plyrCtrl = false;
+ this.enmyCtrl = true;
+ if (this.el) {
+ this.el.classList.remove("hack-mission-player-node");
+ this.el.classList.add("hack-mission-enemy-node");
+ }
+}
+
+//Sets this node to be the active node
+Node.prototype.select = function(actionButtons) {
+ if (this.enmyCtrl) {return;}
+ this.el.classList.add("hack-mission-player-node-active");
+
+ //Make all buttons inactive
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button");
+ actionButtons[i].classList.add("a-link-button-inactive");
+ }
+
+ switch(this.type) {
+ case NodeTypes.Core:
+ //All buttons active
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button-inactive");
+ actionButtons[i].classList.add("a-link-button");
+ }
+ break;
+ case NodeTypes.Transfer:
+ actionButtons[1].classList.remove("a-link-button-inactive");
+ actionButtons[1].classList.add("a-link-button");
+ actionButtons[2].classList.remove("a-link-button-inactive");
+ actionButtons[2].classList.add("a-link-button");
+ actionButtons[3].classList.remove("a-link-button-inactive");
+ actionButtons[3].classList.add("a-link-button");
+ actionButtons[4].classList.remove("a-link-button-inactive");
+ actionButtons[4].classList.add("a-link-button");
+ actionButtons[5].classList.remove("a-link-button-inactive");
+ actionButtons[5].classList.add("a-link-button");
+ break;
+ case NodeTypes.Shield:
+ case NodeTypes.Firewall:
+ actionButtons[3].classList.remove("a-link-button-inactive");
+ actionButtons[3].classList.add("a-link-button");
+ break;
+ default:
+ break;
+ }
+}
+
+Node.prototype.deselect = function(actionButtons) {
+ this.el.classList.remove("hack-mission-player-node-active");
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button");
+ actionButtons[i].classList.add("a-link-button-inactive");
+ }
+}
+
+
+Node.prototype.untarget = function() {
+ if (this.targetedCount === 0) {
+ console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count");
+ return;
+ }
+ --this.targetedCount;
+}
+
+//Hacking mission instance
+//Takes in the reputation of the Faction for which the mission is
+//being conducted
+function HackingMission(rep, fac) {
+ this.faction = fac;
+
+ this.started = false;
+ this.time = 180000; //5 minutes to start, milliseconds
+
+ this.playerCores = [];
+ this.playerNodes = []; //Non-core nodes
+ this.playerAtk = 0;
+ this.playerDef = 0;
+
+ this.enemyCores = [];
+ this.enemyDatabases = [];
+ this.enemyNodes = []; //Non-core nodes
+ this.enemyAtk = 0;
+ this.enemyDef = 0;
+
+ this.miscNodes = [];
+
+ this.selectedNode = []; //Which of the player's nodes are currently selected
+
+ this.actionButtons = []; //DOM buttons for actions
+
+ this.availablePositions = [];
+ for (var r = 0; r < 8; ++r) {
+ for (var c = 0; c < 8; ++c) {
+ this.availablePositions.push([r, c]);
+ }
+ }
+
+ this.map = [];
+ for (var i = 0; i < 8; ++i) {
+ this.map.push([null, null, null, null, null, null, null, null]);
+ }
+
+ this.jsplumbinstance = null;
+
+ this.difficulty = rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToDiffConversion + 1;
+ console.log("difficulty: " + this.difficulty);
+ this.reward = 250 + (rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToRewardConversion);
+}
+
+HackingMission.prototype.init = function() {
+ //Create Header DOM
+ this.createPageDom();
+
+ //Create player starting nodes
+ var home = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer()
+ for (var i = 0; i < home.cpuCores; ++i) {
+ var stats = {
+ atk: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 7.5) + 30,
+ def: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 20),
+ hp: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 4),
+ };
+ this.playerCores.push(new Node(NodeTypes.Core, stats));
+ this.playerCores[i].setControlledByPlayer();
+ this.setNodePosition(this.playerCores[i], i, 0);
+ this.removeAvailablePosition(i, 0);
+ }
+
+ //Randomly generate enemy nodes (CPU and Firewall) based on difficulty
+ var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4)));
+ var numFirewalls = Math.min(20,
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1));
+ var numDatabases = Math.min(10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(1, Math.round(this.difficulty / 3) + 1));
+ var totalNodes = numNodes + numFirewalls + numDatabases;
+ var xlimit = 7 - Math.floor(totalNodes / 8);
+ var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.8 + (this.difficulty / 5), 10);
+ for (var i = 0; i < numNodes; ++i) {
+ var stats = {
+ atk: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(80, 86),
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(5, 10),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 230)
+ }
+ this.enemyCores.push(new Node(NodeTypes.Core, stats));
+ this.enemyCores[i].setControlledByEnemy();
+ this.setNodeRandomPosition(this.enemyCores[i], xlimit);
+ }
+ for (var i = 0; i < numFirewalls; ++i) {
+ var stats = {
+ atk: 0,
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(10, 20),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(275, 300)
+ }
+ this.enemyNodes.push(new Node(NodeTypes.Firewall, stats));
+ this.enemyNodes[i].setControlledByEnemy();
+ this.setNodeRandomPosition(this.enemyNodes[i], xlimit);
+ }
+ for (var i = 0; i < numDatabases; ++i) {
+ var stats = {
+ atk: 0,
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 55),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 275)
+ }
+ var node = new Node(NodeTypes.Database, stats);
+ node.setControlledByEnemy();
+ this.setNodeRandomPosition(node, xlimit);
+ this.enemyDatabases.push(node);
+ }
+ this.calculateDefenses();
+ this.calculateAttacks();
+ this.createMap();
+}
+
+HackingMission.prototype.createPageDom = function() {
+ var container = document.getElementById("mission-container");
+
+ var favorMult = 1 + (this.faction.favor / 100);
+ var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
+ var headerText = document.createElement("p");
+ headerText.innerHTML = "You are about to start a hacking mission! You will gain " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " faction reputation with " + this.faction.name +
+ " if you win. For more information " +
+ "about how hacking missions work, click one of the guide links " +
+ "below (one opens up an in-game guide and the other opens up " +
+ "the guide from the wiki). Click the 'Start' button to begin.";
+ headerText.style.display = "block";
+ headerText.classList.add("hack-mission-header-element");
+ headerText.style.width = "80%";
+
+ var inGameGuideBtn = document.createElement("a");
+ inGameGuideBtn.innerText = "How to Play";
+ inGameGuideBtn.classList.add("a-link-button");
+ inGameGuideBtn.style.display = "inline-block";
+ inGameGuideBtn.classList.add("hack-mission-header-element");
+ inGameGuideBtn.addEventListener("click", function() {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionHowToPlay);
+ return false;
+ });
+
+ var wikiGuideBtn = document.createElement("a");
+ wikiGuideBtn.innerText = "Wiki Guide";
+ wikiGuideBtn.classList.add("a-link-button");
+ wikiGuideBtn.style.display = "inline-block";
+ wikiGuideBtn.classList.add("hack-mission-header-element");
+ wikiGuideBtn.target = "_blank";
+ //TODO Add link to wiki page wikiGuideBtn.href =
+
+
+ //Start button will get replaced with forfeit when game is started
+ var startBtn = document.createElement("a");
+ startBtn.innerHTML = "Start";
+ startBtn.setAttribute("id", "hack-mission-start-btn");
+ startBtn.classList.add("a-link-button");
+ startBtn.classList.add("hack-mission-header-element");
+ startBtn.style.display = "inline-block";
+ startBtn.addEventListener("click", ()=>{
+ this.start();
+ return false;
+ });
+
+ var forfeitMission = document.createElement("a");
+ forfeitMission.innerHTML = "Forfeit Mission (Exit)";
+ forfeitMission.classList.add("a-link-button");
+ forfeitMission.classList.add("hack-mission-header-element");
+ forfeitMission.style.display = "inline-block";
+ forfeitMission.addEventListener("click", ()=> {
+ this.finishMission(false);
+ return false;
+ });
+
+ var timer = document.createElement("p");
+ timer.setAttribute("id", "hacking-mission-timer");
+ timer.style.display = "inline-block";
+ timer.style.margin = "6px";
+
+ //Create Action Buttons (Attack/Scan/Weaken/ etc...)
+ var actionsContainer = document.createElement("span");
+ actionsContainer.style.display = "block";
+ actionsContainer.classList.add("hack-mission-action-buttons-container");
+ for (var i = 0; i < 6; ++i) {
+ this.actionButtons.push(document.createElement("a"));
+ this.actionButtons[i].style.display = "inline-block";
+ this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start
+ this.actionButtons[i].classList.add("tooltip"); //Disabled at start
+ this.actionButtons[i].classList.add("hack-mission-header-element");
+ actionsContainer.appendChild(this.actionButtons[i]);
+ }
+ this.actionButtons[0].innerText = "Attack(a)";
+ var atkTooltip = document.createElement("span");
+ atkTooltip.classList.add("tooltiptexthigh");
+ atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[0].appendChild(atkTooltip);
+ this.actionButtons[1].innerText = "Scan(s)";
+ var scanTooltip = document.createElement("span");
+ scanTooltip.classList.add("tooltiptexthigh");
+ scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[1].appendChild(scanTooltip);
+ this.actionButtons[2].innerText = "Weaken(w)";
+ var WeakenTooltip = document.createElement("span");
+ WeakenTooltip.classList.add("tooltiptexthigh");
+ WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[2].appendChild(WeakenTooltip);
+ this.actionButtons[3].innerText = "Fortify(f)";
+ var fortifyTooltip = document.createElement("span");
+ fortifyTooltip.classList.add("tooltiptexthigh");
+ fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " +
+ "your hacking level";
+ this.actionButtons[3].appendChild(fortifyTooltip);
+ this.actionButtons[4].innerText = "Overflow(r)";
+ var overflowTooltip = document.createElement("span");
+ overflowTooltip.classList.add("tooltiptexthigh");
+ overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " +
+ "of this depends on your hacking level.";
+ this.actionButtons[4].appendChild(overflowTooltip);
+ this.actionButtons[5].innerText = "Drop Connection(d)";
+ var dropconnTooltip = document.createElement("span");
+ dropconnTooltip.classList.add("tooltiptexthigh");
+ dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " +
+ "also be done by simply clicking the white connection line.";
+ this.actionButtons[5].appendChild(dropconnTooltip);
+
+ //Player/enemy defense displays will be in action container
+ var playerStats = document.createElement("p");
+ var enemyStats = document.createElement("p");
+ playerStats.style.display = "inline-block";
+ enemyStats.style.display = "inline-block";
+ playerStats.style.color = "#00ccff";
+ enemyStats.style.color = "red";
+ playerStats.style.margin = "4px";
+ enemyStats.style.margin = "4px";
+ playerStats.setAttribute("id", "hacking-mission-player-stats");
+ enemyStats.setAttribute("id", "hacking-mission-enemy-stats");
+ actionsContainer.appendChild(playerStats);
+ actionsContainer.appendChild(enemyStats);
+
+ //Set Action Button event listeners
+ this.actionButtons[0].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ if (this.selectedNode[0].type !== NodeTypes.Core) {return;}
+ this.setActionButtonsActive(this.selectedNode[0].type);
+ this.setActionButton(NodeActions.Attack, false); //Set attack button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Attack;
+ });
+ });
+
+ this.actionButtons[1].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Scan, false); //Set scan button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Scan;
+ });
+ });
+
+ this.actionButtons[2].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Weaken;
+ });
+ });
+
+ this.actionButtons[3].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ this.setActionButtonsActive(this.selectedNode[0].type);
+ this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Fortify;
+ });
+ });
+
+ this.actionButtons[4].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type;
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Overflow;
+ });
+ });
+
+ this.actionButtons[5].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ this.selectedNode.forEach(function(node){
+ if (node.conn) {
+ var endpoints = node.conn.endpoints;
+ endpoints[0].detachFrom(endpoints[1]);
+ }
+ node.action = NodeActions.Fortify;
+ });
+ // if (this.selectedNode.conn) {
+ // var endpoints = this.selectedNode.conn.endpoints;
+ // endpoints[0].detachFrom(endpoints[1]);
+ // }
+ })
+
+ var timeDisplay = document.createElement("p");
+
+ container.appendChild(headerText);
+ container.appendChild(inGameGuideBtn);
+ container.appendChild(wikiGuideBtn);
+ container.appendChild(startBtn);
+ container.appendChild(forfeitMission);
+ container.appendChild(timer);
+ container.appendChild(actionsContainer);
+ container.appendChild(timeDisplay);
+}
+
+HackingMission.prototype.setActionButtonsInactive = function() {
+ for (var i = 0; i < this.actionButtons.length; ++i) {
+ this.actionButtons[i].classList.remove("a-link-button");
+ this.actionButtons[i].classList.add("a-link-button-inactive");
+ }
+}
+
+HackingMission.prototype.setActionButtonsActive = function(nodeType=null) {
+ for (var i = 0; i < this.actionButtons.length; ++i) {
+ this.actionButtons[i].classList.add("a-link-button");
+ this.actionButtons[i].classList.remove("a-link-button-inactive");
+ }
+
+ //For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled
+ //0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn
+ if (nodeType) {
+ switch (nodeType) {
+ case NodeTypes.Firewall:
+ case NodeTypes.Shield:
+ this.actionButtons[0].classList.remove("a-link-button");
+ this.actionButtons[0].classList.add("a-link-button-inactive");
+ this.actionButtons[1].classList.remove("a-link-button");
+ this.actionButtons[1].classList.add("a-link-button-inactive");
+ this.actionButtons[2].classList.remove("a-link-button");
+ this.actionButtons[2].classList.add("a-link-button-inactive");
+ this.actionButtons[4].classList.remove("a-link-button");
+ this.actionButtons[4].classList.add("a-link-button-inactive");
+ this.actionButtons[5].classList.remove("a-link-button");
+ this.actionButtons[5].classList.add("a-link-button-inactive");
+ break;
+ case NodeTypes.Transfer:
+ this.actionButtons[0].classList.remove("a-link-button");
+ this.actionButtons[0].classList.add("a-link-button-inactive");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+//True for active, false for inactive
+HackingMission.prototype.setActionButton = function(i, active=true) {
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(i)) {
+ switch (i) {
+ case NodeActions.Attack:
+ i = 0;
+ break;
+ case NodeActions.Scan:
+ i = 1;
+ break;
+ case NodeActions.Weaken:
+ i = 2;
+ break;
+ case NodeActions.Fortify:
+ i = 3;
+ break;
+ case NodeActions.Overflow:
+ default:
+ i = 4;
+ break;
+ }
+ }
+ if (active) {
+ this.actionButtons[i].classList.remove("a-link-button-inactive");
+ this.actionButtons[i].classList.add("a-link-button");
+ } else {
+ this.actionButtons[i].classList.remove("a-link-button");
+ this.actionButtons[i].classList.add("a-link-button-inactive");
+ }
+
+}
+
+HackingMission.prototype.calculateAttacks = function() {
+ var total = 0;
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ total += this.playerCores[i].atk;
+ }
+ for (var i = 0; i < this.playerNodes.length; ++i) {
+ total += this.playerNodes[i].atk;
+ }
+ this.playerAtk = total;
+ document.getElementById("hacking-mission-player-stats").innerHTML =
+ "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
+ "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].atk;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].atk;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].atk;
+ }
+ this.enemyAtk = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.calculateDefenses = function() {
+ var total = 0;
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ total += this.playerCores[i].def;
+ }
+ for (var i = 0; i < this.playerNodes.length; ++i) {
+ total += this.playerNodes[i].def;
+ }
+ this.playerDef = total;
+ document.getElementById("hacking-mission-player-stats").innerHTML =
+ "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + "
" +
+ "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].def;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].def;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].def;
+ }
+ this.enemyDef = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + "
" +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.removeAvailablePosition = function(x, y) {
+ for (var i = 0; i < this.availablePositions.length; ++i) {
+ if (this.availablePositions[i][0] === x &&
+ this.availablePositions[i][1] === y) {
+ this.availablePositions.splice(i, 1);
+ return;
+ }
+ }
+ console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y);
+}
+
+HackingMission.prototype.setNodePosition = function(nodeObj, x, y) {
+ if (!(nodeObj instanceof Node)) {
+ console.log("WARNING: Non-Node object passed into setNodePOsition");
+ return;
+ }
+ if (isNaN(x) || isNaN(y)) {
+ console.log("ERR: Invalid values passed as x and y for setNodePosition");
+ console.log(x);
+ console.log(y);
+ return;
+ }
+ nodeObj.pos = [x, y];
+ this.map[x][y] = nodeObj;
+}
+
+HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {
+ var i = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.availablePositions.length - 1);
+ if (this.availablePositions[i][1] < xlimit) {
+ //Recurse if not within limit
+ return this.setNodeRandomPosition(nodeObj, xlimit);
+ }
+ var pos = this.availablePositions.splice(i, 1);
+ pos = pos[0];
+ this.setNodePosition(nodeObj, pos[0], pos[1]);
+}
+
+HackingMission.prototype.createMap = function() {
+ //Use a grid
+ var map = document.createElement("div");
+ map.classList.add("hack-mission-grid");
+ map.setAttribute("id", "hacking-mission-map");
+ document.getElementById("mission-container").appendChild(map);
+
+ //Create random Nodes for every space in the map that
+ //hasn't been filled yet. The stats of each Node will be based on
+ //the player/enemy attack
+ var averageAttack = (this.playerAtk + this.enemyAtk) / 2;
+ for (var x = 0; x < 8; ++x) {
+ for (var y = 0; y < 8; ++y) {
+ if (!(this.map[x][y] instanceof Node)) {
+ var node, type = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, 2);
+ var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.85 + (this.difficulty / 2), 15);
+ switch (type) {
+ case 0: //Spam
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(200, 225)
+ }
+ node = new Node(NodeTypes.Spam, stats);
+ break;
+ case 1: //Transfer
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(250, 275)
+ }
+ node = new Node(NodeTypes.Transfer, stats);
+ break;
+ case 2: //Shield
+ default:
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 70),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(300, 320)
+ }
+ node = new Node(NodeTypes.Shield, stats);
+ break;
+ }
+ this.setNodePosition(node, x, y);
+ this.removeAvailablePosition(x, y);
+ this.miscNodes.push(node);
+ }
+ }
+ }
+
+ //Create DOM elements in order
+ for (var r = 0; r < 8; ++r) {
+ for (var c = 0; c < 8; ++c) {
+ this.createNodeDomElement(this.map[r][c]);
+ }
+ }
+
+ //Configure all Player CPUS
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ console.log("Configuring Player Node: " + this.playerCores[i].el.id);
+ this.configurePlayerNodeElement(this.playerCores[i].el);
+ }
+}
+
+HackingMission.prototype.createNodeDomElement = function(nodeObj) {
+ var nodeDiv = document.createElement("a"), txtEl = document.createElement('p');
+ nodeObj.el = nodeDiv;
+
+ //Set the node element's id based on its coordinates
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ nodeDiv.setAttribute("id", id);
+ txtEl.setAttribute("id", id + "-txt");
+
+ //Set node classes for owner
+ nodeDiv.classList.add("hack-mission-node");
+ if (nodeObj.plyrCtrl) {
+ nodeDiv.classList.add("hack-mission-player-node");
+ } else if (nodeObj.enmyCtrl) {
+ nodeDiv.classList.add("hack-mission-enemy-node");
+ }
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-cpu-node");
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-firewall-node");
+ break;
+ case NodeTypes.Database:
+ txt = "Database
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-database-node");
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-spam-node");
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-transfer-node");
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-shield-node");
+ break;
+ }
+
+ txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ txtEl.innerHTML = txt;
+
+ nodeDiv.appendChild(txtEl);
+ document.getElementById("hacking-mission-map").appendChild(nodeDiv);
+}
+
+HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
+ if (nodeObj.el == null) {
+ console.log("ERR: Calling updateNodeDomElement on a Node without an element");
+ return;
+ }
+
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt");
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Database:
+ txt = "Database
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield
" + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ }
+
+ txt += "
Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ "
Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ if (nodeObj.action) {
+ txt += "
" + nodeObj.action;
+ }
+ txtEl.innerHTML = txt;
+}
+
+//Gets a Node DOM element's corresponding Node object using its
+//element id. Function accepts either the DOM element object or the ID as
+//an argument
+HackingMission.prototype.getNodeFromElement = function(el) {
+ var id;
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(el)) {
+ id = el;
+ } else {
+ id = el.id;
+ }
+ id = id.replace("hacking-mission-node-", "");
+ var res = id.split('-');
+ if (res.length != 2) {
+ console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates");
+ return null;
+ }
+ var x = res[0], y = res[1];
+ if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {
+ console.log("ERROR: Unexpected values for x and y: " + x + ", " + y);
+ return null;
+ }
+ return this.map[x][y];
+}
+
+function selectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("Error getting Node object");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ nodeObj.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(nodeObj);
+}
+
+function multiselectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("ERROR: Getting Node Object in multiselectNode()");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ var type = nodeObj.type;
+ if (type === NodeTypes.Core) {
+ hackMissionInst.playerCores.forEach(function(node) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ });
+ } else {
+ hackMissionInst.playerNodes.forEach(function(node) {
+ if (node.type === type) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ }
+ });
+ }
+}
+
+function clearAllSelectedNodes(hackMissionInst) {
+ if (hackMissionInst.selectedNode.length > 0) {
+ hackMissionInst.selectedNode.forEach(function(node){
+ node.deselect(hackMissionInst.actionButtons);
+ });
+ hackMissionInst.selectedNode.length = 0;
+ }
+}
+
+//Configures a DOM element representing a player-owned node to
+//be selectable and actionable
+//Note: Does NOT change its css class. This is handled by Node.setControlledBy...
+HackingMission.prototype.configurePlayerNodeElement = function(el) {
+ var nodeObj = this.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("Error getting Node object");}
+
+ //Add event listener
+ var self = this;
+ function selectNodeWrapper() {
+ selectNode(self, el);
+ }
+ el.addEventListener("click", selectNodeWrapper);
+
+ function multiselectNodeWrapper() {
+ multiselectNode(self, el);
+ }
+ el.addEventListener("dblclick", multiselectNodeWrapper);
+
+
+ if (el.firstChild) {
+ el.firstChild.addEventListener("click", selectNodeWrapper);
+ }
+}
+
+//Configures a DOM element representing an enemy-node by removing
+//any event listeners
+HackingMission.prototype.configureEnemyNodeElement = function(el) {
+ //Deselect node if it was the selected node
+ var nodeObj = this.getNodeFromElement(el);
+ for (var i = 0; i < this.selectedNode.length; ++i) {
+ if (this.selectedNode[i] == nodeObj) {
+ nodeObj.deselect(this.actionButtons);
+ this.selectedNode.splice(i, 1);
+ break;
+ }
+ }
+}
+
+//Returns bool indicating whether a node is reachable by player
+//by checking if any of the adjacent nodes are owned by the player
+HackingMission.prototype.nodeReachable = function(node) {
+ var x = node.pos[0], y = node.pos[1];
+ if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;}
+ if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.nodeReachableByEnemy = function(node) {
+ if (node == null) {return false;}
+ var x = node.pos[0], y = node.pos[1];
+ if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
+ if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.start = function() {
+ this.started = true;
+ this.initJsPlumb();
+ var startBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("hack-mission-start-btn");
+ startBtn.classList.remove("a-link-button");
+ startBtn.classList.add("a-link-button-inactive");
+}
+
+HackingMission.prototype.initJsPlumb = function() {
+ var instance = jsPlumb.getInstance({
+ DragOptions:{cursor:"pointer", zIndex:2000},
+ PaintStyle: {
+ gradient: { stops: [
+ [ 0, "#FFFFFF" ],
+ [ 1, "#FFFFFF" ]
+ ] },
+ stroke: "#FFFFFF",
+ strokeWidth: 8
+ },
+ });
+
+ this.jsplumbinstance = instance;
+
+ //All player cores are sources
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ instance.makeSource(this.playerCores[i].el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Everything else is a target
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ instance.makeTarget(this.enemyCores[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ instance.makeTarget(this.enemyDatabases[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ instance.makeTarget(this.enemyNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.miscNodes.length; ++i) {
+ instance.makeTarget(this.miscNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Clicking a connection drops it
+ instance.bind("click", function(conn, originalEvent) {
+ var endpoints = conn.endpoints;
+ endpoints[0].detachFrom(endpoints[1]);
+ });
+
+ //Connection events
+ instance.bind("connection", (info)=>{
+ var targetNode = this.getNodeFromElement(info.target);
+
+ //Do not detach for enemy nodes
+ var thisNode = this.getNodeFromElement(info.source);
+ if (thisNode.enmyCtrl) {return;}
+
+ //If the node is not reachable, drop the connection
+ if (!this.nodeReachable(targetNode)) {
+ info.sourceEndpoint.detachFrom(info.targetEndpoint);
+ return;
+ }
+
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = info.connection;
+ var targetNode = this.getNodeFromElement(info.target);
+ ++targetNode.targetedCount;
+ });
+
+ //Detach Connection events
+ instance.bind("connectionDetached", (info, originalEvent)=>{
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = null;
+ var targetNode = this.getNodeFromElement(info.target);
+ targetNode.untarget();
+ });
+
+}
+
+//Drops all connections where the specified node is the source
+HackingMission.prototype.dropAllConnectionsFromNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].source == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+}
+
+//Drops all connections where the specified node is the target
+HackingMission.prototype.dropAllConnectionsToNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].target == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+ node.beingTargeted = false;
+}
+
+var storedCycles = 0;
+HackingMission.prototype.process = function(numCycles=1) {
+ if (!this.started) {return;}
+ storedCycles += numCycles;
+ if (storedCycles < 2) {return;} //Only process every 3 cycles minimum
+
+ var res = false;
+ //Process actions of all player nodes
+ this.playerCores.forEach((node)=>{
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.playerNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //Process actions of all enemy nodes
+ this.enemyCores.forEach((node)=>{
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.enemyNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //The hp of enemy databases increases slowly
+ this.enemyDatabases.forEach((node)=>{
+ node.maxhp += (0.1 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ });
+
+ if (res) {
+ this.calculateAttacks();
+ this.calculateDefenses();
+ }
+
+ //Win if all enemy databases are conquered
+ if (this.enemyDatabases.length === 0) {
+ this.finishMission(true);
+ return;
+ }
+
+ //Lose if all your cores are gone
+ if (this.playerCores.length === 0) {
+ this.finishMission(false);
+ return;
+ }
+
+ //Defense/hp of misc nodes increases slowly over time
+ this.miscNodes.forEach((node)=>{
+ node.def += (0.1 * storedCycles);
+ node.maxhp += (0.05 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ if (node.hp > node.maxhp) {node.hp = node.maxhp;}
+ this.updateNodeDomElement(node);
+ });
+
+ //Update timer and check if player lost
+ this.time -= (storedCycles * _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"]._idleSpeed);
+ if (this.time <= 0) {
+ this.finishMission(false);
+ return;
+ }
+ this.updateTimer();
+
+ storedCycles = 0;
+}
+
+//Returns a bool representing whether defenses need to be re-calculated
+HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
+ if (nodeObj.action == null) {
+ return;
+ }
+
+ var targetNode = null, def, atk;
+ if (nodeObj.conn) {
+ if (nodeObj.conn.target != null) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+
+ if (targetNode == null) {
+ //Player is in the middle of dragging the connection,
+ //so the target node is null. Do nothing here
+ } else if (targetNode.plyrCtrl) {
+ def = this.playerDef;
+ atk = this.enemyAtk;
+ } else if (targetNode.enmyCtrl) {
+ def = this.enemyDef;
+ atk = this.playerAtk;
+ } else { //Misc Node
+ def = targetNode.def;
+ nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;
+ }
+ }
+
+ //Calculations are per second, so divide everything by 5
+ var calcStats = false, plyr = nodeObj.plyrCtrl;
+ var enmyHacking = this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionDifficultyToHacking;
+ switch(nodeObj.action) {
+ case NodeActions.Attack:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var dmg = this.calculateAttackDamage(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.hp -= (dmg/5 * numCycles);
+ break;
+ case NodeActions.Scan:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateScanEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.def -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Weaken:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateWeakenEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.atk -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Fortify:
+ var eff = this.calculateFortifyEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ nodeObj.def += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Overflow:
+ var eff = this.calculateOverflowEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ if (nodeObj.def < eff) {break;}
+ nodeObj.def -= (eff/5 * numCycles);
+ nodeObj.atk += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ default:
+ console.log("ERR: Invalid Node Action: " + nodeObj.action);
+ break;
+ }
+
+ //Stats can't go below 0
+ if (nodeObj.atk < 0) {nodeObj.atk = 0;}
+ if (nodeObj.def < 0) {nodeObj.def = 0;}
+ if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}
+ if (targetNode && targetNode.def < 0) {targetNode.def = 0;}
+
+ //Conquering a node
+ if (targetNode && targetNode.hp <= 0) {
+ var conqueredByPlayer = nodeObj.plyrCtrl;
+ targetNode.hp = targetNode.maxhp;
+ targetNode.action = null;
+ targetNode.conn = null;
+ if (this.selectedNode == targetNode) {
+ targetNode.deselect(this.actionButtons);
+ }
+
+ //The conquered node has its stats reduced
+ targetNode.atk /= 2;
+ targetNode.def /= 3.5;
+
+ //Flag for whether the target node was a misc node
+ var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;
+
+ //Remove all connections from Node
+ this.dropAllConnectionsToNode(targetNode);
+ this.dropAllConnectionsFromNode(targetNode);
+
+ //Changes the css class and turn the node into a JsPlumb Source/Target
+ if (conqueredByPlayer) {
+ targetNode.setControlledByPlayer();
+ this.jsplumbinstance.unmakeTarget(targetNode.el);
+ this.jsplumbinstance.makeSource(targetNode.el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ } else {
+ targetNode.setControlledByEnemy();
+ nodeObj.conn = null; //Clear connection
+ this.jsplumbinstance.unmakeSource(targetNode.el);
+ this.jsplumbinstance.makeTarget(targetNode.el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+
+ calcStats = true;
+
+ //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays
+ function swapNodes(orig, dest, targetNode) {
+ for (var i = 0; i < orig.length; ++i) {
+ if (orig[i] == targetNode) {
+ var node = orig.splice(i, 1);
+ node = node[0];
+ dest.push(node);
+ break;
+ }
+ }
+ }
+
+ switch(targetNode.type) {
+ case NodeTypes.Core:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyCores, this.playerCores, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(this.playerCores, this.enemyCores, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Firewall:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyNodes, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Database:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyDatabases, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyDatabases, targetNode);
+ }
+ break;
+ case NodeTypes.Spam:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ //Conquering spam node increases time limit
+ this.time += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionSpamTimeIncrease;
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ }
+
+ break;
+ case NodeTypes.Transfer:
+ //Conquering a Transfer node increases the attack of all cores by some percentages
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.playerCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.enemyCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Shield:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ }
+
+ //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount
+ if (isMiscNode) { //&& conqueredByPlayer) {
+ this.miscNodes.forEach((node)=>{
+ if (node.targetedCount === 0) {
+ node.def *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionMiscDefenseIncrease;
+ }
+ });
+ }
+ }
+
+ //Update node DOMs
+ this.updateNodeDomElement(nodeObj);
+ if (targetNode) {this.updateNodeDomElement(targetNode);}
+ return calcStats;
+}
+
+//Enemy "AI" for CPU Core and Transfer Nodes
+HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
+ if (nodeObj == null) {return;}
+ switch(nodeObj.type) {
+ case NodeTypes.Core:
+ //Select a single RANDOM target from miscNodes and player's Nodes
+ //If it is reachable, it will target it. If not, no target will
+ //be selected for now, and the next time process() gets called this will repeat
+ if (nodeObj.conn == null) {
+ if (this.miscNodes.length === 0) {
+ //Randomly pick a player node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerNodes.length-1);
+ var node;
+ if (this.playerNodes.length === 0) {
+ node = null;
+ } else {
+ node = this.playerNodes[rand];
+ }
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ } else {
+ //Randomly pick a player core and attack it if its reachable
+ rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerCores.length-1);
+ if (this.playerCores.length === 0) {
+ return; //No Misc Nodes, no player Nodes, no Player cores. Player lost
+ } else {
+ node = this.playerCores[rand];
+ }
+
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ }
+ }
+ } else {
+ //Randomly pick a misc node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.miscNodes.length-1);
+ var node = this.miscNodes[rand];
+ if (this.nodeReachableByEnemy(node)) {
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el,
+ });
+ ++node.targetedCount;
+ }
+ }
+
+ //If no connection was made, set the Core to Fortify
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ //If this node has a selected target
+ var targetNode;
+ if (nodeObj.conn.target) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+ if (targetNode == null) {
+ console.log("Error getting Target node Object in enemyAISelectAction()");
+ }
+
+ if (targetNode.def > this.enemyAtk + 15) {
+ if (nodeObj.def < 50) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) {
+ nodeObj.action = NodeActions.Scan;
+ } else {
+ nodeObj.action = NodeActions.Attack;
+ }
+ }
+ break;
+ case NodeTypes.Transfer:
+ //Switch between fortifying and overflowing as necessary
+ if (nodeObj.def < 125) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ break;
+ case NodeTypes.Firewall:
+ case NodeTypes.Shield:
+ nodeObj.action = NodeActions.Fortify;
+ break;
+ default:
+ break;
+ }
+}
+
+var hackEffWeightSelf = 130; //Weight for Node actions on self
+var hackEffWeightTarget = 25; //Weight for Node Actions against Target
+var hackEffWeightAttack = 80; //Weight for Attack action
+
+//Returns damage per cycle based on stats
+HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) {
+ return Math.max(0.55 * (atk + (hacking / hackEffWeightAttack) - def), 1);
+}
+
+HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) {
+ return Math.max(0.6 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2);
+}
+
+HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) {
+ return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2);
+}
+
+HackingMission.prototype.calculateFortifyEffect = function(hacking=0) {
+ return 0.9 * hacking / hackEffWeightSelf;
+}
+
+HackingMission.prototype.calculateOverflowEffect = function(hacking=0) {
+ return 0.95 * hacking / hackEffWeightSelf;
+}
+
+//Updates timer display
+HackingMission.prototype.updateTimer = function() {
+ var timer = document.getElementById("hacking-mission-timer");
+
+ //Convert time remaining to a string of the form mm:ss
+ var seconds = Math.round(this.time / 1000);
+ var minutes = Math.trunc(seconds / 60);
+ seconds %= 60;
+ var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2);
+ timer.innerText = "Time left: " + str;
+}
+
+//The 'win' argument is a bool for whether or not the player won
+HackingMission.prototype.finishMission = function(win) {
+ inMission = false;
+ currMission = null;
+
+ if (win) {
+ var favorMult = 1 + (this.faction.favor / 100);
+ console.log("Hacking mission base reward: " + this.reward);
+ console.log("favorMult: " + favorMult);
+ console.log("rep mult: " + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult);
+ var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission won! You earned " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " reputation with " + this.faction.name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainIntelligenceExp(this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceHackingMissionBaseExpGain);
+ this.faction.playerReputation += gain;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission lost/forfeited! You did not gain any faction reputation.");
+ }
+
+ //Clear mission container
+ var container = document.getElementById("mission-container");
+ while(container.firstChild) {
+ container.removeChild(container.firstChild);
+ }
+
+ //Return to Faction page
+ document.getElementById("mainmenu-container").style.visibility = "visible";
+ document.getElementById("character-overview-wrapper").style.visibility = "visible";
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(this.faction.name);
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
+
+/***/ }),
+/* 40 */
+/*!****************************!*\
+ !*** ./src/Bladeburner.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bladeburner", function() { return Bladeburner; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./RedPill.js */ 41);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 15);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
+
+var CyclesPerSecond = 5; //Game cycle is 200 ms
+
+var StaminaGainPerSecond = 0.0085;
+var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty
+var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain
+
+var DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time
+
+//The difficulty multiplier affects stamina loss and hp loss of an action. Its formula is:
+//difficulty ^ exponentialFactor + difficulty / linearFactor
+var DiffMultExponentialFactor = 0.28;
+var DiffMultLinearFactor = 670;
+
+var BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action
+
+var PopulationThreshold = 1e9; //Population at which success rates start being affected
+var ChaosThreshold = 50; //City chaos level after which it starts making tasks harder
+
+var BaseStatGain = 1; //Base stat gain per second
+var BaseIntGain = 0.001; //Base intelligence stat gain
+
+var ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value
+
+var RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank
+
+var ContractSuccessesPerLevel = 15; //How many successes you need to level up a contract
+var OperationSuccessesPerLevel = 10; //How many successes you need to level up an op
+
+var RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point
+
+var ContractBaseMoneyGain = 5e3; //Base Money Gained per contract
+
+//DOM related variables
+var ActiveActionCssClass = "bladeburner-active-action";
+
+//Console related stuff
+var consoleHistory = []; //Console command history
+var consoleHistoryIndex = 0;
+var consoleHelpText = {
+ helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.
" +
+ "automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks
" +
+ "clear/cls Clear the console
" +
+ "help [cmd] Display this help text, or help text for a specific command
" +
+ "log [en/dis] [type] Enable or disable logging for events and actions
" +
+ "skill [action] [name] Level or display info about your Bladeburner skills
" +
+ "start [type] [name] Start a Bladeburner action/task
" +
+ "stop Stops your current Bladeburner action/task
",
+ automate:"automate [var] [val] [hi/low]
" +
+ "A simple way to automate your Bladeburner actions. This console command can be used " +
+ "to automatically start an action when your stamina rises above a certain threshold, and " +
+ "automatically switch to another action when your stamina drops below another threshold.
" +
+ "automate status - Check the current status of your automation and get a brief description of what it'll do
" +
+ "automate en - Enable the automation feature
" +
+ "automate dis - Disable the automation feature
" +
+ "There are four properties that must be set for this automation to work properly. Here is how to set them:
" +
+ "automate stamina 100 high
" +
+ "automate contract Tracking high
" +
+ "automate stamina 50 low
" +
+ 'automate general "Field Analysis" low
' +
+ "Using the four console commands above will set the automation to perform Tracking contracts " +
+ "if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below " +
+ "50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must " +
+ "exactly match whatever the name is in the UI.",
+ clear:"clear
Clears the console",
+ cls:"cls
Clears the console",
+ help:"help [command]
" +
+ "Running 'help' with no arguments displays the general help text, which lists all console commands " +
+ "and a brief description of what they do. A command can be specified to get more specific help text " +
+ "about that particular command. For example:
" +
+ "help automate
" +
+ "will display specific information about using the automate console command",
+ log:"log [en/dis] [type]
" +
+ "Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged " +
+ "in the console. There are also random events that are logged in the console as well. The five categories of " +
+ "things that get logged are:
" +
+ "[general, contracts, ops, blackops, events]
" +
+ "The logging for these categories can be enabled or disabled like so:
" +
+ "log dis contracts - Disables logging that occurs when contracts are completed
" +
+ "log en contracts - Enables logging that occurs when contracts are completed
" +
+ "log dis events - Disables logging for Bladeburner random events
" +
+ "Logging can be universally enabled/disabled using the 'all' keyword:
" +
+ "log dis all
" +
+ "log en all",
+ skill:"skill [action] [name]
" +
+ "Level or display information about your skills.
" +
+ "To display information about all of your skills and your multipliers, use:
" +
+ "skill list
" +
+ "To display information about a specific skill, specify the name of the skill afterwards. " +
+ "Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If " +
+ "the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
" +
+ "skill list Reaper
" +
+ 'skill list "Digital Observer"
' +
+ "This console command can also be used to level up skills:
" +
+ "skill level [skill name]",
+ start:"start [type] [name]
" +
+ "Start an action. An action is specified by its type and its name. The " +
+ "name is case-sensitive. It must appear exactly as it does in the UI. If " +
+ "the name of the action has whitespace, enclose it in double quotation marks. " +
+ "Valid action types include:
" +
+ "[general, contract, op, blackop]
" +
+ "Examples:
" +
+ 'start contract Tracking
' +
+ 'start op "Undercover Operation"
',
+ stop:"stop
" +
+ "Stop your current action and go idle",
+}
+
+//Keypresses for Console
+$(document).keydown(function(event) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
+ //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
+ // DomElems.consoleInput.focus();
+ //}
+
+ if (!(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner instanceof Bladeburner)) {return;}
+
+ //NOTE: Keycodes imported from Terminal.js
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].ENTER) {
+ event.preventDefault();
+ var command = DomElems.consoleInput.value;
+ if (command.length > 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.postToConsole("> " + command);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.resetConsoleInput();
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner.executeConsoleCommands(command);
+ }
+ }
+
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].UPARROW) {
+ if (DomElems.consoleInput == null) {return;}
+ var i = consoleHistoryIndex;
+ var len = consoleHistory.length;
+
+ if (len === 0) {return;}
+ if (i < 0 || i > len) {
+ consoleHistoryIndex = len;
+ }
+
+ if (i !== 0) {
+ --consoleHistoryIndex;
+ }
+
+ var prevCommand = consoleHistory[consoleHistoryIndex];
+ DomElems.consoleInput.value = prevCommand;
+ setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);
+ }
+
+ if (event.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_6__["KEY"].DOWNARROW) {
+ if (DomElems.consoleInput == null) {return;}
+ var i = consoleHistoryIndex;
+ var len = consoleHistory.length;
+
+ if (len == 0) {return;}
+ if (i < 0 || i > len) {
+ consoleHistoryIndex = len;
+ }
+
+ //Latest command, put nothing
+ if (i == len || i == len-1) {
+ consoleHistoryIndex = len;
+ DomElems.consoleInput.value = "";
+ } else {
+ ++consoleHistoryIndex;
+ var prevCommand = consoleHistory[consoleHistoryIndex];
+ DomElems.consoleInput.value = prevCommand;
+ }
+ }
+ }
+});
+
+function City(params={}) {
+ this.name = params.name ? params.name : _Location_js__WEBPACK_IMPORTED_MODULE_3__["Locations"].Sector12;
+
+ //Synthoid population and estimate
+ this.pop = params.pop ? params.pop : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(800e6, 1.2*PopulationThreshold);
+ this.popEst = this.pop * (Math.random() + 0.5);
+
+ //Number of Synthoid communities population and estimate
+ this.comms = params.comms ? params.comms : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 40);
+ this.commsEst = this.comms + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-2, 2);
+ if (this.commsEst < 0) {this.commsEst = 0;}
+ this.chaos = 0;
+}
+
+City.prototype.improvePopulationEstimateByCount = function(n) {
+ if (isNaN(n)) {throw new Error("NaN passeed into City.improvePopulationEstimateByCount()");}
+ if (this.popEst < this.pop) {
+ this.popEst += n;
+ if (this.popEst > this.pop) {this.popEst = this.pop;}
+ } else if (this.popEst > this.pop) {
+ this.popEst -= n;
+ if (this.popEst < this.pop) {this.popEst = this.pop;}
+ }
+}
+
+//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
+City.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {
+ p = p*skillMult;
+ if (isNaN(p)) {throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()");}
+ if (this.popEst < this.pop) {
+ ++this.popEst; //In case estimate is 0
+ this.popEst *= (1 + (p/100));
+ if (this.popEst > this.pop) {this.popEst = this.pop;}
+ } else if (this.popEst > this.pop) {
+ this.popEst *= (1 - (p/100));
+ if (this.popEst < this.pop) {this.popEst = this.pop;}
+ }
+}
+
+City.prototype.improveCommunityEstimate = function(n=1) {
+ if (isNaN(n)) {throw new Error("NaN passed into City.improveCommunityEstimate()");}
+ if (this.commsEst < this.comms) {
+ this.commsEst += n;
+ if (this.commsEst > this.comms) {this.commsEst = this.comms;}
+ } else if (this.commsEst > this.comms) {
+ this.commsEst -= n;
+ if (this.commsEst < this.comms) {this.commsEst = this.comms;}
+ }
+}
+
+//@params options:
+// estChange(int): How much the estimate should change by
+// estOffset(int): Add offset to estimate (offset by percentage)
+City.prototype.changePopulationByCount = function(n, params={}) {
+ if (isNaN(n)) {throw new Error("NaN passed into City.changePopulationByCount()");}
+ this.pop += n;
+ if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}
+ if (params.estOffset) {
+ this.popEst = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(this.popEst, params.estOffset);
+ }
+ this.popEst = Math.max(this.popEst, 0);
+}
+
+//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
+//@params options:
+// changeEstEqually(bool) - Change the population estimate by an equal amount
+// nonZero (bool) - Set to true to ensure that population always changes by at least 1
+City.prototype.changePopulationByPercentage = function(p, params={}) {
+ if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
+ if (p === 0) {return;}
+ var change = Math.round(this.pop * (p/100));
+
+ //Population always changes by at least 1
+ if (params.nonZero && change === 0) {
+ p > 0 ? change = 1 : change = -1;
+ }
+
+ this.pop += change;
+ if (params.changeEstEqually) {
+ this.popEst += change;
+ if (this.popEst < 0) {this.popEst = 0;}
+ }
+ return change;
+}
+
+City.prototype.changeChaosByCount = function(n) {
+ if (isNaN(n)) {throw new Error("NaN passed into City.changeChaosByCount()");}
+ if (n === 0) {return;}
+ this.chaos += n;
+ if (this.chaos < 0) {this.chaos = 0;}
+}
+
+//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
+City.prototype.changeChaosByPercentage = function(p) {
+ if (isNaN(p)) {throw new Error("NaN passed into City.chaosChaosByPercentage()");}
+ if (p === 0) {return;}
+ var change = this.chaos * (p/100);
+ this.chaos += change;
+ if (this.chaos < 0) {this.chaos = 0;}
+}
+
+City.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("City", this);
+}
+City.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(City, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.City = City;
+
+function Skill(params={name:"foo", desc:"foo"}) {
+ if (params.name) {
+ this.name = params.name;
+ } else {
+ throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor");
+ }
+ if (params.desc) {
+ this.desc = params.desc;
+ } else {
+ throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor");
+ }
+ this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points
+ this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level
+
+ if (params.maxLvl) {this.maxLvl = params.maxLvl;}
+
+ //These benefits are additive. So total multiplier will be level (handled externally) times the
+ //effects below
+ if (params.successChanceAll) {this.successChanceAll = params.successChanceAll;}
+ if (params.successChanceStealth) {this.successChanceStealth = params.successChanceStealth;}
+ if (params.successChanceKill) {this.successChanceKill = params.successChanceKill;}
+ if (params.successChanceContract) {this.successChanceContract = params.successChanceContract;}
+ if (params.successChanceOperation) {this.successChanceOperation = params.successChanceOperation;}
+
+ //This multiplier affects everything that increases synthoid population/community estimate
+ //e.g. Field analysis, Investigation Op, Undercover Op
+ if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
+
+ if (params.actionTime) {this.actionTime = params.actionTime;}
+ if (params.effHack) {this.effHack = params.effHack;}
+ if (params.effStr) {this.effStr = params.effStr;}
+ if (params.effDef) {this.effDef = params.effDef;}
+ if (params.effDex) {this.effDex = params.effDex;}
+ if (params.effAgi) {this.effAgi = params.effAgi;}
+ if (params.effCha) {this.effCha = params.effCha;}
+
+ if (params.stamina) {this.stamina = params.stamina;}
+
+ //Equipment
+ if (params.weaponAbility) {this.weaponAbility = params.weaponAbility;}
+ if (params.gunAbility) {this.gunAbility = params.gunAbility;}
+}
+var Skills = {};
+var SkillNames = {
+ BladesIntuition: "Blade's Intuition",
+ Reaper: "Reaper",
+ Cloak: "Cloak",
+ Marksman: "Marksman",
+ WeaponProficiency: "Weapon Proficiency",
+ Overclock: "Overclock",
+ EvasiveSystem: "Evasive System",
+ ShortCircuit: "Short-Circuit",
+ DigitalObserver: "Digital Observer",
+ Datamancer: "Datamancer",
+ Tracer: "Tracer",
+ CybersEdge: "Cyber's Edge"
+}
+
+//Base Class for Contracts, Operations, and BlackOps
+function Action(params={}) {
+ this.name = params.name ? params.name : "";
+ this.desc = params.desc ? params.desc : "";
+
+ //Difficulty scales with level
+ //Exact formula is not set in stone
+ //Initial design: baseDifficulty * (difficultyFac ^ level)?
+ //difficulty Fac is slightly greater than 1
+ this.level = 1;
+ this.maxLevel = 1;
+ this.autoLevel = true;
+ this.baseDifficulty = params.baseDifficulty ? Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(params.baseDifficulty, 10) : 100;
+ this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;
+
+ //Rank increase/decrease is affected by this exponent
+ this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;
+
+ this.successes = 0;
+ this.failures = 0;
+
+ //All of these scale with level/difficulty
+ this.rankGain = params.rankGain ? params.rankGain : 0;
+ if (params.rankLoss) {this.rankLoss = params.rankLoss;}
+ if (params.hpLoss) {
+ this.hpLoss = params.hpLoss;
+ this.hpLost = 0;
+ }
+
+ //Action Category. Current categories are stealth and kill
+ this.isStealth = params.isStealth ? true : false;
+ this.isKill = params.isKill ? true : false;
+
+ //Number of this contract remaining, and its growth rate
+ //Growth rate is an integer and the count will increase by that integer every "cycle"
+ this.count = params.count ? params.count : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1e3, 25e3);
+ this.countGrowth = params.countGrowth ? params.countGrowth : Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5);
+
+ //Weighting of each stat in determining action success rate
+ var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};
+ this.weights = params.weights ? params.weights : defaultWeights;
+
+ //Check to make sure weights are summed properly
+ var sum = 0;
+ for (var weight in this.weights) {
+ if (this.weights.hasOwnProperty(weight)) {
+ sum += this.weights[weight];
+ }
+ }
+ if (sum - 1 >= 10 * Number.EPSILON) {
+ throw new Error("Invalid weights when constructing Action " + this.name +
+ ". The weights should sum up to 1. They sum up to :" + 1);
+ }
+
+ //Diminishing returns of stats (stat ^ decay where 0 <= decay <= 1)
+ var defaultDecays = {hack:0.9,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.9,int:0.9};
+ this.decays = params.decays ? params.decays : defaultDecays;
+ for (var decay in this.decays) {
+ if (this.decays.hasOwnProperty(decay)) {
+ if (this.decays[decay] > 1) {
+ throw new Error("Invalid decays when constructing " +
+ "Action " + this.name + ". " +
+ "Decay value cannot be greater than 1");
+ }
+ }
+ }
+}
+
+Action.prototype.getDifficulty = function() {
+ var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);
+ if (isNaN(difficulty)) {throw new Error("Calculated NaN in Action.getDifficulty()");}
+ return difficulty;
+}
+
+//@inst - Bladeburner Object
+//@params - options:
+// est (bool): Get success chance estimate instead of real success chance
+Action.prototype.getSuccessChance = function(inst, params={}) {
+ if (inst == null) {throw new Error("Invalid Bladeburner instance passed into Action.getSuccessChance");}
+ var difficulty = this.getDifficulty();
+ var competence = 0;
+ for (var stat in this.weights) {
+ if (this.weights.hasOwnProperty(stat)) {
+ var playerStatLvl = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].queryStatFromString(stat);
+ var key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
+ var effMultiplier = inst.skillMultipliers[key];
+ if (effMultiplier == null) {
+ console.log("ERROR: Failed to find Bladeburner Skill multiplier for: " + stat);
+ effMultiplier = 1;
+ }
+ competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));
+ }
+ }
+ competence *= inst.calculateStaminaPenalty();
+
+ //For Operations, factor in team members
+ if (this instanceof Operation || this instanceof BlackOperation) {
+ if (this.teamCount && this.teamCount > 0) {
+ this.teamCount = Math.min(this.teamCount, inst.teamSize);
+ var teamMultiplier = Math.pow(this.teamCount, 0.05);
+ competence *= teamMultiplier;
+ }
+ }
+
+ //Lower city population results in lower chances
+ if (!(this instanceof BlackOperation)) {
+ var city = inst.getCurrentCity();
+ if (params.est) {
+ competence *= (city.popEst / PopulationThreshold);
+ } else {
+ competence *= (city.pop / PopulationThreshold);
+ }
+
+ //Too high of a chaos results in lower chances
+ if (city.chaos > ChaosThreshold) {
+ var diff = 1 + (city.chaos - ChaosThreshold);
+ var mult = Math.pow(diff, 0.1);
+ difficulty *= mult;
+ }
+
+ //For Raid Operations, no communities = fail
+ if (this instanceof Operation && this.name === "Raid") {
+ if (city.comms <= 0) {return 0;}
+ }
+ }
+
+ //Factor skill multipliers into success chance
+ competence *= inst.skillMultipliers.successChanceAll;
+ if (this instanceof Operation || this instanceof BlackOperation) {
+ competence *= inst.skillMultipliers.successChanceOperation;
+ }
+ if (this instanceof Contract) {
+ competence *= inst.skillMultipliers.successChanceContract;
+ }
+ if (this.isStealth) {
+ competence *= inst.skillMultipliers.successChanceStealth;
+ }
+ if (this.isKill) {
+ competence *= inst.skillMultipliers.successChanceKill;
+ }
+
+ //Augmentation multiplier
+ competence *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_success_chance_mult;
+
+ if (isNaN(competence)) {throw new Error("Competence calculated as NaN in Action.getSuccessChance()");}
+ return Math.min(1, competence / difficulty);
+}
+
+//Tests for success. Should be called when an action has completed
+// @inst - Bladeburner Object
+Action.prototype.attempt = function(inst) {
+ return (Math.random() < this.getSuccessChance(inst));
+}
+
+Action.prototype.getActionTime = function(inst) {
+ var difficulty = this.getDifficulty();
+ var baseTime = difficulty / DifficultyToTimeFactor;
+ var skillFac = inst.skillMultipliers.actionTime; //Always < 1
+
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * inst.skillMultipliers.effAgi;
+ var effDexterity = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity * inst.skillMultipliers.effDex;
+ var statFac = 0.5 * (Math.pow(effAgility, 0.03) + Math.pow(effDexterity, 0.03)); //Always > 1
+
+ baseTime = Math.max(1, baseTime * skillFac / statFac);
+
+ if (this instanceof Contract) {
+ return Math.ceil(baseTime);
+ } else if (this instanceof Operation) {
+ return Math.ceil(baseTime);
+ } else if (this instanceof BlackOperation) {
+ return Math.ceil(baseTime * 1.5);
+ } else {
+ throw new Error("Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation");
+ }
+}
+
+Action.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Action", this);
+}
+Action.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Action, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Action = Action;
+var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
+
+//Action Identifier
+var ActionTypes = Object.freeze({
+ "Idle": 1,
+ "Contract": 2,
+ "Operation": 3,
+ "BlackOp": 4,
+ "BlackOperation": 4,
+ "Training": 5,
+ "Recruitment": 6,
+ "FieldAnalysis": 7,
+ "Field Analysis": 7
+});
+function ActionIdentifier(params={}) {
+ if (params.name) {this.name = params.name;}
+ if (params.type) {this.type = params.type;}
+}
+ActionIdentifier.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("ActionIdentifier", this);
+}
+ActionIdentifier.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(ActionIdentifier, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.ActionIdentifier = ActionIdentifier;
+
+//Contracts
+function Contract(params={}) {
+ Action.call(this, params);
+}
+Contract.prototype = Object.create(Action.prototype);
+Contract.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Contract", this);
+}
+Contract.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Contract, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Contract = Contract;
+
+//Operations
+function Operation(params={}) {
+ Action.call(this, params);
+ this.reqdRank = params.reqdRank ? params.reqdRank : 100;
+ this.teamCount = params.teamCount ? params.teamCount : 0; //# of team members to use
+}
+Operation.prototype = Object.create(Action.prototype);
+Operation.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Operation", this);
+}
+Operation.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Operation, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Operation = Operation;
+
+//Black Operations
+function BlackOperation(params={}) {
+ Operation.call(this, params);
+
+ //Black ops are one time missions
+ this.count = 1;
+ this.countGrowth = 0;
+}
+BlackOperation.prototype = Object.create(Action.prototype);
+BlackOperation.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("BlackOperation", this);
+}
+BlackOperation.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(BlackOperation, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.BlackOperation = BlackOperation;
+var BlackOperations = {};
+
+function Bladeburner(params={}) {
+ this.numHosp = 0; //Number of hospitalizations
+ this.moneyLost = 0; //Money lost due to hospitalizations
+ this.rank = 0;
+ this.maxRank = 0; //Used to determine skill points
+
+ this.skillPoints = 0;
+ this.totalSkillPoints = 0;
+
+ this.teamSize = 0; //Number of team members
+ this.teamLost = 0; //Number of team members lost
+
+ this.storedCycles = 0;
+
+ this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600); //5-10 minutes
+
+ //These times are in seconds
+ this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)
+ this.actionTimeCurrent = 0;
+
+ //ActionIdentifier Object
+ var idleActionType = ActionTypes["Idle"];
+ this.action = new ActionIdentifier({type:idleActionType});
+
+ this.cities = {};
+ for (var i = 0; i < CityNames.length; ++i) {
+ this.cities[CityNames[i]] = new City({name:CityNames[i]});
+ }
+ this.city = _Location_js__WEBPACK_IMPORTED_MODULE_3__["Locations"].Sector12;
+
+ //Map of SkillNames -> level
+ this.skills = {};
+ this.skillMultipliers = {};
+ this.updateSkillMultipliers(); //Calls resetSkillMultipliers()
+
+ //Max Stamina is based on stats and Bladeburner-specific bonuses
+ this.staminaBonus = 0; //Gained from training
+ this.maxStamina = 0;
+ this.calculateMaxStamina();
+ this.stamina = this.maxStamina;
+
+ //Contracts and Operations objects. These objects have unique
+ //properties because they are randomized in each instance and have stats like
+ //successes/failures, so they need to be saved/loaded by the game.
+ this.contracts = {};
+ this.operations = {};
+
+ //Object that contains name of all Black Operations that have been completed
+ this.blackops = {};
+
+ //Flags for whether these actions should be logged to console
+ this.logging = {
+ general:true,
+ contracts:true,
+ ops:true,
+ blackops:true,
+ events:true,
+ }
+
+ //Simple automation values
+ this.automateEnabled = false;
+ this.automateActionHigh = 0;
+ this.automateThreshHigh = 0; //Stamina Threshold
+ this.automateActionLow = 0;
+ this.automateThreshLow = 0; //Stamina Threshold
+
+ //Initialization
+ initBladeburner();
+ this.initializeDomElementRefs();
+ if (params.new) {this.create();}
+}
+
+Bladeburner.prototype.create = function() {
+ this.contracts["Tracking"] = new Contract({
+ name:"Tracking",
+ desc:"Identify and locate Synthoids. This contract involves reconnaissance " +
+ "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
" +
+ "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " +
+ "whatever city you are currently in.",
+ baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,
+ rankGain:0.3, hpLoss:0.5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5),
+ weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},
+ isStealth:true
+ });
+ this.contracts["Bounty Hunter"] = new Contract({
+ name:"Bounty Hunter",
+ desc:"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
" +
+ "Successfully completing a Bounty Hunter contract will lower the population in your " +
+ "current city, and will also increase its chaos level.",
+ baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,
+ rankGain:0.9, hpLoss:1,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 3),
+ weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
+ isKill:true
+ });
+ this.contracts["Retirement"] = new Contract({
+ name:"Retirement",
+ desc:"Hunt down and retire (kill) rogue Synthoids.
" +
+ "Successfully copmleting a Retirement contract will lower the population in your current " +
+ "city, and will also increase its chaos level.",
+ baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,
+ rankGain:0.6, hpLoss:1,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1,4),
+ weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},
+ decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
+ isKill:true
+ });
+
+ this.operations["Investigation"] = new Operation({
+ name:"Investigation",
+ desc:"As a field agent, investigate and identify Synthoid " +
+ "populations, movements, and operations.
Successful " +
+ "Investigation ops will increase the accuracy of your " +
+ "synthoid data.
" +
+ "You will NOT lose HP from failed Investigation ops.",
+ baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,
+ rankGain:2, rankLoss:0.2,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 400), countGrowth:1,
+ weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},
+ decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Undercover Operation"] = new Operation({
+ name:"Undercover Operation",
+ desc:"Conduct undercover operations to identify hidden " +
+ "and underground Synthoid communities and organizations.
" +
+ "Successful Undercover ops will increase the accuracy of your synthoid " +
+ "data.",
+ baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,
+ rankGain:4, rankLoss:0.4, hpLoss:2,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 300), countGrowth:1,
+ weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},
+ decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Sting Operation"] = new Operation({
+ name:"Sting Operation",
+ desc:"Conduct a sting operation to bait and capture particularly " +
+ "notorious Synthoid criminals.",
+ baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,
+ rankGain:5, rankLoss:0.5, hpLoss:2.5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25,400), countGrowth:0.75,
+ weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},
+ decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},
+ isStealth:true
+ });
+ this.operations["Raid"] = new Operation({
+ name:"Raid",
+ desc:"Lead an assault on a known Synthoid community. Note that " +
+ "there must be an existing Synthoid community in your current city " +
+ "in order for this Operation to be successful",
+ baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,
+ rankGain:50,rankLoss:2.5,hpLoss:50,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 150), countGrowth:0.2,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
+ isKill:true
+ });
+ this.operations["Stealth Retirement Operation"] = new Operation({
+ name:"Stealth Retirement Operation",
+ desc:"Lead a covert operation to retire Synthoids. The " +
+ "objective is to complete the task without " +
+ "drawing any attention. Stealth and discretion are key.",
+ baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,
+ rankGain:20, rankLoss:2, hpLoss:10,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 250), countGrowth:0.1,
+ weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
+ decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
+ isStealth:true, isKill:true
+ });
+ this.operations["Assassination"] = new Operation({
+ name:"Assassination",
+ desc:"Assassinate Synthoids that have been identified as " +
+ "important, high-profile social and political leaders " +
+ "in the Synthoid communities.",
+ baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,
+ rankGain:40, rankLoss:4, hpLoss:5,
+ count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(25, 200), countGrowth:0.1,
+ weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},
+ isStealth:true, isKill:true
+ });
+}
+
+Bladeburner.prototype.storeCycles = function(numCycles=1) {
+ this.storedCycles += numCycles;
+}
+
+Bladeburner.prototype.process = function() {
+ //If the Player starts doing some other actions, set action to idle and alert
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].isWorking) {
+ if (this.action.type !== ActionTypes["Idle"]) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Your Bladeburner action was cancelled because you started " +
+ "doing something else");
+ }
+ this.resetAction();
+ }
+
+ //A 'tick' for this mechanic is one second (= 5 game cycles)
+ if (this.storedCycles >= CyclesPerSecond) {
+ var seconds = Math.floor(this.storedCycles / CyclesPerSecond);
+ seconds = Math.min(seconds, 5); //Max of 5 'ticks'
+ this.storedCycles -= seconds * CyclesPerSecond;
+
+ //Stamina
+ this.calculateMaxStamina();
+ this.stamina += (this.calculateStaminaGainPerSecond() * seconds);
+ this.stamina = Math.min(this.maxStamina, this.stamina);
+
+ //Count increase for contracts/operations
+ for (var contractName in this.contracts) {
+ if (this.contracts.hasOwnProperty(contractName)) {
+ var contract = this.contracts[contractName];
+ contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);
+ }
+ }
+ for (var operationName in this.operations) {
+ if (this.operations.hasOwnProperty(operationName)) {
+ var op = this.operations[operationName];
+ op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);
+ }
+ }
+
+ //Chaos goes down very slowly
+ for (var i = 0; i < CityNames.length; ++i) {
+ var city = this.cities[CityNames[i]];
+ if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
+ city.chaos -= (0.0001 * seconds);
+ city.chaos = Math.max(0, city.chaos);
+ }
+
+ //Random Events
+ this.randomEventCounter -= seconds;
+ if (this.randomEventCounter <= 0) {
+ this.randomEvent();
+ this.randomEventCounter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600);
+ }
+
+ this.processAction(seconds);
+
+ //Automation
+ if (this.automateEnabled) {
+ if (this.stamina <= this.automateThreshLow) {
+ if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {
+ this.action = this.automateActionLow;
+ this.startAction(this.action);
+ }
+ } else if (this.stamina >= this.automateThreshHigh) {
+ if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {
+ this.action = this.automateActionHigh;
+ this.startAction(this.action);
+ }
+ }
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
+ this.updateContent();
+ }
+ }
+}
+
+Bladeburner.prototype.calculateMaxStamina = function() {
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * this.skillMultipliers.effAgi;
+ var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);
+ maxStamina *= this.skillMultipliers.stamina;
+ maxStamina *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_max_stamina_mult;
+ if (isNaN(maxStamina)) {throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()");}
+ this.maxStamina = maxStamina;
+}
+
+Bladeburner.prototype.calculateStaminaGainPerSecond = function() {
+ var effAgility = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility * this.skillMultipliers.effAgi;
+ var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;
+ var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);
+ return gain * (this.skillMultipliers.stamina * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_stamina_gain_mult);
+}
+
+Bladeburner.prototype.calculateStaminaPenalty = function() {
+ return Math.min(1, this.stamina / (0.5 * this.maxStamina));
+}
+
+Bladeburner.prototype.changeRank = function(change) {
+ if (isNaN(change)) {throw new Error("NaN passed into Bladeburner.changeRank()");}
+ this.rank += change;
+ if (this.rank < 0) {this.rank = 0;}
+ this.maxRank = Math.max(this.rank, this.maxRank);
+
+ var bladeburnersFactionName = "Bladeburners";
+ if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["factionExists"])(bladeburnersFactionName)) {
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][bladeburnersFactionName];
+ if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
+ throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
+ }
+ if (bladeburnerFac.isMember) {
+ bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].faction_rep_mult);
+ }
+ }
+
+ //Gain skill points. You get 1 every 4 ranks
+ var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;
+ if (this.maxRank >= rankNeededForSp) {
+ //Calculate how many skill points to gain
+ var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);
+ this.skillPoints += gainedSkillPoints;
+ this.totalSkillPoints += gainedSkillPoints;
+ }
+}
+
+Bladeburner.prototype.getCurrentCity = function() {
+ var city = this.cities[this.city];
+ if (!(city instanceof City)) {
+ throw new Error("Bladeburner.getCurrentCity() did not properly return a City object");
+ }
+ return city;
+}
+
+Bladeburner.prototype.resetSkillMultipliers = function() {
+ this.skillMultipliers = {
+ successChanceAll:1,
+ successChanceStealth:1,
+ successChanceKill:1,
+ successChanceContract:1,
+ successChanceOperation:1,
+ successChanceEstimate:1,
+ actionTime:1,
+ effHack:1,
+ effStr:1,
+ effDef:1,
+ effDex:1,
+ effAgi:1,
+ effCha:1,
+ effInt:1,
+ stamina:1,
+ weaponAbility:1,
+ gunAbility:1,
+ };
+}
+
+Bladeburner.prototype.updateSkillMultipliers = function() {
+ this.resetSkillMultipliers();
+ for (var skillName in this.skills) {
+ if (this.skills.hasOwnProperty(skillName)) {
+ var skill = Skills[skillName];
+ if (skill == null) {
+ throw new Error("Could not find Skill Object for: " + skillName);
+ }
+ var level = this.skills[skillName];
+ if (level == null || level <= 0) {continue;} //Not upgraded
+
+ var multiplierNames = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multiplierNames.length; ++i) {
+ var multiplierName = multiplierNames[i];
+ if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {
+ var value = skill[multiplierName] * level;
+ var multiplierValue = 1 + (value / 100);
+ if (multiplierName === "actionTime") {
+ multiplierValue = 1 - (value / 100);
+ }
+ this.skillMultipliers[multiplierName] *= multiplierValue;
+ }
+ }
+ }
+ }
+}
+
+Bladeburner.prototype.upgradeSkill = function(skill) {
+ //This does NOT handle deduction of skill points
+ var skillName = skill.name;
+ if (this.skills[skillName]) {
+ ++this.skills[skillName];
+ } else {
+ this.skills[skillName] = 1;
+ }
+ if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {
+ throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]);
+ }
+ this.updateSkillMultipliers();
+}
+
+Bladeburner.prototype.getActionObject = function(actionId) {
+ //Given an ActionIdentifier object, returns the corresponding
+ //Contract, Operation, or BlackOperation object
+ switch (actionId.type) {
+ case ActionTypes["Contract"]:
+ return this.contracts[actionId.name];
+ break;
+ case ActionTypes["Operation"]:
+ return this.operations[actionId.name];
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ return BlackOperations[actionId.name];
+ break;
+ default:
+ return null;
+ console.log("WARNING: Bladeburner.getActionObject() called with an unexpected " +
+ "ActionIdentifier type: " + actionId.type);
+ }
+}
+
+//Sets the player to the "IDLE" action
+Bladeburner.prototype.resetAction = function() {
+ this.action = new ActionIdentifier({type:ActionTypes.Idle});
+}
+
+Bladeburner.prototype.startAction = function(actionId) {
+ this.action = actionId;
+ this.actionTimeCurrent = 0;
+ switch (actionId.type) {
+ case ActionTypes["Idle"]:
+ this.actionTimeToComplete = 0;
+ break;
+ case ActionTypes["Contract"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error("Failed to get Contract Object for: " + actionId.name);
+ }
+ if (action.count < 1) {return this.resetAction();}
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Operation"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error ("Failed to get Operation Object for: " + actionId.name);
+ }
+ if (action.count < 1) {return this.resetAction();}
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ try {
+ var action = this.getActionObject(actionId);
+ if (action == null) {
+ throw new Error("Failed to get BlackOperation object for: " + actionId.name);
+ }
+ this.actionTimeToComplete = action.getActionTime(this);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Training"]:
+ this.actionTimeToComplete = 30;
+ break;
+ case ActionTypes["Recruitment"]:
+ var effCharisma = _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma * this.skillMultipliers.effCha;
+ var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;
+ var time = Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));
+ this.actionTimeToComplete = time;
+ break;
+ case ActionTypes["FieldAnalysis"]:
+ case ActionTypes["Field Analysis"]:
+ this.actionTimeToComplete = 30;
+ break;
+ default:
+ throw new Error("Invalid Action Type in Bladeburner.startAction(): " + actionId.type);
+ break;
+ }
+}
+
+Bladeburner.prototype.processAction = function(seconds) {
+ if (this.action.type === ActionTypes["Idle"]) {return;}
+ if (this.actionTimeToComplete <= 0) {
+ console.log("action.type: " + this.action.type);
+ throw new Error("Invalid actionTimeToComplete value: " + this.actionTimeToComplete);
+ }
+ if (!(this.action instanceof ActionIdentifier)) {
+ throw new Error("Bladeburner.action is not an ActionIdentifier Object");
+ }
+
+ this.actionTimeCurrent += seconds;
+ if (this.actionTimeCurrent >= this.actionTimeToComplete) {
+ return this.completeAction();
+ }
+}
+
+Bladeburner.prototype.completeAction = function() {
+ switch (this.action.type) {
+ case ActionTypes["Contract"]:
+ case ActionTypes["Operation"]:
+ try {
+ var isOperation = (this.action.type === ActionTypes["Operation"]);
+ var action = this.getActionObject(this.action);
+ if (action == null) {
+ throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
+ }
+ var difficulty = action.getDifficulty();
+ var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
+ var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);
+
+ //Stamina loss is based on difficulty
+ this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
+ if (this.stamina < 0) {this.stamina = 0;}
+
+ //Process Contract/Operation success/failure
+ if (action.attempt(this)) {
+ this.gainActionStats(action, true);
+ ++action.successes;
+ --action.count;
+
+ //Earn money for contracts
+ var moneyGain = 0;
+ if (!isOperation) {
+ moneyGain = ContractBaseMoneyGain * rewardMultiplier;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainMoney(moneyGain);
+ }
+
+ if (isOperation) {
+ action.maxLevel = Math.floor(action.successes / OperationSuccessesPerLevel) + 1;
+ } else {
+ action.maxLevel = Math.floor(action.successes / ContractSuccessesPerLevel) + 1;
+ }
+ if (action.rankGain) {
+ var gain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankGain * rewardMultiplier, 10);
+ this.changeRank(gain);
+ if (isOperation && this.logging.ops) {
+ this.log(action.name + " successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(gain, 3) + " rank");
+ } else if (!isOperation && this.logging.contracts) {
+ this.log(action.name + " contract successfully completed! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(gain, 3) + " rank and " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(moneyGain).format("$0.000a"));
+ }
+ }
+ isOperation ? this.completeOperation(true) : this.completeContract(true);
+ } else {
+ this.gainActionStats(action, false);
+ ++action.failures;
+ var loss = 0, damage = 0;
+ if (action.rankLoss) {
+ loss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankLoss * rewardMultiplier, 10);
+ this.changeRank(-1 * loss);
+ }
+ if (action.hpLoss) {
+ damage = action.hpLoss * difficultyMultiplier;
+ damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(damage, 10));
+ this.hpLost += damage;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].takeDamage(damage)) {
+ ++this.numHosp;
+ this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].max_hp);
+ }
+ }
+ var logLossText = "";
+ if (loss > 0) {logLossText += "Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(loss, 3) + " rank.";}
+ if (damage > 0) {logLossText += "Took " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(damage, 0) + " damage.";}
+ if (isOperation && this.logging.ops) {
+ this.log(action.name + " failed! " + logLossText);
+ } else if (!isOperation && this.logging.contracts) {
+ this.log(action.name + " contract failed! " + logLossText);
+ }
+ isOperation ? this.completeOperation(false) : this.completeContract(false);
+ }
+ if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel
+ this.startAction(this.action); //Repeat action
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["BlackOp"]:
+ case ActionTypes["BlackOperation"]:
+ try {
+ var action = this.getActionObject(this.action);
+ if (action == null || !(action instanceof BlackOperation)) {
+ throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
+ }
+ var difficulty = action.getDifficulty();
+ var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
+
+ //Stamina loss is based on difficulty
+ this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
+ if (this.stamina < 0) {this.stamina = 0;}
+
+ //Team loss variables
+ var teamCount = action.teamCount, teamLossMax;
+
+ if (action.attempt(this)) {
+ this.gainActionStats(action, true);
+ action.count = 0;
+ this.blackops[action.name] = true;
+ var rankGain = 0;
+ if (action.rankGain) {
+ rankGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankGain, 10);
+ this.changeRank(rankGain);
+ }
+ teamLossMax = Math.ceil(teamCount/2);
+
+ //Operation Daedalus
+ if (action.name === "Operation Daedalus") {
+ this.resetAction();
+ return Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_5__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bitNodeN);
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {
+ this.createActionAndSkillsContent();
+ }
+
+ if (this.logging.blackops) {
+ this.log(action.name + " successful! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(rankGain, 1) + " rank");
+ }
+ } else {
+ this.gainActionStats(action, false);
+ var rankLoss = 0, damage = 0;
+ if (action.rankLoss) {
+ rankLoss = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(action.rankLoss, 10);
+ this.changeRank(-1 * rankLoss);
+ }
+ if (action.hpLoss) {
+ damage = action.hpLoss * difficultyMultiplier;
+ damage = Math.ceil(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["addOffset"])(damage, 10));
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].takeDamage(damage)) {
+ ++this.numHosp;
+ this.moneyLost += (_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HospitalCostPerHp * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].max_hp);
+ }
+ }
+ teamLossMax = Math.floor(teamCount);
+
+ if (this.logging.blackops) {
+ this.log(action.name + " failed! Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(rankLoss, 1) + " rank and took" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(damage, 0) + " damage");
+ }
+ }
+
+ this.resetAction(); //Stop regardless of success or fail
+
+ //Calculate team lossses
+ if (teamCount >= 1) {
+ var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, teamLossMax);
+ this.teamSize -= losses;
+ this.teamLost += losses;
+ if (this.logging.blackops) {
+ this.log("You lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(losses, 0) + " team members during " + action.name);
+ }
+ }
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+ break;
+ case ActionTypes["Training"]:
+ this.stamina -= (0.5 * BaseStaminaLoss);
+ var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult,
+ defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult,
+ dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult,
+ agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult,
+ staminaGain = 0.04 * this.skillMultipliers.stamina;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(strExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(defExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDexterityExp(dexExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainAgilityExp(agiExpGain);
+ this.staminaBonus += (staminaGain);
+ if (this.logging.general) {
+ this.log("Training completed. Gained: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(strExpGain, 1) + " str exp, " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(defExpGain, 1) + " def exp, " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(dexExpGain, 1) + " dex exp, " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(agiExpGain, 1) + " agi exp, " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(staminaGain, 3) + " max stamina");
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ case ActionTypes["FieldAnalysis"]:
+ case ActionTypes["Field Analysis"]:
+ //Does not use stamina. Effectiveness depends on hacking, int, and cha
+ var eff = 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_skill, 0.3) +
+ 0.04 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].intelligence, 0.9) +
+ 0.02 * Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma, 0.3);
+ eff *= _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_analysis_mult;
+ if (isNaN(eff) || eff < 0) {
+ throw new Error("Field Analysis Effectiveness calculated to be NaN or negative");
+ }
+ var hackingExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_exp_mult,
+ charismaExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma_exp_mult;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainHackingExp(hackingExpGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainIntelligenceExp(BaseIntGain);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(charismaExpGain);
+ this.changeRank(0.1);
+ console.log("DEBUG: Field Analysis effectiveness is " + (eff * this.skillMultipliers.successChanceEstimate));
+ this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
+ if (this.logging.general) {
+ this.log("Field analysis completed. Gained 0.1 rank, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(hackingExpGain, 1) + " hacking exp, and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(charismaExpGain, 1) + " charisma exp");
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ case ActionTypes["Recruitment"]:
+ var successChance = Math.pow(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma, 0.45) / (this.teamSize + 1);
+ console.log("Bladeburner recruitment success chance: " + successChance);
+ if (Math.random() < successChance) {
+ var expGain = 2 * BaseStatGain * this.actionTimeToComplete;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(expGain);
+ ++this.teamSize;
+ if (this.logging.general) {
+ this.log("Successfully recruited a team member! Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(expGain, 1) + " charisma exp");
+ }
+ } else {
+ var expGain = BaseStatGain * this.actionTimeToComplete;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(expGain);
+ if (this.logging.general) {
+ this.log("Failed to recruit a team member. Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(expGain, 1) + " charisma exp");
+ }
+ }
+ this.startAction(this.action); //Repeat action
+ break;
+ default:
+ break;
+ }
+}
+
+Bladeburner.prototype.completeContract = function(success) {
+ if (this.action.type !== ActionTypes.Contract) {
+ throw new Error("completeContract() called even though current action is not a Contract");
+ }
+ var city = this.getCurrentCity();
+ if (success) {
+ switch (this.action.name) {
+ case "Tracking":
+ //Increase estimate accuracy by a relatively small amount
+ city.improvePopulationEstimateByCount(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 1e3));
+ break;
+ case "Bounty Hunter":
+ city.changePopulationByCount(-1, {estChange:-1});
+ city.changeChaosByCount(0.02);
+ break;
+ case "Retirement":
+ city.changePopulationByCount(-1, {estChange:-1});
+ city.changeChaosByCount(0.04);
+ break;
+ default:
+ throw new Error("Invalid Action name in completeContract: " + this.action.name);
+ }
+ }
+}
+
+Bladeburner.prototype.completeOperation = function(success) {
+ if (this.action.type !== ActionTypes.Operation) {
+ throw new Error("completeOperation() called even though current action is not an Operation");
+ }
+ var action = this.getActionObject(this.action);
+ if (action == null) {
+ throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
+ }
+
+ //Calculate team losses
+ var teamCount = action.teamCount, max;
+ if (teamCount >= 1) {
+ if (success) {
+ max = Math.ceil(teamCount/2);
+ } else {
+ max = Math.floor(teamCount)
+ }
+ var losses = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, max);
+ this.teamSize -= losses;
+ this.teamLost += losses;
+ if (this.logging.ops && losses > 0) {
+ this.log("Lost " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(losses, 0) + " team members during this " + action.name);
+ }
+ }
+
+ var city = this.getCurrentCity();
+ if (this.logging.ops) {
+ if (success) {
+ this.log(action.name + " completed successfully! ")
+ } else {
+
+ }
+ }
+ switch (action.name) {
+ case "Investigation":
+ if (success) {
+ city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);
+ if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
+ city.improveCommunityEstimate(1);
+ }
+ } else {
+ this.triggerPotentialMigration(this.city, 0.1);
+ }
+ break;
+ case "Undercover Operation":
+ if (success) {
+ city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);
+ if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
+ city.improveCommunityEstimate(1);
+ }
+ } else {
+ this.triggerPotentialMigration(this.city, 0.15);
+ }
+ break;
+ case "Sting Operation":
+ if (success) {
+ city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});
+ }
+ city.changeChaosByCount(0.1);
+ break;
+ case "Raid":
+ if (success) {
+ city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});
+ --city.comms;
+ --city.commsEst;
+ } else {
+ var change = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-3, -1);
+ city.changePopulationByPercentage(change, {nonZero:true});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5));
+ break;
+ case "Stealth Retirement Operation":
+ if (success) {
+ city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-3, -1));
+ break;
+ case "Assassination":
+ if (success) {
+ city.changePopulationByCount(-1, {estChange:-1});
+ }
+ city.changeChaosByPercentage(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(-5, 5));
+ break;
+ default:
+ throw new Error("Invalid Action name in completeOperation: " + this.action.name);
+ }
+}
+
+//Process stat gains from Contracts, Operations, and Black Operations
+//@action(Action obj) - Derived action class
+//@success(bool) - Whether action was successful
+Bladeburner.prototype.gainActionStats = function(action, success) {
+ var difficulty = action.getDifficulty();
+
+ //Gain multiplier based on difficulty. If this changes then the
+ //same variable calculated in completeAction() needs to change too
+ var difficultyMult = Math.pow(difficulty, 0.21);
+
+ var time = this.actionTimeToComplete;
+ var successMult = success ? 1 : 0.5;
+
+ var unweightedGain = time * BaseStatGain * successMult * difficultyMult;
+ var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainHackingExp(unweightedGain * action.weights.hack * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].hacking_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(unweightedGain * action.weights.str * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(unweightedGain * action.weights.def * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDexterityExp(unweightedGain * action.weights.dex * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainAgilityExp(unweightedGain * action.weights.agi * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainCharismaExp(unweightedGain * action.weights.cha * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].charisma_exp_mult);
+ _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainIntelligenceExp(unweightedIntGain * action.weights.int);
+}
+
+Bladeburner.prototype.randomEvent = function() {
+ var chance = Math.random();
+
+ //Choose random source/destination city for events
+ var sourceCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
+ var sourceCity = this.cities[sourceCityName];
+ if (!(sourceCity instanceof City)) {
+ throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
+ }
+
+ var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
+ while (destCityName === sourceCityName) {
+ destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
+ }
+ var destCity = this.cities[destCityName];
+
+ if (!(sourceCity instanceof City) || !(destCity instanceof City)) {
+ throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
+ }
+
+ if (chance <= 0.05) {
+ //New Synthoid Community, 5%
+ ++sourceCity.comms;
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a new Synthoid community was formed in a city");
+ }
+ } else if (chance <= 0.1) {
+ //Synthoid Community Migration, 5%
+ if (sourceCity.comms <= 0) {
+ //If no comms in source city, then instead trigger a new Synthoid community event
+ ++sourceCity.comms;
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a new Synthoid community was formed in a city");
+ }
+ } else {
+ --sourceCity.comms;
+ ++destCity.comms;
+
+ //Change pop
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(10, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ destCity.pop += count;
+
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city");
+ }
+ }
+ } else if (chance <= 0.3) {
+ //New Synthoids (non community), 20%
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(8, 24) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop += count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
+ }
+ } else if (chance <= 0.5) {
+ //Synthoid migration (non community) 20%
+ this.triggerMigration(sourceCityName);
+ if (this.logging.events) {
+ this.log("Intelligence indicates that a large number of Synthoids migrated from " + sourceCityName + " to some other city");
+ }
+ } else if (chance <= 0.7) {
+ //Synthoid Riots (+chaos), 20%
+ sourceCity.chaos += 1;
+ sourceCity.chaos *= (1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(5, 10) / 100);
+ if (this.logging.events) {
+ this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
+ }
+ } else if (chance <= 0.9) {
+ //Less Synthoids, 20%
+ var percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(5, 20) / 100;
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ if (this.logging.events) {
+ this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
+ }
+ }
+ //20% chance of nothing happening
+}
+
+Bladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {
+ if (chance == null || isNaN(chance)) {
+ console.log("ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()");
+ }
+ if (chance > 1) {chance /= 100;}
+ if (Math.random() < chance) {this.triggerMigration(sourceCityName);}
+}
+
+Bladeburner.prototype.triggerMigration = function(sourceCityName) {
+ var destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
+ while (destCityName === sourceCityName) {
+ destCityName = CityNames[Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(0, 5)];
+ }
+ var destCity = this.cities[destCityName];
+ var sourceCity = this.cities[sourceCityName];
+ if (destCity == null || sourceCity == null) {
+ throw new Error("Failed to find City with name: " + destCityName);
+ }
+ var rand = Math.random(), percentage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(3, 15) / 100;
+
+ if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration
+ percentage *= Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(2, 4); //Migration increases population change
+ --sourceCity.comms;
+ ++destCity.comms;
+ }
+ var count = Math.round(sourceCity.pop * percentage);
+ sourceCity.pop -= count;
+ destCity.pop += count;
+}
+
+var DomElems = {};
+
+Bladeburner.prototype.initializeDomElementRefs = function() {
+ DomElems = {
+ bladeburnerDiv: null,
+
+ //Main Divs
+ overviewConsoleParentDiv: null,
+
+ overviewDiv: null, //Overview of stats that stays fixed on left
+ actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)
+ currentTab: null, //Contracts, Operations, Black Ops, Skills
+
+ consoleDiv: null,
+ consoleTable: null,
+ consoleInputRow: null, //tr
+ consoleInputCell: null, //td
+ consoleInputHeader: null, //"> "
+ consoleInput: null, //Actual input element
+
+ //Overview Content
+ overviewRank: null,
+ overviewStamina: null,
+ overviewStaminaHelpTip: null,
+ overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city
+ overviewEstPop: null,
+ overviewEstPopHelpTip: null,
+ overviewEstComms: null,
+ overviewChaos: null,
+ overviewSkillPoints: null,
+ overviewAugSuccessMult: null,
+ overviewAugMaxStaminaMult: null,
+ overviewAugStaminaGainMult: null,
+ overviewAugAnalysisMult: null,
+
+ //Actions and Skills Content
+ actionsAndSkillsDesc: null,
+ actionsAndSkillsList: null, //ul element of all UI elements in this panel
+ generalActions: {},
+ contracts: {},
+ operations: {},
+ blackops: {},
+ skills: {},
+ };
+}
+
+Bladeburner.prototype.createContent = function() {
+ DomElems.bladeburnerDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ id:"bladeburner-container", position:"fixed", class:"generic-menupage-container",
+ });
+
+ //Parent Div for Overview and Console
+ DomElems.overviewConsoleParentDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ height:"60%", display:"block", position:"relative",
+ });
+
+ //Overview and Action/Skill pane
+ DomElems.overviewDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ width:"30%", display:"inline-block", border:"1px solid white",
+ });
+
+ DomElems.actionAndSkillsDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ height:"60%", width:"70%", display:"block",
+ border:"1px solid white", margin:"6px", padding:"6px",
+ });
+
+ DomElems.currentTab = "general";
+
+ this.createOverviewContent();
+ this.createActionAndSkillsContent();
+
+ //Console
+ DomElems.consoleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-console-div",
+ clickListener:()=>{
+ if (DomElems.consoleInput instanceof Element) {
+ DomElems.consoleInput.focus();
+ }
+ return false;
+ }
+ });
+ DomElems.consoleTable = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("table", {class:"bladeburner-console-table"});
+ DomElems.consoleInputRow = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("tr", {class:"bladeburner-console-input-row", id:"bladeubrner-console-input-row"});
+ DomElems.consoleInputCell = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("td", {class:"bladeburner-console-input-cell"});
+ DomElems.consoleInputHeader = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {innerText:"> "});
+ DomElems.consoleInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
+ type:"text", class:"bladeburner-console-input", tabIndex:1,
+ onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}
+ });
+
+ DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);
+ DomElems.consoleInputCell.appendChild(DomElems.consoleInput);
+ DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);
+ DomElems.consoleTable.appendChild(DomElems.consoleInputRow);
+ DomElems.consoleDiv.appendChild(DomElems.consoleTable);
+
+ DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);
+ DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);
+ DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);
+ DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);
+
+ document.getElementById("entire-game-container").appendChild(DomElems.bladeburnerDiv);
+
+ this.postToConsole("Bladeburner Console BETA");
+ this.postToConsole("Type 'help' to see console commands");
+ DomElems.consoleInput.focus();
+}
+
+Bladeburner.prototype.clearContent = function() {
+ if (DomElems.bladeburnerDiv instanceof Element) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.bladeburnerDiv);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElement"])(DomElems.bladeburnerDiv);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems);
+ this.initializeDomElementRefs();
+}
+
+Bladeburner.prototype.createOverviewContent = function() {
+ if (DomElems.overviewDiv == null) {
+ throw new Error("Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null");
+ }
+
+ DomElems.overviewRank = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"Rank: ",
+ display:"inline-block",
+ tooltip:"Your rank within the Bladeburner division",
+ });
+
+ DomElems.overviewStamina = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"inline-block",
+ });
+
+ DomElems.overviewStaminaHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ innerText:"?", class:"help-tip",
+ clickListener:()=>{
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Performing actions will use up your stamina.
" +
+ "Your max stamina is determined primarily by your agility stat.
" +
+ "Your stamina gain rate is determined by both your agility and your " +
+ "max stamina. Higher max stamina leads to a higher gain rate.
" +
+ "Once your " +
+ "stamina falls below 50% of its max value, it begins to negatively " +
+ "affect the success rate of your contracts/operations. This penalty " +
+ "is shown in the overview panel. If the penalty is 15%, then this means " +
+ "your success rate would be multipled by 85% (100 - 15).
" +
+ "Your max stamina and stamina gain rate can also be increased by " +
+ "training, or through skills and Augmentation upgrades.");
+ }
+ });
+
+ DomElems.overviewGen1 = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ });
+
+ DomElems.overviewEstPop = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"Est. Synthoid Population: ",
+ display:"inline-block",
+ tooltip:"This is your Bladeburner division's estimate of how many Synthoids exist " +
+ "in your current city."
+ });
+
+ DomElems.overviewEstPopHelpTip = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ innerText:"?", class:"help-tip",
+ clickListener:()=>{
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("The success rate of your contracts/operations depends on " +
+ "the population of Synthoids in your current city. " +
+ "The success rate that is shown to you is only an estimate, " +
+ "and it is based on your Synthoid population estimate.
" +
+ "Therefore, it is important that this Synthoid population estimate " +
+ "is accurate so that you have a better idea of your " +
+ "success rate for contracts/operations. Certain " +
+ "actions will increase the accuracy of your population " +
+ "estimate.
" +
+ "The Synthoid populations of cities can change due to your " +
+ "actions or random events. If random events occur, they will " +
+ "be logged in the Bladeburner Console.");
+ }
+ });
+
+ DomElems.overviewEstComms = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"Est. Synthoid Communities: ",
+ display:"inline-block",
+ tooltip:"This is your Bladeburner divison's estimate of how many Synthoid " +
+ "communities exist in your current city.",
+ });
+
+ DomElems.overviewChaos = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"City Chaos: ",
+ display:"inline-block",
+ tooltip:"The city's chaos level due to tensions and conflicts between humans and Synthoids. " +
+ "Having too high of a chaos level can make contracts and operations harder."
+ });
+
+ DomElems.overviewSkillPoints = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
+
+ DomElems.overviewAugSuccessMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugMaxStaminaMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugStaminaGainMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
+ DomElems.overviewAugAnalysisMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {display:"block"});
+
+
+ DomElems.overviewDiv.appendChild(DomElems.overviewRank);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewStamina);
+ DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);
+ DomElems.overviewDiv.appendChild(DomElems.overviewGen1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewChaos);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 2);
+ DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);
+ DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);
+
+ //Travel to new city button
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(DomElems.overviewDiv, 1);
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerHTML:"Travel", class:"a-link-button", display:"inline-block",
+ clickListener:()=>{
+ var popupId = "bladeburner-travel-popup-cancel-btn";
+ var popupArguments = [];
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Cancel Button
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId); return false;
+ }
+ }))
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", { //Info Text
+ innerText:"Travel to a different city for your Bladeburner " +
+ "activities. This does not cost any money. The city you are " +
+ "in for your Bladeburner duties does not affect " +
+ "your location in the game otherwise",
+ }));
+ for (var i = 0; i < CityNames.length; ++i) {
+ (function(inst, i) {
+ popupArguments.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ //Reusing this css class...it adds a border and makes it
+ //so that background color changes when you hover
+ class:"cmpy-mgmt-find-employee-option",
+ innerText:CityNames[i],
+ clickListener:()=>{
+ inst.city = CityNames[i];
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
+ inst.updateOverviewContent();
+ return false;
+ }
+ }));
+ })(this, i);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, popupArguments);
+ }
+ }));
+
+ //Faction button
+ var bladeburnersFactionName = "Bladeburners";
+ if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["factionExists"])(bladeburnersFactionName)) {
+ var bladeburnerFac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][bladeburnersFactionName];
+ if (!(bladeburnerFac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
+ throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
+ }
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Faction", class:"a-link-button", display:"inline-block",
+ tooltip:"Apply to the Bladeburner Faction, or go to the faction page if you are already a member",
+ clickListener:()=>{
+ if (bladeburnerFac.isMember) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(bladeburnersFactionName);
+ } else {
+ if (this.rank >= 25) {
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["joinFaction"])(bladeburnerFac);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Congratulations! You were accepted into the Bladeburners faction");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.overviewDiv);
+ this.createOverviewContent();
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("You need a rank of 25 to join the Bladeburners Faction!")
+ }
+ }
+ return false;
+ }
+ }));
+ }
+
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
+ DomElems.overviewDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
+
+ this.updateOverviewContent();
+}
+
+Bladeburner.prototype.createActionAndSkillsContent = function() {
+ if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.actionAndSkillsDiv);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.generalActions);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.contracts);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.operations);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.blackops);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["clearObject"])(DomElems.skills);
+
+ //Navigation buttons
+ var currTab = DomElems.currentTab.toLowerCase();
+ var buttons = ["General", "Contracts", "Operations", "BlackOps", "Skills"];
+ for (var i = 0; i < buttons.length; ++i) {
+ (function(buttons, i, inst, currTab) {
+
+ DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:buttons[i],
+ class:currTab === buttons[i].toLowerCase() ? "bladeburner-nav-button-inactive" : "bladeburner-nav-button",
+ clickListener:()=>{
+ DomElems.currentTab = buttons[i].toLowerCase();
+ inst.createActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }) (buttons, i, this, currTab);
+ }
+
+ //General info/description for each action
+ DomElems.actionsAndSkillsDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block", margin:"4px", padding:"4px"
+ });
+
+ //List for actions/skills
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(DomElems.actionsAndSkillsList);
+ DomElems.actionsAndSkillsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("ul");
+
+ switch(currTab) {
+ case "general":
+ this.createGeneralActionsContent();
+ break;
+ case "contracts":
+ this.createContractsContent();
+ break;
+ case "operations":
+ this.createOperationsContent();
+ break;
+ case "blackops":
+ this.createBlackOpsContent();
+ break;
+ case "skills":
+ this.createSkillsContent();
+ break;
+ default:
+ throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
+ }
+ this.updateContent();
+
+ DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);
+ DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);
+}
+
+Bladeburner.prototype.createGeneralActionsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createGeneralActionsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerText =
+ "These are generic actions that will assist you in your Bladeburner " +
+ "duties. They will not affect your Bladeburner rank in any way."
+
+ for (var actionName in GeneralActions) {
+ if (GeneralActions.hasOwnProperty(actionName)) {
+ DomElems.generalActions[actionName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-action", name:actionName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createContractsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createContractsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Complete contracts in order to increase your Bitburner rank and earn money. " +
+ "Failing a contract will cause you to lose HP, which can lead to hospitalization.
" +
+ "You can unlock higher-level contracts by successfully completing them. " +
+ "Higher-level contracts are more difficult, but grant more rank, experience, and money.";
+
+ for (var contractName in this.contracts) {
+ if (this.contracts.hasOwnProperty(contractName)) {
+ DomElems.contracts[contractName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-action", name:contractName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createOperationsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createOperationsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Carry out operations for the Bladeburner division. " +
+ "Failing an operation will reduce your Bladeburner rank. It will also " +
+ "cause you to lose HP, which can lead to hospitalization. In general, " +
+ "operations are harder and more punishing than contracts, " +
+ "but are also more rewarding.
" +
+ "Operations can affect the chaos level and Synthoid population of your " +
+ "current city. The exact effects vary between different Operations.
" +
+ "For operations, you can use a team. You must first recruit team members. " +
+ "Having a larger team will improves your chances of success.
" +
+ "You can unlock higher-level operations by successfully completing them. " +
+ "Higher-level operations are more difficult, but grant more rank and experience.";
+
+ for (var operationName in this.operations) {
+ if (this.operations.hasOwnProperty(operationName)) {
+ DomElems.operations[operationName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-action", name:operationName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);
+ }
+ }
+}
+
+Bladeburner.prototype.createBlackOpsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createBlackOpsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "Black Operations (Black Ops) are special, one-time covert operations. " +
+ "Each Black Op must be unlocked successively by completing " +
+ "the one before it.
" +
+ "Like normal operations, you may use a team for Black Ops. Failing " +
+ "a black op will incur heavy HP and rank losses.";
+
+ //Put Black Operations in sequence of required rank
+ var blackops = [];
+ for (var blackopName in BlackOperations) {
+ if (BlackOperations.hasOwnProperty(blackopName)) {
+ blackops.push(BlackOperations[blackopName]);
+ }
+ }
+ blackops.sort(function(a, b) {
+ return (a.reqdRank - b.reqdRank);
+ });
+
+ for (var i = 0; i < blackops.length; ++i) {
+ DomElems.blackops[blackops[i].name] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-action", name:blackops[i].name
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);
+ if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops
+ }
+}
+
+Bladeburner.prototype.createSkillsContent = function() {
+ if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
+ throw new Error("Bladeburner.createSkillsContent called with either " +
+ "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
+ }
+
+ //Display Current multipliers
+ DomElems.actionsAndSkillsDesc.innerHTML =
+ "You will gain one skill point every " + RanksPerSkillPoint + " ranks.
" +
+ "Note that when upgrading a skill, the benefit for that skill is additive. " +
+ "However, the effects of different skills with each other is multiplicative.
"
+ var multKeys = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multKeys.length; ++i) {
+ var mult = this.skillMultipliers[multKeys[i]];
+ if (mult && mult !== 1) {
+ mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mult, 3);
+ switch(multKeys[i]) {
+ case "successChanceAll":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Total Success Chance: x" + mult + "
";
+ break;
+ case "successChanceStealth":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Stealth Success Chance: x" + mult + "
";
+ break;
+ case "successChanceKill":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Retirement Success Chance: x" + mult + "
";
+ break;
+ case "successChanceContract":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Contract Success Chance: x" + mult + "
";
+ break;
+ case "successChanceOperation":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Operation Success Chance: x" + mult + "
";
+ break;
+ case "successChanceEstimate":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Synthoid Data Estimate: x" + mult + "
";
+ break;
+ case "actionTime":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Action Time: x" + mult + "
";
+ break;
+ case "effHack":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Hacking Skill: x" + mult + "
";
+ break;
+ case "effStr":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Strength: x" + mult + "
";
+ break;
+ case "effDef":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Defense: x" + mult + "
";
+ break;
+ case "effDex":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Dexterity: x" + mult + "
";
+ break;
+ case "effAgi":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Agility: x" + mult + "
";
+ break;
+ case "effCha":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Charisma: x" + mult + "
";
+ break;
+ case "effInt":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Intelligence: x" + mult + "
";
+ break;
+ case "stamina":
+ DomElems.actionsAndSkillsDesc.innerHTML += "Stamina: x" + mult + "
";
+ break;
+ case "weaponAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML +=
+ break;
+ case "gunAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML
+ break;
+ default:
+ console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
+ break;
+ }
+ }
+ }
+
+ //Skill Points
+ DomElems.actionAndSkillsDiv.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerHTML:"
Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skillPoints, 0) + ""
+ }));
+
+ //UI Element for each skill
+ for (var skillName in Skills) {
+ if (Skills.hasOwnProperty(skillName)) {
+ DomElems.skills[skillName] = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("div", {
+ class:"bladeburner-action", name:skillName
+ });
+ DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);
+ }
+ }
+}
+
+Bladeburner.prototype.updateContent = function() {
+ this.updateOverviewContent();
+ this.updateActionAndSkillsContent();
+}
+
+Bladeburner.prototype.updateOverviewContent = function() {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Bladeburner) {return;}
+ DomElems.overviewRank.childNodes[0].nodeValue = "Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.rank, 2);
+ DomElems.overviewStamina.innerText = "Stamina: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.stamina, 3) + " / " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.maxStamina, 3);
+ DomElems.overviewGen1.innerHTML =
+ "Stamina Penalty: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])((1-this.calculateStaminaPenalty())*100, 1) + "%
" +
+ "Team Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.teamSize, 0) + "
" +
+ "Team Members Lost: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.teamLost, 0) + "
" +
+ "Num Times Hospitalized: " + this.numHosp + "
" +
+ "Money Lost From Hospitalizations: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.moneyLost).format("$0.000a") + "
" +
+ "Current City: " + this.city + "
";
+
+ DomElems.overviewEstPop.childNodes[0].nodeValue = "Est. Synthoid Population: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_10___default()(this.getCurrentCity().popEst).format("0.000a");
+ DomElems.overviewEstComms.childNodes[0].nodeValue = "Est. Synthoid Communities: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.getCurrentCity().comms, 0);
+ DomElems.overviewChaos.childNodes[0].nodeValue = "City Chaos: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.getCurrentCity().chaos);
+ DomElems.overviewSkillPoints.innerText = "Skill Points: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skillPoints, 0);
+ DomElems.overviewAugSuccessMult.innerText = "Aug. Success Chance Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_success_chance_mult*100, 1) + "%";
+ DomElems.overviewAugMaxStaminaMult.innerText = "Aug. Max Stamina Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_max_stamina_mult*100, 1) + "%";
+ DomElems.overviewAugStaminaGainMult.innerText = "Aug. Stamina Gain Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_stamina_gain_mult*100, 1) + "%";
+ DomElems.overviewAugAnalysisMult.innerText = "Aug. Field Analysis Mult: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].bladeburner_analysis_mult*100, 1) + "%";
+}
+
+Bladeburner.prototype.updateActionAndSkillsContent = function() {
+ if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
+ switch(DomElems.currentTab.toLowerCase()) {
+ case "general":
+ var actionElems = Object.keys(DomElems.generalActions);
+ for (var i = 0; i < actionElems.length; ++i) {
+ var actionElem = DomElems.generalActions[actionElems[i]];
+ var name = actionElem.name;
+ var actionObj = GeneralActions[name];
+ if (actionObj == null) {
+ throw new Error("Could not find Object " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ if (this.action.type === ActionTypes[name]) {
+ actionElem.classList.add(ActiveActionCssClass);
+ } else {
+ actionElem.classList.remove(ActiveActionCssClass);
+ }
+ this.updateGeneralActionsUIElement(actionElem, actionObj);
+ }
+ break;
+ case "contracts":
+ var contractElems = Object.keys(DomElems.contracts);
+ for (var i = 0; i < contractElems.length; ++i) {
+ var contractElem = DomElems.contracts[contractElems[i]];
+ var name = contractElem.name;
+ if (this.action.type === ActionTypes["Contract"] && name === this.action.name) {
+ contractElem.classList.add(ActiveActionCssClass);
+ } else {
+ contractElem.classList.remove(ActiveActionCssClass);
+ }
+ var contract = this.contracts[name];
+ if (contract == null) {
+ throw new Error("Could not find Contract " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateContractsUIElement(contractElem, contract);
+ }
+ break;
+ case "operations":
+ var operationElems = Object.keys(DomElems.operations);
+ for (var i = 0; i < operationElems.length; ++i) {
+ var operationElem = DomElems.operations[operationElems[i]];
+ var name = operationElem.name;
+ if (this.action.type === ActionTypes["Operation"] && name === this.action.name) {
+ operationElem.classList.add(ActiveActionCssClass);
+ } else {
+ operationElem.classList.remove(ActiveActionCssClass);
+ }
+ var operation = this.operations[name];
+ if (operation == null) {
+ throw new Error("Could not find Operation " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateOperationsUIElement(operationElem, operation);
+ }
+ break;
+ case "blackops":
+ var blackopsElems = Object.keys(DomElems.blackops);
+ for (var i = 0; i < blackopsElems.length; ++i) {
+ var blackopElem = DomElems.blackops[blackopsElems[i]];
+ var name = blackopElem.name;
+ if (this.action.type === ActionTypes["BlackOperation"] && name === this.action.name) {
+ blackopElem.classList.add(ActiveActionCssClass);
+ } else {
+ blackopElem.classList.remove(ActiveActionCssClass);
+ }
+ var blackop = BlackOperations[name];
+ if (blackop == null) {
+ throw new Error("Could not find BlackOperation " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateBlackOpsUIElement(blackopElem, blackop);
+ }
+ break;
+ case "skills":
+ var skillElems = Object.keys(DomElems.skills);
+ for (var i = 0; i < skillElems.length; ++i) {
+ var skillElem = DomElems.skills[skillElems[i]];
+ var name = skillElem.name;
+ var skill = Skills[name];
+ if (skill == null) {
+ throw new Error("Could not find Skill " + name + " in Bladeburner.updateActionAndSkillsContent()");
+ }
+ this.updateSkillsUIElement(skillElem, skill);
+ }
+ break;
+ default:
+ throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
+ }
+}
+
+Bladeburner.prototype.updateGeneralActionsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block",
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
+ }));
+ } else {
+ //Start button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes[action.name];
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", { //Info
+ innerHTML:action.desc, display:"inline-block"
+ }));
+
+
+}
+
+Bladeburner.prototype.updateContractsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block"
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
+ }));
+ } else { //Start button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ padding:"3px", margin:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes.Contract;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ }
+
+ //Level and buttons to change level
+ var maxLevel = (action.level >= action.maxLevel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
+ display:"inline-block",
+ innerText:"Level: " + action.level + " / " + action.maxLevel
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
+ display:"inline",
+ clickListener:()=>{
+ ++action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateContractsUIElement(el, action);
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the contract" : "",
+ display:"inline",
+ clickListener:()=>{
+ --action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateContractsUIElement(el, action);
+ return false;
+ }
+ }));
+
+ var actionTime = action.getActionTime(this);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", { //Info
+ display:"inline-block",
+ innerHTML:action.desc + "\n\n" +
+ "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required (s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 0) + "\n" +
+ "Contracts remaining: " + Math.floor(action.count) + "\n" +
+ "Successes: " + action.successes + "\n" +
+ "Failures: " + action.failures,
+ }));
+
+ //Autolevel Checkbox
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
+ var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("label", {
+ for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
+ tooltip:"Automatically increase contract level when possible"
+ }));
+ var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
+ type:"checkbox", id:autolevelCheckboxId, margin:"4px",
+ checked:action.autoLevel,
+ changeListener:()=>{
+ action.autoLevel = autolevelCheckbox.checked;
+ }
+ });
+ el.appendChild(autolevelCheckbox);
+}
+
+Bladeburner.prototype.updateOperationsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block"
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
+ }));
+ } else { //Start button and set Team Size button
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Start", class: "a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ this.action.type = ActionTypes.Operation;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ var popupId = "bladeburner-operation-set-team-size-popup";
+ var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"Enter the amount of team members you would like to take on these " +
+ "operations. If you do not have the specified number of team members, " +
+ "then as many as possible will be used. Note that team members may " +
+ "be lost during operations."
+
+ });
+ var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
+ type:"number", placeholder: "Team Members"
+ });
+ var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Confirm", class:"a-link-button",
+ clickListener:()=>{
+ var num = Math.round(parseFloat(input.value));
+ if (isNaN(num)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
+ } else {
+ action.teamCount = num;
+ this.updateOperationsUIElement(el, action);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
+ }
+ }));
+ }
+
+ //Level and buttons to change level
+ var maxLevel = (action.level >= action.maxLevel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
+ display:"inline-block",
+ innerText:"Level: " + action.level + " / " + action.maxLevel
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ class: maxLevel ? "a-link-button-inactive" : "a-link-button", innerHTML:"↑",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
+ display:"inline",
+ clickListener:()=>{
+ ++action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateOperationsUIElement(el, action);
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ class: (action.level <= 1) ? "a-link-button-inactive" : "a-link-button", innerHTML:"↓",
+ padding:"2px", margin:"2px",
+ tooltip: isActive ? "WARNING: changing the level will restart the Operation" : "",
+ display:"inline",
+ clickListener:()=>{
+ --action.level;
+ if (isActive) {this.startAction(this.action);} //Restart Action
+ this.updateOperationsUIElement(el, action);
+ return false;
+ }
+ }));
+
+ //General Info
+ var difficulty = action.getDifficulty();
+ var actionTime = action.getActionTime(this);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("pre", {
+ display:"inline-block",
+ innerHTML:action.desc + "\n\n" +
+ "Estimated success chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 1) + "\n" +
+ "Operations remaining: " + Math.floor(action.count) + "\n" +
+ "Successes: " + action.successes + "\n" +
+ "Failures: " + action.failures,
+ }));
+
+ //Autolevel Checkbox
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("br"));
+ var autolevelCheckboxId = "bladeburner-" + action.name + "-autolevel-checkbox";
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("label", {
+ for:autolevelCheckboxId, innerText:"Autolevel",color:"white",
+ tooltip:"Automatically increase operation level when possible"
+ }));
+ var autolevelCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
+ type:"checkbox", id:autolevelCheckboxId, margin:"4px",
+ checked:action.autoLevel,
+ changeListener:()=>{
+ action.autoLevel = autolevelCheckbox.checked;
+ }
+ });
+ el.appendChild(autolevelCheckbox);
+}
+
+Bladeburner.prototype.updateBlackOpsUIElement = function(el, action) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
+ var isActive = el.classList.contains(ActiveActionCssClass);
+ var isCompleted = (this.blackops[action.name] != null);
+ var estimatedSuccessChance = action.getSuccessChance(this, {est:true});
+ var difficulty = action.getDifficulty();
+ var actionTime = action.getActionTime(this);
+ var hasReqdRank = this.rank >= action.reqdRank;
+
+ //UI for Completed Black Op
+ if (isCompleted) {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", {
+ innerText:action.name + " (COMPLETED)", display:"block",
+ }));
+ return;
+ }
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
+ innerText:isActive ? action.name + " (IN PROGRESS - " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeCurrent, 0) + " / " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.actionTimeToComplete, 0) + ")"
+ : action.name,
+ display:"inline-block",
+ }));
+
+ if (isActive) { //Progress bar if its active
+ var progress = this.actionTimeCurrent / this.actionTimeToComplete;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ innerText:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createProgressBarText"])({progress:progress})
+ }));
+ } else {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Start button
+ innerText:"Start", margin:"3px", padding:"3px",
+ class:hasReqdRank ? "a-link-button" : "a-link-button-inactive",
+ clickListener:()=>{
+ this.action.type = ActionTypes.BlackOperation;
+ this.action.name = action.name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ return false;
+ }
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Set Team Size Button
+ innerText:"Set Team Size (Curr Size: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.teamCount, 0) + ")", class:"a-link-button",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ var popupId = "bladeburner-operation-set-team-size-popup";
+ var txt = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ innerText:"Enter the amount of team members you would like to take on this " +
+ "BlackOp. If you do not have the specified number of team members, " +
+ "then as many as possible will be used. Note that team members may " +
+ "be lost during operations."
+
+ });
+ var input = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("input", {
+ type:"number", placeholder: "Team Members"
+ });
+ var setBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Confirm", class:"a-link-button",
+ clickListener:()=>{
+ var num = Math.round(parseFloat(input.value));
+ if (isNaN(num)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])("Invalid value entered for number of Team Members (must be numeric)")
+ } else {
+ action.teamCount = num;
+ this.updateBlackOpsUIElement(el, action);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ var cancelBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", {
+ innerText:"Cancel", class:"a-link-button",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
+ return false;
+ }
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createPopup"])(popupId, [txt, input, setBtn, cancelBtn]);
+ }
+ }));
+ }
+
+ //Info
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"inline-block",
+ innerHTML:"
" + action.desc + "
",
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block", color:hasReqdRank ? "white" : "red",
+ innerHTML:"Required Rank: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(action.reqdRank, 0) + "
"
+ }));
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"inline-block",
+ innerHTML:"Estimated Success Chance: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(estimatedSuccessChance*100, 1) + "%\n" +
+ "Time Required(s): " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(actionTime, 1),
+ }))
+}
+
+Bladeburner.prototype.updateSkillsUIElement = function(el, skill) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["removeChildrenFromElement"])(el);
+ var skillName = skill.name;
+ var currentLevel = 0;
+ if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
+ currentLevel = this.skills[skillName];
+ }
+ var pointCost = skill.baseCost + (currentLevel * skill.costInc);
+
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("h2", { //Header
+ innerText:skill.name + " (Lvl " + currentLevel + ")", display:"inline-block"
+ }));
+
+ var canLevel = this.skillPoints >= pointCost;
+ var maxLvl = skill.maxLvl ? currentLevel >= skill.maxLvl : false;
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("a", { //Level up button
+ innerText:"Level", display:"inline-block",
+ class: canLevel && !maxLvl ? "a-link-button" : "a-link-button-inactive",
+ margin:"3px", padding:"3px",
+ clickListener:()=>{
+ this.skillPoints -= pointCost;
+ this.upgradeSkill(skill);
+ this.createActionAndSkillsContent();
+ return false;
+ }
+ }));
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["appendLineBreaks"])(el, 2);
+ if (maxLvl) {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ color:"red", display:"block",
+ innerText:"MAX LEVEL"
+ }));
+ } else {
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", {
+ display:"block",
+ innerText:"Skill Points required: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(pointCost, 0),
+ }));
+ }
+ el.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["createElement"])("p", { //Info/Description
+ innerHTML:skill.desc, display:"inline-block",
+ }));
+}
+
+//Bladeburner Console Window
+Bladeburner.prototype.postToConsole = function(input) {
+ if (input == null || DomElems.consoleDiv == null) {return;}
+ $("#bladeubrner-console-input-row").before(' ');
+ if (DomElems.consoleTable.childNodes.length > 200) {
+ DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
+ }
+ this.updateConsoleScroll();
+}
+
+Bladeburner.prototype.updateConsoleScroll = function() {
+ DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;
+}
+
+Bladeburner.prototype.resetConsoleInput = function() {
+ DomElems.consoleInput.value = "";
+}
+
+Bladeburner.prototype.clearConsole = function() {
+ while (DomElems.consoleTable.childNodes.length > 1) {
+ DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
+ }
+}
+
+Bladeburner.prototype.log = function(input) {
+ //Adds a timestamp and then just calls postToConsole
+ var d = new Date();
+ var timestamp = d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes();
+ this.postToConsole("[" + timestamp + "] " + input);
+}
+
+//Handles a potential series of commands (comm1; comm2; comm3;)
+Bladeburner.prototype.executeConsoleCommands = function(commands) {
+ try {
+ //Console History
+ if (consoleHistory[consoleHistory.length-1] != commands) {
+ consoleHistory.push(commands);
+ if (consoleHistory.length > 50) {
+ consoleHistory.splice(0, 1);
+ }
+ }
+ consoleHistoryIndex = consoleHistory.length;
+
+ var arrayOfCommands = commands.split(";");
+ for (var i = 0; i < arrayOfCommands.length; ++i) {
+ this.executeConsoleCommand(arrayOfCommands[i]);
+ }
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["exceptionAlert"])(e);
+ }
+}
+
+//A single command
+Bladeburner.prototype.executeConsoleCommand = function(command) {
+ command = command.trim();
+ command = command.replace(/\s\s+/g, ' '); //Replace all whitespace w/ a single space
+
+ var args = this.parseCommandArguments(command);
+ if (args.length <= 0) {return;} //Log an error?
+
+ switch(args[0].toLowerCase()) {
+ case "automate":
+ this.executeAutomateConsoleCommand(args);
+ break;
+ case "clear":
+ case "cls":
+ this.clearConsole();
+ break;
+ case "help":
+ this.executeHelpConsoleCommand(args);
+ break;
+ case "log":
+ this.executeLogConsoleCommand(args);
+ break;
+ case "skill":
+ this.executeSkillConsoleCommand(args);
+ break;
+ case "start":
+ this.executeStartConsoleCommand(args);
+ break;
+ case "stop":
+ this.resetAction();
+ break;
+ default:
+ this.postToConsole("Invalid console command");
+ break;
+ }
+}
+
+Bladeburner.prototype.parseCommandArguments = function(command) {
+ //Returns an array with command and its arguments in each index.
+ //e.g. skill "blade's intuition" foo returns [skill, blade's intuition, foo]
+ //The input to this fn will be trimmed and will have all whitespace replaced w/ a single space
+ var args = [];
+ var start = 0, i = 0;
+ while (i < command.length) {
+ var c = command.charAt(i);
+ if (c === '"') {
+ var endQuote = command.indexOf('"', i+1);
+ if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === " ")) {
+ args.push(command.substr(i+1, (endQuote - i - 1)));
+ if (endQuote === command.length-1) {
+ start = i = endQuote+1;
+ } else {
+ start = i = endQuote+2; //Skip the space
+ }
+ continue;
+ }
+ } else if (c === " ") {
+ args.push(command.substr(start, i-start));
+ start = i+1;
+ }
+ ++i;
+ }
+ if (start !== i) {args.push(command.substr(start, i-start));}
+ console.log("Bladeburner.parseCommandArguments returned: " + args);
+ return args;
+}
+
+Bladeburner.prototype.executeAutomateConsoleCommand = function(args) {
+ if (args.length !== 2 && args.length !== 4) {
+ this.postToConsole("Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info");
+ return;
+ }
+
+ //Enable/Disable
+ if (args.length === 2) {
+ var flag = args[1];
+ if (flag.toLowerCase() === "status") {
+ this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
+ if (this.automateEnabled) {
+ this.postToConsole("When your stamina drops to " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.automateThreshLow, 0) +
+ ", you will automatically switch to " + this.automateActionLow.name +
+ ". When your stamina recovers to " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.automateThreshHigh, 0) + ", you will automatically " +
+ "switch to " + this.automateActionHigh.name + ".");
+ }
+
+ } else if (flag.toLowerCase().includes("en")) {
+ if (!(this.automateActionLow instanceof ActionIdentifier) ||
+ !(this.automateActionHigh instanceof ActionIdentifier)) {
+ return this.log("Failed to enable automation. Actions were not set");
+ }
+ this.automateEnabled = true;
+ this.log("Bladeburner automation enabled");
+ } else if (flag.toLowerCase().includes("d")) {
+ this.automateEnabled = false;
+ this.log("Bladeburner automation disabled");
+ } else {
+ this.log("Invalid argument for 'automate' console command: " + args[1]);
+ }
+ return;
+ }
+
+ //Set variables
+ if (args.length === 4) {
+ var variable = args[1], val = args[2];
+
+ var highLow = false; //True for high, false for low
+ if (args[3].toLowerCase().includes("hi")) {highLow = true;}
+
+ switch (variable) {
+ case "general":
+ case "gen":
+ if (GeneralActions[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes[val], name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid action name specified: " + val);
+ }
+ break;
+ case "contract":
+ case "contracts":
+ if (this.contracts[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes.Contract, name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid contract name specified: " + val);
+ }
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ if (this.operations[val] != null) {
+ var action = new ActionIdentifier({
+ type:ActionTypes.Operation, name:val
+ });
+ if (highLow) {
+ this.automateActionHigh = action;
+ } else {
+ this.automateActionLow = action;
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
+ } else {
+ this.postToConsole("Invalid Operation name specified: " + val);
+ }
+ break;
+ case "stamina":
+ if (isNaN(val)) {
+ this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val);
+ } else {
+ if (highLow) {
+ this.automateThreshHigh = Number(val);
+ } else {
+ this.automateThreshLow = Number(val);
+ }
+ this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return;
+ }
+}
+
+Bladeburner.prototype.executeHelpConsoleCommand = function(args) {
+ if (args.length === 1) {
+ this.postToConsole(consoleHelpText.helpList);
+ } else {
+ for (var i = 1; i < args.length; ++i) {
+ var commandText = consoleHelpText[args[i]];
+ if (commandText != null) {
+ this.postToConsole(commandText);
+ this.postToConsole("' + input + '
");
+ }
+ }
+ }
+}
+
+Bladeburner.prototype.executeLogConsoleCommand = function(args) {
+ if (args.length < 3) {
+ this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]");
+ this.postToConsole("Use 'help log' for more details and examples");
+ return;
+ }
+
+ var flag = true;
+ if (args[1].toLowerCase().includes("d")) {flag = false;} //d for disable
+
+ switch (args[2].toLowerCase()) {
+ case "general":
+ case "gen":
+ this.logging.general = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions");
+ break;
+ case "contract":
+ case "contracts":
+ this.logging.contracts = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts");
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ this.logging.ops = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations");
+ break;
+ case "blackops":
+ case "blackop":
+ case "black operations":
+ case "black operation":
+ this.logging.blackops = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps");
+ break;
+ case "event":
+ case "events":
+ this.logging.events = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for events");
+ break;
+ case "all":
+ this.logging.general = flag;
+ this.logging.contracts = flag;
+ this.logging.ops = flag;
+ this.logging.blackops = flag;
+ this.logging.events = flag;
+ this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything");
+ break;
+ default:
+ this.postToConsole("Invalid action/event type specified: " + args[2]);
+ this.postToConsole("Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]");
+ break;
+ }
+}
+
+Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
+ switch (args.length) {
+ case 1:
+ //Display Skill Help Command
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ break;
+ case 2:
+ if (args[1].toLowerCase() === "list") {
+ //List all skills and their level
+ this.postToConsole("Skills: ");
+ var skillNames = Object.keys(Skills);
+ for(var i = 0; i < skillNames.length; ++i) {
+ var skill = Skills[skillNames[i]];
+ var level = 0;
+ if (this.skills[skill.name] != null) {level = this.skills[skill.name];}
+ this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(level, 0));
+ }
+ this.postToConsole(" ");
+ this.postToConsole("Effects: ");
+ var multKeys = Object.keys(this.skillMultipliers);
+ for (var i = 0; i < multKeys.length; ++i) {
+ var mult = this.skillMultipliers[multKeys[i]];
+ if (mult && mult !== 1) {
+ mult = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(mult, 3);
+ switch(multKeys[i]) {
+ case "successChanceAll":
+ this.postToConsole("Total Success Chance: x" + mult);
+ break;
+ case "successChanceStealth":
+ this.postToConsole("Stealth Success Chance: x" + mult);
+ break;
+ case "successChanceKill":
+ this.postToConsole("Retirement Success Chance: x" + mult);
+ break;
+ case "successChanceContract":
+ this.postToConsole("Contract Success Chance: x" + mult);
+ break;
+ case "successChanceOperation":
+ this.postToConsole("Operation Success Chance: x" + mult);
+ break;
+ case "successChanceEstimate":
+ this.postToConsole("Synthoid Data Estimate: x" + mult);
+ break;
+ case "actionTime":
+ this.postToConsole("Action Time: x" + mult);
+ break;
+ case "effHack":
+ this.postToConsole("Hacking Skill: x" + mult);
+ break;
+ case "effStr":
+ this.postToConsole("Strength: x" + mult);
+ break;
+ case "effDef":
+ this.postToConsole("Defense: x" + mult);
+ break;
+ case "effDex":
+ this.postToConsole("Dexterity: x" + mult);
+ break;
+ case "effAgi":
+ this.postToConsole("Agility: x" + mult);
+ break;
+ case "effCha":
+ this.postToConsole("Charisma: x" + mult);
+ break;
+ case "effInt":
+ this.postToConsole("Intelligence: x" + mult);
+ break;
+ case "stamina":
+ this.postToConsole("Stamina: x" + mult);
+ break;
+ case "weaponAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML +=
+ break;
+ case "gunAbility":
+ //DomElems.actionsAndSkillsDesc.innerHTML
+ break;
+ default:
+ console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
+ break;
+ }
+ }
+ }
+ } else {
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ }
+ break;
+ case 3:
+ var skillName = args[2];
+ var skill = Skills[skillName];
+ if (skill == null || !(skill instanceof Skill)) {
+ return this.postToConsole("Invalid skill name (Note that this is case-sensitive): " + skillName);
+ }
+ if (args[1].toLowerCase() === "list") {
+ this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(this.skills[skill.name]), 0);
+ } else if (args[1].toLowerCase() === "level") {
+ var currentLevel = 0;
+ if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
+ currentLevel = this.skills[skillName];
+ }
+ var pointCost = skill.baseCost + (currentLevel * skill.costInc);
+ if (this.skillPoints >= pointCost) {
+ this.skillPoints -= pointCost;
+ this.upgradeSkill(skill);
+ this.log(skill.name + " upgraded to Level " + this.skills[skillName]);
+ this.createActionAndSkillsContent();
+ } else {
+ this.postToConsole("You do not have enough Skill Points to upgrade this. You need " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["formatNumber"])(pointCost, 0));
+ }
+
+ } else {
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ }
+ break;
+ default:
+ this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
+ this.postToConsole("Use 'help skill' for more info");
+ break;
+ }
+}
+
+Bladeburner.prototype.executeStartConsoleCommand = function(args) {
+ if (args.length !== 3) {
+ this.postToConsole("Invalid usage of 'start' console command: start [type] [name]");
+ this.postToConsole("Use 'help start' for more info");
+ return;
+ }
+ var name = args[2];
+ switch (args[1].toLowerCase()) {
+ case "general":
+ case "gen":
+ if (GeneralActions[name] != null) {
+ this.action.type = ActionTypes[name];
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid action name specified: " + args[2]);
+ }
+ break;
+ case "contract":
+ case "contracts":
+ if (this.contracts[name] != null) {
+ this.action.type = ActionTypes.Contract;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid contract name specified: " + args[2]);
+ }
+ break;
+ case "ops":
+ case "op":
+ case "operations":
+ case "operation":
+ if (this.operations[name] != null) {
+ this.action.type = ActionTypes.Operation;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid Operation name specified: " + args[2]);
+ }
+ break;
+ case "blackops":
+ case "blackop":
+ case "black operations":
+ case "black operation":
+ if (BlackOperations[name] != null) {
+ this.action.type = ActionTypes.BlackOperation;
+ this.action.name = name;
+ this.startAction(this.action);
+ this.updateActionAndSkillsContent();
+ } else {
+ this.postToConsole("Invalid BlackOp name specified: " + args[2]);
+ }
+ break;
+ default:
+ this.postToConsole("Invalid action/event type specified: " + args[1]);
+ this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]");
+ break;
+ }
+}
+
+
+Bladeburner.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_toJSON"])("Bladeburner", this);
+}
+Bladeburner.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Generic_fromJSON"])(Bladeburner, value.data);
+}
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__["Reviver"].constructors.Bladeburner = Bladeburner;
+
+//This initialized Bladeburner-related data that is NOT saved/loaded
+// eg: Skill Objects, BLack Operations
+//Any data that is saved/loaded should go in Bladeburner object
+// eg: contracts, operations
+function initBladeburner() {
+ //Skills
+ Skills[SkillNames.BladesIntuition] = new Skill({
+ name:SkillNames.BladesIntuition,
+ desc:"Each level of this skill increases your success chance " +
+ "for all contracts and operations by 3%",
+ baseCost:5, costInc:2,
+ successChanceAll:3
+ });
+ Skills[SkillNames.Reaper] = new Skill({
+ name:SkillNames.Reaper,
+ desc:"Each level of this skill increases your " +
+ "effective combat stats for Bladeburner actions by 3%",
+ baseCost:3, costInc:2,
+ effStr:3, effDef:3, effDex:3, effAgi:3
+ });
+ Skills[SkillNames.Cloak] = new Skill({
+ name:SkillNames.Cloak,
+ desc:"Each level of this skill increases your " +
+ "success chance in stealth-related contracts and operations by 5.5%",
+ baseCost:3, costInc:1,
+ successChanceStealth:5.5
+ });
+
+ //TODO Marksman
+ //TODO Weapon Proficiency
+
+ Skills[SkillNames.Overclock] = new Skill({
+ name:SkillNames.Overclock,
+ desc:"Each level of this skill decreases the time it takes " +
+ "to attempt a contract or operation by 1% (Max Level: 95)",
+ baseCost:5, costInc:1, maxLvl:95,
+ actionTime:1
+ });
+ Skills[SkillNames.EvasiveSystem] = new Skill({
+ name:SkillNames.EvasiveSystem,
+ desc:"Each level of this skill increases your effective " +
+ "dexterity and agility for Bladeburner actions by 5%",
+ baseCost:2, costInc: 1,
+ effDex:5, effAgi:5
+ });
+ Skills[SkillNames.ShortCircuit] = new Skill({
+ name:SkillNames.ShortCircuit,
+ desc:"Each level of this skill increases your success chance " +
+ "in contracts and operations that involve retirement by 5.5%",
+ baseCost:3, costInc:2,
+ successChanceKill:5.5
+ });
+ Skills[SkillNames.DigitalObserver] = new Skill({
+ name:SkillNames.DigitalObserver,
+ desc:"Each level of this skill increases your success chance in " +
+ "all operations by 4%",
+ baseCost:5, costInc:2,
+ successChanceOperation:4
+ });
+ Skills[SkillNames.Datamancer] = new Skill({
+ name:SkillNames.Datamancer,
+ desc:"Each level of this skill increases your effectiveness in " +
+ "synthoid population analysis and investigation by 5%. " +
+ "This affects all actions that can potentially increase " +
+ "the accuracy of your synthoid population/community estimates.",
+ baseCost:3,costInc:1,
+ successChanceEstimate:5
+ });
+ Skills[SkillNames.Tracer] = new Skill({
+ name:SkillNames.Tracer,
+ desc:"Each level of this skill increases your success chance in " +
+ "all contracts by 4%",
+ baseCost:3, costInc:2,
+ successChanceContract:4
+ });
+ Skills[SkillNames.CybersEdge] = new Skill({
+ name:SkillNames.CybersEdge,
+ desc:"Each level of this skill increases your max " +
+ "stamina by 2%",
+ baseCost:1, costInc:3,
+ stamina:2
+ });
+
+ //General Actions
+ var actionName = "Training";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Improve your abilities at the Bladeburner unit's specialized training " +
+ "center. Doing this gives experience for all combat stats and also " +
+ "increases your max stamina."
+ });
+
+ var actionName = "Field Analysis";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Mine and analyze Synthoid-related data. This improve the " +
+ "Bladeburner's unit intelligence on Synthoid locations and " +
+ "activities. Completing this action will improve the accuracy " +
+ "of your Synthoid population estimated in the current city.
" +
+ "Does NOT require stamina."
+ });
+
+ var actionName = "Recruitment";
+ GeneralActions[actionName] = new Action({
+ name:actionName,
+ desc:"Attempt to recruit members for your Bladeburner team. These members " +
+ "can help you conduct operations.
" +
+ "Does NOT require stamina."
+ });
+
+ //Black Operations
+ BlackOperations["Operation Typhoon"] = new BlackOperation({
+ name:"Operation Typhoon",
+ desc:"Obadiah Zenyatta is the leader of a RedWater PMC. It has long " +
+ "been known among the intelligence community that Zenyatta, along " +
+ "with the rest of the PMC, is a Synthoid.
" +
+ "The goal of Operation Typhoon is to find and eliminate " +
+ "Zenyatta and RedWater by any means necessary. After the task " +
+ "is completed, the actions must be covered up from the general public.",
+ baseDifficulty:2000, reqdRank:2.5e3,
+ rankGain:25, rankLoss:10, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Zero"] = new BlackOperation({
+ name:"Operation Zero",
+ desc:"AeroCorp is one of the world's largest defense contractors. " +
+ "It's leader, Steve Watataki, is thought to be a supporter of " +
+ "Synthoid rights. He must be removed.
" +
+ "The goal of Operation Zero is to covertly infiltrate AeroCorp and " +
+ "uncover any incriminating evidence or " +
+ "information against Watataki that will cause him to be removed " +
+ "from his position at AeroCorp. Incriminating evidence can be " +
+ "fabricated as a last resort. Be warned that AeroCorp has some of " +
+ "the most advanced security measures in the world.",
+ baseDifficulty:2500, reqdRank:5e3,
+ rankGain:30, rankLoss:15, hpLoss:50,
+ weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation X"] = new BlackOperation({
+ name:"Operation X",
+ desc:"We have recently discovered an underground publication " +
+ "group called Samizdat. Even though most of their publications " +
+ "are nonsensical conspiracy theories, the average human is " +
+ "gullible enough to believe them. Many of their works discuss " +
+ "Synthoids and pose a threat to society. The publications are spreading " +
+ "rapidly in China and other Eastern countries.
" +
+ "Samizdat has done a good job of keeping hidden and anonymous. " +
+ "However, we've just received intelligence that their base of " +
+ "operations is in Ishima's underground sewer systems. Your task is to " +
+ "investigate the sewer systems, and eliminate Samizdat. They must " +
+ "never publish anything again.",
+ baseDifficulty:3000, reqdRank:7.5e3,
+ rankGain:30, rankLoss:15, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Titan"] = new BlackOperation({
+ name:"Operation Titan",
+ desc:"Several months ago Titan Laboratories' Bioengineering department " +
+ "was infiltrated by Synthoids. As far as we know, Titan Laboratories' " +
+ "management has no knowledge about this. We don't know what the " +
+ "Synthoids are up to, but the research that they could " +
+ "be conducting using Titan Laboraties' vast resources is potentially " +
+ "very dangerous.
" +
+ "Your goal is to enter and destroy the Bioengineering department's " +
+ "facility in Aevum. The task is not just to retire the Synthoids there, but " +
+ "also to destroy any information or research at the facility that " +
+ "is relevant to the Synthoids and their goals.",
+ baseDifficulty:4000, reqdRank:10e3,
+ rankGain:40, rankLoss:20, hpLoss:100,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Ares"] = new BlackOperation({
+ name:"Operation Ares",
+ desc:"One of our undercover agents, Agent Carter, has informed us of a " +
+ "massive weapons deal going down in Dubai between rogue Russian " +
+ "militants and a radical Synthoid community. These weapons are next-gen " +
+ "plasma and energy weapons. It is critical for the safety of humanity " +
+ "that this deal does not happen.
" +
+ "Your task is to intercept the deal. Leave no survivors.",
+ baseDifficulty:5000, reqdRank:12.5e3,
+ rankGain:40, rankLoss:20, hpLoss:200,
+ weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Archangel"] = new BlackOperation({
+ name:"Operation Archangel",
+ desc:"Our analysts have discovered that the popular Red Rabbit brothel in " +
+ "Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence " +
+ "suggests that the profit from this brothel is used to fund a large " +
+ "black market arms trafficking operation.
" +
+ "The goal of this operation is to take out the leaders that are running " +
+ "the Red Rabbit brothel. Try to limit the number of other casualties, " +
+ "but do what you must to complete the mission.",
+ baseDifficulty:7500, reqdRank:15e3,
+ rankGain:50, rankLoss:20, hpLoss:25,
+ weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Juggernaut"] = new BlackOperation({
+ name:"Operation Juggernaut",
+ desc:"The CIA has just encountered a new security threat. A new " +
+ "criminal group, lead by a shadowy operative who calls himself " +
+ "Juggernaut, has been smuggling drugs and weapons (including " +
+ "suspected bioweapons) into Sector-12. We also have reason " +
+ "to believe the tried to break into one of Universal Energy's " +
+ "facilities in order to cause a city-wide blackout. The CIA " +
+ "suspects that Juggernaut is a heavily-augmented Synthoid, and " +
+ "have thus enlisted our help.
" +
+ "Your mission is to eradicate Juggernaut and his followers.",
+ baseDifficulty:10e3, reqdRank:20e3,
+ rankGain:75, rankLoss:40, hpLoss:300,
+ weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Red Dragon"] = new BlackOperation({
+ name:"Operation Red Dragon",
+ desc:"The Tetrads criminal organization is suspected of " +
+ "reverse-engineering the MK-VI Synthoid design. We believe " +
+ "they altered and possibly improved the design and began " +
+ "manufacturing their own Synthoid models in order to bolster " +
+ "their criminal activities.
" +
+ "Your task is to infiltrate and destroy the Tetrads' base of operations " +
+ "in Los Angeles. Intelligence tells us that their base houses " +
+ "one of their Synthoid manufacturing units.",
+ baseDifficulty:12.5e3, reqdRank:25e3,
+ rankGain:100, rankLoss:50, hpLoss:500,
+ weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation K"] = new BlackOperation({
+ name:"Operation K",
+ desc:"CODE RED SITUATION. Our intelligence tells us that VitaLife " +
+ "has discovered a new android cloning technology. This technology " +
+ "is supposedly capable of cloning Synthoid, not only physically " +
+ "but also their advanced AI modules. We do not believe that " +
+ "VitaLife is trying to use this technology illegally or " +
+ "maliciously, but if any Synthoids were able to infiltrate the " +
+ "corporation and take advantage of this technology then the " +
+ "results would be catastrophic.
" +
+ "We do not have the power or jurisdiction to shutdown this down " +
+ "through legal or political means, so we must resort to a covert " +
+ "operation. Your goal is to destroy this technology and eliminate" +
+ "anyone who was involved in its creation.",
+ baseDifficulty:15e3, reqdRank:30e3,
+ rankGain:120, rankLoss:60, hpLoss:1000,
+ weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Deckard"] = new BlackOperation({
+ name:"Operation Deckard",
+ desc:"Despite your success in eliminating VitaLife's new android-replicating " +
+ "technology in Operation K, we've discovered that a small group of " +
+ "MK-VI Synthoids were able to make off with the schematics and design " +
+ "of the technology before the Operation. It is almost a certainty that " +
+ "these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising." +
+ "The goal of Operation Deckard is to hunt down these Synthoids and retire " +
+ "them. I don't need to tell you how critical this mission is.",
+ baseDifficulty:20e3, reqdRank:40e3,
+ rankGain:150, rankLoss:75, hpLoss:200,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Tyrell"] = new BlackOperation({
+ name:"Operation Tyrell",
+ desc:"A week ago Blade Industries reported a small break-in at one " +
+ "of their Aevum Augmentation storage facitilities. We figured out " +
+ "that The Dark Army was behind the heist, and didn't think any more " +
+ "of it. However, we've just discovered that several known MK-VI Synthoids " +
+ "were part of that break-in group.
" +
+ "We cannot have Synthoids upgrading their already-enhanced abilities " +
+ "with Augmentations. Your task is to hunt down the associated Dark Army " +
+ "members and eliminate them.",
+ baseDifficulty:25e3, reqdRank:50e3,
+ rankGain:200, rankLoss:100, hpLoss:500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true,
+ });
+ BlackOperations["Operation Wallace"] = new BlackOperation({
+ name:"Operation Wallace",
+ desc:"Based on information gathered from Operation Tyrell, we've discovered " +
+ "that The Dark Army was well aware that there were Synthoids amongst " +
+ "their ranks. Even worse, we believe that The Dark Army is working " +
+ "together with other criminal organizations such as The Syndicate and " +
+ "that they are planning some sort of large-scale takeover of multiple major " +
+ "cities, most notably Aevum. We suspect that Synthoids have infiltrated " +
+ "the ranks of these criminal factions and are trying to stage another " +
+ "Synthoid uprising.
" +
+ "The best way to deal with this is to prevent it before it even happens. " +
+ "The goal of Operation Wallace is to destroy the Dark Army and " +
+ "Syndicate factions in Aevum immediately. Leave no survivors.",
+ baseDifficulty:30e3, reqdRank:75e3,
+ rankGain:500, rankLoss:150, hpLoss:1500,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Shoulder of Orion"] = new BlackOperation({
+ name:"Operation Shoulder of Orion",
+ desc:"China's Solaris Space Systems is secretly launching the first " +
+ "manned spacecraft in over a decade using Synthoids. We believe " +
+ "China is trying to establish the first off-world colonies.
" +
+ "The mission is to prevent this launch without instigating an " +
+ "international conflict. When you accept this mission you will be " +
+ "officially disavowed by the NSA and the national government until after you " +
+ "successfully return. In the event of failure, all of the operation's " +
+ "team members must not let themselves be captured alive.",
+ baseDifficulty:35e3, reqdRank:100e3,
+ rankGain:1e3, rankLoss:500, hpLoss:1500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation Hyron"] = new BlackOperation({
+ name:"Operation Hyron",
+ desc:"Our intelligence tells us that Fulcrum Technologies is developing " +
+ "a quantum supercomputer using human brains as core " +
+ "processors. This supercomputer " +
+ "is rumored to be able to store vast amounts of data and " +
+ "perform computations unmatched by any other supercomputer on the " +
+ "planet. But more importantly, the use of organic human brains " +
+ "means that the supercomputer may be able to reason abstractly " +
+ "and become self-aware.
" +
+ "I do not need to remind you why sentient-level AIs pose a serious " +
+ "thread to all of mankind.
" +
+ "The research for this project is being conducted at one of Fulcrum " +
+ "Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. " +
+ "Infiltrate the compound, delete and destroy the work, and then find and kill the " +
+ "project lead.",
+ baseDifficulty:40e3, reqdRank:125e3,
+ rankGain:2e3, rankLoss:1e3, hpLoss:500,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Morpheus"] = new BlackOperation({
+ name:"Operation Morpheus",
+ desc:"DreamSense Technologies is an advertising company that uses " +
+ "special technology to transmit their ads into the peoples " +
+ "dreams and subconcious. They do this using broadcast transmitter " +
+ "towers. Based on information from our agents and informants in " +
+ "Chonqging, we have reason to believe that one of the broadcast " +
+ "towers there has been compromised by Synthoids and is being used " +
+ "to spread pro-Synthoid propaganda.
" +
+ "The mission is to destroy this broadcast tower. Speed and " +
+ "stealth are of the upmost important for this.",
+ baseDifficulty:45e3, reqdRank:150e3,
+ rankGain:5e3, rankLoss:1e3, hpLoss:100,
+ weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isStealth:true
+ });
+ BlackOperations["Operation Ion Storm"] = new BlackOperation({
+ name:"Operation Ion Storm",
+ desc:"Our analysts have uncovered a gathering of MK-VI Synthoids " +
+ "that have taken up residence in the Sector-12 Slums. We " +
+ "don't know if they are rogue Synthoids from the Uprising, " +
+ "but we do know that they have been stockpiling " +
+ "weapons, money, and other resources. This makes them dangerous.
" +
+ "This is a full-scale assault operation to find and retire all of these " +
+ "Synthoids in the Sector-12 Slums.",
+ baseDifficulty:50e3, reqdRank:175e3,
+ rankGain:5e3, rankLoss:1e3, hpLoss:5000,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Annihilus"] = new BlackOperation({
+ name:"Operation Annihilus",
+ desc:"Our superiors have ordered us to eradicate everything and everyone " +
+ "in an underground facility located in Aevum. They tell us " +
+ "that the facility houses many dangerous Synthoids and " +
+ "belongs to a terrorist organization called " +
+ "'The Covenant'. We have no prior intelligence about this " +
+ "organization, so you are going in blind.",
+ baseDifficulty:55e3, reqdRank:200e3,
+ rankGain:5e3, rankLoss:1e3, hpLoss:10e3,
+ weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Ultron"] = new BlackOperation({
+ name:"Operation Ultron",
+ desc:"OmniTek Incorporated, the original designer and manufacturer of Synthoids, " +
+ "has notified us of a malfunction in their AI design. This malfunction, " +
+ "when triggered, causes MK-VI Synthoids to become radicalized and seek out " +
+ "the destruction of humanity. They say that this bug affects all MK-VI Synthoids, " +
+ "not just the rogue ones from the Uprising.
" +
+ "OmniTek has also told us they they believe someone has triggered this " +
+ "malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids " +
+ "are now amassing in Volhaven to form a terrorist group called Ultron.
" +
+ "Intelligence suggests Ultron is heavily armed and that their members are " +
+ "augmented. We believe Ultron is making moves to take control of " +
+ "and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
" +
+ "Your task is to find and destroy Ultron.",
+ baseDifficulty:60e3, reqdRank:250e3,
+ rankGain:10e3, rankLoss:2e3, hpLoss:10e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ isKill:true
+ });
+ BlackOperations["Operation Centurion"] = new BlackOperation({
+ name:"Operation Centurion",
+ desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
+ "Throughout all of humanity's history, we have relied on " +
+ "technology to survive, conquer, and progress. Its advancement became our primary goal. " +
+ "And at the peak of human civilization technology turned into " +
+ "power. Global, absolute power.
" +
+ "It seems that the universe is not without a sense of irony.
" +
+ "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
+ baseDifficulty:70e3, reqdRank:300e3,
+ rankGain:15e3, rankLoss:5e3, hpLoss:10e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+ BlackOperations["Operation Vindictus"] = new BlackOperation({
+ name:"Operation Vindictus",
+ desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
+ "The bits are all around us. The daemons that hold the Node " +
+ "together can manifest themselves in many different ways.
" +
+ "D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)",
+ baseDifficulty:75e3, reqdRank:350e3,
+ rankGain:20e3, rankLoss:20e3, hpLoss:20e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+ BlackOperations["Operation Daedalus"] = new BlackOperation({
+ name:"Operation Daedalus",
+ desc:"Yesterday we obeyed kings and bent our neck to emperors. " +
+ "Today we kneel only to truth.",
+ baseDifficulty:80e3, reqdRank:400e3,
+ rankGain:40e3, rankLoss:10e3, hpLoss:100e3,
+ weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
+ decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
+ });
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
+
+/***/ }),
+/* 41 */
/*!************************!*\
!*** ./src/RedPill.js ***!
\************************/
@@ -58428,15 +56838,15 @@ function applySourceFile(srcFile) {
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "redPillFlag", function() { return redPillFlag; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hackWorldDaemon", function() { return hackWorldDaemon; });
-/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 15);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 12);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Prestige.js */ 57);
-/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SourceFile.js */ 44);
-/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 18);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
+/* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Prestige.js */ 53);
+/* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SourceFile.js */ 37);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 15);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
@@ -58764,74 +57174,313 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
/***/ }),
-/* 46 */
-/*!******************************!*\
- !*** ./src/NetscriptPort.js ***!
- \******************************/
+/* 42 */
+/*!********************************!*\
+ !*** ./src/ActiveScriptsUI.js ***!
+ \********************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; });
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 23);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; });
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptWorker.js */ 22);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/LogBox.js */ 47);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! numeral/min/numeral.min */ 10);
+/* harmony import */ var numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-function NetscriptPort() {
- this.data = [];
-}
-NetscriptPort.prototype.write = function(data) {
- this.data.push(data);
- if (this.data.length > _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
- return this.data.shift();
+
+
+
+
+
+
+
+/* {
+ * serverName: {
+ * header: Server Header Element
+ * panel: Server Panel List (ul) element
+ * scripts: {
+ * script id: Ref to Script information
+ * }
+ * }
+ * ...
+ */
+let ActiveScriptsUI = {};
+let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
+
+function createActiveScriptsServerPanel(server) {
+ let hostname = server.hostname;
+
+ var activeScriptsList = document.getElementById("active-scripts-list");
+
+ let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname});
+ let li = res[0];
+ var hdr = res[1];
+ let panel = res[2];
+
+ if (ActiveScriptsUI[hostname] != null) {
+ console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
+ return;
}
- return null;
+
+ var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul");
+ panel.appendChild(panelScriptList);
+ activeScriptsList.appendChild(li);
+
+ ActiveScriptsUI[hostname] = {
+ header: hdr,
+ panel: panel,
+ panelList: panelScriptList,
+ scripts: {}, //Holds references to li elements for each active script
+ scriptHdrs: {}, //Holds references to header elements for each active script
+ scriptStats: {} //Holds references to the p elements containing text for each active script
+ };
+
+ return li;
}
-NetscriptPort.prototype.tryWrite = function(data) {
- if (this.data.length >= _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
- return false;
+//Deletes the info for a particular server (Dropdown header + Panel with all info)
+//in the Active Scripts page if it exists
+function deleteActiveScriptsServerPanel(server) {
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null) {
+ console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
+ return;
}
- this.data.push(data);
- return true;
-}
-NetscriptPort.prototype.read = function() {
- if (this.data.length === 0) {
- return "NULL PORT DATA";
+ //Make sure it's empty
+ if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) {
+ console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting");
+ return;
}
- return this.data.shift();
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel);
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header);
+ delete ActiveScriptsUI[hostname];
}
-NetscriptPort.prototype.peek = function() {
- if (this.data.length === 0) {
- return "NULL PORT DATA";
- } else {
- var foo = this.data.slice();
- return foo[0];
+function addActiveScriptsItem(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()");
+ return;
}
+ let hostname = server.hostname;
+
+ ActiveScriptsTasks.push(function(workerscript, hostname) {
+ if (ActiveScriptsUI[hostname] == null) {
+ createActiveScriptsServerPanel(server);
+ }
+
+ //Create the unique identifier (key) for this script
+ var itemNameArray = ["active", "scripts", hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:workerscript.name});
+ let li = res[0];
+ let hdr = res[1];
+ let panel = res[2];
+
+ hdr.classList.remove("accordion-header");
+ hdr.classList.add("active-scripts-script-header");
+ panel.classList.remove("accordion-panel");
+ panel.classList.add("active-scripts-script-panel");
+
+ //Handle the constant elements on the panel that don't change after creation
+ //Threads, args, kill/log button
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
+ innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" +
+ "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args)
+ }));
+ var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", {
+ innerText:"Loading...", fontSize:"14px",
+ });
+ panel.appendChild(panelText);
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br"));
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
+ innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px",
+ clickListener:()=>{
+ Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef);
+ return false;
+ }
+ }));
+ panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", {
+ innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px",
+ clickListener:()=>{
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete...");
+ return false;
+ }
+ }));
+
+ //Append element to list
+ ActiveScriptsUI[hostname]["panelList"].appendChild(li);
+ ActiveScriptsUI[hostname].scripts[itemName] = li;
+ ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr;
+ ActiveScriptsUI[hostname].scriptStats[itemName] = panelText;
+ }.bind(null, workerscript, hostname));
}
-NetscriptPort.prototype.full = function() {
- return this.data.length == _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity;
+function deleteActiveScriptsItem(workerscript) {
+ ActiveScriptsTasks.push(function(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " +
+ "you tried to delete a large number of scripts and also deleted servers at the " +
+ "same time. It's not a big deal, just save and refresh the game.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null) {
+ console.log("ERROR: Trying to delete Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
+ return;
+ }
+
+ var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ let li = ActiveScriptsUI[hostname].scripts[itemName];
+ if (li == null) {
+ console.log("ERROR: Cannot find Active Script UI element for workerscript: ");
+ console.log(workerscript);
+ return;
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(li);
+ delete ActiveScriptsUI[hostname].scripts[itemName];
+ delete ActiveScriptsUI[hostname].scriptHdrs[itemName];
+ delete ActiveScriptsUI[hostname].scriptStats[itemName];
+ if (Object.keys(ActiveScriptsUI[hostname].scripts).length === 0) {
+ deleteActiveScriptsServerPanel(server);
+ }
+ }.bind(null, workerscript));
}
-NetscriptPort.prototype.empty = function() {
- return this.data.length === 0;
+//Update the ActiveScriptsItems array
+function updateActiveScriptsItems(maxTasks=100) {
+ //Run tasks that need to be done sequentially (adding items, creating/deleting server panels)
+ //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once...
+ let numTasks = Math.min(maxTasks, ActiveScriptsTasks.length);
+ for (let i = 0; i < numTasks; ++i) {
+ let task = ActiveScriptsTasks.shift();
+ try {
+ task();
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
+ console.log(task);
+ }
+ }
+
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;}
+ var total = 0;
+ for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) {
+ try {
+ total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]);
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e);
+ }
+ }
+ document.getElementById("active-scripts-total-prod").innerHTML =
+ "Total online production of Active Scripts: " + numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" +
+ "Total online production since last Aug installation: " +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" +
+ numeral_min_numeral_min__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)";
+ return total;
}
-NetscriptPort.prototype.clear = function() {
- this.data.length = 0;
+//Updates the content of the given item in the Active Scripts list
+function updateActiveScriptsItemContent(workerscript) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null) {
+ return; //Hasn't been created yet. We'll skip it
+ }
+
+ var itemNameArray = ["active", "scripts", server.hostname, workerscript.name];
+ for (var i = 0; i < workerscript.args.length; ++i) {
+ itemNameArray.push(String(workerscript.args[i]));
+ }
+ var itemName = itemNameArray.join("-");
+
+ if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) {
+ return; //Hasn't been fully added yet. We'll skip it
+ }
+ var item = ActiveScriptsUI[hostname].scriptStats[itemName];
+
+ //Update the text if necessary. This fn returns the online $/s production
+ return updateActiveScriptsText(workerscript, item, itemName);
+}
+
+function updateActiveScriptsText(workerscript, item, itemName) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp);
+ if (server == null) {
+ console.log("ERROR: Invalid server IP for workerscript.");
+ return;
+ }
+ let hostname = server.hostname;
+ if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == null) {
+ console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname);
+ return;
+ }
+
+ var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
+
+ //Only update if the item is visible
+ if (ActiveScriptsUI[hostname].header.classList.contains("active") === false) {return onlineMps;}
+ if (ActiveScriptsUI[hostname].scriptHdrs[itemName].classList.contains("active") === false) {return onlineMps;}
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item);
+
+ //Online
+ var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2);
+ var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " ");
+
+ var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second";
+ var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime;
+ var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " ");
+
+ //Offline
+ var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2);
+ var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " ");
+
+ var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime;
+ var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second";
+ var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime;
+ var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " ");
+
+ item.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" +
+ onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" +
+ offlineMpsText + "
" + offlineEpsText + "
";
+ return onlineMps;
}
/***/ }),
-/* 47 */
+/* 43 */
/*!***************************!*\
!*** ./src/SaveObject.js ***!
\***************************/
@@ -58841,27 +57490,27 @@ NetscriptPort.prototype.clear = function() {
__webpack_require__.r(__webpack_exports__);
/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "saveObject", function() { return saveObject; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGame", function() { return loadGame; });
-/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30);
-/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Company.js */ 9);
+/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 25);
+/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Company.js */ 8);
/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3);
/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5);
-/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 11);
-/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 33);
-/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Gang.js */ 37);
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HacknetNode.js */ 40);
-/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Message.js */ 29);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 9);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 30);
+/* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Gang.js */ 33);
+/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HacknetNode.js */ 38);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Message.js */ 27);
/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Player.js */ 0);
-/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Script.js */ 26);
-/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Server.js */ 10);
-/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 23);
-/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
-/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 22);
-/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/DialogBox.js */ 7);
-/* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/GameOptions.js */ 54);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Script.js */ 24);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Server.js */ 14);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 19);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 16);
+/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 29);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/GameOptions.js */ 50);
/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
-/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 7);
/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
-/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! decimal.js */ 24);
+/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! decimal.js */ 20);
@@ -59478,10 +58127,10 @@ function openImportFileHandler(evt) {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
/***/ }),
-/* 48 */
+/* 44 */
/*!***********************************!*\
!*** (webpack)/buildin/global.js ***!
\***********************************/
@@ -59510,7 +58159,7 @@ module.exports = g;
/***/ }),
-/* 49 */
+/* 45 */
/*!***********************************************!*\
!*** ./node_modules/pako/lib/utils/common.js ***!
\***********************************************/
@@ -59625,7 +58274,7 @@ exports.setTyped(TYPED_OK);
/***/ }),
-/* 50 */
+/* 46 */
/*!*******************************************!*\
!*** ./node_modules/jszip/lib/support.js ***!
\*******************************************/
@@ -59666,15 +58315,15 @@ else {
}
try {
- exports.nodestream = !!__webpack_require__(/*! readable-stream */ 112).Readable;
+ exports.nodestream = !!__webpack_require__(/*! readable-stream */ 110).Readable;
} catch(e) {
exports.nodestream = false;
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 61).Buffer))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 56).Buffer))
/***/ }),
-/* 51 */
+/* 47 */
/*!*************************!*\
!*** ./utils/LogBox.js ***!
\*************************/
@@ -59686,7 +58335,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxUpdateText", function() { return logBoxUpdateText; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxOpened", function() { return logBoxOpened; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxCurrentScript", function() { return logBoxCurrentScript; });
-/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 21);
+/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 22);
/* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelperFunctions.js */ 1);
@@ -59756,10 +58405,10 @@ function logBoxUpdateText() {
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 39)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 35)))
/***/ }),
-/* 52 */
+/* 48 */
/*!************************************************************!*\
!*** ./node_modules/readable-stream/lib/_stream_duplex.js ***!
\************************************************************/
@@ -59796,7 +58445,7 @@ function logBoxUpdateText() {
/*
" + this.text, true);
+}
+
+TextFile.prototype.download = function() {
+ var filename = this.fn;
+ var file = new Blob([this.text], {type: 'text/plain'});
+ if (window.navigator.msSaveOrOpenBlob) {// IE10+
+ window.navigator.msSaveOrOpenBlob(file, filename);
+ } else { // Others
+ var a = document.createElement("a"),
+ url = URL.createObjectURL(file);
+ a.href = url;
+ a.download = this.fn;
+ document.body.appendChild(a);
+ a.click();
+ setTimeout(function() {
+ document.body.removeChild(a);
+ window.URL.revokeObjectURL(url);
+ }, 0);
+ }
+}
+
+TextFile.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Generic_toJSON"])("TextFile", this);
+}
+
+TextFile.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Generic_fromJSON"])(TextFile, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_2__["Reviver"].constructors.TextFile = TextFile;
+
+function getTextFile(fn, server) {
+ if (!fn.endsWith(".txt")) {fn += ".txt";}
+ for (var i = 0; i < server.textFiles.length; ++i) {
+ if (server.textFiles[i].fn === fn) {
+ return server.textFiles[i];
+ }
+ }
+ return null;
+}
+
+//Returns the TextFile object that was just created
+function createTextFile(fn, txt, server) {
+ if (getTextFile(fn, server) !== null) {
+ console.log("ERROR: createTextFile failed because the specified " +
+ "server already has a text file with the same fn");
+ return;
+ }
+ var file = new TextFile(fn, txt);
+ server.textFiles.push(file);
+ return file;
+}
+
+function deleteTextFile(fn, server) {
+ if (!fn.endsWith(".txt")) {fn += ".txt";}
+ for (var i = 0; i < server.textFiles.length; ++i) {
+ if (server.textFiles[i].fn === fn) {
+ server.textFiles.splice(i, 1);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+/***/ }),
+/* 59 */,
+/* 60 */
/*!*************************************!*\
!*** ./src/NetscriptJSEvaluator.js ***!
\*************************************/
@@ -63210,7 +61965,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeScriptBlob", function() { return makeScriptBlob; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "executeJSScript", function() { return executeJSScript; });
/* harmony import */ var _NetscriptJSPreamble_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NetscriptJSPreamble.js */ 128);
-/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 6);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 31);
@@ -63323,7 +62078,7 @@ function _getScriptUrls(script, scripts, seen) {
/***/ }),
-/* 64 */
+/* 61 */
/*!****************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_global.js ***!
\****************************************************************************/
@@ -63335,7 +62090,7 @@ var global = module.exports = typeof window != 'undefined' && window.Math == Mat
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
/***/ }),
-/* 65 */
+/* 62 */
/*!***********************************************!*\
!*** ./node_modules/jszip/lib/nodejsUtils.js ***!
\***********************************************/
@@ -63395,17 +62150,17 @@ module.exports = {
}
};
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 61).Buffer))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ 56).Buffer))
/***/ }),
-/* 66 */
+/* 63 */
/*!*******************************************!*\
!*** ./node_modules/safe-buffer/index.js ***!
\*******************************************/
/***/ (function(module, exports, __webpack_require__) {
/* eslint-disable node/no-deprecated-api */
-var buffer = __webpack_require__(/*! buffer */ 61)
+var buffer = __webpack_require__(/*! buffer */ 56)
var Buffer = buffer.Buffer
// alternative to using Object.keys for old browsers
@@ -63469,7 +62224,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
/***/ }),
-/* 67 */
+/* 64 */
/*!****************************************************!*\
!*** ./node_modules/process-nextick-args/index.js ***!
\****************************************************/
@@ -63521,349 +62276,74 @@ function nextTick(fn, arg1, arg2, arg3) {
}
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../process/browser.js */ 60)))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../process/browser.js */ 57)))
/***/ }),
-/* 68 */
-/*!************************************************!*\
- !*** ./node_modules/sprintf-js/src/sprintf.js ***!
- \************************************************/
-/***/ (function(module, exports, __webpack_require__) {
-
-var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */
-
-!function() {
- 'use strict'
-
- var re = {
- not_string: /[^s]/,
- not_bool: /[^t]/,
- not_type: /[^T]/,
- not_primitive: /[^v]/,
- number: /[diefg]/,
- numeric_arg: /[bcdiefguxX]/,
- json: /[j]/,
- not_json: /[^j]/,
- text: /^[^\x25]+/,
- modulo: /^\x25{2}/,
- placeholder: /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
- key: /^([a-z_][a-z_\d]*)/i,
- key_access: /^\.([a-z_][a-z_\d]*)/i,
- index_access: /^\[(\d+)\]/,
- sign: /^[\+\-]/
- }
-
- function sprintf(key) {
- // `arguments` is not an array, but should be fine for this call
- return sprintf_format(sprintf_parse(key), arguments)
- }
-
- function vsprintf(fmt, argv) {
- return sprintf.apply(null, [fmt].concat(argv || []))
- }
-
- function sprintf_format(parse_tree, argv) {
- var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, match, pad, pad_character, pad_length, is_positive, sign
- for (i = 0; i < tree_length; i++) {
- if (typeof parse_tree[i] === 'string') {
- output += parse_tree[i]
- }
- else if (Array.isArray(parse_tree[i])) {
- match = parse_tree[i] // convenience purposes only
- if (match[2]) { // keyword argument
- arg = argv[cursor]
- for (k = 0; k < match[2].length; k++) {
- if (!arg.hasOwnProperty(match[2][k])) {
- throw new Error(sprintf('[sprintf] property "%s" does not exist', match[2][k]))
- }
- arg = arg[match[2][k]]
- }
- }
- else if (match[1]) { // positional argument (explicit)
- arg = argv[match[1]]
- }
- else { // positional argument (implicit)
- arg = argv[cursor++]
- }
-
- if (re.not_type.test(match[8]) && re.not_primitive.test(match[8]) && arg instanceof Function) {
- arg = arg()
- }
-
- if (re.numeric_arg.test(match[8]) && (typeof arg !== 'number' && isNaN(arg))) {
- throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
- }
-
- if (re.number.test(match[8])) {
- is_positive = arg >= 0
- }
-
- switch (match[8]) {
- case 'b':
- arg = parseInt(arg, 10).toString(2)
- break
- case 'c':
- arg = String.fromCharCode(parseInt(arg, 10))
- break
- case 'd':
- case 'i':
- arg = parseInt(arg, 10)
- break
- case 'j':
- arg = JSON.stringify(arg, null, match[6] ? parseInt(match[6]) : 0)
- break
- case 'e':
- arg = match[7] ? parseFloat(arg).toExponential(match[7]) : parseFloat(arg).toExponential()
- break
- case 'f':
- arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg)
- break
- case 'g':
- arg = match[7] ? String(Number(arg.toPrecision(match[7]))) : parseFloat(arg)
- break
- case 'o':
- arg = (parseInt(arg, 10) >>> 0).toString(8)
- break
- case 's':
- arg = String(arg)
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 't':
- arg = String(!!arg)
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'T':
- arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'u':
- arg = parseInt(arg, 10) >>> 0
- break
- case 'v':
- arg = arg.valueOf()
- arg = (match[7] ? arg.substring(0, match[7]) : arg)
- break
- case 'x':
- arg = (parseInt(arg, 10) >>> 0).toString(16)
- break
- case 'X':
- arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
- break
- }
- if (re.json.test(match[8])) {
- output += arg
- }
- else {
- if (re.number.test(match[8]) && (!is_positive || match[3])) {
- sign = is_positive ? '+' : '-'
- arg = arg.toString().replace(re.sign, '')
- }
- else {
- sign = ''
- }
- pad_character = match[4] ? match[4] === '0' ? '0' : match[4].charAt(1) : ' '
- pad_length = match[6] - (sign + arg).length
- pad = match[6] ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
- output += match[5] ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
- }
- }
- }
- return output
- }
-
- var sprintf_cache = Object.create(null)
-
- function sprintf_parse(fmt) {
- if (sprintf_cache[fmt]) {
- return sprintf_cache[fmt]
- }
-
- var _fmt = fmt, match, parse_tree = [], arg_names = 0
- while (_fmt) {
- if ((match = re.text.exec(_fmt)) !== null) {
- parse_tree.push(match[0])
- }
- else if ((match = re.modulo.exec(_fmt)) !== null) {
- parse_tree.push('%')
- }
- else if ((match = re.placeholder.exec(_fmt)) !== null) {
- if (match[2]) {
- arg_names |= 1
- var field_list = [], replacement_field = match[2], field_match = []
- if ((field_match = re.key.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
- if ((field_match = re.key_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- }
- else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
- field_list.push(field_match[1])
- }
- else {
- throw new SyntaxError('[sprintf] failed to parse named argument key')
- }
- }
- }
- else {
- throw new SyntaxError('[sprintf] failed to parse named argument key')
- }
- match[2] = field_list
- }
- else {
- arg_names |= 2
- }
- if (arg_names === 3) {
- throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
- }
- parse_tree.push(match)
- }
- else {
- throw new SyntaxError('[sprintf] unexpected placeholder')
- }
- _fmt = _fmt.substring(match[0].length)
- }
- return sprintf_cache[fmt] = parse_tree
- }
-
- /**
- * export to either browser or node.js
- */
- /* eslint-disable quote-props */
- if (true) {
- exports['sprintf'] = sprintf
- exports['vsprintf'] = vsprintf
- }
- if (typeof window !== 'undefined') {
- window['sprintf'] = sprintf
- window['vsprintf'] = vsprintf
-
- if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
- return {
- 'sprintf': sprintf,
- 'vsprintf': vsprintf
- }
- }).call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
- }
- }
- /* eslint-enable quote-props */
-}()
-
-
-/***/ }),
-/* 69 */
-/*!*************************************!*\
- !*** ./src/NetscriptEnvironment.js ***!
- \*************************************/
+/* 65 */
+/*!******************************!*\
+ !*** ./src/NetscriptPort.js ***!
+ \******************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Environment", function() { return Environment; });
-/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HacknetNode.js */ 40);
-/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 31);
-/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./NetscriptPort.js */ 46);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; });
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 19);
-
-
-/* Environment
- * NetScript program environment
- */
-function Environment(workerScript,parent) {
- if (parent){
- //Create a copy of parent's variables
- //this.vars = parent.vars;
- this.vars = Object.assign({}, parent.vars);
- } else {
- this.vars = Object(_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_1__["NetscriptFunctions"])(workerScript);
- }
- this.parent = parent;
- this.stopFlag = false;
+function NetscriptPort() {
+ this.data = [];
}
-Environment.prototype = {
- //Create a "subscope", which is a new new "sub-environment"
- //The subscope is linked to this through its parent variable
- extend: function() {
- return new Environment(null, this);
- },
- //Finds the scope where the variable with the given name is defined
- lookup: function(name) {
- var scope = this;
- while (scope) {
- if (Object.prototype.hasOwnProperty.call(scope.vars, name)) {
- return scope;
- }
- scope = scope.parent;
- }
- return null;
- },
-
- //Get the current value of a variable
- get: function(name) {
- if (name in this.vars) {
- return this.vars[name];
- }
- throw new Error("Undefined variable " + name);
- },
-
- //Sets the value of a variable in any scope
- set: function(name, value) {
- var scope = this.lookup(name);
-
- //If scope has a value, then this variable is already set in a higher scope, so
- //set is there. Otherwise, create a new variable in the local scope
- if (scope !== null) {
- return scope.vars[name] = value;
- } else {
- return this.vars[name] = value;
- }
- },
-
- setArrayElement: function(name, idx, value) {
- if (!(idx instanceof Array)) {
- throw new Error("idx parameter is not an Array");
- }
- var scope = this.lookup(name);
- if (!scope && this.parent) {
- throw new Error("Undefined variable " + name);
- }
- var arr = (scope || this).vars[name];
- if (!(arr.constructor === Array || arr instanceof Array)) {
- throw new Error("Variable is not an array: " + name);
- }
- var res = arr;
- for (var iterator = 0; iterator < idx.length-1; ++iterator) {
- var i = idx[iterator];
- if (!(res instanceof Array) || i >= res.length) {
- throw new Error("Out-of-bounds array access");
- }
- res = res[i];
- }
-
- //Cant assign to ports or HacknetNodes
- if (res[idx[idx.length-1]] instanceof _HacknetNode_js__WEBPACK_IMPORTED_MODULE_0__["HacknetNode"]) {
- throw new Error("Cannot assign a Hacknet Node handle to a new value");
- }
- if (res[idx[idx.length-1]] instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_2__["NetscriptPort"]) {
- throw new Error("Cannot assign a Netscript Port handle to a new value");
- }
- return res[idx[idx.length-1]] = value;
- },
-
- //Creates (or overwrites) a variable in the current scope
- def: function(name, value) {
- return this.vars[name] = value;
+NetscriptPort.prototype.write = function(data) {
+ this.data.push(data);
+ if (this.data.length > _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
+ return this.data.shift();
}
-};
+ return null;
+}
+
+NetscriptPort.prototype.tryWrite = function(data) {
+ if (this.data.length >= _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity) {
+ return false;
+ }
+ this.data.push(data);
+ return true;
+}
+
+NetscriptPort.prototype.read = function() {
+ if (this.data.length === 0) {
+ return "NULL PORT DATA";
+ }
+ return this.data.shift();
+}
+
+NetscriptPort.prototype.peek = function() {
+ if (this.data.length === 0) {
+ return "NULL PORT DATA";
+ } else {
+ var foo = this.data.slice();
+ return foo[0];
+ }
+}
+
+NetscriptPort.prototype.full = function() {
+ return this.data.length == _Settings_js__WEBPACK_IMPORTED_MODULE_0__["Settings"].MaxPortCapacity;
+}
+
+NetscriptPort.prototype.empty = function() {
+ return this.data.length === 0;
+}
+
+NetscriptPort.prototype.clear = function() {
+ this.data.length = 0;
+}
/***/ }),
-/* 70 */
+/* 66 */
/*!******************************!*\
!*** ./src/CinematicText.js ***!
\******************************/
@@ -63976,7 +62456,7 @@ function cinematicTextEnd() {
/***/ }),
-/* 71 */
+/* 67 */
/*!*************************!*\
!*** ./src/HelpText.js ***!
\*************************/
@@ -64206,10 +62686,10 @@ let HelpTexts = {
/***/ }),
-/* 72 */,
-/* 73 */,
-/* 74 */,
-/* 75 */
+/* 68 */,
+/* 69 */,
+/* 70 */,
+/* 71 */
/*!************************************************!*\
!*** ./node_modules/pako/lib/zlib/messages.js ***!
\************************************************/
@@ -64251,7 +62731,7 @@ module.exports = {
/***/ }),
-/* 76 */
+/* 72 */
/*!*****************************************!*\
!*** ./node_modules/jszip/lib/crc32.js ***!
\*****************************************/
@@ -64260,7 +62740,7 @@ module.exports = {
"use strict";
-var utils = __webpack_require__(/*! ./utils */ 32);
+var utils = __webpack_require__(/*! ./utils */ 28);
/**
* The following functions come from pako, from pako/lib/zlib/crc32.js
@@ -64338,7 +62818,7 @@ module.exports = function crc32wrapper(input, crc) {
/***/ }),
-/* 77 */
+/* 73 */
/*!****************************************************!*\
!*** ./node_modules/jszip/lib/compressedObject.js ***!
\****************************************************/
@@ -64347,11 +62827,11 @@ module.exports = function crc32wrapper(input, crc) {
"use strict";
-var external = __webpack_require__(/*! ./external */ 58);
-var DataWorker = __webpack_require__(/*! ./stream/DataWorker */ 98);
-var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 97);
-var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ 96);
-var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 97);
+var external = __webpack_require__(/*! ./external */ 54);
+var DataWorker = __webpack_require__(/*! ./stream/DataWorker */ 97);
+var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 96);
+var Crc32Probe = __webpack_require__(/*! ./stream/Crc32Probe */ 95);
+var DataLengthProbe = __webpack_require__(/*! ./stream/DataLengthProbe */ 96);
/**
* Represent a compressed object, with everything needed to decompress it.
@@ -64423,19 +62903,19 @@ module.exports = CompressedObject;
/***/ }),
-/* 78 */
+/* 74 */
/*!*********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_descriptors.js ***!
\*********************************************************************************/
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
-module.exports = !__webpack_require__(/*! ./_fails */ 102)(function(){
+module.exports = !__webpack_require__(/*! ./_fails */ 101)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
/***/ }),
-/* 79 */
+/* 75 */
/*!*******************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_is-object.js ***!
\*******************************************************************************/
@@ -64446,7 +62926,7 @@ module.exports = function(it){
};
/***/ }),
-/* 80 */
+/* 76 */
/*!**************************************************************!*\
!*** ./node_modules/readable-stream/lib/_stream_writable.js ***!
\**************************************************************/
@@ -64482,7 +62962,7 @@ module.exports = function(it){
/*
" +
+ "Only then can you discover immortality.", [], true, true, true, false),
+
+ //Megacorporations, each forms its own faction
+ "ECorp": new FactionInfo("ECorp's mission is simple: to connect the world of today with the technology of tomorrow. " +
+ "With our wide range of Internet-related software and commercial hardware, ECorp makes the world's " +
+ "information universally accessible.", [], true, true, true, true),
+
+ "MegaCorp": new FactionInfo("MegaCorp does things that others don't. We imagine. We create. We invent. We build things that " +
+ "others have never even dreamed of. Our work fills the world's needs for food, water, power, and " +
+ "transporation on an unprecendented scale, in ways that no other company can.
" +
+ "In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.", [], true, true, true, true),
+
+ "Bachman & Associates": new FactionInfo("Where Law and Business meet - thats where we are.
" +
+ "Legal Insight - Business Instinct - Experience Innovation", [], true, true, true, true),
+
+ "Blade Industries": new FactionInfo("Augmentation is salvation", [], true, true, true, true),
+
+ "NWO": new FactionInfo("The human being does not truly desire freedom. It wants " +
+ "to be observed, understood, and judged. It wants to be given purpose and " +
+ "direction in its life. That is why humans created God. " +
+ "And that is why humans created civilization - " +
+ "not because of willingness, " +
+ "but because of a need to be incorporated into higher orders of structure and meaning.", [], true, true, true, true),
+
+ "Clarke Incorporated": new FactionInfo("Unlocking the power of the genome", [], true, true, true, true),
+
+ "OmniTek Incorporated": new FactionInfo("Simply put, our mission is to design and build robots that make a difference", [], true, true, true, true),
+
+ "Four Sigma": new FactionInfo("The scientific method is the best way to approach investing. Big strategies backed up with big data. Driven by " +
+ "deep learning and innovative ideas. And improved by iteration. That's Four Sigma.", [], true, true, true, true),
+
+ "KuaiGong International": new FactionInfo("Dream big. Work hard. Make history.", [], true, true, true, true),
+
+ //Other Corporations
+ "Fulcrum Secret Technologies": new FactionInfo("The human organism has an innate desire to worship. " +
+ "That is why they created gods. If there were no gods, " +
+ "it would be necessary to create them. And now we can.", [], true, true, false, true),
+
+ //Hacker groups
+ "BitRunners": new FactionInfo("Our entire lives are controlled by bits. All of our actions, our thoughts, our personal information. "+
+ "It's all transformed into bits, stored in bits, communicated through bits. It’s impossible for any person " +
+ "to move, to live, to operate at any level without the use of bits. " +
+ "And when a person moves, lives, and operates, they leave behind their bits, mere traces of seemingly " +
+ "meaningless fragments of information. But these bits can be reconstructed. Transformed. Used.
" +
+ "Those who run the bits, run the world", [], true, true, false, false),
+
+
+ "The Black Hand": new FactionInfo("The world, so afraid of strong government, now has no government. Only power - Digital power. Financial power. " +
+ "Technological power. " +
+ "And those at the top rule with an invisible hand. They built a society where the rich get richer, " +
+ "and everyone else suffers.
" +
+ "So much pain. So many lives. Their darkness must end.", [], true, true, true, false),
+
+ "NiteSec": new FactionInfo(
+" __..__
" +
+" _.nITESECNIt.
" +
+" .-'NITESECNITESEc.
" +
+" .' NITESECNITESECn
" +
+" / NITESECNITESEC;
" +
+" : :NITESECNITESEC;
" +
+" ; $ NITESECNITESECN
" +
+" : _, ,N'ITESECNITESEC
" +
+" : .+^^`, : `NITESECNIT
" +
+" ) /), `-,-=,NITESECNI
" +
+" / ^ ,-;|NITESECN;
" +
+" / _.' '-';NITESECN
" +
+" ( , ,-''`^NITE'
" +
+" )` :`. .'
" +
+" )-- ; `- /
" +
+" \' _.-' :
" +
+" ( _.-' \. \
" +
+" \------. \ \
" +
+" \. \ \
" +
+" \ _.nIt
" +
+" \ _.nITESECNi
" +
+" nITESECNIT^' \
" +
+" NITE^' ___ \
" +
+" / .gP''''Tp. \
" +
+" : d' . `b \
" +
+" ; d' o `b ;
" +
+" / d; `b|
" +
+" /, $; @ `:
" +
+" /' $$ ;
" +
+" .' $$b o |
" +
+" .' d$$$; :
" +
+" / .d$$$$; , ;
" +
+" d .dNITESEC $ |
" +
+" :bp.__.gNITESEC$$ :$ ;
" +
+" NITESECNITESECNIT $$b :
", [], true, true, false, false),
+
+ //City factions, essentially governments
+ "Chongqing": new FactionInfo("Serve the people", ["Sector-12", "Aevum", "Volhaven"], true, true, true, true),
+ "Sector-12": new FactionInfo("The City of the Future", ["Chongqing", "New Tokyo", "Ishima", "Volhaven"], true, true, true, true),
+ "New Tokyo": new FactionInfo("Asia's World City", ["Sector-12", "Aevum", "Volhaven"], true, true, true, true),
+ "Aevum": new FactionInfo("The Silicon City", ["Chongqing", "New Tokyo", "Ishima", "Volhaven"], true, true, true, true),
+ "Ishima": new FactionInfo("The East Asian Order of the Future", ["Sector-12", "Aevum", "Volhaven"], true, true, true, true),
+ "Volhaven": new FactionInfo("Benefit, Honour, and Glory", ["Chongqing", "Sector-12", "New Tokyo", "Aevum", "Ishima"], true, true, true, true),
+
+ //Criminal Organizations/Gangs
+ "Speakers for the Dead": new FactionInfo("It is better to reign in hell than to serve in heaven.", [], true, true, true, true),
+
+ "The Dark Army": new FactionInfo("The World doesn't care about right or wrong. It's all about power.", [], true, true, true, false),
+
+ "The Syndicate": new FactionInfo("Honor holds you back", [], true, true, true, true),
+
+ "Silhouette": new FactionInfo("Corporations have filled the void of power left behind by the collapse of Western government. The issue is they've become so big " +
+ "that you don't know who they're working for. And if you're employed at one of these corporations, you don't even know who you're working " +
+ "for.\n\n" +
+ "That's terror. Terror, fear, and corruption. All born into the system, all propagated by the system.", [], true, true, true, false),
+
+ "Tetrads": new FactionInfo("Following the Mandate of Heaven and Carrying out the Way", [], false, false, true, true),
+
+ "Slum Snakes": new FactionInfo("Slum Snakes rule!", [], false, false, true, true),
+
+ //Earlygame factions - factions the player will prestige with early on that don't
+ //belong in other categories
+ "Netburners": new FactionInfo("~~//*>H4CK|\|3T 8URN3R5**>?>\\~~", [], true, true, false, false),
+
+ "Tian Di Hui": new FactionInfo("Obey Heaven and Work Righteousness", [], true, true, false, true),
+
+ "CyberSec": new FactionInfo("The Internet is the first thing that humanity has built that humanity doesn’t understand, " +
+ "the largest experiment in anarchy that we have ever had. And as the world becomes increasingly " +
+ "dominated by the internet, society approaches the brink of total chaos. " +
+ "We serve only to protect society, to protect humanity, to protect the world from its imminent collapse.", [], true, true, false, false),
+
+ //Special Factions
+ "Bladeburners": new FactionInfo("It's too bad they won't live. But then again, who does?
" +
+ "Note that for this faction, reputation can only be gained through Bladeburner actions. Completing " +
+ "Bladeburner contracts/operations will increase your reputation.", [], false, false, false, false),
+}
+
+
+
+
+/***/ }),
+/* 84 */
/*!***********************************************************!*\
!*** ./node_modules/jszip/lib/reader/Uint8ArrayReader.js ***!
\***********************************************************/
@@ -65568,8 +64546,8 @@ function purchaseRamForHomeComputer(cost) {
"use strict";
-var ArrayReader = __webpack_require__(/*! ./ArrayReader */ 87);
-var utils = __webpack_require__(/*! ../utils */ 32);
+var ArrayReader = __webpack_require__(/*! ./ArrayReader */ 86);
+var utils = __webpack_require__(/*! ../utils */ 28);
function Uint8ArrayReader(data) {
ArrayReader.call(this, data);
@@ -65592,7 +64570,7 @@ module.exports = Uint8ArrayReader;
/***/ }),
-/* 86 */
+/* 85 */
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/reader/DataReader.js ***!
\*****************************************************/
@@ -65600,7 +64578,7 @@ module.exports = Uint8ArrayReader;
"use strict";
-var utils = __webpack_require__(/*! ../utils */ 32);
+var utils = __webpack_require__(/*! ../utils */ 28);
function DataReader(data) {
this.data = data; // type : see implementation
@@ -65718,7 +64696,7 @@ module.exports = DataReader;
/***/ }),
-/* 87 */
+/* 86 */
/*!******************************************************!*\
!*** ./node_modules/jszip/lib/reader/ArrayReader.js ***!
\******************************************************/
@@ -65726,8 +64704,8 @@ module.exports = DataReader;
"use strict";
-var DataReader = __webpack_require__(/*! ./DataReader */ 86);
-var utils = __webpack_require__(/*! ../utils */ 32);
+var DataReader = __webpack_require__(/*! ./DataReader */ 85);
+var utils = __webpack_require__(/*! ../utils */ 28);
function ArrayReader(data) {
DataReader.call(this, data);
@@ -65785,7 +64763,7 @@ module.exports = ArrayReader;
/***/ }),
-/* 88 */
+/* 87 */
/*!****************************************************!*\
!*** ./node_modules/jszip/lib/reader/readerFor.js ***!
\****************************************************/
@@ -65794,12 +64772,12 @@ module.exports = ArrayReader;
"use strict";
-var utils = __webpack_require__(/*! ../utils */ 32);
-var support = __webpack_require__(/*! ../support */ 50);
-var ArrayReader = __webpack_require__(/*! ./ArrayReader */ 87);
-var StringReader = __webpack_require__(/*! ./StringReader */ 133);
-var NodeBufferReader = __webpack_require__(/*! ./NodeBufferReader */ 132);
-var Uint8ArrayReader = __webpack_require__(/*! ./Uint8ArrayReader */ 85);
+var utils = __webpack_require__(/*! ../utils */ 28);
+var support = __webpack_require__(/*! ../support */ 46);
+var ArrayReader = __webpack_require__(/*! ./ArrayReader */ 86);
+var StringReader = __webpack_require__(/*! ./StringReader */ 132);
+var NodeBufferReader = __webpack_require__(/*! ./NodeBufferReader */ 131);
+var Uint8ArrayReader = __webpack_require__(/*! ./Uint8ArrayReader */ 84);
/**
* Create a reader adapted to the data.
@@ -65823,7 +64801,7 @@ module.exports = function (data) {
/***/ }),
-/* 89 */
+/* 88 */
/*!*********************************************!*\
!*** ./node_modules/jszip/lib/signature.js ***!
\*********************************************/
@@ -65840,7 +64818,7 @@ exports.DATA_DESCRIPTOR = "PK\x07\x08";
/***/ }),
-/* 90 */
+/* 89 */
/*!*************************************************!*\
!*** ./node_modules/pako/lib/zlib/constants.js ***!
\*************************************************/
@@ -65918,7 +64896,7 @@ module.exports = {
/***/ }),
-/* 91 */
+/* 90 */
/*!***********************************************!*\
!*** ./node_modules/pako/lib/zlib/zstream.js ***!
\***********************************************/
@@ -65975,7 +64953,7 @@ module.exports = ZStream;
/***/ }),
-/* 92 */
+/* 91 */
/*!************************************************!*\
!*** ./node_modules/pako/lib/utils/strings.js ***!
\************************************************/
@@ -65986,7 +64964,7 @@ module.exports = ZStream;
-var utils = __webpack_require__(/*! ./common */ 49);
+var utils = __webpack_require__(/*! ./common */ 45);
// Quick check if we can use fast array to bin string conversion
@@ -66170,7 +65148,7 @@ exports.utf8border = function (buf, max) {
/***/ }),
-/* 93 */
+/* 92 */
/*!*********************************************!*\
!*** ./node_modules/pako/lib/zlib/crc32.js ***!
\*********************************************/
@@ -66239,7 +65217,7 @@ module.exports = crc32;
/***/ }),
-/* 94 */
+/* 93 */
/*!***********************************************!*\
!*** ./node_modules/pako/lib/zlib/adler32.js ***!
\***********************************************/
@@ -66300,7 +65278,7 @@ module.exports = adler32;
/***/ }),
-/* 95 */
+/* 94 */
/*!************************************************!*\
!*** ./node_modules/jszip/lib/compressions.js ***!
\************************************************/
@@ -66309,7 +65287,7 @@ module.exports = adler32;
"use strict";
-var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ 38);
+var GenericWorker = __webpack_require__(/*! ./stream/GenericWorker */ 34);
exports.STORE = {
magic: "\x00\x00",
@@ -66320,11 +65298,11 @@ exports.STORE = {
return new GenericWorker("STORE decompression");
}
};
-exports.DEFLATE = __webpack_require__(/*! ./flate */ 147);
+exports.DEFLATE = __webpack_require__(/*! ./flate */ 146);
/***/ }),
-/* 96 */
+/* 95 */
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/stream/Crc32Probe.js ***!
\*****************************************************/
@@ -66333,9 +65311,9 @@ exports.DEFLATE = __webpack_require__(/*! ./flate */ 147);
"use strict";
-var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 38);
-var crc32 = __webpack_require__(/*! ../crc32 */ 76);
-var utils = __webpack_require__(/*! ../utils */ 32);
+var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 34);
+var crc32 = __webpack_require__(/*! ../crc32 */ 72);
+var utils = __webpack_require__(/*! ../utils */ 28);
/**
* A worker which calculate the crc32 of the data flowing through.
@@ -66358,7 +65336,7 @@ module.exports = Crc32Probe;
/***/ }),
-/* 97 */
+/* 96 */
/*!**********************************************************!*\
!*** ./node_modules/jszip/lib/stream/DataLengthProbe.js ***!
\**********************************************************/
@@ -66367,8 +65345,8 @@ module.exports = Crc32Probe;
"use strict";
-var utils = __webpack_require__(/*! ../utils */ 32);
-var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 38);
+var utils = __webpack_require__(/*! ../utils */ 28);
+var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 34);
/**
* A worker which calculate the total length of the data flowing through.
@@ -66397,7 +65375,7 @@ module.exports = DataLengthProbe;
/***/ }),
-/* 98 */
+/* 97 */
/*!*****************************************************!*\
!*** ./node_modules/jszip/lib/stream/DataWorker.js ***!
\*****************************************************/
@@ -66406,8 +65384,8 @@ module.exports = DataLengthProbe;
"use strict";
-var utils = __webpack_require__(/*! ../utils */ 32);
-var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 38);
+var utils = __webpack_require__(/*! ../utils */ 28);
+var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 34);
// the size of the generated chunks
// TODO expose this as a public variable
@@ -66523,7 +65501,7 @@ module.exports = DataWorker;
/***/ }),
-/* 99 */
+/* 98 */
/*!********************************************!*\
!*** ./node_modules/jszip/lib/defaults.js ***!
\********************************************/
@@ -66544,7 +65522,7 @@ exports.dosPermissions = null;
/***/ }),
-/* 100 */
+/* 99 */
/*!*******************************************************!*\
!*** ./node_modules/jszip/lib/stream/StreamHelper.js ***!
\*******************************************************/
@@ -66553,17 +65531,17 @@ exports.dosPermissions = null;
"use strict";
/* WEBPACK VAR INJECTION */(function(Buffer) {
-var utils = __webpack_require__(/*! ../utils */ 32);
-var ConvertWorker = __webpack_require__(/*! ./ConvertWorker */ 151);
-var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 38);
-var base64 = __webpack_require__(/*! ../base64 */ 105);
-var support = __webpack_require__(/*! ../support */ 50);
-var external = __webpack_require__(/*! ../external */ 58);
+var utils = __webpack_require__(/*! ../utils */ 28);
+var ConvertWorker = __webpack_require__(/*! ./ConvertWorker */ 150);
+var GenericWorker = __webpack_require__(/*! ./GenericWorker */ 34);
+var base64 = __webpack_require__(/*! ../base64 */ 104);
+var support = __webpack_require__(/*! ../support */ 46);
+var external = __webpack_require__(/*! ../external */ 54);
var NodejsStreamOutputAdapter = null;
if (support.nodestream) {
try {
- NodejsStreamOutputAdapter = __webpack_require__(/*! ../nodejs/NodejsStreamOutputAdapter */ 150);
+ NodejsStreamOutputAdapter = __webpack_require__(/*! ../nodejs/NodejsStreamOutputAdapter */ 149);
} catch(e) {}
}
@@ -66764,17 +65742,17 @@ StreamHelper.prototype = {
module.exports = StreamHelper;
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ 61).Buffer))
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ 56).Buffer))
/***/ }),
-/* 101 */
+/* 100 */
/*!********************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_dom-create.js ***!
\********************************************************************************/
/***/ (function(module, exports, __webpack_require__) {
-var isObject = __webpack_require__(/*! ./_is-object */ 79)
- , document = __webpack_require__(/*! ./_global */ 64).document
+var isObject = __webpack_require__(/*! ./_is-object */ 75)
+ , document = __webpack_require__(/*! ./_global */ 61).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
@@ -66782,7 +65760,7 @@ module.exports = function(it){
};
/***/ }),
-/* 102 */
+/* 101 */
/*!***************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_fails.js ***!
\***************************************************************************/
@@ -66797,14 +65775,14 @@ module.exports = function(exec){
};
/***/ }),
-/* 103 */
+/* 102 */
/*!*************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_ctx.js ***!
\*************************************************************************/
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
-var aFunction = __webpack_require__(/*! ./_a-function */ 164);
+var aFunction = __webpack_require__(/*! ./_a-function */ 163);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
@@ -66825,7 +65803,7 @@ module.exports = function(fn, that, length){
};
/***/ }),
-/* 104 */
+/* 103 */
/*!**************************************************************************!*\
!*** ./node_modules/jszip/node_modules/core-js/library/modules/_core.js ***!
\**************************************************************************/
@@ -66835,7 +65813,7 @@ var core = module.exports = {version: '2.3.0'};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
/***/ }),
-/* 105 */
+/* 104 */
/*!******************************************!*\
!*** ./node_modules/jszip/lib/base64.js ***!
\******************************************/
@@ -66843,8 +65821,8 @@ if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
"use strict";
-var utils = __webpack_require__(/*! ./utils */ 32);
-var support = __webpack_require__(/*! ./support */ 50);
+var utils = __webpack_require__(/*! ./utils */ 28);
+var support = __webpack_require__(/*! ./support */ 46);
// private property
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -66951,7 +65929,7 @@ exports.decode = function(input) {
/***/ }),
-/* 106 */
+/* 105 */
/*!***************************************************************!*\
!*** ./node_modules/readable-stream/lib/_stream_transform.js ***!
\***************************************************************/
@@ -67025,11 +66003,11 @@ exports.decode = function(input) {
module.exports = Transform;
-var Duplex = __webpack_require__(/*! ./_stream_duplex */ 52);
+var Duplex = __webpack_require__(/*! ./_stream_duplex */ 48);
/*